summaryrefslogtreecommitdiff
path: root/mysql-test/main
diff options
context:
space:
mode:
authorMarko Mรคkelรค <marko.makela@mariadb.com>2019-09-23 17:35:29 +0300
committerMarko Mรคkelรค <marko.makela@mariadb.com>2019-09-23 17:35:29 +0300
commit5a92ccbaea1bb3973e23846a741f5694a1e687bd (patch)
treeaafc504552502b48b79cadcb06b2b5c7eba4f374 /mysql-test/main
parentc997af7d1f432dfca922958453f0e2313287f1eb (diff)
parentc016ea660ede8b7ff75f8ca65f73e2958262263a (diff)
downloadmariadb-git-5a92ccbaea1bb3973e23846a741f5694a1e687bd.tar.gz
Merge 10.3 into 10.4
Disable MDEV-20576 assertions until MDEV-20595 has been fixed.
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/compare.result20
-rw-r--r--mysql-test/main/compare.test14
-rw-r--r--mysql-test/main/create_drop_server.result4
-rw-r--r--mysql-test/main/cte_nonrecursive.result4
-rw-r--r--mysql-test/main/cte_recursive.result6
-rw-r--r--mysql-test/main/ctype_uca.result46
-rw-r--r--mysql-test/main/ctype_uca_innodb.result31
-rw-r--r--mysql-test/main/ctype_utf8.result77
-rw-r--r--mysql-test/main/opt_trace.result2
-rw-r--r--mysql-test/main/order_by_innodb.result27
-rw-r--r--mysql-test/main/order_by_innodb.test28
-rw-r--r--mysql-test/main/processlist.result4
-rw-r--r--mysql-test/main/range.result10
-rw-r--r--mysql-test/main/range_mrr_icp.result10
-rw-r--r--mysql-test/main/selectivity.result85
-rw-r--r--mysql-test/main/selectivity.test81
-rw-r--r--mysql-test/main/selectivity_innodb.result85
-rw-r--r--mysql-test/main/stat_tables.result37
-rw-r--r--mysql-test/main/stat_tables.test39
-rw-r--r--mysql-test/main/stat_tables_innodb.result37
-rw-r--r--mysql-test/main/system_mysql_db.result4
-rw-r--r--mysql-test/main/system_mysql_db_fix40123.result4
-rw-r--r--mysql-test/main/table_value_constr.result13
-rw-r--r--mysql-test/main/table_value_constr.test10
24 files changed, 491 insertions, 187 deletions
diff --git a/mysql-test/main/compare.result b/mysql-test/main/compare.result
index b4a6b22ba3a..c4650014326 100644
--- a/mysql-test/main/compare.result
+++ b/mysql-test/main/compare.result
@@ -100,3 +100,23 @@ CREATE TABLE t1(a INT ZEROFILL);
SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
1
DROP TABLE t1;
+CREATE TABLE t1 (a char(2), index (a));
+insert into t1 values ("aa"),("bb");
+select * from t1 where a="aa";
+a
+aa
+select * from t1 where a="aaa";
+a
+select * from t1 where a="aa ";
+a
+aa
+select * from t1 where a>="aaa";
+a
+bb
+explain select * from t1 where a="aaa";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 3 const 1 Using where; Using index
+explain select * from t1 where a="aa ";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 3 const 1 Using where; Using index
+drop table t1;
diff --git a/mysql-test/main/compare.test b/mysql-test/main/compare.test
index d2b2a7e5523..38bda6754d8 100644
--- a/mysql-test/main/compare.test
+++ b/mysql-test/main/compare.test
@@ -94,3 +94,17 @@ DROP TABLE t1;
CREATE TABLE t1(a INT ZEROFILL);
SELECT 1 FROM t1 WHERE t1.a IN (1, t1.a) AND t1.a=2;
DROP TABLE t1;
+
+#
+# Check what happens when comparing to long string
+#
+
+CREATE TABLE t1 (a char(2), index (a));
+insert into t1 values ("aa"),("bb");
+select * from t1 where a="aa";
+select * from t1 where a="aaa";
+select * from t1 where a="aa ";
+select * from t1 where a>="aaa";
+explain select * from t1 where a="aaa";
+explain select * from t1 where a="aa ";
+drop table t1;
diff --git a/mysql-test/main/create_drop_server.result b/mysql-test/main/create_drop_server.result
index 29c4fe7e123..4f5d13b3541 100644
--- a/mysql-test/main/create_drop_server.result
+++ b/mysql-test/main/create_drop_server.result
@@ -38,9 +38,9 @@ DROP SERVER server_1;
CREATE SERVER server_1 FOREIGN DATA WRAPPER mysql OPTIONS (USER 'Remote', HOST 'Server.Example.Com', DATABASE 'test');
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
Host
-server.example.com
+Server.Example.Com
ALTER SERVER server_1 OPTIONS(HOST 'Server.Example.Org');
SELECT Host FROM mysql.servers WHERE Server_Name = 'server_1';
Host
-server.example.org
+Server.Example.Org
DROP SERVER server_1;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 12a7e2ea789..8fba35d8ed4 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -606,7 +606,7 @@ with t(c) as (select a from t1 where b >= 'c')
select * from t r1 where r1.c=4;
show create view v3;
View Create View character_set_client collation_connection
-v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t as (select `t1`.`a` AS `c` from `t1` where `t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci
+v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS with t(c) as (select `t1`.`a` AS `c` from `t1` where `t1`.`b` >= 'c')select `r1`.`c` AS `c` from `t` `r1` where `r1`.`c` = 4 latin1 latin1_swedish_ci
select * from v3;
c
4
@@ -618,7 +618,7 @@ with t(c) as (select a from t1 where b >= 'c')
select * from t r1, t r2 where r1.c=r2.c and r2.c=4;
show create view v4;
View Create View character_set_client collation_connection
-v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c') `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci
+v4 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v4` AS with t(c) as (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c')select `r1`.`c` AS `c`,`r2`.`c` AS `d` from (`t` `r1` join (select `test`.`t1`.`a` AS `c` from `test`.`t1` where `test`.`t1`.`b` >= 'c') `r2`) where `r1`.`c` = `r2`.`c` and `r2`.`c` = 4 latin1 latin1_swedish_ci
select * from v4;
c d
4 4
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index 0b22da8f72a..b88f0ff6255 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -699,7 +699,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 with recursive ancestor_couple_ids as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id`
+Note 1003 with recursive ancestor_couple_ids(h_id,w_id) as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors(id,name,dob,father,mother) as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id`
# simple mutual recursion
with recursive
ancestor_couple_ids(h_id, w_id)
@@ -3091,7 +3091,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
4 DEPENDENT SUBQUERY <derived2> ALL NULL NULL NULL NULL 16 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 with recursive destinations as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations`
+Note 1003 with recursive destinations(city,legs) as (/* select#2 */ select `test`.`a`.`arrival` AS `city`,1 AS `legs` from `test`.`flights` `a` where `test`.`a`.`departure` = 'Cairo' union /* select#3 */ select `test`.`b`.`arrival` AS `arrival`,`r`.`legs` + 1 AS `r.legs + 1` from `destinations` `r` join `test`.`flights` `b` where `r`.`city` = `test`.`b`.`departure` and !<in_optimizer>(`test`.`b`.`arrival`,<exists>(/* select#4 */ select `destinations`.`city` from `destinations` where trigcond(`test`.`b`.`arrival` = `destinations`.`city` or `destinations`.`city` is null) having trigcond(`destinations`.`city` is null))))/* select#1 */ select `destinations`.`city` AS `city`,`destinations`.`legs` AS `legs` from `destinations`
set standard_compliant_cte=default;
drop table flights;
#
@@ -3378,7 +3378,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 with recursive rcte as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2`
+Note 1003 with recursive rcte(a) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2`
prepare stmt from "with recursive
rcte(a) as
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
diff --git a/mysql-test/main/ctype_uca.result b/mysql-test/main/ctype_uca.result
index 41d2a1149ee..d4b242d035f 100644
--- a/mysql-test/main/ctype_uca.result
+++ b/mysql-test/main/ctype_uca.result
@@ -6748,14 +6748,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -6771,22 +6770,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -6829,8 +6820,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -6850,14 +6839,10 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
ch
a
@@ -6877,8 +6862,6 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
@@ -6889,24 +6872,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
@@ -6992,14 +6967,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -7015,22 +6989,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
diff --git a/mysql-test/main/ctype_uca_innodb.result b/mysql-test/main/ctype_uca_innodb.result
index bd6f3b8a21f..7c64f17190e 100644
--- a/mysql-test/main/ctype_uca_innodb.result
+++ b/mysql-test/main/ctype_uca_innodb.result
@@ -23,14 +23,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -46,22 +45,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -104,8 +95,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -125,14 +114,10 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
ch
a
@@ -152,8 +137,6 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
@@ -164,24 +147,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result
index de2cd005c22..63336fc03ea 100644
--- a/mysql-test/main/ctype_utf8.result
+++ b/mysql-test/main/ctype_utf8.result
@@ -5467,14 +5467,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -5490,22 +5489,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -5548,8 +5539,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -5569,14 +5558,10 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
ch
a
@@ -5596,8 +5581,6 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
@@ -5608,24 +5591,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
@@ -5711,14 +5686,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -5734,22 +5708,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -5792,8 +5758,6 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
@@ -5813,14 +5777,10 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch<'a๐Œ†b' ORDER BY ch;
ch
a
@@ -5840,8 +5800,6 @@ ab
az
aะ€
aึ€
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
@@ -5852,24 +5810,16 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ch ch 183 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch>'a๐Œ†b' ORDER BY ch;
ch
z
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
ALTER TABLE t1 DROP KEY ch;
# 0xD18F would be a good 2-byte character, 0xD1 is an incomplete sequence
SET @query=CONCAT('SELECT ch FROM t1 WHERE ch=''a', 0xD1,'''');
@@ -5955,14 +5905,13 @@ t1 CREATE TABLE `t1` (
INSERT INTO t1 (ch) VALUES ('admin'),('admin1');
SELECT ch FROM t1 WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
+EXPLAIN SELECT ch FROM t1 WHERE ch='admin๐Œ†';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch='admin๐Œ†';
ch
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='admin๐Œ†';
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
DELETE FROM t1;
INSERT INTO t1 (ch) VALUES ('a'), ('a?'), ('a??'), ('a???'), ('a????');
INSERT INTO t1 (ch) VALUES ('ab'),('a?b'),('a??b'),('a???b'),('a????b');
@@ -5978,22 +5927,14 @@ EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86' for column `test`.`t1`.`ch` at row 1
EXPLAIN
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL # Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 FORCE KEY (ch) WHERE ch='a๐Œ†b' ORDER BY ch;
ch
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9D\x8C\x86b' for column `test`.`t1`.`ch` at row 1
SELECT ch FROM t1 IGNORE KEY (ch) WHERE ch<'a๐Œ†' ORDER BY ch;
ch
a
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index 63a86615186..72cee2a428f 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -2193,7 +2193,7 @@ explain select * from t1 where a=1 and b=2 order by c limit 1 {
"range_analysis": {
"table_scan": {
"rows": 1000,
- "cost": 1202
+ "cost": 2e308
},
"potential_range_indexes": [
{
diff --git a/mysql-test/main/order_by_innodb.result b/mysql-test/main/order_by_innodb.result
index 3ff1f92e94a..9cdf9800cee 100644
--- a/mysql-test/main/order_by_innodb.result
+++ b/mysql-test/main/order_by_innodb.result
@@ -49,6 +49,32 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index_merge key1,key2 key1,key2 5,5 NULL # Using sort_union(key1,key2); Using where
drop table t0, t1;
#
+# MDEV-18094: Query with order by limit picking index scan over filesort
+#
+create table t0 (a int);
+INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0);
+CREATE TABLE t1 (
+a int(11),
+b int(11),
+c int(11),
+KEY a_c (a,c),
+KEY a_b (a,b)
+) ENGINE=InnoDB;
+insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C;
+# should use ref access
+explain select a,b,c from t1 where a=1 and c=2 order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a_c,a_b a_c 10 const,const 20 Using where; Using filesort
+# both should use range access
+explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where
+explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a_c,a_b a_b 5 NULL 200 Using where
+drop table t1,t0;
+# Start of 10.2 tests
+#
# MDEV-14071: wrong results with orderby_uses_equalities=on
# (duplicate of MDEV-13994)
#
@@ -121,3 +147,4 @@ i n
656 eight
set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+# End of 10.2 tests
diff --git a/mysql-test/main/order_by_innodb.test b/mysql-test/main/order_by_innodb.test
index 0debb777749..f4c738263ae 100644
--- a/mysql-test/main/order_by_innodb.test
+++ b/mysql-test/main/order_by_innodb.test
@@ -63,6 +63,32 @@ where key1<3 or key2<3;
drop table t0, t1;
--echo #
+--echo # MDEV-18094: Query with order by limit picking index scan over filesort
+--echo #
+
+create table t0 (a int);
+INSERT INTO t0 VALUES (0),(0),(0),(0),(2),(0),(0),(1),(1),(0);
+
+CREATE TABLE t1 (
+a int(11),
+b int(11),
+c int(11),
+KEY a_c (a,c),
+KEY a_b (a,b)
+) ENGINE=InnoDB;
+insert into t1 select A.a , B.a, C.a from t0 A, t0 B, t0 C;
+
+--echo # should use ref access
+explain select a,b,c from t1 where a=1 and c=2 order by b;
+
+--echo # both should use range access
+explain select a,b,c from t1 where a=1 and c=2 order by b limit 1000;
+explain select a,b,c from t1 where a=1 and c=2 order by b limit 2000;
+drop table t1,t0;
+
+--echo # Start of 10.2 tests
+
+--echo #
--echo # MDEV-14071: wrong results with orderby_uses_equalities=on
--echo # (duplicate of MDEV-13994)
--echo #
@@ -108,3 +134,5 @@ eval $q2;
set optimizer_switch= @save_optimizer_switch;
DROP TABLE t1,t2,t3;
+
+--echo # End of 10.2 tests
diff --git a/mysql-test/main/processlist.result b/mysql-test/main/processlist.result
index ab518d961ef..4be643c1790 100644
--- a/mysql-test/main/processlist.result
+++ b/mysql-test/main/processlist.result
@@ -36,10 +36,6 @@ SELECT INFO, INFO_BINARY, 'xxx๐Ÿ˜Žyyy' AS utf8mb4_string FROM INFORMATION_SCHEMA
INFO SELECT INFO, INFO_BINARY, 'xxx????yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%'
INFO_BINARY SELECT INFO, INFO_BINARY, 'xxx๐Ÿ˜Žyyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%'
utf8mb4_string xxx๐Ÿ˜Žyyy
-Warnings:
-Level Warning
-Code 1366
-Message Incorrect string value: '\xF0\x9F\x98\x8Eyy...' for column `information_schema`.`(temporary)`.`INFO` at row 1
#
# End of 10.1 tests
#
diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result
index e4b89939063..bb111f25a07 100644
--- a/mysql-test/main/range.result
+++ b/mysql-test/main/range.result
@@ -2115,23 +2115,15 @@ explain
SELECT * FROM t1 WHERE fd='๐Ÿ˜';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
SELECT * FROM t1 WHERE fd='๐Ÿ˜';
id fd
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
# The following must not use range access:
explain select count(*) from t1 where fd <'๐Ÿ˜';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ix_fd ix_fd 63 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
select count(*) from t1 where fd <'๐Ÿ˜';
count(*)
40960
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
select count(*) from t1 ignore index (ix_fd) where fd <'๐Ÿ˜';
count(*)
40960
@@ -2353,8 +2345,6 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
EXPLAIN SELECT * FROM t1 WHERE a<=>'๐Ÿ˜Ž';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column `test`.`t1`.`a` at row 1
DROP TABLE t1;
#
# MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in
diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result
index 5bfb2ed0782..c286c49cac0 100644
--- a/mysql-test/main/range_mrr_icp.result
+++ b/mysql-test/main/range_mrr_icp.result
@@ -2118,23 +2118,15 @@ explain
SELECT * FROM t1 WHERE fd='๐Ÿ˜';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
SELECT * FROM t1 WHERE fd='๐Ÿ˜';
id fd
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
# The following must not use range access:
explain select count(*) from t1 where fd <'๐Ÿ˜';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index ix_fd ix_fd 63 NULL # Using where; Using index
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
select count(*) from t1 where fd <'๐Ÿ˜';
count(*)
40960
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x81' for column `test`.`t1`.`fd` at row 1
select count(*) from t1 ignore index (ix_fd) where fd <'๐Ÿ˜';
count(*)
40960
@@ -2356,8 +2348,6 @@ INSERT INTO t1 VALUES ('a'),('b'),('c'),('d'),('e');
EXPLAIN SELECT * FROM t1 WHERE a<=>'๐Ÿ˜Ž';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
-Warnings:
-Warning 1366 Incorrect string value: '\xF0\x9F\x98\x8E' for column `test`.`t1`.`a` at row 1
DROP TABLE t1;
#
# MDEV-10185: Assertion `tree1->keys[key_no] && tree2->keys[key_no]' failed in
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 43e3c88c0a1..f11fee4b985 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -1668,5 +1668,90 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+#
+# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
+#
+set @@optimizer_use_condition_selectivity=2;
+set names utf8;
+CREATE DATABASE world;
+use world;
+CREATE TABLE Country (
+Code char(3) NOT NULL default '',
+Name char(52) NOT NULL default '',
+SurfaceArea float(10,2) NOT NULL default '0.00',
+Population int(11) NOT NULL default '0',
+Capital int(11) default NULL,
+PRIMARY KEY (Code),
+UNIQUE INDEX (Name)
+);
+CREATE TABLE City (
+ID int(11) NOT NULL auto_increment,
+Name char(35) NOT NULL default '',
+Country char(3) NOT NULL default '',
+Population int(11) NOT NULL default '0',
+PRIMARY KEY (ID),
+INDEX (Population),
+INDEX (Country)
+);
+CREATE TABLE CountryLanguage (
+Country char(3) NOT NULL default '',
+Language char(30) NOT NULL default '',
+Percentage float(3,1) NOT NULL default '0.0',
+PRIMARY KEY (Country, Language),
+INDEX (Percentage)
+);
+CREATE INDEX Name ON City(Name);
+CREATE INDEX CountryPopulation ON City(Country,Population);
+CREATE INDEX CountryName ON City(Country,Name);
+set @@optimizer_use_condition_selectivity=2;
+EXPLAIN
+SELECT * FROM City WHERE Country='FIN';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE City ref Country,CountryPopulation,CountryName CountryName 3 const 5 Using index condition
+DROP DATABASE world;
+use test;
+CREATE TABLE t1 (
+a INT,
+b INT NOT NULL,
+c char(100),
+KEY (b, c),
+KEY (b, a, c)
+) ENGINE=MyISAM
+DEFAULT CHARSET = utf8;
+INSERT INTO t1 VALUES
+(1, 1, 1),
+(2, 2, 2),
+(3, 3, 3),
+(4, 4, 4),
+(5, 5, 5),
+(6, 6, 6),
+(7, 7, 7),
+(8, 8, 8),
+(9, 9, 9);
+INSERT INTO t1 SELECT a + 10, b, c FROM t1;
+INSERT INTO t1 SELECT a + 20, b, c FROM t1;
+INSERT INTO t1 SELECT a + 40, b, c FROM t1;
+INSERT INTO t1 SELECT a + 80, b, c FROM t1;
+INSERT INTO t1 SELECT a + 160, b, c FROM t1;
+INSERT INTO t1 SELECT a + 320, b, c FROM t1;
+INSERT INTO t1 SELECT a + 640, b, c FROM t1;
+INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
+EXPLAIN
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+a
+2071
+2061
+2051
+2041
+2031
+2021
+2011
+2001
+1991
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+DROP TABLE t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test
index a3b69789da6..a9588ea205d 100644
--- a/mysql-test/main/selectivity.test
+++ b/mysql-test/main/selectivity.test
@@ -1125,6 +1125,87 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+
+--echo #
+--echo # MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
+--echo #
+
+set @@optimizer_use_condition_selectivity=2;
+
+set names utf8;
+
+CREATE DATABASE world;
+
+use world;
+
+--source include/world_schema.inc
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+--source include/world.inc
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+CREATE INDEX Name ON City(Name);
+CREATE INDEX CountryPopulation ON City(Country,Population);
+CREATE INDEX CountryName ON City(Country,Name);
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+ANALYZE TABLE City;
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+set @@optimizer_use_condition_selectivity=2;
+
+EXPLAIN
+SELECT * FROM City WHERE Country='FIN';
+
+DROP DATABASE world;
+
+use test;
+
+CREATE TABLE t1 (
+ a INT,
+ b INT NOT NULL,
+ c char(100),
+ KEY (b, c),
+ KEY (b, a, c)
+) ENGINE=MyISAM
+DEFAULT CHARSET = utf8;
+
+INSERT INTO t1 VALUES
+(1, 1, 1),
+(2, 2, 2),
+(3, 3, 3),
+(4, 4, 4),
+(5, 5, 5),
+(6, 6, 6),
+(7, 7, 7),
+(8, 8, 8),
+(9, 9, 9);
+
+INSERT INTO t1 SELECT a + 10, b, c FROM t1;
+INSERT INTO t1 SELECT a + 20, b, c FROM t1;
+INSERT INTO t1 SELECT a + 40, b, c FROM t1;
+INSERT INTO t1 SELECT a + 80, b, c FROM t1;
+INSERT INTO t1 SELECT a + 160, b, c FROM t1;
+INSERT INTO t1 SELECT a + 320, b, c FROM t1;
+INSERT INTO t1 SELECT a + 640, b, c FROM t1;
+INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
+
+EXPLAIN
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+
+DROP TABLE t1;
+
--echo # End of 10.1 tests
#
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index 3075a060d67..80295473e9b 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -1678,6 +1678,91 @@ drop table t1;
set use_stat_tables= @save_use_stat_tables;
set @@histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+#
+# MDEV-20576: failing assertion DBUG_ASSERT(0.0 < sel && sel <= 1)
+#
+set @@optimizer_use_condition_selectivity=2;
+set names utf8;
+CREATE DATABASE world;
+use world;
+CREATE TABLE Country (
+Code char(3) NOT NULL default '',
+Name char(52) NOT NULL default '',
+SurfaceArea float(10,2) NOT NULL default '0.00',
+Population int(11) NOT NULL default '0',
+Capital int(11) default NULL,
+PRIMARY KEY (Code),
+UNIQUE INDEX (Name)
+);
+CREATE TABLE City (
+ID int(11) NOT NULL auto_increment,
+Name char(35) NOT NULL default '',
+Country char(3) NOT NULL default '',
+Population int(11) NOT NULL default '0',
+PRIMARY KEY (ID),
+INDEX (Population),
+INDEX (Country)
+);
+CREATE TABLE CountryLanguage (
+Country char(3) NOT NULL default '',
+Language char(30) NOT NULL default '',
+Percentage float(3,1) NOT NULL default '0.0',
+PRIMARY KEY (Country, Language),
+INDEX (Percentage)
+);
+CREATE INDEX Name ON City(Name);
+CREATE INDEX CountryPopulation ON City(Country,Population);
+CREATE INDEX CountryName ON City(Country,Name);
+set @@optimizer_use_condition_selectivity=2;
+EXPLAIN
+SELECT * FROM City WHERE Country='FIN';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE City ref Country,CountryPopulation,CountryName Country 3 const 7 Using index condition
+DROP DATABASE world;
+use test;
+CREATE TABLE t1 (
+a INT,
+b INT NOT NULL,
+c char(100),
+KEY (b, c),
+KEY (b, a, c)
+) ENGINE=MyISAM
+DEFAULT CHARSET = utf8;
+INSERT INTO t1 VALUES
+(1, 1, 1),
+(2, 2, 2),
+(3, 3, 3),
+(4, 4, 4),
+(5, 5, 5),
+(6, 6, 6),
+(7, 7, 7),
+(8, 8, 8),
+(9, 9, 9);
+INSERT INTO t1 SELECT a + 10, b, c FROM t1;
+INSERT INTO t1 SELECT a + 20, b, c FROM t1;
+INSERT INTO t1 SELECT a + 40, b, c FROM t1;
+INSERT INTO t1 SELECT a + 80, b, c FROM t1;
+INSERT INTO t1 SELECT a + 160, b, c FROM t1;
+INSERT INTO t1 SELECT a + 320, b, c FROM t1;
+INSERT INTO t1 SELECT a + 640, b, c FROM t1;
+INSERT INTO t1 SELECT a + 1280, b, c FROM t1 LIMIT 80;
+EXPLAIN
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b,b_2 b 4 NULL 226 Using where
+SELECT a FROM t1 WHERE b = 1 ORDER BY c DESC LIMIT 9;
+a
+2071
+2061
+2051
+2041
+2031
+2021
+2011
+2001
+1991
+set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+DROP TABLE t1;
# End of 10.1 tests
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result
index 161a04478fb..a9105308d42 100644
--- a/mysql-test/main/stat_tables.result
+++ b/mysql-test/main/stat_tables.result
@@ -800,7 +800,38 @@ col1
2004-01-01
2004-02-29
0000-10-31
+set @@sql_mode= @save_sql_mode;
+set @@use_stat_tables=@save_use_stat_tables;
+set @@histogram_size= @save_histogram_size;
+set @@histogram_type=@save_histogram_type;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
+#
+# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
+#
+set names utf8;
+create table t1 ( a varchar(255) character set utf8);
+insert into t1 values (REPEAT('ำฅ',255)), (REPEAT('รง',255));
+set use_stat_tables='preferably';
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+set @save_sql_mode= @@sql_mode;
+set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+update mysql.column_stats set min_value= REPEAT('ำฅ',256) where db_name='test' and table_name='t1';
+Warnings:
+Warning 1265 Data truncated for column 'min_value' at row 1
+set @@sql_mode= @save_sql_mode;
+select length(a) from t1 where a=REPEAT('ำฅ',255);
+length(a)
+510
+set names latin1;
+set @@use_stat_tables=@save_use_stat_tables;
+drop table t1;
+# please keep this at the last
+set @@global.histogram_size=@save_histogram_size;
+# Start of 10.4 tests
set histogram_size=0;
#
# MDEV-17255: New optimizer defaults and ANALYZE TABLE
@@ -858,8 +889,4 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set @@global.histogram_size=@save_histogram_size;
-set @@histogram_size= @save_histogram_size;
-set @@histogram_type=@save_histogram_type;
-set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
-set @@sql_mode= @save_sql_mode;
-set @@use_stat_tables=@save_use_stat_tables;
+# End of 10.4 tests
diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test
index 8dd9c361cd8..ca341a93b81 100644
--- a/mysql-test/main/stat_tables.test
+++ b/mysql-test/main/stat_tables.test
@@ -544,7 +544,40 @@ analyze table t1;
update mysql.column_stats set min_value='2004-0-31123' where db_name='test' and table_name='t1';
select min_value from mysql.column_stats where db_name='test' and table_name='t1';
select * from t1;
+set @@sql_mode= @save_sql_mode;
+set @@use_stat_tables=@save_use_stat_tables;
+set @@histogram_size= @save_histogram_size;
+set @@histogram_type=@save_histogram_type;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
+
+--echo #
+--echo # MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
+--echo #
+
+set names utf8;
+create table t1 ( a varchar(255) character set utf8);
+insert into t1 values (REPEAT('ำฅ',255)), (REPEAT('รง',255));
+
+set use_stat_tables='preferably';
+analyze table t1 persistent for all;
+
+set @save_sql_mode= @@sql_mode;
+set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+update mysql.column_stats set min_value= REPEAT('ำฅ',256) where db_name='test' and table_name='t1';
+set @@sql_mode= @save_sql_mode;
+
+select length(a) from t1 where a=REPEAT('ำฅ',255);
+
+set names latin1;
+set @@use_stat_tables=@save_use_stat_tables;
+drop table t1;
+
+--echo # please keep this at the last
+set @@global.histogram_size=@save_histogram_size;
+
+--echo # Start of 10.4 tests
+
set histogram_size=0;
--echo #
@@ -590,9 +623,5 @@ select * from t1 where a=1 and b=3;
drop table t1;
set @@global.histogram_size=@save_histogram_size;
-set @@histogram_size= @save_histogram_size;
-set @@histogram_type=@save_histogram_type;
-set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
-set @@sql_mode= @save_sql_mode;
-set @@use_stat_tables=@save_use_stat_tables;
+--echo # End of 10.4 tests
diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result
index c2f6981fa16..d504b531170 100644
--- a/mysql-test/main/stat_tables_innodb.result
+++ b/mysql-test/main/stat_tables_innodb.result
@@ -832,7 +832,38 @@ col1
2004-01-01
2004-02-29
0000-10-31
+set @@sql_mode= @save_sql_mode;
+set @@use_stat_tables=@save_use_stat_tables;
+set @@histogram_size= @save_histogram_size;
+set @@histogram_type=@save_histogram_type;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
+#
+# MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value
+#
+set names utf8;
+create table t1 ( a varchar(255) character set utf8);
+insert into t1 values (REPEAT('ำฅ',255)), (REPEAT('รง',255));
+set use_stat_tables='preferably';
+analyze table t1 persistent for all;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+set @save_sql_mode= @@sql_mode;
+set sql_mode='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+update mysql.column_stats set min_value= REPEAT('ำฅ',256) where db_name='test' and table_name='t1';
+Warnings:
+Warning 1265 Data truncated for column 'min_value' at row 1
+set @@sql_mode= @save_sql_mode;
+select length(a) from t1 where a=REPEAT('ำฅ',255);
+length(a)
+510
+set names latin1;
+set @@use_stat_tables=@save_use_stat_tables;
+drop table t1;
+# please keep this at the last
+set @@global.histogram_size=@save_histogram_size;
+# Start of 10.4 tests
set histogram_size=0;
#
# MDEV-17255: New optimizer defaults and ANALYZE TABLE
@@ -890,11 +921,7 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 2.78 10.00 Using where
drop table t1;
set @@global.histogram_size=@save_histogram_size;
-set @@histogram_size= @save_histogram_size;
-set @@histogram_type=@save_histogram_type;
-set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
-set @@sql_mode= @save_sql_mode;
-set @@use_stat_tables=@save_use_stat_tables;
+# End of 10.4 tests
set global innodb_stats_persistent= @innodb_stats_persistent_save;
set global innodb_stats_persistent_sample_pages=
@innodb_stats_persistent_sample_pages_save;
diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result
index e7cd9bc628b..6a243ca0c43 100644
--- a/mysql-test/main/system_mysql_db.result
+++ b/mysql-test/main/system_mysql_db.result
@@ -124,14 +124,14 @@ show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '',
- `Host` char(64) NOT NULL DEFAULT '',
+ `Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
- `Owner` char(64) NOT NULL DEFAULT '',
+ `Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result
index ad7341a2a5c..bc235227b42 100644
--- a/mysql-test/main/system_mysql_db_fix40123.result
+++ b/mysql-test/main/system_mysql_db_fix40123.result
@@ -162,14 +162,14 @@ show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL DEFAULT '',
- `Host` char(64) NOT NULL DEFAULT '',
+ `Host` varchar(2048) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`Username` char(80) NOT NULL DEFAULT '',
`Password` char(64) NOT NULL DEFAULT '',
`Port` int(4) NOT NULL DEFAULT 0,
`Socket` char(64) NOT NULL DEFAULT '',
`Wrapper` char(64) NOT NULL DEFAULT '',
- `Owner` char(64) NOT NULL DEFAULT '',
+ `Owner` varchar(512) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result
index a9b085fe31e..b395a896000 100644
--- a/mysql-test/main/table_value_constr.result
+++ b/mysql-test/main/table_value_constr.result
@@ -2586,3 +2586,16 @@ create view v1 as
union
( values (5), (7), (1), (3), (4) order by 2 limit 2 );
ERROR 42S22: Unknown column '2' in 'order clause'
+#
+# MDEV-20229: view defined as select using
+# CTE with named columns defined as TVC
+#
+create view v1 as with t(a) as (values (2), (1)) select a from t;
+show create view v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS with t(a) as (values (2),(1))select `t`.`a` AS `a` from `t` latin1 latin1_swedish_ci
+select * from v1;
+a
+2
+1
+drop view v1;
diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test
index 6b89816cc0c..4464eb7b77b 100644
--- a/mysql-test/main/table_value_constr.test
+++ b/mysql-test/main/table_value_constr.test
@@ -1316,3 +1316,13 @@ create view v1 as
( values (5), (7), (1), (3), (4) limit 2 offset 1 )
union
( values (5), (7), (1), (3), (4) order by 2 limit 2 );
+
+--echo #
+--echo # MDEV-20229: view defined as select using
+--echo # CTE with named columns defined as TVC
+--echo #
+
+create view v1 as with t(a) as (values (2), (1)) select a from t;
+show create view v1;
+select * from v1;
+drop view v1;