1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

* Bug #20792: Incorrect results from aggregate subquery

When processing aggregate functions all tables values are reset
to NULLs at the end of each group. 
When doing that if there are no rows found for a group
the const tables must not be reset as they are not recalculated 
by do_select()/sub_select() for each group.


mysql-test/r/subselect2.result:
  * Bug #20792: Incorrect results from aggregate subquery
   - test suite for the bug. This is dependent on InnoDB despite
     the fact that the bug and the fix are not InnoDB specific.
     This is because of the table flag HA_NOT_EXACT_COUNT.
     When this flag is off (as in MyISAM) both t2 and t3 become of
     join type 'system' as they are estimated to have 1 record and
     and this statistics can be trusted (according to the absence of
     HA_NOT_EXACT_COUNT).
mysql-test/t/subselect2.test:
  * Bug #20792: Incorrect results from aggregate subquery
   - test suite for the bug
sql/sql_select.cc:
  * Bug #20792: Incorrect results from aggregate subquery
   - when clearing results if there are not rows found for group
     the const tables must not be reset as they are not recalculated
     for each group.
This commit is contained in:
unknown
2006-07-26 19:19:30 +03:00
parent 5a77e566ab
commit 6b75e24b73
3 changed files with 38 additions and 2 deletions

View File

@ -4452,10 +4452,16 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
DBUG_RETURN(0);
}
/*
used only in JOIN::clear
*/
static void clear_tables(JOIN *join)
{
for (uint i=0 ; i < join->tables ; i++)
/*
must clear only the non-const tables, as const tables
are not re-calculated.
*/
for (uint i=join->const_tables ; i < join->tables ; i++)
mark_as_null_row(join->table[i]); // All fields are NULL
}