[Commits] 89a5832: MDEV-18943: Group Concat with limit not working with views
revision-id: 89a583247bdfaea92598919f01079101b8003e02 (mariadb-10.3.12-86-g89a5832) parent(s): 51e48b9f8981986257a1cfbdf75e4fc29a5959c1 author: Varun Gupta committer: Varun Gupta timestamp: 2019-03-16 09:02:14 +0530 message: MDEV-18943: Group Concat with limit not working with views Adjusted the Item_func_group_concat::print function to take into account limit if present with GROUP_CONCAT --- mysql-test/main/func_gconcat.result | 14 ++++++++++++++ mysql-test/main/func_gconcat.test | 12 ++++++++++++ sql/item_sum.cc | 14 +++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_gconcat.result b/mysql-test/main/func_gconcat.result index 723a195..1701bb3 100644 --- a/mysql-test/main/func_gconcat.result +++ b/mysql-test/main/func_gconcat.result @@ -1378,5 +1378,19 @@ group_concat(a,b limit ?) 1a,1b,2x,2y drop table t2; # +# MDEV-18943: Group Concat with limit not working with views +# +create table t1 (a int, b varchar(10)); +insert into t1 values(1,'a'),(1,'b'),(NULL,'c'),(2,'x'),(2,'y'); +select group_concat(a,b limit 2) from t1; +group_concat(a,b limit 2) +1a,1b +create view v1 as select group_concat(a,b limit 2) from t1; +select * from v1; +group_concat(a,b limit 2) +1a,1b +drop view v1; +drop table t1; +# # End of 10.3 tests # diff --git a/mysql-test/main/func_gconcat.test b/mysql-test/main/func_gconcat.test index 5cbc696..b8ab96b 100644 --- a/mysql-test/main/func_gconcat.test +++ b/mysql-test/main/func_gconcat.test @@ -986,5 +986,17 @@ execute STMT using @x; drop table t2; --echo # +--echo # MDEV-18943: Group Concat with limit not working with views +--echo # + +create table t1 (a int, b varchar(10)); +insert into t1 values(1,'a'),(1,'b'),(NULL,'c'),(2,'x'),(2,'y'); +select group_concat(a,b limit 2) from t1; +create view v1 as select group_concat(a,b limit 2) from t1; +select * from v1; +drop view v1; +drop table t1; + +--echo # --echo # End of 10.3 tests --echo # diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 44e5a86..4fe547a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -4159,7 +4159,19 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) } str->append(STRING_WITH_LEN(" separator \'")); str->append_for_single_quote(separator->ptr(), separator->length()); - str->append(STRING_WITH_LEN("\')")); + str->append(STRING_WITH_LEN("\'")); + + if (limit_clause) + { + str->append(STRING_WITH_LEN(" limit ")); + if (offset_limit) + { + offset_limit->print(str, query_type); + str->append(','); + } + row_limit->print(str, query_type); + } + str->append(STRING_WITH_LEN(")")); }
participants (1)
-
varun