Commit d5b1d620 authored by unknown's avatar unknown

Bug#30897 GROUP_CONCAT returns extra comma on empty fields

The fix is a copy of Martin Friebe's suggestion.
added testing for no_appended which will be false if anything,
including the empty string is in result


mysql-test/r/func_gconcat.result:
  test result
mysql-test/t/func_gconcat.test:
  test case
sql/item_sum.cc:
  added testing for no_appended which will be False if anything,
  including the empty string is in result
parent 95e66de2
...@@ -861,4 +861,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1; ...@@ -861,4 +861,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1;
group_concat(distinct a, c order by a desc, c desc) group_concat(distinct a, c order by a desc, c desc)
31,11,10,01,00 31,11,10,01,00
drop table t1; drop table t1;
create table t1 (f1 char(20));
insert into t1 values (''),('');
select group_concat(distinct f1) from t1;
group_concat(distinct f1)
select group_concat(f1) from t1;
group_concat(f1)
,
drop table t1;
End of 5.0 tests End of 5.0 tests
...@@ -590,4 +590,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1; ...@@ -590,4 +590,13 @@ select group_concat(distinct a, c order by a desc, c desc) from t1;
drop table t1; drop table t1;
#
# Bug#30897 GROUP_CONCAT returns extra comma on empty fields
#
create table t1 (f1 char(20));
insert into t1 values (''),('');
select group_concat(distinct f1) from t1;
select group_concat(f1) from t1;
drop table t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -3406,7 +3406,7 @@ String* Item_func_group_concat::val_str(String* str) ...@@ -3406,7 +3406,7 @@ String* Item_func_group_concat::val_str(String* str)
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
if (null_value) if (null_value)
return 0; return 0;
if (!result.length() && tree) if (no_appended && tree)
/* Tree is used for sorting as in ORDER BY */ /* Tree is used for sorting as in ORDER BY */
tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this,
left_root_right); left_root_right);
......
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