1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-30240 Wrong result upon aggregate function with SQL_BUFFER_RESULT

The problem was that when storing rows into a temporary table,
MIN/MAX items that where marked as constants (as theire value had
been computed at start of query) would be reset.

Fixed by not reseting MIN/MAX items that are marked as const in
Item_sum_min_max::clear().
This commit is contained in:
Monty
2023-01-02 18:34:19 +02:00
parent 8b9b4ab3f5
commit d0603fc5ba
5 changed files with 50 additions and 4 deletions

View File

@@ -438,7 +438,7 @@ int opt_sum_query(THD *thd,
The optimization is not applicable in both cases:
(a) 'expr' is a non-constant expression. Then we can't
replace 'expr' by a constant.
(b) 'expr' is a costant. According to ANSI, MIN/MAX must return
(b) 'expr' is a constant. According to ANSI, MIN/MAX must return
NULL if the query does not return any rows. Thus, if we are not
able to determine if the query returns any rows, we can't apply
the optimization and replace MIN/MAX with a constant.