From 8f5c3f3981acdf45a7ffa67b2a74b2a72bcdf1c9 Mon Sep 17 00:00:00 2001 From: "bell@laptop.sanja.is.com.ua" <> Date: Sun, 12 Oct 2003 16:10:40 +0300 Subject: [PATCH] fixed fix_fields() parameters for GROUP_CONCAT() ORDER BY clause (BUG#1537) --- mysql-test/r/func_gconcat.result | 11 +++++++++++ mysql-test/t/func_gconcat.test | 9 ++++++++- sql/item_sum.cc | 4 ++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 2b6079d5ffd..5eae6b4b871 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -196,3 +196,14 @@ insert into t1 values('test'),('test2'); select * from t1 having group_concat(bar)=''; bar drop table t1; +create table t1 (a int, a1 varchar(10)); +create table t2 (a0 int); +insert into t1 values (0,"a"),(0,"b"),(1,"c"); +insert into t2 values (1),(2),(3); +select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1; +group_concat(a1 order by (t1.a IN (select a0 from t2))) +b,a,c +select group_concat(a1 order by (t1.a)) from t1; +group_concat(a1 order by (t1.a)) +b,a,c +drop table t1, t2; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index e82d732d42c..041225bdaf5 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -119,4 +119,11 @@ insert into t1 values('test'),('test2'); select * from t1 having group_concat(bar)=''; drop table t1; - +# ORDER BY fix_fields() +create table t1 (a int, a1 varchar(10)); +create table t2 (a0 int); +insert into t1 values (0,"a"),(0,"b"),(1,"c"); +insert into t2 values (1),(2),(3); +select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1; +select group_concat(a1 order by (t1.a)) from t1; +drop table t1, t2; \ No newline at end of file diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 967abbc5ab8..6a213962c6a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1773,8 +1773,8 @@ Item_func_group_concat::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) for (i= 0 ; i < arg_count_order ; i++) { ORDER *order_item= order[i]; - Item *item=*order_item->item; - if (item->fix_fields(thd, tables, &item) || item->check_cols(1)) + if ((*order_item->item)->fix_fields(thd, tables, order_item->item) || + (*order_item->item)->check_cols(1)) return 1; } result_field= 0;