mirror of
https://github.com/MariaDB/server.git
synced 2025-03-26 17:08:41 +01:00
MDEV-31276 Wrong warnings on 2-nd execution of PS for query with GROUP_CONCAT
If a query with GROUP_CONCAT is executed then the server reports a warning every time when the length of the result of this function exceeds the set value of the system variable group_concat_max_len. This bug led to the set of warnings from the second execution of the prepared statement that did not coincide with the one from the first execution if the executed query was a grouping query over a join of tables using GROUP_CONCAT function and join cache was not allowed to be employed. The descrepancy of the sets of warnings was due to lack of cleanup for Item_func_group_concat::row_count after execution of the query. Approved by Oleksandr Byelkin <sanja@mariadb.com>
This commit is contained in:
parent
e63311c2cf
commit
8778a83eee
5 changed files with 116 additions and 15 deletions
|
@ -1443,3 +1443,78 @@ drop table t1;
|
|||
#
|
||||
# End of 10.3 tests
|
||||
#
|
||||
#
|
||||
# MDEV-31276: Execution of PS from grouping query with join
|
||||
# and GROUP_CONCAT set function
|
||||
#
|
||||
create table t1 (a int, b varchar(20)) engine=myisam;
|
||||
create table t2 (a int, c varchar(20)) engine=myisam;
|
||||
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
|
||||
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
|
||||
insert into t2 values (1,"eeeeeee"),(2,"fffffff");
|
||||
set group_concat_max_len=5;
|
||||
select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
explain select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
|
||||
prepare stmt from "select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a";
|
||||
execute stmt;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
execute stmt;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
deallocate prepare stmt;
|
||||
set join_cache_level=0;
|
||||
select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
explain select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using filesort
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
|
||||
prepare stmt from "select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a";
|
||||
execute stmt;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
execute stmt;
|
||||
count(*) group_concat(t1.b,t2.c)
|
||||
2 aaaaa
|
||||
2 bbbbb
|
||||
Warnings:
|
||||
Warning 1260 Row 1 was cut by GROUP_CONCAT()
|
||||
Warning 1260 Row 2 was cut by GROUP_CONCAT()
|
||||
deallocate prepare stmt;
|
||||
set join_cache_level=default;
|
||||
set group_concat_max_len=default;
|
||||
drop table t1,t2;
|
||||
# End of 10.5 tests
|
||||
|
|
|
@ -1066,3 +1066,43 @@ drop table t1;
|
|||
--echo #
|
||||
--echo # End of 10.3 tests
|
||||
--echo #
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-31276: Execution of PS from grouping query with join
|
||||
--echo # and GROUP_CONCAT set function
|
||||
--echo #
|
||||
|
||||
create table t1 (a int, b varchar(20)) engine=myisam;
|
||||
create table t2 (a int, c varchar(20)) engine=myisam;
|
||||
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
|
||||
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
|
||||
insert into t2 values (1,"eeeeeee"),(2,"fffffff");
|
||||
|
||||
let $q=
|
||||
select count(*), group_concat(t1.b,t2.c)
|
||||
from t1 join t2 on t1.a=t2.a group by t1.a;
|
||||
|
||||
set group_concat_max_len=5;
|
||||
|
||||
eval $q;
|
||||
eval explain $q;
|
||||
eval prepare stmt from "$q";
|
||||
execute stmt;
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
set join_cache_level=0;
|
||||
|
||||
eval $q;
|
||||
eval explain $q;
|
||||
eval prepare stmt from "$q";
|
||||
execute stmt;
|
||||
execute stmt;
|
||||
deallocate prepare stmt;
|
||||
|
||||
set join_cache_level=default;
|
||||
set group_concat_max_len=default;
|
||||
|
||||
drop table t1,t2;
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
|
|
@ -685,15 +685,9 @@ create table t1 (a int, b varchar(20));
|
|||
create table t2 (a int, c varchar(20));
|
||||
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
|
||||
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
|
||||
#Enable after fix MDEV-31276
|
||||
--disable_ps2_protocol
|
||||
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
|
||||
--enable_ps2_protocol
|
||||
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
|
||||
#Enable after fix MDEV-31276
|
||||
--disable_ps2_protocol
|
||||
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a;
|
||||
--enable_ps2_protocol
|
||||
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a;
|
||||
drop table t1, t2;
|
||||
set group_concat_max_len=default;
|
||||
|
|
|
@ -523,8 +523,6 @@ where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
|
|||
# group_concat with a blob argument - depends on
|
||||
# the variable group_concat_max_len, and
|
||||
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
|
||||
#Check after fix MDEV-31276
|
||||
--disable_ps2_protocol
|
||||
explain extended select left(a1,7), left(a2,7)
|
||||
from t1_512
|
||||
where a1 in (select group_concat(b1) from t2_512 group by b2);
|
||||
|
@ -542,7 +540,6 @@ where a1 in (select group_concat(b1) from t2_512 group by b2);
|
|||
select left(a1,7), left(a2,7)
|
||||
from t1_512
|
||||
where a1 in (select group_concat(b1) from t2_512 group by b2);
|
||||
--enable_ps2_protocol
|
||||
|
||||
drop table t1_512, t2_512, t3_512;
|
||||
|
||||
|
@ -608,8 +605,6 @@ where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
|
|||
# group_concat with a blob argument - depends on
|
||||
# the variable group_concat_max_len, and
|
||||
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
|
||||
#Check after fix MDEV-31276
|
||||
--disable_ps2_protocol
|
||||
explain extended select left(a1,7), left(a2,7)
|
||||
from t1_1024
|
||||
where a1 in (select group_concat(b1) from t2_1024 group by b2);
|
||||
|
@ -627,7 +622,6 @@ where a1 in (select group_concat(b1) from t2_1024 group by b2);
|
|||
select left(a1,7), left(a2,7)
|
||||
from t1_1024
|
||||
where a1 in (select group_concat(b1) from t2_1024 group by b2);
|
||||
--enable_ps2_protocol
|
||||
|
||||
drop table t1_1024, t2_1024, t3_1024;
|
||||
|
||||
|
@ -693,8 +687,6 @@ where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
|
|||
# group_concat with a blob argument - depends on
|
||||
# the variable group_concat_max_len, and
|
||||
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
|
||||
#Check after fix MDEV-31276
|
||||
--disable_ps2_protocol
|
||||
explain extended select left(a1,7), left(a2,7)
|
||||
from t1_1025
|
||||
where a1 in (select group_concat(b1) from t2_1025 group by b2);
|
||||
|
@ -712,7 +704,6 @@ where a1 in (select group_concat(b1) from t2_1025 group by b2);
|
|||
select left(a1,7), left(a2,7)
|
||||
from t1_1025
|
||||
where a1 in (select group_concat(b1) from t2_1025 group by b2);
|
||||
--enable_ps2_protocol
|
||||
|
||||
drop table t1_1025, t2_1025, t3_1025;
|
||||
|
||||
|
|
|
@ -4056,6 +4056,7 @@ void Item_func_group_concat::cleanup()
|
|||
unique_filter= NULL;
|
||||
}
|
||||
}
|
||||
row_count= 0;
|
||||
DBUG_ASSERT(tree == 0);
|
||||
}
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue