summaryrefslogtreecommitdiff
path: root/sql/sql_select.h
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-10-30 18:54:53 +0300
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-10-30 18:54:53 +0300
commit23b05d0002a3581ecac1bdef860c097f2088677d (patch)
tree9067b717467268c2f50af517ad7c74803685ad5b /sql/sql_select.h
parentf359b258ee73135c8bbcc4e22fc81c25bb4236a5 (diff)
downloadmariadb-git-23b05d0002a3581ecac1bdef860c097f2088677d.tar.gz
Bug #48131: crash group by with rollup, distinct, filesort,
with temporary tables There were two problems the test case from this bug was triggering: 1. JOIN::rollup_init() was supposed to wrap all constant Items into another object for queries with the WITH ROLLUP modifier to ensure they are never considered as constants and therefore are written into temporary tables if the optimizer chooses to employ them for DISTINCT/GROUP BY handling. However, JOIN::rollup_init() was called before make_join_statistics(), so Items corresponding to fields in const tables could not be handled as intended, which was causing all kinds of problems later in the query execution. In particular, create_tmp_table() assumed all constant items except "hidden" ones to be removed earlier by remove_const() which led to improperly initialized Field objects for the temporary table being created. This is what was causing crashes and valgrind errors in storage engines. 2. Even when the above problem had been fixed, the query from the test case produced incorrect results due to some DISTINCT/GROUP BY optimizations being performed by the optimizer that are inapplicable in the WITH ROLLUP case. Fixed by disabling inapplicable DISTINCT/GROUP BY optimizations when the WITH ROLLUP modifier is present, and splitting the const-wrapping part of JOIN::rollup_init() into a separate method which is now invoked after make_join_statistics() when the const tables are already known.
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r--sql/sql_select.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h
index c328737c1c6..a217d199a30 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -452,6 +452,7 @@ public:
}
bool rollup_init();
+ bool rollup_process_const_fields();
bool rollup_make_fields(List<Item> &all_fields, List<Item> &fields,
Item_sum ***func);
int rollup_send_data(uint idx);