diff options
-rw-r--r-- | mysql-test/r/func_gconcat.result | 3 | ||||
-rw-r--r-- | mysql-test/t/func_gconcat.test | 5 | ||||
-rw-r--r-- | sql/item_sum.cc | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 9faee3cbc01..a6c25fcd26c 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -548,3 +548,6 @@ FROM t1 JOIN t2 ON t1.bID = t2.bID; COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') 2 test DROP TABLE t1,t2; +select * from (select group_concat('c') from DUAL) t; +group_concat('c') +NULL diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 9793d0d0a2c..827a2813718 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -343,4 +343,9 @@ SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') 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 diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 74a7fee113e..000dcdb4997 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1916,7 +1916,7 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) } thd->allow_sum_func= 0; - maybe_null= 0; + maybe_null= 1; item_thd= thd; /* @@ -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]->check_cols(1)) return 1; - if (i < arg_count_field) - maybe_null|= args[i]->maybe_null; } if (agg_item_charsets(collation, func_name(), |