summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatiana A. Nurnberg <azundris@mysql.com>2010-02-19 19:06:47 +0000
committerTatiana A. Nurnberg <azundris@mysql.com>2010-02-19 19:06:47 +0000
commitecf4ba96ffaa13eccbc0db64a1c82bc29c4e3112 (patch)
treeca01d689dff2d01fe5f03cdac4803c238a0a93d5
parentb38ac49cf6cdf36ea142a86c60946394f2c3913f (diff)
parent3678457d3c707b341a7461d4d2c0e4d71e75e4f9 (diff)
downloadmariadb-git-ecf4ba96ffaa13eccbc0db64a1c82bc29c4e3112.tar.gz
manual merge
-rw-r--r--mysql-test/r/func_gconcat.result17
-rw-r--r--mysql-test/t/func_gconcat.test15
-rw-r--r--sql/item_sum.cc4
3 files changed, 35 insertions, 1 deletions
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index 3b78851a1b9..8d1fcade88d 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -978,4 +978,21 @@ GROUP BY t1.a
1
1
DROP TABLE t1, t2;
+CREATE TABLE t1 (f1 INT);
+INSERT INTO t1 VALUES (),();
+EXPLAIN EXTENDED SELECT 1 FROM
+(SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort; Distinct
+2 DERIVED td ALL NULL NULL NULL NULL 2 100.00 Distinct; Using join buffer
+Warnings:
+Note 1003 select 1 AS `1` from (select distinct group_concat(`test`.`td`.`f1` separator ',') AS `GROUP_CONCAT(td.f1)` from `test`.`t1` join `test`.`t1` `td` group by `test`.`td`.`f1`) `d` join `test`.`t1`
+SELECT 1 FROM
+(SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+1
+1
+1
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index e92f3e96303..cfb4cdc9ecd 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -693,4 +693,19 @@ SELECT 1 FROM t1 WHERE t1.a NOT IN
DROP TABLE t1, t2;
+#
+# Bug #49487: crash with explain extended and group_concat in a derived table
+#
+
+CREATE TABLE t1 (f1 INT);
+INSERT INTO t1 VALUES (),();
+
+EXPLAIN EXTENDED SELECT 1 FROM
+ (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+
+SELECT 1 FROM
+ (SELECT DISTINCT GROUP_CONCAT(td.f1) FROM t1,t1 AS td GROUP BY td.f1) AS d,t1;
+
+DROP TABLE t1;
+
--echo End of 5.0 tests
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 4ab8e75ddf5..142e90639e8 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3402,6 +3402,8 @@ String* Item_func_group_concat::val_str(String* str)
void Item_func_group_concat::print(String *str, enum_query_type query_type)
{
+ /* orig_args is not filled with valid values until fix_fields() */
+ Item **pargs= fixed ? orig_args : args;
str->append(STRING_WITH_LEN("group_concat("));
if (distinct)
str->append(STRING_WITH_LEN("distinct "));
@@ -3409,7 +3411,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type)
{
if (i)
str->append(',');
- args[i]->print(str, query_type);
+ pargs[i]->print(str, query_type);
}
if (arg_count_order)
{