summaryrefslogtreecommitdiff
path: root/mysql-test/main
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-05-17 08:42:53 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-05-17 08:42:53 +0300
commit4c7608aeb187383f2629e96e085b5b50fc81337f (patch)
treefc8dce68b02a63ca204203034dae81a7162a4b9f /mysql-test/main
parentc2352c45fbd670f50b73415eeeb676aa67fb4a29 (diff)
parenta4e7800701d0764fe4cbb85b81d7c7cb54677334 (diff)
downloadmariadb-git-4c7608aeb187383f2629e96e085b5b50fc81337f.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/alter_table_errors.result10
-rw-r--r--mysql-test/main/alter_table_errors.test10
-rw-r--r--mysql-test/main/check_constraint.result41
-rw-r--r--mysql-test/main/check_constraint.test24
-rw-r--r--mysql-test/main/derived_cond_pushdown.result428
-rw-r--r--mysql-test/main/derived_cond_pushdown.test99
-rw-r--r--mysql-test/main/derived_view.result4
-rw-r--r--mysql-test/main/distinct.result10
-rw-r--r--mysql-test/main/distinct.test8
-rw-r--r--mysql-test/main/multi_update.result72
-rw-r--r--mysql-test/main/multi_update.test46
-rw-r--r--mysql-test/main/subselect-crash_15755.result317
-rw-r--r--mysql-test/main/subselect-crash_15755.test60
-rw-r--r--mysql-test/main/subselect_extra.result4
14 files changed, 1129 insertions, 4 deletions
diff --git a/mysql-test/main/alter_table_errors.result b/mysql-test/main/alter_table_errors.result
new file mode 100644
index 00000000000..020a30304d0
--- /dev/null
+++ b/mysql-test/main/alter_table_errors.result
@@ -0,0 +1,10 @@
+create table t (a int, v int as (a)) engine=innodb;
+alter table t change column a b tinyint, algorithm=inplace;
+ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY
+show create table t;
+Table Create Table
+t CREATE TABLE `t` (
+ `a` int(11) DEFAULT NULL,
+ `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t;
diff --git a/mysql-test/main/alter_table_errors.test b/mysql-test/main/alter_table_errors.test
new file mode 100644
index 00000000000..d9982ac26f4
--- /dev/null
+++ b/mysql-test/main/alter_table_errors.test
@@ -0,0 +1,10 @@
+--source include/have_innodb.inc
+
+#
+# MDEV-16110 ALTER with ALGORITHM=INPLACE breaks temporary table with virtual columns
+#
+create table t (a int, v int as (a)) engine=innodb;
+--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+alter table t change column a b tinyint, algorithm=inplace;
+show create table t;
+drop table t;
diff --git a/mysql-test/main/check_constraint.result b/mysql-test/main/check_constraint.result
index 70d64cd6ff7..9a32e6f12bc 100644
--- a/mysql-test/main/check_constraint.result
+++ b/mysql-test/main/check_constraint.result
@@ -156,3 +156,44 @@ create table t1 (id int auto_increment primary key, datecol datetime, check (dat
insert into t1 (datecol) values (now());
insert into t1 (datecol) values (now());
drop table t1;
+CREATE TABLE t1 (
+EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
+FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2))
+);
+INSERT INTO t1 VALUES (NULL, 'Ken');
+ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
+SHOW WARNINGS;
+Level Code Message
+Error 1292 Truncated incorrect DOUBLE value: 'Ken'
+Error 4025 CONSTRAINT `FirstName` failed for `test`.`t1`
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+ERROR 22007: Truncated incorrect DOUBLE value: 'Ken'
+SHOW WARNINGS;
+Level Code Message
+Error 1292 Truncated incorrect DOUBLE value: 'Ken'
+Error 4025 CONSTRAINT `FirstName` failed for `test`.`t1`
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken');
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
+Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
+set sql_mode="";
+INSERT INTO t1 VALUES (NULL, 'Ken');
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'Ken'
+Warning 1292 Truncated incorrect DOUBLE value: 'Brian'
+set sql_mode=default;
+select * from t1;
+EmployeeID FirstName
+1 Ken
+2 Ken
+3 Brian
+4 Ken
+5 Ken
+6 Brian
+drop table t1;
diff --git a/mysql-test/main/check_constraint.test b/mysql-test/main/check_constraint.test
index 9a77736acd7..02081071bd4 100644
--- a/mysql-test/main/check_constraint.test
+++ b/mysql-test/main/check_constraint.test
@@ -111,3 +111,27 @@ create table t1 (id int auto_increment primary key, datecol datetime, check (dat
insert into t1 (datecol) values (now());
insert into t1 (datecol) values (now());
drop table t1;
+
+#
+# MDEV-15461 Check Constraints with binary logging makes insert inconsistent
+#
+
+CREATE TABLE t1 (
+ EmployeeID SMALLINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
+ FirstName VARCHAR(30) NOT NULL CHECK (CHAR_LENGTH(FirstName > 2))
+);
+
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES (NULL, 'Ken');
+SHOW WARNINGS;
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+SHOW WARNINGS;
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken');
+INSERT IGNORE INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+set sql_mode="";
+INSERT INTO t1 VALUES (NULL, 'Ken');
+INSERT INTO t1 VALUES (NULL, 'Ken'),(NULL, 'Brian');
+set sql_mode=default;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index 326e56b222f..867da5bbbf3 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -12778,6 +12778,434 @@ where t.d between date ('2017-01-01') and date ('2019-01-01');
d
2018-01-01
#
+# MDEV-16088: pushdown into derived defined in the IN subquery
+#
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (e INT, f INT, g INT);
+INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24);
+INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1);
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+a b
+2 32
+3 24
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["func", "func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.e > 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 18",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.e > 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+a b
+1 19
+3 24
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["func", "func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.max_f < 25",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 18 and max_f < 25",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+a b
+2 32
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t1.a is not null and t1.b is not null"
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "temporary_table": {
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.e > 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.e > 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+a b
+2 32
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t1.a is not null and t1.b is not null"
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "temporary_table": {
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.max_f > 20",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 20",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+#
+# MDEV-15765: pushing condition with IN subquery defined with constants
+# using substitution
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM
+(
+SELECT DISTINCT * FROM t1
+) der_tab
+WHERE (a>0 AND a<2 OR a IN (2,3)) AND
+(a=2 OR 0);
+a
+2
+DROP TABLE t1;
+#
# MDEV-10855: Pushdown into derived with window functions
#
set @save_optimizer_switch= @@optimizer_switch;
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index 596641299ae..d523ea3916f 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -2221,6 +2221,105 @@ select * from (select date('2018-01-01') as d
select * from (select date('2018-01-01') as d) as t
where t.d between date ('2017-01-01') and date ('2019-01-01');
+--echo #
+--echo # MDEV-16088: pushdown into derived defined in the IN subquery
+--echo #
+
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (e INT, f INT, g INT);
+INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24);
+INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1);
+
+LET $query=
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+ (
+ SELECT d_tab.e,d_tab.max_f
+ FROM (
+ SELECT t2.e, MAX(t2.f) AS max_f
+ FROM t2
+ GROUP BY t2.e
+ HAVING max_f>18
+ ) as d_tab
+ WHERE d_tab.e>1
+ )
+;
+EVAL $query;
+EVAL EXPLAIN $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+ (
+ SELECT d_tab.e,d_tab.max_f
+ FROM (
+ SELECT t2.e, MAX(t2.f) AS max_f
+ FROM t2
+ GROUP BY t2.e
+ HAVING max_f>18
+ ) as d_tab
+ WHERE d_tab.max_f<25
+ )
+;
+EVAL $query;
+EVAL EXPLAIN $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+ (
+ SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+ FROM (
+ SELECT t2.e, MAX(t2.f) as max_f, t2.g
+ FROM t2
+ GROUP BY t2.e
+ ) as d_tab
+ WHERE d_tab.e>1
+ GROUP BY d_tab.g
+ )
+;
+EVAL $query;
+EVAL EXPLAIN $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+ (
+ SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+ FROM (
+ SELECT t2.e, MAX(t2.f) as max_f, t2.g
+ FROM t2
+ GROUP BY t2.e
+ ) as d_tab
+ WHERE d_tab.max_f>20
+ GROUP BY d_tab.g
+ )
+;
+EVAL $query;
+EVAL EXPLAIN $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-15765: pushing condition with IN subquery defined with constants
+--echo # using substitution
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM
+(
+ SELECT DISTINCT * FROM t1
+) der_tab
+WHERE (a>0 AND a<2 OR a IN (2,3)) AND
+ (a=2 OR 0);
+
+DROP TABLE t1;
+
# Start of 10.3 tests
--echo #
diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result
index 85e56ff176e..6c4b3310e11 100644
--- a/mysql-test/main/derived_view.result
+++ b/mysql-test/main/derived_view.result
@@ -1841,7 +1841,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; Start temporary; End temporary
-3 DERIVED t1 ALL NULL NULL NULL NULL 3
+3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t3
WHERE t3.b IN (SELECT v1.b FROM v1, t2
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
@@ -1856,7 +1856,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY <derived3> ref key1 key1 8 const,const 0 Start temporary
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
-3 DERIVED t1 ALL NULL NULL NULL NULL 3
+3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t3
WHERE t3.b IN (SELECT v1.b FROM v1, t2
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result
index 926dc17d0c4..70bce519ad2 100644
--- a/mysql-test/main/distinct.result
+++ b/mysql-test/main/distinct.result
@@ -1039,4 +1039,14 @@ count(distinct case when id<=63 then id end)
63
drop table tb;
SET @@tmp_table_size= @tmp_table_size_save;
+#
+# MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array<Element_type>::operator
+#
+CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT);
+INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0);
+SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1;
+b1+'0' b2+'0' b3+'0' b4+'0' b5+'0' b6 +'0'
+1 0 0 1 0 1
+0 1 0 0 1 0
+DROP TABLE t1;
End of 5.5 tests
diff --git a/mysql-test/main/distinct.test b/mysql-test/main/distinct.test
index 7cf3d6810bb..c11f8b501bc 100644
--- a/mysql-test/main/distinct.test
+++ b/mysql-test/main/distinct.test
@@ -790,4 +790,12 @@ drop table tb;
SET @@tmp_table_size= @tmp_table_size_save;
+--echo #
+--echo # MDEV-14695: Assertion `n < m_size' failed in Bounds_checked_array<Element_type>::operator
+--echo #
+
+CREATE TABLE t1 (b1 BIT, b2 BIT, b3 BIT, b4 BIT , b5 BIT, b6 BIT);
+INSERT INTO t1 VALUES (1,0,0,1,0,1),(0,1,0,0,1,0);
+SELECT DISTINCT b1+'0', b2+'0', b3+'0', b4+'0', b5+'0', b6 +'0' FROM t1;
+DROP TABLE t1;
--echo End of 5.5 tests
diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result
index 45239f6e090..c40de47668a 100644
--- a/mysql-test/main/multi_update.result
+++ b/mysql-test/main/multi_update.result
@@ -968,3 +968,75 @@ NULL 6
7 7
8 8
drop table t1, t2;
+create table t1 (i int) engine=memory;
+insert t1 values (1),(2);
+create table t2 (f int) engine=myisam;
+insert t2 values (1),(2);
+explain update t1, t2 set f = 126 order by f limit 2;
+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 2
+update t1, t2 set f = 126 order by f limit 2;
+select * from t2;
+f
+126
+2
+drop table t1, t2;
+create table t0(a int);
+insert t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int, key(a));
+insert t1 select a,a,a from t0;
+create table t2 as select * from t1;
+create table t3 as select * from t1;
+select * from t1, t2 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5;
+a b c a b c
+0 0 0 0 0 0
+1 1 1 1 1 1
+2 2 2 2 2 2
+3 3 3 3 3 3
+4 4 4 4 4 4
+set optimizer_switch='firstmatch=off';
+explain update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c< t2.c) order by t2.c, t1.c limit 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
+1 PRIMARY t1 ALL a NULL NULL NULL 10 Using where
+1 PRIMARY t3 ALL NULL NULL NULL NULL 10 Using where; Start temporary; End temporary
+update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5;
+select * from t2;
+a b c
+0 0 1
+1 1 1
+2 2 1
+3 3 1
+4 4 1
+5 5 5
+6 6 6
+7 7 7
+8 8 8
+9 9 9
+set optimizer_switch=default;
+drop table t0,t1,t2,t3;
+create table t0 (x int);
+create table t1 (a int);
+create table t2 (b int, c int default 0);
+insert t0 (x) values (0),(10);
+insert t1 (a) values (1), (2);
+insert t2 (b) values (1), (2);
+create view v1 as select t2.b,t2.c from t1, t2
+where t1.a=t2.b and t2.b < 3 with check option;
+select * from t0 join v1 on (x=c);
+x b c
+0 1 0
+0 2 0
+explain update v1,t0 set c=1 where b=1 and x=c order by x,b limit 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t0 ALL NULL NULL NULL NULL 2 Using where
+update v1,t0 set c=1 where b<3 and x=c order by x,b limit 1;
+select * from v1;
+b c
+1 1
+2 0
+drop view v1;
+drop table t0, t1,t2;
diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test
index 5feebe87a5a..42e34d1e4a1 100644
--- a/mysql-test/main/multi_update.test
+++ b/mysql-test/main/multi_update.test
@@ -914,3 +914,49 @@ update t1 set c1=NULL;
update t1, t2 set t1.c1=t2.c3 where t1.c3=t2.c3 order by t1.c3 desc limit 2;
select * from t1;
drop table t1, t2;
+
+#
+# MDEV-14551 Can't find record in table on multi-table update with ORDER BY
+#
+
+# simple test with multi-update and Using temporary:
+create table t1 (i int) engine=memory;
+insert t1 values (1),(2);
+create table t2 (f int) engine=myisam;
+insert t2 values (1),(2);
+explain update t1, t2 set f = 126 order by f limit 2;
+update t1, t2 set f = 126 order by f limit 2;
+select * from t2;
+drop table t1, t2;
+
+# test with DuplicateElimination
+# (so that keep_current_rowid is set for DuplicateElimination too)
+create table t0(a int);
+insert t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int, key(a));
+insert t1 select a,a,a from t0;
+create table t2 as select * from t1;
+create table t3 as select * from t1;
+select * from t1, t2 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5;
+set optimizer_switch='firstmatch=off';
+explain update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c< t2.c) order by t2.c, t1.c limit 10;
+update t1, t2 set t2.c=1 where t1.a=t2.a and t1.b in (select b from t3 where t3.c<=t2.c) order by t2.c, t1.c limit 5;
+select * from t2;
+set optimizer_switch=default;
+drop table t0,t1,t2,t3;
+
+# test WITH CHECK OPTION
+create table t0 (x int);
+create table t1 (a int);
+create table t2 (b int, c int default 0);
+insert t0 (x) values (0),(10);
+insert t1 (a) values (1), (2);
+insert t2 (b) values (1), (2);
+create view v1 as select t2.b,t2.c from t1, t2
+ where t1.a=t2.b and t2.b < 3 with check option;
+select * from t0 join v1 on (x=c);
+explain update v1,t0 set c=1 where b=1 and x=c order by x,b limit 1;
+update v1,t0 set c=1 where b<3 and x=c order by x,b limit 1;
+select * from v1;
+drop view v1;
+drop table t0, t1,t2;
diff --git a/mysql-test/main/subselect-crash_15755.result b/mysql-test/main/subselect-crash_15755.result
new file mode 100644
index 00000000000..81b4bd16ab5
--- /dev/null
+++ b/mysql-test/main/subselect-crash_15755.result
@@ -0,0 +1,317 @@
+set global innodb_stats_persistent= 1;
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 'test.t1'
+create table t1 (
+f1 bigint(20) default 0,
+f2 varchar(50) default '',
+f3 int(10) default 0,
+f4 bigint(20) default 0,
+f5 bigint(20) default 0,
+f6 varchar(50) default '',
+f7 varchar(64) default '',
+f8 varchar(30) default '',
+f9 varchar(30) default '',
+f10 bigint(20) default 0,
+f11 bigint(20) default 0,
+f12 bigint(20) default 0,
+f13 bigint(20) default 0,
+f14 varchar(50) default '',
+f15 varchar(100) default '',
+f16 varchar(30) default '',
+f17 varchar(40) default '',
+f18 varchar(30) default '',
+f19 varchar(10) default '',
+f20 varchar(30) default '',
+f21 int(10) default 0,
+f22 int(10) default 0,
+f23 int(10) default 0,
+f24 int(10) default 0,
+f25 varchar(20) default '',
+f26 varchar(20) default '',
+f27 varchar(100) default '',
+f28 varchar(55) default '',
+f29 varchar(20) default '',
+f30 varchar(100) default '',
+f31 varchar(30) default '',
+f32 varchar(20) default '',
+f33 int(10) default 0,
+f34 int(10) default 0,
+f35 varchar(30) default '',
+f36 varchar(30) default '',
+f37 varchar(30) default '',
+f38 varchar(20) default '',
+f39 tinyint(4) default 0,
+f40 tinyint(4) default 0,
+f41 bigint(20) default 0,
+f42 varchar(50) default '',
+f43 varchar(50) default '',
+f44 varchar(50) default '',
+f45 int(10) default 0,
+f46 tinyint(1) default 0
+) engine=innodb row_format=dynamic;
+insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+select * from t1 where f2 in (select f2 from t1 group by f2 having count(distinct f3) = 1);
+f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30 f31 f32 f33 f34 f35 f36 f37 f38 f39 f40 f41 f42 f43 f44 f45 f46
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 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0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+drop table t1;
+set global innodb_stats_persistent= 0;
diff --git a/mysql-test/main/subselect-crash_15755.test b/mysql-test/main/subselect-crash_15755.test
new file mode 100644
index 00000000000..79e259d6337
--- /dev/null
+++ b/mysql-test/main/subselect-crash_15755.test
@@ -0,0 +1,60 @@
+--source include/have_innodb.inc
+set global innodb_stats_persistent= 1;
+drop table if exists t1;
+create table t1 (
+ f1 bigint(20) default 0,
+ f2 varchar(50) default '',
+ f3 int(10) default 0,
+ f4 bigint(20) default 0,
+ f5 bigint(20) default 0,
+ f6 varchar(50) default '',
+ f7 varchar(64) default '',
+ f8 varchar(30) default '',
+ f9 varchar(30) default '',
+ f10 bigint(20) default 0,
+ f11 bigint(20) default 0,
+ f12 bigint(20) default 0,
+ f13 bigint(20) default 0,
+ f14 varchar(50) default '',
+ f15 varchar(100) default '',
+ f16 varchar(30) default '',
+ f17 varchar(40) default '',
+ f18 varchar(30) default '',
+ f19 varchar(10) default '',
+ f20 varchar(30) default '',
+ f21 int(10) default 0,
+ f22 int(10) default 0,
+ f23 int(10) default 0,
+ f24 int(10) default 0,
+ f25 varchar(20) default '',
+ f26 varchar(20) default '',
+ f27 varchar(100) default '',
+ f28 varchar(55) default '',
+ f29 varchar(20) default '',
+ f30 varchar(100) default '',
+ f31 varchar(30) default '',
+ f32 varchar(20) default '',
+ f33 int(10) default 0,
+ f34 int(10) default 0,
+ f35 varchar(30) default '',
+ f36 varchar(30) default '',
+ f37 varchar(30) default '',
+ f38 varchar(20) default '',
+ f39 tinyint(4) default 0,
+ f40 tinyint(4) default 0,
+ f41 bigint(20) default 0,
+ f42 varchar(50) default '',
+ f43 varchar(50) default '',
+ f44 varchar(50) default '',
+ f45 int(10) default 0,
+ f46 tinyint(1) default 0
+) engine=innodb row_format=dynamic;
+
+insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+insert into t1 select * from t1;
+select * from t1 where f2 in (select f2 from t1 group by f2 having count(distinct f3) = 1);
+drop table t1;
+set global innodb_stats_persistent= 0;
diff --git a/mysql-test/main/subselect_extra.result b/mysql-test/main/subselect_extra.result
index 73642c09324..a3a0f1f9a15 100644
--- a/mysql-test/main/subselect_extra.result
+++ b/mysql-test/main/subselect_extra.result
@@ -434,7 +434,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 Using where; FirstMatch(t3); Using join buffer (flat, BNL join)
-3 DERIVED t1 ALL NULL NULL NULL NULL 3
+3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t3
WHERE t3.b IN (SELECT v1.b FROM v1, t2
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);
@@ -449,7 +449,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 system NULL NULL NULL NULL 1
1 PRIMARY <derived3> ref key1 key1 8 const,const 0 Start temporary
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where; End temporary; Using join buffer (flat, BNL join)
-3 DERIVED t1 ALL NULL NULL NULL NULL 3
+3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
SELECT * FROM t3
WHERE t3.b IN (SELECT v1.b FROM v1, t2
WHERE t2.c = v1.c AND t2.c = v1.b AND v1.b = t3.c);