From: Date: October 29 2007 11:53am Subject: bk commit into 5.0 tree (gluh:1.2555) BUG#30897 List-Archive: http://lists.mysql.com/commits/36538 X-Bug: 30897 Message-Id: <20071029105314.B12CA24A0077@eagle.localdomain> Below is the list of changes that have just been committed into a local 5.0 repository of gluh. When gluh does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-10-29 14:53:10+04:00, gluh@stripped +3 -0 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@stripped, 2007-10-29 14:53:09+04:00, gluh@stripped +9 -0 test result mysql-test/t/func_gconcat.test@stripped, 2007-10-29 14:53:09+04:00, gluh@stripped +9 -0 test case sql/item_sum.cc@stripped, 2007-10-29 14:53:09+04:00, gluh@stripped +1 -1 added testing for no_appended which will be False if anything, including the empty string is in result diff -Nrup a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result --- a/mysql-test/r/func_gconcat.result 2007-10-11 17:20:32 +05:00 +++ b/mysql-test/r/func_gconcat.result 2007-10-29 14:53:09 +04:00 @@ -861,4 +861,13 @@ select group_concat(distinct a, c order group_concat(distinct a, c order by a desc, c desc) 31,11,10,01,00 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 diff -Nrup a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test --- a/mysql-test/t/func_gconcat.test 2007-10-11 17:20:32 +05:00 +++ b/mysql-test/t/func_gconcat.test 2007-10-29 14:53:09 +04:00 @@ -590,4 +590,13 @@ select group_concat(distinct a, c order 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 diff -Nrup a/sql/item_sum.cc b/sql/item_sum.cc --- a/sql/item_sum.cc 2007-10-23 18:48:55 +05:00 +++ b/sql/item_sum.cc 2007-10-29 14:53:09 +04:00 @@ -3406,7 +3406,7 @@ String* Item_func_group_concat::val_str( DBUG_ASSERT(fixed == 1); if (null_value) return 0; - if (!result.length() && tree) + if (no_appended && tree) /* Tree is used for sorting as in ORDER BY */ tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, left_root_right);