Commit f1fb30a1 authored by evgen@moonbone.local's avatar evgen@moonbone.local

Fix bug #12861 client hang with group_concat insubquery FROM DUAL.

Item_func_group_concat::fix_fields() set maybe_null flag to 0, and set it to
1 only if some of it's arguments may be null. When used in subquery in tmp 
table created field which can't be null. When no data retireved result field
have to be set to null and error mentioned in bug report occurs. Also this 
bug can occur if selecting from not null field in empty table.

Function group_concat now marked maybe_null from the very beginning not only
if some of it's argument may be null.
parent b5c01d79
...@@ -548,3 +548,6 @@ FROM t1 JOIN t2 ON t1.bID = t2.bID; ...@@ -548,3 +548,6 @@ FROM t1 JOIN t2 ON t1.bID = t2.bID;
COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
2 test 2 test
DROP TABLE t1,t2; DROP TABLE t1,t2;
select * from (select group_concat('c') from DUAL) t;
group_concat('c')
NULL
...@@ -343,4 +343,9 @@ SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') ...@@ -343,4 +343,9 @@ SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug #12861 hang with group_concat insubquery FROM DUAL
#
select * from (select group_concat('c') from DUAL) t;
# End of 4.1 tests # End of 4.1 tests
...@@ -1916,7 +1916,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1916,7 +1916,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
} }
thd->allow_sum_func= 0; thd->allow_sum_func= 0;
maybe_null= 0; maybe_null= 1;
item_thd= thd; item_thd= thd;
/* /*
...@@ -1929,8 +1929,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -1929,8 +1929,6 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
args[i]->fix_fields(thd, tables, args + i)) || args[i]->fix_fields(thd, tables, args + i)) ||
args[i]->check_cols(1)) args[i]->check_cols(1))
return 1; return 1;
if (i < arg_count_field)
maybe_null|= args[i]->maybe_null;
} }
if (agg_item_charsets(collation, func_name(), if (agg_item_charsets(collation, func_name(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment