diff options
author | unknown <timour@mysql.com> | 2005-11-30 12:52:12 +0200 |
---|---|---|
committer | unknown <timour@mysql.com> | 2005-11-30 12:52:12 +0200 |
commit | e3f575522824ee79ade046cf96f4f3679d68c1a3 (patch) | |
tree | 93c8fe49567155c829f0e7241c60faa6b980c051 /sql/sql_class.h | |
parent | 35d40868fd0f3d6a90e7190ebc63ee3183860e9f (diff) | |
download | mariadb-git-e3f575522824ee79ade046cf96f4f3679d68c1a3.tar.gz |
Fix for BUG#14920 Ordering aggregated result sets corrupts resultset.
The cause of the bug was the use of end_write_group instead of end_write
in the case when ORDER BY required a temporary table, which didn't take
into account the fact that loose index scan already computes the result
of MIN/MAX aggregate functions (and performs grouping).
The solution is to call end_write instead of end_write_group and to add
the MIN/MAX functions to the list of regular functions so that their
values are inserted into the temporary table.
mysql-test/r/group_min_max.result:
Test for BUG#14920
mysql-test/t/group_min_max.test:
Test for BUG#14920
sql/sql_class.cc:
Added new member to TMP_TABLE_PARAM.
sql/sql_class.h:
Added new member to TMP_TABLE_PARAM.
sql/sql_select.cc:
Enable result rows generated by loose index scan being written into
a temporary table. The change is necessary because loose index
scan already computes the result of GROUP BY and the MIN/MAX aggregate
functions. This is realized by three changes:
- create_tmp_table allocates space for aggregate functions in the
list of regular functions,
- use end_write instead of end_write group,
- copy the pointers to the MIN/MAX aggregate functions to the list
of regular functions TMP_TABLE_PARAM::items_to_copy.
sql/sql_select.h:
New parameter to create_tmp_table.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index ed6f5732ca8..c5f661cebd5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1819,11 +1819,18 @@ public: uint convert_blob_length; CHARSET_INFO *table_charset; bool schema_table; + /* + True if GROUP BY and its aggregate functions are already computed + by a table access method (e.g. by loose index scan). In this case + query execution should not perform aggregation and should treat + aggregate functions as normal functions. + */ + bool precomputed_group_by; TMP_TABLE_PARAM() :copy_field(0), group_parts(0), group_length(0), group_null_parts(0), convert_blob_length(0), - schema_table(0) + schema_table(0), precomputed_group_by(0) {} ~TMP_TABLE_PARAM() { |