Commit 879878e4 authored by Varun Gupta's avatar Varun Gupta

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
parent 51823483
...@@ -1378,5 +1378,19 @@ group_concat(a,b limit ?) ...@@ -1378,5 +1378,19 @@ group_concat(a,b limit ?)
1a,1b,2x,2y 1a,1b,2x,2y
drop table t2; 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 # End of 10.3 tests
# #
...@@ -985,6 +985,18 @@ prepare STMT from 'select group_concat(a,b limit ?) from t2'; ...@@ -985,6 +985,18 @@ prepare STMT from 'select group_concat(a,b limit ?) from t2';
execute STMT using @x; execute STMT using @x;
drop table t2; 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 #
--echo # End of 10.3 tests --echo # End of 10.3 tests
--echo # --echo #
...@@ -4172,7 +4172,19 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) ...@@ -4172,7 +4172,19 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type)
} }
str->append(STRING_WITH_LEN(" separator \'")); str->append(STRING_WITH_LEN(" separator \'"));
str->append_for_single_quote(separator->ptr(), separator->length()); 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(")"));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment