diff options
author | unknown <hf@deer.(none)> | 2003-06-21 16:59:40 +0500 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2003-06-21 16:59:40 +0500 |
commit | 1688ada0e2ce3bf5e62f1539811f0cfb0d8bc4b6 (patch) | |
tree | ef1e497407bdf746aa2bad6b59eaa1175b2f8775 /sql/sql_select.cc | |
parent | 070f4fbb95ad20e8e8b5efcb61ded04787566885 (diff) | |
download | mariadb-git-1688ada0e2ce3bf5e62f1539811f0cfb0d8bc4b6.tar.gz |
Proposed fix for #674
This crash happens in rather exotic case when we try to run
SELECT DISTINCT some_func(SUM(some_field)) GROUP BY another_field;
on a table with single row.
Optimizer marks this table as const, sets group=NULL (with remove_const)
thus, create_tmp_table makes mistake collecting columns for temporary table
and then crashes because the field_count gets less than hidden_columns_count.
sql/sql_select.cc:
There's several ways to fix this bug.
This one looks easy and correct to me
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0e8b191e4ef..cb056100e2a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -453,6 +453,9 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, goto err; thd->proc_info="preparing"; + + select_distinct= select_distinct && (join.const_tables != join.tables); + if (result->initialize_tables(&join)) goto err; if (join.const_table_map != join.found_const_table_map && |