diff options
author | jimw@mysql.com <> | 2005-04-04 18:29:18 -0700 |
---|---|---|
committer | jimw@mysql.com <> | 2005-04-04 18:29:18 -0700 |
commit | 247f2ac563f6ff157b6b3c6f0d9408ea9a2d276b (patch) | |
tree | 3272382754e3df3ca707e76b48a80bd01e39a8f5 | |
parent | 59b1a1f62f096a939ce14873804b63c88a6b5e17 (diff) | |
parent | 624f855e948c374bda73f0594e4be9090dd90be0 (diff) | |
download | mariadb-git-247f2ac563f6ff157b6b3c6f0d9408ea9a2d276b.tar.gz |
Merge new tests
-rw-r--r-- | mysql-test/r/join_outer.result | 19 | ||||
-rw-r--r-- | mysql-test/t/join_outer.test | 11 | ||||
-rw-r--r-- | sql/item_sum.cc | 23 |
3 files changed, 44 insertions, 9 deletions
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index b035f88da41..b6265aac4a3 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -864,3 +864,22 @@ a b a b 3 1 NULL NULL 4 2 NULL NULL DROP TABLE t1,t2; +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() +drop table t1, t2; +set group_concat_max_len=default; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index fe9ec1e0963..d5fa1592965 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -614,4 +614,13 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE not(0+(t1.a=30 and t2.b=1)); DROP TABLE t1,t2; - +# 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; +drop table t1, t2; +set group_concat_max_len=default; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 6bd2cc00b3e..7e9c5d09136 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1787,16 +1787,26 @@ Item_func_group_concat::Item_func_group_concat(THD *thd, void Item_func_group_concat::cleanup() { + THD *thd= current_thd; + DBUG_ENTER("Item_func_group_concat::cleanup"); Item_sum::cleanup(); + /* 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 +1819,6 @@ void Item_func_group_concat::cleanup() 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 +2079,10 @@ String* Item_func_group_concat::val_str(String* str) 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)); |