List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:March 25 2005 1:25am
Subject:bk commit into 4.1 tree (jimw:1.2146) BUG#8681
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw 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
  1.2146 05/03/24 16:25:01 jimw@stripped +3 -0
  Make sure that warning message when GROUP_CONCAT() cuts values is always
  updated with the correct number of lines. (Bug #8681)

  sql/item_sum.cc
    1.133 05/03/24 16:24:58 jimw@stripped +17 -8
    Move cleanup of warning message outside of "if (original)" test or it won't
    always get cleaned up, and add assert that there is no warning on the
    original.

  mysql-test/t/func_gconcat.test
    1.26 05/03/24 16:24:58 jimw@stripped +12 -0
    Add regression test

  mysql-test/r/func_gconcat.result
    1.35 05/03/24 16:24:58 jimw@stripped +25 -0
    Add results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-8681b

--- 1.132/sql/item_sum.cc	2005-02-22 02:51:20 -08:00
+++ 1.133/sql/item_sum.cc	2005-03-24 16:24:58 -08:00
@@ -1787,16 +1787,28 @@
 
 void Item_func_group_concat::cleanup()
 {
+  THD *thd= current_thd;
+
   DBUG_ENTER("Item_func_group_concat::cleanup");
   Item_sum::cleanup();
 
+  DBUG_ASSERT(!original || !original->warning);
+
+  /* Adjust warning message to include total number of cut values */
+  if (warning)
+  {
+    char warn_buff[MYSQL_ERRMSG_SIZE];
+    sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values);
+    warning->set_msg(thd, warn_buff);
+    warning= 0;
+  }
+
   /*
     Free table and tree if they belong to this item (if item have not pointer
     to original item from which was made copy => it own its objects )
   */
   if (!original)
   {
-    THD *thd= current_thd;
     if (table)
     {
       free_tmp_table(thd, table);
@@ -1809,13 +1821,6 @@
       tree_mode= 0;
       delete_tree(tree); 
     }
-    if (warning)
-    {
-      char warn_buff[MYSQL_ERRMSG_SIZE];
-      sprintf(warn_buff, ER(ER_CUT_VALUE_GROUP_CONCAT), count_cut_values);
-      warning->set_msg(thd, warn_buff);
-      warning= 0;
-    }
   }
   DBUG_VOID_RETURN;
 }
@@ -2076,6 +2081,10 @@
   if (null_value)
     return 0;
   if (count_cut_values && !warning)
+    /*
+      ER_CUT_VALUE_GROUP_CONCAT needs an argument, but this gets set in
+      Item_func_group_concat::cleanup().
+    */
     warning= push_warning(item_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
                           ER_CUT_VALUE_GROUP_CONCAT,
                           ER(ER_CUT_VALUE_GROUP_CONCAT));

--- 1.34/mysql-test/r/func_gconcat.result	2005-03-16 05:44:22 -08:00
+++ 1.35/mysql-test/r/func_gconcat.result	2005-03-24 16:24:58 -08:00
@@ -469,3 +469,28 @@
 1	1,1
 2	2,2
 drop table r2;
+set group_concat_max_len=5;
+create table t1 (a int, b varchar(20));
+create table t2 (a int, c varchar(20));
+insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
+insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
+select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
+group_concat(t1.b,t2.c)
+aaaaa
+bbbbb
+Warnings:
+Warning	1260	2 line(s) were cut by GROUP_CONCAT()
+select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
+group_concat(t1.b,t2.c)
+aaaaa
+bbbbb
+Warnings:
+Warning	1260	2 line(s) were cut by GROUP_CONCAT()
+select a from t1 where substring(b,1,5) in (select group_concat(t1.b,t2.c) from t1 inner
join t2 using(a) group by t1.a);
+a
+1
+2
+Warnings:
+Warning	1260	4 line(s) were cut by GROUP_CONCAT()
+drop table t1, t2;
+set group_concat_max_len=default;

--- 1.25/mysql-test/t/func_gconcat.test	2005-03-16 05:44:22 -08:00
+++ 1.26/mysql-test/t/func_gconcat.test	2005-03-24 16:24:58 -08:00
@@ -292,3 +292,15 @@
 insert into r2 values (1,1), (2,2);
 select  b x, (select group_concat(x) from r2) from  r2;
 drop table r2;
+
+# Bug #8681: Bad warning message when group_concat() exceeds max length
+set group_concat_max_len=5;
+create table t1 (a int, b varchar(20));
+create table t2 (a int, c varchar(20));
+insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
+insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
+select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
+select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
+select a from t1 where substring(b,1,5) in (select group_concat(t1.b,t2.c) from t1 inner
join t2 using(a) group by t1.a);
+drop table t1, t2;
+set group_concat_max_len=default;
Thread
bk commit into 4.1 tree (jimw:1.2146) BUG#8681Jim Winstead25 Mar