Skip to content

Commit

Permalink
Merge 10.4 into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Jun 7, 2020
2 parents 7ae1237 + eb14e07 commit 0e69f60
Show file tree
Hide file tree
Showing 33 changed files with 407 additions and 58 deletions.
10 changes: 8 additions & 2 deletions include/ilist.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ template <class T, class Tag= void> class ilist
reference operator*() { return *static_cast<pointer>(node_); }
pointer operator->() { return static_cast<pointer>(node_); }

bool operator==(const Iterator &rhs) { return node_ == rhs.node_; }
bool operator!=(const Iterator &rhs) { return !(*this == rhs); }
friend bool operator==(const Iterator &lhs, const Iterator &rhs)
{
return lhs.node_ == rhs.node_;
}
friend bool operator!=(const Iterator &lhs, const Iterator &rhs)
{
return !(lhs == rhs);
}

private:
ListNode *node_;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/include/ctype_utf8mb4.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,7 @@ drop table t1;
--echo #
--echo # Check strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine;
insert into t1 values ('a'),('b'),('c');
Expand Down
151 changes: 150 additions & 1 deletion mysql-test/main/cte_recursive.result
Original file line number Diff line number Diff line change
Expand Up @@ -3694,7 +3694,156 @@ select * from t1 as t;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ALL NULL NULL NULL NULL 4
drop table t1,t2;
# End of 10.2 tests
#
# MDEV-22042: ANALYZE of query using stored function and recursive CTE
#
create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
insert into t1 values (1,1),(2,2),(3,3);
create table t2 (
a2 varchar(20) primary key, b1 varchar(20), key (b1)
) engine=myisam;
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);
create function f1(id varchar(20)) returns varchar(50)
begin
declare res varchar (50);
select a2 into res from t2 where a2=id and b1=1 limit 1;
return res;
end$$
select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
fv
NULL
explain select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
1 PRIMARY <derived3> ref key0 key0 23 test.t1.a1 1 FirstMatch(t1)
3 DERIVED t2 const PRIMARY PRIMARY 22 const 1 Using index
4 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 2 Using where
4 RECURSIVE UNION tt2 ref b1 b1 23 cte.a2 2
NULL UNION RESULT <union3,4> ALL NULL NULL NULL NULL NULL
analyze format=json select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);
ANALYZE
{
"query_block": {
"select_id": 1,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "t1",
"access_type": "ALL",
"r_loops": 1,
"rows": 3,
"r_rows": 3,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "t1.a1 is not null"
},
"table": {
"table_name": "<derived3>",
"access_type": "ref",
"possible_keys": ["key0"],
"key": "key0",
"key_length": "23",
"used_key_parts": ["a2"],
"ref": ["test.t1.a1"],
"r_loops": 3,
"rows": 1,
"r_rows": 0.333333333,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"first_match": "t1",
"materialized": {
"query_block": {
"recursive_union": {
"table_name": "<union3,4>",
"access_type": "ALL",
"r_loops": 0,
"r_rows": null,
"query_specifications": [
{
"query_block": {
"select_id": 3,
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "t2",
"access_type": "const",
"possible_keys": ["PRIMARY"],
"key": "PRIMARY",
"key_length": "22",
"used_key_parts": ["a2"],
"ref": ["const"],
"r_loops": 0,
"rows": 1,
"r_rows": null,
"filtered": 100,
"r_filtered": null,
"using_index": true
}
}
},
{
"query_block": {
"select_id": 4,
"operation": "UNION",
"r_loops": 1,
"r_total_time_ms": "REPLACED",
"table": {
"table_name": "<derived3>",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 1,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100,
"attached_condition": "cte.a2 is not null"
},
"table": {
"table_name": "tt2",
"access_type": "ref",
"possible_keys": ["b1"],
"key": "b1",
"key_length": "23",
"used_key_parts": ["b1"],
"ref": ["cte.a2"],
"r_loops": 1,
"rows": 2,
"r_rows": 1,
"r_table_time_ms": "REPLACED",
"r_other_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
}
}
}
]
}
}
}
}
}
}
drop function f1;
drop table t1,t2;
End of 10.2 tests
#
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
#
Expand Down
40 changes: 39 additions & 1 deletion mysql-test/main/cte_recursive.test
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,45 @@ select * from t1 as t;

drop table t1,t2;

--echo # End of 10.2 tests

--echo #
--echo # MDEV-22042: ANALYZE of query using stored function and recursive CTE
--echo #

create table t1 (a1 varchar(20),a2 varchar(20)) engine=myisam;
insert into t1 values (1,1),(2,2),(3,3);

create table t2 (
a2 varchar(20) primary key, b1 varchar(20), key (b1)
) engine=myisam;
insert into t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7);
insert into t2 values (11,11),(12,12),(13,13),(14,14),(15,15),(16,16),(17,17);

delimiter $$;
create function f1(id varchar(20)) returns varchar(50)
begin
declare res varchar (50);
select a2 into res from t2 where a2=id and b1=1 limit 1;
return res;
end$$
delimiter ;$$

let q=
select fv
from (select t1.a1, f1(t1.a2) fv from t1) dt
where (dt.a1) in (with recursive cte as (select a2 from t2 where a2='2'
union select tt2.a2 from t2 tt2 join cte on tt2.b1=cte.a2)
select a2 from cte);

eval $q;
eval explain $q;
--source include/analyze-format.inc
eval analyze format=json $q;

drop function f1;
drop table t1,t2;

--echo End of 10.2 tests

--echo #
--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf16.result
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf16.test
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf16le.result
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf16le.test
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ CREATE TABLE t1 AS SELECT REPEAT('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf32.result
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ ab
ab
AE
AE
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
s1
ab
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf32.test
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ CREATE TABLE t1 AS SELECT repeat('a',2) as s1 LIMIT 0;
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES ('ab'),('AE'),('ab'),('AE');
SELECT * FROM t1 ORDER BY s1;
SET max_sort_length=4;
SET max_sort_length=8;
SELECT * FROM t1 ORDER BY s1;
DROP TABLE t1;
SET max_sort_length=DEFAULT;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf8.result
Original file line number Diff line number Diff line change
Expand Up @@ -6757,10 +6757,10 @@ DFFFDFFF9CFF9DFF9EFF
#
# Checking strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf8.test
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ set @@collation_connection=utf8_bin;
--echo #
--echo # Checking strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
create table t1 (a varchar(128) character set utf8 collate utf8_general_ci);
insert into t1 values ('a'),('b'),('c');
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf8mb4.result
Original file line number Diff line number Diff line change
Expand Up @@ -2371,10 +2371,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/main/ctype_utf8mb4.test
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ drop table t1;
--echo #
--echo # Check strnxfrm() with odd length
--echo #
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci);
insert into t1 values ('a'),('b'),('c');
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf8mb4_heap.result
Original file line number Diff line number Diff line change
Expand Up @@ -2203,10 +2203,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine heap;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf8mb4_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -2329,10 +2329,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine InnoDB;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/main/ctype_utf8mb4_myisam.result
Original file line number Diff line number Diff line change
Expand Up @@ -2336,10 +2336,10 @@ drop table t1;
#
# Check strnxfrm() with odd length
#
set max_sort_length=5;
set max_sort_length=9;
select @@max_sort_length;
@@max_sort_length
5
9
create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine MyISAM;
insert into t1 values ('a'),('b'),('c');
select * from t1 order by a;
Expand Down
19 changes: 19 additions & 0 deletions mysql-test/main/long_unique_bugs.result
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,24 @@ ERROR 42000: Specified key was too long; max key length is 2000 bytes
create table t1(a int, unique(a) using hash);
#BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES)
drop table t1;
SET binlog_row_image= NOBLOB;
CREATE TABLE t1 (pk INT PRIMARY KEY, a text ,UNIQUE(a) using hash);
INSERT INTO t1 VALUES (1,'foo');
create table t2(id int primary key, a blob, b varchar(20) as (LEFT(a,2)));
INSERT INTO t2 VALUES (1, 'foo', default);
DROP TABLE t1, t2;
SET binlog_row_image= FULL;
CREATE TABLE t1 (a int, b VARCHAR(1000), UNIQUE (a,b)) ENGINE=MyISAM;
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 a 1 a A NULL NULL NULL YES HASH
t1 0 a 2 b A NULL NULL NULL YES HASH
CREATE TABLE t2 (a varchar(900), b VARCHAR(900), UNIQUE (a,b)) ENGINE=MyISAM;
show index from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t2 0 a 1 a A NULL NULL NULL YES HASH
t2 0 a 2 b A NULL NULL NULL YES HASH
DROP TABLE t1,t2;
create temporary table tmp ( a int, b int, c blob not null, d int, e int default 0, f int, unique key (c)) engine=innodb;
create table t2 (x int);
lock table t2 write;
Expand Down Expand Up @@ -341,3 +359,4 @@ create table t1 (a int, b int, unique (b) using hash) engine=innodb partition by
insert into t1 values (1,10),(2,20);
update t1 set b = 30 limit 1;
drop table t1;
# End of 10.5 tests
Loading

0 comments on commit 0e69f60

Please sign in to comment.