From a5c87958a6ae43bd4b998dd4d54a19043a8e3b0f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Mar 2005 16:44:28 +0300 Subject: [PATCH] Fix for bug#8656: Crash with group_concat on alias in outer table fixed result_field support of Item_ref --- mysql-test/r/func_gconcat.result | 7 +++++++ mysql-test/t/func_gconcat.test | 8 ++++++++ sql/item.h | 1 + 3 files changed, 16 insertions(+) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 390b33fdddc..c1ac1c084df 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -462,3 +462,10 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; gc NULL DROP TABLE t1; +create table r2 (a int, b int); +insert into r2 values (1,1), (2,2); +select b x, (select group_concat(x) from r2) from r2; +x (select group_concat(x) from r2) +1 1,1 +2 2,2 +drop table r2; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 6a91a7ac9c7..d32c8796075 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -284,3 +284,11 @@ drop table t1; CREATE TABLE t1 (id int); SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; DROP TABLE t1; + +# +# Bug #8656: Crash with group_concat on alias in outer table +# +create table r2 (a int, b int); +insert into r2 values (1,1), (2,2); +select b x, (select group_concat(x) from r2) from r2; +drop table r2; diff --git a/sql/item.h b/sql/item.h index adc780677e1..78de2a1f58e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -902,6 +902,7 @@ public: void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); } enum Item_result result_type () const { return (*ref)->result_type(); } enum_field_types field_type() const { return (*ref)->field_type(); } + Field *get_tmp_table_field() { return result_field; } table_map used_tables() const { return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();