Skip to content

Commit c7a2fb1

Browse files
committed
Merge 10.3 into 10.4
2 parents 9d479e2 + 4612cb8 commit c7a2fb1

32 files changed

+431
-66
lines changed

include/ilist.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ template <class T, class Tag= void> class ilist
9999
reference operator*() { return *static_cast<pointer>(node_); }
100100
pointer operator->() { return static_cast<pointer>(node_); }
101101

102-
bool operator==(const Iterator &rhs) { return node_ == rhs.node_; }
103-
bool operator!=(const Iterator &rhs) { return !(*this == rhs); }
102+
friend bool operator==(const Iterator &lhs, const Iterator &rhs)
103+
{
104+
return lhs.node_ == rhs.node_;
105+
}
106+
friend bool operator!=(const Iterator &lhs, const Iterator &rhs)
107+
{
108+
return !(lhs == rhs);
109+
}
104110

105111
private:
106112
ListNode *node_;

mysql-test/include/ctype_utf8mb4.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ drop table t1;
15871587
--echo #
15881588
--echo # Check strnxfrm() with odd length
15891589
--echo #
1590-
set max_sort_length=5;
1590+
set max_sort_length=9;
15911591
select @@max_sort_length;
15921592
eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine;
15931593
insert into t1 values ('a'),('b'),('c');

mysql-test/main/cte_recursive.result

Lines changed: 162 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3692,7 +3692,168 @@ select * from t1 as t;
36923692
id select_type table type possible_keys key key_len ref rows Extra
36933693
1 PRIMARY t ALL NULL NULL NULL NULL 4
36943694
drop table t1,t2;
3695-
# End of 10.2 tests
3695+
#
3696+
# MDEV-22042: ANALYZE of query using stored function and recursive CTE
3697+
#
3698+
create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
3699+
insert into t1 values (1,1),(2,2),(3,3);
3700+
create table t2 (
3701+
a2 varchar(20) primary key, b1 varchar(20), key (b1)
3702+
) engine=myisam;
3703+
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
3704+
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);
3705+
create function f1(id varchar(20)) returns varchar(50)
3706+
begin
3707+
declare res varchar (50);
3708+
select a2 into res from t2 where a2=id and b1=1 limit 1;
3709+
return res;
3710+
end$$
3711+
select fv
3712+
from (select t1.a1, f1(t1.a2) fv from t1) dt
3713+
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
3714+
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
3715+
select a2 from cte);
3716+
fv
3717+
NULL
3718+
explain select fv
3719+
from (select t1.a1, f1(t1.a2) fv from t1) dt
3720+
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
3721+
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
3722+
select a2 from cte);
3723+
id select_type table type possible_keys key key_len ref rows Extra
3724+
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
3725+
1 PRIMARY <subquery5> eq_ref distinct_key distinct_key 23 func 1
3726+
5 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2
3727+
3 DERIVED t2 const PRIMARY PRIMARY 22 const 1 Using index
3728+
4 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 2 Using where
3729+
4 RECURSIVE UNION tt2 ref b1 b1 23 cte.a2 2
3730+
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
3731+
analyze format=json select fv
3732+
from (select t1.a1, f1(t1.a2) fv from t1) dt
3733+
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
3734+
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
3735+
select a2 from cte);
3736+
ANALYZE
3737+
{
3738+
"query_block": {
3739+
"select_id": 1,
3740+
"r_loops": 1,
3741+
"r_total_time_ms": "REPLACED",
3742+
"const_condition": "1",
3743+
"table": {
3744+
"table_name": "t1",
3745+
"access_type": "ALL",
3746+
"r_loops": 1,
3747+
"rows": 3,
3748+
"r_rows": 3,
3749+
"r_total_time_ms": "REPLACED",
3750+
"filtered": 100,
3751+
"r_filtered": 100
3752+
},
3753+
"table": {
3754+
"table_name": "<subquery5>",
3755+
"access_type": "eq_ref",
3756+
"possible_keys": ["distinct_key"],
3757+
"key": "distinct_key",
3758+
"key_length": "23",
3759+
"used_key_parts": ["a2"],
3760+
"ref": ["func"],
3761+
"r_loops": 3,
3762+
"rows": 1,
3763+
"r_rows": 0.3333,
3764+
"r_total_time_ms": "REPLACED",
3765+
"filtered": 100,
3766+
"r_filtered": 100,
3767+
"materialized": {
3768+
"unique": 1,
3769+
"query_block": {
3770+
"select_id": 5,
3771+
"table": {
3772+
"table_name": "<derived3>",
3773+
"access_type": "ALL",
3774+
"r_loops": 1,
3775+
"rows": 2,
3776+
"r_rows": 1,
3777+
"r_total_time_ms": "REPLACED",
3778+
"filtered": 100,
3779+
"r_filtered": 100,
3780+
"materialized": {
3781+
"query_block": {
3782+
"recursive_union": {
3783+
"table_name": "<union3,4>",
3784+
"access_type": "ALL",
3785+
"r_loops": 0,
3786+
"r_rows": null,
3787+
"query_specifications": [
3788+
{
3789+
"query_block": {
3790+
"select_id": 3,
3791+
"r_loops": 1,
3792+
"r_total_time_ms": "REPLACED",
3793+
"table": {
3794+
"table_name": "t2",
3795+
"access_type": "const",
3796+
"possible_keys": ["PRIMARY"],
3797+
"key": "PRIMARY",
3798+
"key_length": "22",
3799+
"used_key_parts": ["a2"],
3800+
"ref": ["const"],
3801+
"r_loops": 0,
3802+
"rows": 1,
3803+
"r_rows": null,
3804+
"filtered": 100,
3805+
"r_filtered": null,
3806+
"using_index": true
3807+
}
3808+
}
3809+
},
3810+
{
3811+
"query_block": {
3812+
"select_id": 4,
3813+
"operation": "UNION",
3814+
"r_loops": 1,
3815+
"r_total_time_ms": "REPLACED",
3816+
"table": {
3817+
"table_name": "<derived3>",
3818+
"access_type": "ALL",
3819+
"r_loops": 1,
3820+
"rows": 2,
3821+
"r_rows": 1,
3822+
"r_total_time_ms": "REPLACED",
3823+
"filtered": 100,
3824+
"r_filtered": 100,
3825+
"attached_condition": "cte.a2 is not null"
3826+
},
3827+
"table": {
3828+
"table_name": "tt2",
3829+
"access_type": "ref",
3830+
"possible_keys": ["b1"],
3831+
"key": "b1",
3832+
"key_length": "23",
3833+
"used_key_parts": ["b1"],
3834+
"ref": ["cte.a2"],
3835+
"r_loops": 1,
3836+
"rows": 2,
3837+
"r_rows": 1,
3838+
"r_total_time_ms": "REPLACED",
3839+
"filtered": 100,
3840+
"r_filtered": 100
3841+
}
3842+
}
3843+
}
3844+
]
3845+
}
3846+
}
3847+
}
3848+
}
3849+
}
3850+
}
3851+
}
3852+
}
3853+
}
3854+
drop function f1;
3855+
drop table t1,t2;
3856+
End of 10.2 tests
36963857
#
36973858
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
36983859
#

mysql-test/main/cte_recursive.test

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2571,7 +2571,45 @@ select * from t1 as t;
25712571

25722572
drop table t1,t2;
25732573

2574-
--echo # End of 10.2 tests
2574+
2575+
--echo #
2576+
--echo # MDEV-22042: ANALYZE of query using stored function and recursive CTE
2577+
--echo #
2578+
2579+
create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
2580+
insert into t1 values (1,1),(2,2),(3,3);
2581+
2582+
create table t2 (
2583+
a2 varchar(20) primary key, b1 varchar(20), key (b1)
2584+
) engine=myisam;
2585+
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
2586+
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);
2587+
2588+
delimiter $$;
2589+
create function f1(id varchar(20)) returns varchar(50)
2590+
begin
2591+
declare res varchar (50);
2592+
select a2 into res from t2 where a2=id and b1=1 limit 1;
2593+
return res;
2594+
end$$
2595+
delimiter ;$$
2596+
2597+
let q=
2598+
select fv
2599+
from (select t1.a1, f1(t1.a2) fv from t1) dt
2600+
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
2601+
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
2602+
select a2 from cte);
2603+
2604+
eval $q;
2605+
eval explain $q;
2606+
--source include/analyze-format.inc
2607+
eval analyze format=json $q;
2608+
2609+
drop function f1;
2610+
drop table t1,t2;
2611+
2612+
--echo End of 10.2 tests
25752613

25762614
--echo #
25772615
--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field

mysql-test/main/ctype_utf16.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ ab
14911491
ab
14921492
AE
14931493
AE
1494-
SET max_sort_length=4;
1494+
SET max_sort_length=8;
14951495
SELECT * FROM t1 ORDER BY s1;
14961496
s1
14971497
ab

mysql-test/main/ctype_utf16.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
723723
SHOW CREATE TABLE t1;
724724
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
725725
SELECT * FROM t1 ORDER BY s1;
726-
SET max_sort_length=4;
726+
SET max_sort_length=8;
727727
SELECT * FROM t1 ORDER BY s1;
728728
DROP TABLE t1;
729729
SET max_sort_length=DEFAULT;

mysql-test/main/ctype_utf16le.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ ab
17641764
ab
17651765
AE
17661766
AE
1767-
SET max_sort_length=4;
1767+
SET max_sort_length=8;
17681768
SELECT * FROM t1 ORDER BY s1;
17691769
s1
17701770
ab

mysql-test/main/ctype_utf16le.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0;
685685
SHOW CREATE TABLE t1;
686686
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
687687
SELECT * FROM t1 ORDER BY s1;
688-
SET max_sort_length=4;
688+
SET max_sort_length=8;
689689
SELECT * FROM t1 ORDER BY s1;
690690
DROP TABLE t1;
691691
SET max_sort_length=DEFAULT;

mysql-test/main/ctype_utf32.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ ab
15041504
ab
15051505
AE
15061506
AE
1507-
SET max_sort_length=4;
1507+
SET max_sort_length=8;
15081508
SELECT * FROM t1 ORDER BY s1;
15091509
s1
15101510
ab

mysql-test/main/ctype_utf32.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
779779
SHOW CREATE TABLE t1;
780780
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
781781
SELECT * FROM t1 ORDER BY s1;
782-
SET max_sort_length=4;
782+
SET max_sort_length=8;
783783
SELECT * FROM t1 ORDER BY s1;
784784
DROP TABLE t1;
785785
SET max_sort_length=DEFAULT;

0 commit comments

Comments
 (0)