summaryrefslogtreecommitdiff
path: root/mysql-test/suite/maria
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/suite/maria')
-rw-r--r--mysql-test/suite/maria/compat_aliases-master.opt (renamed from mysql-test/suite/maria/t/compat_aliases-master.opt)0
-rw-r--r--mysql-test/suite/maria/group_commit.result (renamed from mysql-test/suite/maria/r/group_commit.result)0
-rw-r--r--mysql-test/suite/maria/group_commit.test (renamed from mysql-test/suite/maria/t/group_commit.test)0
-rw-r--r--mysql-test/suite/maria/icp.result845
-rw-r--r--mysql-test/suite/maria/icp.test17
-rw-r--r--mysql-test/suite/maria/lock.result29
-rw-r--r--mysql-test/suite/maria/lock.test44
-rw-r--r--mysql-test/suite/maria/locking.result (renamed from mysql-test/suite/maria/r/locking.result)0
-rw-r--r--mysql-test/suite/maria/locking.test (renamed from mysql-test/suite/maria/t/locking.test)0
-rw-r--r--mysql-test/suite/maria/maria-autozerofill.result (renamed from mysql-test/suite/maria/r/maria-autozerofill.result)0
-rw-r--r--mysql-test/suite/maria/maria-autozerofill.test (renamed from mysql-test/suite/maria/t/maria-autozerofill.test)0
-rw-r--r--mysql-test/suite/maria/maria-big.result (renamed from mysql-test/suite/maria/r/maria-big.result)0
-rw-r--r--mysql-test/suite/maria/maria-big.test (renamed from mysql-test/suite/maria/t/maria-big.test)0
-rw-r--r--mysql-test/suite/maria/maria-big2.result (renamed from mysql-test/suite/maria/r/maria-big2.result)0
-rw-r--r--mysql-test/suite/maria/maria-big2.test (renamed from mysql-test/suite/maria/t/maria-big2.test)0
-rw-r--r--mysql-test/suite/maria/maria-connect.result (renamed from mysql-test/suite/maria/r/maria-connect.result)0
-rw-r--r--mysql-test/suite/maria/maria-connect.test (renamed from mysql-test/suite/maria/t/maria-connect.test)0
-rw-r--r--mysql-test/suite/maria/maria-gis-recovery.opt (renamed from mysql-test/suite/maria/t/maria-gis-recovery.opt)0
-rw-r--r--mysql-test/suite/maria/maria-gis-recovery.result (renamed from mysql-test/suite/maria/r/maria-gis-recovery.result)0
-rw-r--r--mysql-test/suite/maria/maria-gis-recovery.test (renamed from mysql-test/suite/maria/t/maria-gis-recovery.test)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-dynamic.result (renamed from mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-dynamic.test (renamed from mysql-test/suite/maria/t/maria-gis-rtree-dynamic.test)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-trans.result (renamed from mysql-test/suite/maria/r/maria-gis-rtree-trans.result)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree-trans.test (renamed from mysql-test/suite/maria/t/maria-gis-rtree-trans.test)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree.result (renamed from mysql-test/suite/maria/r/maria-gis-rtree.result)0
-rw-r--r--mysql-test/suite/maria/maria-gis-rtree.test (renamed from mysql-test/suite/maria/t/maria-gis-rtree.test)0
-rw-r--r--mysql-test/suite/maria/maria-mvcc.result (renamed from mysql-test/suite/maria/r/maria-mvcc.result)0
-rw-r--r--mysql-test/suite/maria/maria-mvcc.test (renamed from mysql-test/suite/maria/t/maria-mvcc.test)0
-rw-r--r--mysql-test/suite/maria/maria-no-logging.result (renamed from mysql-test/suite/maria/r/maria-no-logging.result)0
-rw-r--r--mysql-test/suite/maria/maria-no-logging.test (renamed from mysql-test/suite/maria/t/maria-no-logging.test)0
-rw-r--r--mysql-test/suite/maria/maria-page-checksum.result (renamed from mysql-test/suite/maria/r/maria-page-checksum.result)0
-rw-r--r--mysql-test/suite/maria/maria-page-checksum.test (renamed from mysql-test/suite/maria/t/maria-page-checksum.test)0
-rw-r--r--mysql-test/suite/maria/maria-partitioning.result (renamed from mysql-test/suite/maria/r/maria-partitioning.result)4
-rw-r--r--mysql-test/suite/maria/maria-partitioning.test (renamed from mysql-test/suite/maria/t/maria-partitioning.test)9
-rw-r--r--mysql-test/suite/maria/maria-preload.result (renamed from mysql-test/suite/maria/r/maria-preload.result)0
-rw-r--r--mysql-test/suite/maria/maria-preload.test (renamed from mysql-test/suite/maria/t/maria-preload.test)0
-rw-r--r--mysql-test/suite/maria/maria-purge.result (renamed from mysql-test/suite/maria/r/maria-purge.result)0
-rw-r--r--mysql-test/suite/maria/maria-purge.test (renamed from mysql-test/suite/maria/t/maria-purge.test)0
-rw-r--r--mysql-test/suite/maria/maria-recover-master.opt (renamed from mysql-test/suite/maria/t/maria-recover-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recover.result (renamed from mysql-test/suite/maria/r/maria-recover.result)0
-rw-r--r--mysql-test/suite/maria/maria-recover.test (renamed from mysql-test/suite/maria/t/maria-recover.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-big-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery-big-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-big.result (renamed from mysql-test/suite/maria/r/maria-recovery-big.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-big.test (renamed from mysql-test/suite/maria/t/maria-recovery-big.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-bitmap-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery-bitmap-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-bitmap.result (renamed from mysql-test/suite/maria/r/maria-recovery-bitmap.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-bitmap.test (renamed from mysql-test/suite/maria/t/maria-recovery-bitmap.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-rtree-ft-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery-rtree-ft-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-rtree-ft.result (renamed from mysql-test/suite/maria/r/maria-recovery-rtree-ft.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery-rtree-ft.test (renamed from mysql-test/suite/maria/t/maria-recovery-rtree-ft.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery.result (renamed from mysql-test/suite/maria/r/maria-recovery.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery.test (renamed from mysql-test/suite/maria/t/maria-recovery.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery2-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery2-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery2.result (renamed from mysql-test/suite/maria/r/maria-recovery2.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery2.test (renamed from mysql-test/suite/maria/t/maria-recovery2.test)0
-rw-r--r--mysql-test/suite/maria/maria-recovery3-master.opt (renamed from mysql-test/suite/maria/t/maria-recovery3-master.opt)0
-rw-r--r--mysql-test/suite/maria/maria-recovery3.result (renamed from mysql-test/suite/maria/r/maria-recovery3.result)0
-rw-r--r--mysql-test/suite/maria/maria-recovery3.test (renamed from mysql-test/suite/maria/t/maria-recovery3.test)0
-rw-r--r--mysql-test/suite/maria/maria-ucs2.result (renamed from mysql-test/suite/maria/r/maria-ucs2.result)0
-rw-r--r--mysql-test/suite/maria/maria-ucs2.test (renamed from mysql-test/suite/maria/t/maria-ucs2.test)0
-rw-r--r--mysql-test/suite/maria/maria.result (renamed from mysql-test/suite/maria/r/maria.result)0
-rw-r--r--mysql-test/suite/maria/maria.test (renamed from mysql-test/suite/maria/t/maria.test)0
-rw-r--r--mysql-test/suite/maria/maria2.result (renamed from mysql-test/suite/maria/r/maria2.result)0
-rw-r--r--mysql-test/suite/maria/maria2.test (renamed from mysql-test/suite/maria/t/maria2.test)0
-rw-r--r--mysql-test/suite/maria/maria3.result (renamed from mysql-test/suite/maria/r/maria3.result)0
-rw-r--r--mysql-test/suite/maria/maria3.test (renamed from mysql-test/suite/maria/t/maria3.test)0
-rw-r--r--mysql-test/suite/maria/maria_notembedded.result (renamed from mysql-test/suite/maria/r/maria_notembedded.result)0
-rw-r--r--mysql-test/suite/maria/maria_notembedded.test (renamed from mysql-test/suite/maria/t/maria_notembedded.test)0
-rw-r--r--mysql-test/suite/maria/maria_partition.result (renamed from mysql-test/suite/maria/r/maria_partition.result)0
-rw-r--r--mysql-test/suite/maria/maria_partition.test (renamed from mysql-test/suite/maria/t/maria_partition.test)0
-rw-r--r--mysql-test/suite/maria/maria_showlog_error.result (renamed from mysql-test/suite/maria/r/maria_showlog_error.result)0
-rw-r--r--mysql-test/suite/maria/maria_showlog_error.test (renamed from mysql-test/suite/maria/t/maria_showlog_error.test)0
-rw-r--r--mysql-test/suite/maria/max_length.result (renamed from mysql-test/suite/maria/r/max_length.result)0
-rw-r--r--mysql-test/suite/maria/max_length.test (renamed from mysql-test/suite/maria/t/max_length.test)0
-rw-r--r--mysql-test/suite/maria/mrr.result443
-rw-r--r--mysql-test/suite/maria/mrr.test213
-rw-r--r--mysql-test/suite/maria/optimize.result (renamed from mysql-test/suite/maria/r/optimize.result)0
-rw-r--r--mysql-test/suite/maria/optimize.test (renamed from mysql-test/suite/maria/t/optimize.test)0
-rw-r--r--mysql-test/suite/maria/ps_maria.result (renamed from mysql-test/suite/maria/r/ps_maria.result)0
-rw-r--r--mysql-test/suite/maria/ps_maria.test (renamed from mysql-test/suite/maria/t/ps_maria.test)0
-rw-r--r--mysql-test/suite/maria/small_blocksize-master.opt (renamed from mysql-test/suite/maria/t/small_blocksize-master.opt)0
-rw-r--r--mysql-test/suite/maria/small_blocksize.result (renamed from mysql-test/suite/maria/r/small_blocksize.result)0
-rw-r--r--mysql-test/suite/maria/small_blocksize.test (renamed from mysql-test/suite/maria/t/small_blocksize.test)0
84 files changed, 1604 insertions, 0 deletions
diff --git a/mysql-test/suite/maria/t/compat_aliases-master.opt b/mysql-test/suite/maria/compat_aliases-master.opt
index a1dcde828cd..a1dcde828cd 100644
--- a/mysql-test/suite/maria/t/compat_aliases-master.opt
+++ b/mysql-test/suite/maria/compat_aliases-master.opt
diff --git a/mysql-test/suite/maria/r/group_commit.result b/mysql-test/suite/maria/group_commit.result
index 4fb85b912ec..4fb85b912ec 100644
--- a/mysql-test/suite/maria/r/group_commit.result
+++ b/mysql-test/suite/maria/group_commit.result
diff --git a/mysql-test/suite/maria/t/group_commit.test b/mysql-test/suite/maria/group_commit.test
index 38b2c9d3bf4..38b2c9d3bf4 100644
--- a/mysql-test/suite/maria/t/group_commit.test
+++ b/mysql-test/suite/maria/group_commit.test
diff --git a/mysql-test/suite/maria/icp.result b/mysql-test/suite/maria/icp.result
new file mode 100644
index 00000000000..feca63402a4
--- /dev/null
+++ b/mysql-test/suite/maria/icp.result
@@ -0,0 +1,845 @@
+set @save_storage_engine= @@storage_engine;
+set storage_engine=Maria;
+set @maria_icp_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
+#
+# Bug#36981 - "innodb crash when selecting for update"
+#
+CREATE TABLE t1 (
+c1 CHAR(1),
+c2 CHAR(10),
+KEY (c1)
+);
+INSERT INTO t1 VALUES ('3', null);
+SELECT * FROM t1 WHERE c1='3' FOR UPDATE;
+c1 c2
+3 NULL
+DROP TABLE t1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 SELECT A.a + 10*(B.a + 10*C.a) FROM t1 A, t1 B, t1 C;
+CREATE TABLE t3 (
+c1 CHAR(10) NOT NULL,
+c2 CHAR(10) NOT NULL,
+c3 CHAR(200) NOT NULL,
+KEY (c1)
+);
+INSERT INTO t3
+SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',1000+ t2.a,'=w'), 'filler'
+ FROM t2;
+INSERT INTO t3
+SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',2000+t2.a,'=w'), 'filler-1'
+ FROM t2;
+INSERT INTO t3
+SELECT CONCAT('c-',1000+t2.a,'=w'), CONCAT('c-',3000+t2.a,'=w'), 'filler-2'
+ FROM t2;
+SELECT c1,c3 FROM t3 WHERE c1 >= 'c-1994=w' and c1 != 'c-1996=w' FOR UPDATE;
+c1 c3
+c-1994=w filler
+c-1994=w filler-1
+c-1994=w filler-2
+c-1995=w filler
+c-1995=w filler-1
+c-1995=w filler-2
+c-1997=w filler
+c-1997=w filler-1
+c-1997=w filler-2
+c-1998=w filler
+c-1998=w filler-1
+c-1998=w filler-2
+c-1999=w filler
+c-1999=w filler-1
+c-1999=w filler-2
+DROP TABLE t1,t2,t3;
+#
+# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for
+# null-safe operator <=> NULL
+#
+CREATE TABLE t1(
+c1 DATE NOT NULL,
+c2 DATE NULL,
+c3 DATETIME,
+c4 TIMESTAMP,
+PRIMARY KEY(c1),
+UNIQUE(c2)
+);
+
+INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05');
+INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26');
+INSERT INTO t1 VALUES('2008-01-01', NULL , '2008-01-02', '2008-01-03');
+INSERT INTO t1 VALUES('2008-01-17', NULL , NULL , '2009-01-29');
+INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29');
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2;
+c1 c2 c3 c4
+2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00
+2008-01-17 NULL NULL 2009-01-29 00:00:00
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2;
+c1 c2 c3 c4
+2008-01-01 NULL 2008-01-02 00:00:00 2008-01-03 00:00:00
+2008-01-17 NULL NULL 2009-01-29 00:00:00
+
+DROP TABLE t1;
+#
+# Bug#43617 - Innodb returns wrong results with timestamp's range value
+# in IN clause
+# (Note: Fixed by patch for BUG#42580)
+#
+CREATE TABLE t1(
+c1 TIMESTAMP NOT NULL,
+c2 TIMESTAMP NULL,
+c3 DATE,
+c4 DATETIME,
+PRIMARY KEY(c1),
+UNIQUE INDEX(c2)
+);
+INSERT INTO t1 VALUES
+('0000-00-00 00:00:00','0000-00-00 00:00:00','2008-01-04','2008-01-05 00:00:00'),
+('1971-01-01 00:00:01','1980-01-01 00:00:01','2009-01-01','2009-01-02 00:00:00'),
+('1999-01-01 00:00:00','1999-01-01 00:00:00', NULL, NULL),
+('2007-05-23 09:15:28','2007-05-23 09:15:28','2007-05-24','2007-05-24 09:15:28'),
+('2007-05-27 00:00:00','2007-05-25 00:00:00','2007-05-26','2007-05-26 00:00:00'),
+('2008-01-01 00:00:00', NULL, '2008-01-02','2008-01-03 00:00:00'),
+('2009-01-29 11:11:27','2009-01-29 11:11:27','2009-01-29','2009-01-29 11:11:27'),
+('2038-01-09 03:14:07','2038-01-09 03:14:07','2009-01-05','2009-01-06 00:00:00');
+
+SELECT *
+FROM t1
+WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07')
+ORDER BY c2;
+c1 c2 c3 c4
+2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
+
+SELECT *
+FROM t1
+WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07')
+ORDER BY c2 LIMIT 2;
+c1 c2 c3 c4
+2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
+
+SELECT *
+FROM t1
+WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07')
+ORDER BY c2 DESC;
+c1 c2 c3 c4
+2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
+
+SELECT *
+FROM t1
+WHERE c2 IN ('1971-01-01 00:00:01','2038-01-09 03:14:07')
+ORDER BY c2 DESC LIMIT 2;
+c1 c2 c3 c4
+2038-01-09 03:14:07 2038-01-09 03:14:07 2009-01-05 2009-01-06 00:00:00
+
+DROP TABLE t1;
+#
+# BUG#43618: MyISAM&Maria returns wrong results with 'between'
+# on timestamp
+#
+CREATE TABLE t1(
+ts TIMESTAMP NOT NULL,
+c char NULL,
+PRIMARY KEY(ts)
+);
+INSERT INTO t1 VALUES
+('1971-01-01','a'),
+('2007-05-25','b'),
+('2008-01-01','c'),
+('2038-01-09','d');
+
+# Execute select with invalid timestamp, desc ordering
+SELECT *
+FROM t1
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
+ORDER BY ts DESC
+LIMIT 2;
+ts c
+2008-01-01 00:00:00 c
+2007-05-25 00:00:00 b
+
+# Should use index condition
+EXPLAIN
+SELECT *
+FROM t1
+WHERE ts BETWEEN '0000-00-00' AND '2010-00-01 00:00:00'
+ORDER BY ts DESC
+LIMIT 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using index condition
+
+DROP TABLE t1;
+#
+# BUG#49906: Assertion failed - Field_varstring::val_str in field.cc
+# (Note: Fixed by patch for LP BUG#625841)
+#
+CREATE TABLE t1 (
+f1 VARCHAR(1024),
+f2 VARCHAR(10),
+INDEX test_idx USING BTREE (f2,f1(5))
+);
+INSERT INTO t1 VALUES ('a','c'), ('b','d');
+SELECT f1
+FROM t1
+WHERE f2 LIKE 'd'
+ORDER BY f1;
+f1
+b
+DROP TABLE t1;
+#
+# Bug#52660 - "Perf. regr. using ICP for MyISAM on range queries on
+# an index containing TEXT"
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 SELECT A.a + 10*(B.a) FROM t1 A, t1 B;
+CREATE TABLE t3 (
+c1 TINYTEXT NOT NULL,
+i1 INT NOT NULL,
+KEY (c1(6),i1)
+);
+INSERT INTO t3 SELECT CONCAT('c-',1000+t2.a,'=w'), 1 FROM t2;
+EXPLAIN
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range c1 c1 8 NULL 3 Using where
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w';
+c1
+c-1004=w
+c-1005=w
+c-1006=w
+EXPLAIN
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range c1 c1 12 NULL 2 Using index condition; Using where
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' and i1 > 2;
+c1
+EXPLAIN
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ALL c1 NULL NULL NULL 100 Using where
+SELECT c1 FROM t3 WHERE c1 >= 'c-1004=w' and c1 <= 'c-1006=w' or i1 > 2;
+c1
+c-1004=w
+c-1005=w
+c-1006=w
+DROP TABLE t1, t2, t3;
+#
+# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on
+#
+CREATE TABLE t (
+dummy INT PRIMARY KEY,
+a INT UNIQUE,
+b INT
+);
+INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5);
+SELECT * FROM t WHERE a > 2 FOR UPDATE;
+dummy a b
+3 3 3
+5 5 5
+DROP TABLE t;
+#
+# Bug#35080 - Innodb crash at mem_block_get_len line 72
+#
+CREATE TABLE t1 (
+t1_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+PRIMARY KEY (t1_autoinc),
+KEY k (uuid)
+);
+CREATE TABLE t2 (
+t2_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+date DATETIME DEFAULT NULL,
+PRIMARY KEY (t2_autoinc),
+KEY k (uuid)
+);
+CREATE VIEW v1 AS
+SELECT t1_autoinc, uuid
+FROM t1
+WHERE (ISNULL(uuid) OR (uuid like '%-%'));
+CREATE VIEW v2 AS
+SELECT t2_autoinc, uuid, date
+FROM t2
+WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36));
+CREATE PROCEDURE delete_multi (IN uuid CHAR(36))
+DELETE v1, v2 FROM v1 INNER JOIN v2
+ON v1.uuid = v2.uuid
+WHERE v1.uuid = @uuid;
+SET @uuid = UUID();
+INSERT INTO v1 (uuid) VALUES (@uuid);
+INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09');
+CALL delete_multi(@uuid);
+DROP procedure delete_multi;
+DROP table t1,t2;
+DROP view v1,v2;
+#
+# Bug#41996 - multi-table delete crashes server (InnoDB table)
+#
+CREATE TABLE t1 (
+b BIGINT,
+i INT,
+KEY (b)
+);
+INSERT INTO t1 VALUES (2, 2);
+DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b;
+DROP TABLE t1;
+#
+# Bug#43448 - Server crashes on multi table delete with Innodb
+#
+CREATE TABLE t1 (
+id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+t CHAR(12)
+);
+CREATE TABLE t2 (
+id2 INT NOT NULL,
+t CHAR(12)
+);
+CREATE TABLE t3(
+id3 INT NOT NULL,
+t CHAR(12),
+INDEX(id3)
+);
+CREATE PROCEDURE insert_data ()
+BEGIN
+DECLARE i1 INT DEFAULT 20;
+DECLARE i2 INT;
+DECLARE i3 INT;
+WHILE (i1 > 0) DO
+INSERT INTO t1(t) VALUES (i1);
+SET i2 = 2;
+WHILE (i2 > 0) DO
+INSERT INTO t2(id2, t) VALUES (i1, i2);
+SET i3 = 2;
+WHILE (i3 > 0) DO
+INSERT INTO t3(id3, t) VALUES (i1, i2);
+SET i3 = i3 -1;
+END WHILE;
+SET i2 = i2 -1;
+END WHILE;
+SET i1 = i1 - 1;
+END WHILE;
+END |
+CALL insert_data();
+SELECT COUNT(*) FROM t1 WHERE id1 > 10;
+COUNT(*)
+10
+SELECT COUNT(*) FROM t2 WHERE id2 > 10;
+COUNT(*)
+20
+SELECT COUNT(*) FROM t3 WHERE id3 > 10;
+COUNT(*)
+40
+DELETE t1, t2, t3
+FROM t1, t2, t3
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+6
+SELECT COUNT(*) FROM t3;
+COUNT(*)
+12
+DROP PROCEDURE insert_data;
+DROP TABLE t1, t2, t3;
+#
+# Bug#57372 "Multi-table updates and deletes fail when running with ICP
+# against InnoDB"
+#
+CREATE TABLE t1 (
+a INT KEY,
+b INT
+);
+CREATE TABLE t2 (
+a INT KEY,
+b INT
+);
+INSERT INTO t1 VALUES (1, 101), (2, 102), (3, 103), (4, 104), (5, 105);
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+UPDATE t1, t2
+SET t1.a = t1.a + 100, t2.b = t1.a + 10
+WHERE t1.a BETWEEN 2 AND 4 AND t2.a = t1.b - 100;
+SELECT * FROM t1;
+a b
+1 101
+102 102
+103 103
+104 104
+5 105
+SELECT * FROM t2;
+a b
+1 1
+2 12
+3 13
+4 14
+5 5
+DROP TABLE t1, t2;
+#
+# Bug#52605 - "Adding LIMIT 1 clause to query with complex range
+# predicate causes wrong results"
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT,
+PRIMARY KEY (pk),
+KEY k1 (c1)
+);
+INSERT INTO t1 VALUES (1,NULL);
+INSERT INTO t1 VALUES (2,6);
+INSERT INTO t1 VALUES (3,NULL);
+INSERT INTO t1 VALUES (4,6);
+INSERT INTO t1 VALUES (5,NULL);
+INSERT INTO t1 VALUES (6,NULL);
+INSERT INTO t1 VALUES (7,9);
+INSERT INTO t1 VALUES (8,0);
+SELECT pk, c1
+FROM t1
+WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
+ORDER BY c1
+LIMIT 1;
+pk c1
+4 6
+EXPLAIN SELECT pk, c1
+FROM t1
+WHERE (pk BETWEEN 4 AND 5 OR pk < 2) AND c1 < 240
+ORDER BY c1
+LIMIT 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY,k1 k1 5 NULL 4 Using where
+DROP TABLE t1;
+#
+#
+# Bug#59259 "Incorrect rows returned for a correlated subquery
+# when ICP is on"
+#
+CREATE TABLE t1 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1266 Using storage engine Aria for table 't1'
+INSERT INTO t1 VALUES (11,0);
+INSERT INTO t1 VALUES (12,5);
+INSERT INTO t1 VALUES (15,0);
+CREATE TABLE t2 (pk INTEGER PRIMARY KEY, i INTEGER NOT NULL) ENGINE=InnoDB;
+Warnings:
+Warning 1286 Unknown storage engine 'InnoDB'
+Warning 1266 Using storage engine Aria for table 't2'
+INSERT INTO t2 VALUES (11,1);
+INSERT INTO t2 VALUES (12,2);
+INSERT INTO t2 VALUES (15,4);
+set @save_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='semijoin=off';
+EXPLAIN
+SELECT * FROM t1
+WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 DEPENDENT SUBQUERY it eq_ref PRIMARY PRIMARY 4 func 1 Using index condition
+2 DEPENDENT SUBQUERY t2 index NULL PRIMARY 4 NULL 3 Using where; Using index; Using join buffer (flat, BNL join)
+SELECT * FROM t1
+WHERE pk IN (SELECT it.pk FROM t2 JOIN t2 AS it ON it.i=it.i WHERE it.pk-t1.i<10);
+pk i
+12 5
+set optimizer_switch=@save_optimizer_switch;
+DROP TABLE t1, t2;
+#
+# Bug #58816 "Extra temporary duplicate rows in result set when
+# switching ICP off"
+#
+set @save_optimizer_switch= @@optimizer_switch;
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,9),(2,7),(3,6),(4,3),(5,1);
+EXPLAIN SELECT pk, c1 FROM t1 WHERE pk <> 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 5 Using where
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT pk, c1 FROM t1 WHERE pk <> 3;
+pk c1
+1 9
+2 7
+4 3
+5 1
+DROP TABLE t1;
+set optimizer_switch= @save_optimizer_switch;
+#
+# Bug#58837: ICP crash or valgrind error due to uninitialized
+# value in innobase_index_cond
+#
+CREATE TABLE t1 (
+t1_int INT,
+t1_time TIME
+);
+CREATE TABLE t2 (
+t2_int int PRIMARY KEY,
+t2_int2 INT
+);
+INSERT INTO t2 VALUES ();
+INSERT INTO t1 VALUES ();
+SELECT * FROM t1 AS t1a
+WHERE NOT EXISTS (SELECT * FROM t1 AS t1b
+WHERE t1b.t1_int NOT IN
+(SELECT t2.t2_int FROM t2
+WHERE t1b.t1_time LIKE t1b.t1_int
+OR t1b.t1_time <> t2.t2_int2
+AND 6=7));
+t1_int t1_time
+DROP TABLE t1,t2;
+#
+# Bug#59186: Wrong results of join when ICP is enabled
+# (fixed by the patch for LP bug #694092)
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'y'),(0,'or');
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+c1 VARCHAR(3) NOT NULL,
+c2 VARCHAR(6) NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (6,'y','RPOYT'),(10,'m','JINQE');
+EXPLAIN
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan
+1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
+SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
+WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
+(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
+c2
+DROP TABLE t1, t2;
+#
+# Bug#58838: "Wrong results with HAVING + LIMIT without GROUP BY when
+# ICP is enabled".
+# (Fixed by the patches for LP bugs #668644, #702322)
+#
+CREATE TABLE t1 (
+pk INT NOT NULL,
+c1 INT,
+PRIMARY KEY (pk),
+KEY col_int_key (c1)
+);
+INSERT INTO t1 VALUES (1,37),(2,8),(3,-25),(4,NULL),(5,55);
+SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 0;
+pk
+SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 1;
+pk
+3
+SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 2;
+pk
+3
+SELECT pk FROM t1 WHERE c1 <> 1 HAVING pk = 3 ORDER BY pk LIMIT 5;
+pk
+3
+DROP TABLE t1;
+#
+# Bug#59483 "Crash on INSERT/REPLACE in
+# rec_convert_dtuple_to_rec_comp with ICP on"
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT PRIMARY KEY,
+i1 INTEGER,
+c1 CHAR(6),
+i2 INTEGER NOT NULL,
+KEY (i2)
+);
+INSERT INTO t1 VALUES
+(NULL, 4, 'that', 8),
+(NULL, 1, 'she', 6),
+(NULL, 6, 'tell', 2);
+SELECT * FROM t1 WHERE i2 IN (3, 6) LIMIT 2 FOR UPDATE;
+pk i1 c1 i2
+2 1 she 6
+INSERT INTO t1 (i2) VALUES (1);
+DROP TABLE t1;
+#
+# Bug #11766678 - 59843:
+# USING UNINITIALISED VALUE IN USES_INDEX_FIELDS_ONLY
+#
+CREATE TABLE t1 (
+col999 FLOAT NOT NULL,
+COL1000 VARBINARY(179) NOT NULL,
+col1003 DATE DEFAULT NULL,
+KEY idx4267 (col1000, col1003)
+);
+INSERT INTO t1 VALUES (),();
+Warnings:
+Warning 1364 Field 'col999' doesn't have a default value
+Warning 1364 Field 'COL1000' doesn't have a default value
+SELECT col999 FROM t1 WHERE col1000 = "3" AND col1003 <=> sysdate();
+col999
+DROP TABLE t1;
+#
+# BUG#12822678 - ICP WITH STRAIGHT_JOIN
+#
+CREATE TABLE t1 (
+i1 INTEGER NOT NULL,
+d1 DOUBLE,
+KEY k1 (d1)
+);
+INSERT INTO t1 VALUES (10,1), (17,NULL), (22,NULL);
+CREATE TABLE t2 (
+pk INTEGER NOT NULL,
+i1 INTEGER NOT NULL,
+PRIMARY KEY (pk)
+);
+INSERT INTO t2 VALUES (4,1);
+EXPLAIN
+SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
+WHERE t2.pk <> t1.d1 AND t2.pk = 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k1 9 NULL 3 Using index
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1 Using where
+SELECT t1.d1, t2.pk, t2.i1 FROM t1 STRAIGHT_JOIN t2 ON t2.i1
+WHERE t2.pk <> t1.d1 AND t2.pk = 4;
+d1 pk i1
+1 4 1
+DROP TABLE t1, t2;
+#
+# BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89
+#
+CREATE TABLE t1 ( f11 int) ;
+INSERT IGNORE INTO t1 VALUES (0);
+CREATE TABLE t2 ( f10 int) ;
+INSERT IGNORE INTO t2 VALUES (0);
+CREATE TABLE t3 ( f1 int NOT NULL , f10 int, PRIMARY KEY (f1)) ;
+INSERT IGNORE INTO t3 VALUES (6,0),(10,0);
+CREATE TABLE t4 ( f11 int) ;
+INSERT IGNORE INTO t4 VALUES
+(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(NULL),
+(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
+set @tmp_778434=@@optimizer_switch;
+SET optimizer_switch='materialization=off,in_to_exists=on,subquery_cache=off,semijoin=off';
+SELECT * FROM t1 INNER JOIN t2 ON t2.f10 = t1.f11
+WHERE (6, 234) IN (
+SELECT t3.f1, t3.f1
+FROM t3 JOIN t4 ON t4.f11 = t3.f10
+);
+f11 f10
+DROP TABLE t1,t2,t3,t4;
+set optimizer_switch= @tmp_778434;
+#
+# Bug#885168: ICP for one index + potential ORDER BY for another
+#
+CREATE TABLE t1 (a varchar(64), b varchar(10), INDEX(a), INDEX(b)) ;
+INSERT INTO t1 VALUES
+('Ohio','Iowa'), ('k','d'), ('bdkpj','mbdkpjdanp'), ('d','xdmbdkpjda'),
+('fkxdmbdkpjdanpje','o'), ('f','Pennsylvan'), ('Virginia','ei');
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+EXPLAIN
+SELECT * FROM t1
+WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
+ ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b b 13 NULL 2 Using where; Rowid-ordered scan; Using filesort
+SELECT * FROM t1
+WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
+ ORDER BY a;
+a b
+d xdmbdkpjda
+SET SESSION optimizer_switch='index_condition_pushdown=on';
+EXPLAIN
+SELECT * FROM t1
+WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
+ ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b b 13 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using filesort
+SELECT * FROM t1
+WHERE NOT(b = 'Texas') AND b BETWEEN 'wy' AND 'y' OR b = 'Pennsylvania'
+ ORDER BY a;
+a b
+d xdmbdkpjda
+DROP TABLE t1;
+#
+# Bug#886145: join with ICP + ORDER BY
+#
+CREATE TABLE t1 (b int NOT NULL, c int, a varchar(1024), PRIMARY KEY (b));
+INSERT INTO t1 VALUES (1,4,'Ill');
+CREATE TABLE t2 (a varchar(1024), KEY (a(512)));
+INSERT INTO t2 VALUES
+('Ill'), ('eckqzsflbzaffti'), ('w'), ('she'), ('gxbwypqtjzwywwer'), ('w');
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+EXPLAIN
+SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
+HAVING t1.c != 5 ORDER BY t1.c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
+1 SIMPLE t2 ref a a 515 const 1 Using where
+SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
+HAVING t1.c != 5 ORDER BY t1.c;
+b c
+1 4
+SET SESSION optimizer_switch='index_condition_pushdown=on';
+EXPLAIN
+SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
+HAVING t1.c != 5 ORDER BY t1.c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system PRIMARY NULL NULL NULL 1
+1 SIMPLE t2 ref a a 515 const 1 Using where
+SELECT t1.b, t1.c FROM t1, t2 WHERE t1.a = t2.a AND t1.b != 0
+HAVING t1.c != 5 ORDER BY t1.c;
+b c
+1 4
+DROP TABLE t1,t2;
+#
+# Bug#879871: InnoDB: possible ICP + GROUP BY primary index
+#
+CREATE TABLE t1 (
+a int NOT NULL, b int, c varchar(1), d varchar(1),
+PRIMARY KEY (a), KEY c (c,b)
+);
+INSERT INTO t1 VALUES (10,8,'g','g');
+SET SESSION optimizer_switch='index_condition_pushdown=off';
+SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
+a
+SET SESSION optimizer_switch='index_condition_pushdown=on';
+SELECT a FROM t1 WHERE c IS NULL AND d IS NOT NULL GROUP BY 1;
+a
+DROP TABLE t1;
+#
+# Bug#904832: an attempt to perform an index condition pushdown
+# of a condition containing a subquery
+#
+CREATE TABLE t1 (
+a INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
+b INT, c INT, d DATE NOT NULL, e VARCHAR(1),
+KEY (c), KEY (d), KEY k2(b), KEY k3(b), KEY k4(b)
+);
+INSERT INTO t1 (b,c,d,e) VALUES
+(6,5,'2006-05-25','y'),(1,5,'2008-01-23','t'),
+(6,5,'2007-06-18','d'),(4,5,'1900-01-01','r'),
+(8,5,'1900-01-01','m'),(4,5,'2006-03-09','b'),
+(4,5,'2001-06-05','x'),(1,5,'2008-01-23','t'),
+(6,5,'2007-06-18','d'),(4,5,'1900-01-01','r'),
+(8,5,'1900-01-01','m'),(4,5,'2006-03-09','b'),
+(4,5,'2001-06-05','x'),(1,5,'2008-01-23','t'),
+(4,5,'1900-01-01','r'),(8,5,'1900-01-01','m'),
+(4,5,'2006-03-09','b'),(4,5,'2001-06-05','x'),
+(1,5,'2008-01-23','t'),(6,5,'2007-06-18','d'),
+(4,5,'1900-01-01','r'),(8,5,'1900-01-01','m'),
+(4,5,'2006-03-09','b'),(4,5,'2001-06-05','f'),
+(4,5,'2001-06-05','x'),(8,5,'1900-01-01','m'),
+(4,5,'2006-03-09','b'),(4,5,'2001-06-05','x'),
+(1,5,'2008-01-23','t'),(6,5,'2007-06-18','d'),
+(4,5,'1900-01-01','r'),(8,5,'1900-01-01','m'),
+(4,5,'2006-03-09','b'),(6,5,'2007-06-18','d'),
+(6,5,'2007-06-18','d'),(4,5,'1900-01-01','r'),
+(8,5,'1900-01-01','m'),(4,5,'2006-03-09','b'),
+(6,5,'2007-06-18','d'),(4,5,'1900-01-01','r'),
+(8,5,'1900-01-01','m'),(4,5,'2006-03-09','b'),
+(4,5,'2006-03-09','b'),(4,5,'2001-06-05','x'),
+(1,5,'2008-01-23','t'),(6,5,'2007-06-18','d'),
+(4,5,'1900-01-01','r'),(8,5,'1900-01-01','m'),
+(4,5,'2006-03-09','b'),(4,5,'2001-06-05','x'),
+(4,5,'2001-06-05','x'),(1,5,'2008-01-23','t'),
+(6,5,'2007-06-18','d'),(4,5,'1900-01-01','r'),
+(8,5,'1900-01-01','m'),(4,5,'2006-03-09','b'),
+(4,5,'2001-06-05','x'),(1,5,'2008-01-23','t'),
+(6,5,'2007-06-18','d'),(4,1,'1900-01-01','r'),
+(8,8,'1900-01-01','m'),(4,1,'2006-03-09','b'),
+(4,1,'2001-06-05','x'),(7,1,'2006-05-28','g');
+CREATE TABLE t2 (
+f INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
+g INT,
+h VARCHAR(1),
+KEY (g)
+);
+INSERT INTO t2 (g,h) VALUES
+(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
+(5,'l'),(8,'y'),(0,'p'),(0,'f'),(0,'p'),(7,'d'),
+(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u'),
+(6,'i'),(1,'x'),(5,'l'),(8,'y'),(0,'p'),(0,'f'),
+(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
+(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
+(7,'d'),(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),
+(9,'u'),(6,'i'),(1,'x'),(5,'l'),(8,'y'),(0,'p'),
+(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),(3,'e'),
+(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),(5,'l'),
+(6,'q'),(2,'n'),(4,'r'),(4,'b'),(8,'y'),(0,'p'),
+(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),(3,'e'),
+(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),(5,'l'),
+(8,'y'),(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),
+(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),
+(1,'x'),(5,'l'),(8,'y'),(0,'p'),(0,'f'),(0,'p'),
+(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),(3,'e'),
+(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),(7,'d'),
+(7,'f'),(5,'j'),(3,'e'),(1,'u'),(0,'f'),(0,'p'),
+(7,'d'),(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),
+(9,'u'),(6,'i'),(1,'x'),(5,'l'),(8,'y'),(0,'p'),
+(0,'f'),(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),
+(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),
+(1,'x'),(7,'d'),(7,'f'),(5,'j'),(3,'e'),(1,'u'),
+(4,'v'),(9,'u'),(6,'i'),(1,'x'),(5,'l'),(8,'y'),
+(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
+(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
+(5,'l'),(6,'q'),(2,'n'),(4,'r'),(4,'b'),(8,'y'),
+(0,'p'),(0,'f'),(0,'p'),(7,'d'),(7,'f'),(5,'j'),
+(3,'e'),(1,'u'),(4,'v'),(9,'u'),(6,'i'),(1,'x'),
+(7,'f'),(5,'j'),(3,'e'),(1,'u'),(4,'v'),(9,'u');
+SET @save_optimize_switch=@@optimizer_switch;
+SET optimizer_switch='materialization=on';
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS t, t2
+WHERE c = g
+AND (EXISTS (SELECT * FROM t1, t2 WHERE a = f AND h <= t.e AND a > t.b)
+OR a = 0 AND h < 'z' );
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t ALL PRIMARY,c NULL NULL NULL 64 Using where
+1 PRIMARY t2 ref g g 5 test.t.c 19 Using where
+2 DEPENDENT SUBQUERY t1 index PRIMARY PRIMARY 4 NULL 64 Using where; Using index
+2 DEPENDENT SUBQUERY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using index condition; Using where
+SELECT COUNT(*) FROM t1 AS t, t2
+WHERE c = g
+AND (EXISTS (SELECT * FROM t1, t2 WHERE a = f AND h <= t.e AND a > t.b)
+OR a = 0 AND h < 'z' );
+COUNT(*)
+1478
+SELECT COUNT(*) FROM t1 AS t, t2
+WHERE c = g
+AND (EXISTS (SELECT * FROM t1, t2 WHERE a = f AND h <= t.e AND a > t.b)
+OR a = 0 AND h < 'z' );
+COUNT(*)
+1478
+SET optimizer_switch=@save_optimizer_switch;
+DROP TABLE t1,t2;
+# check "Handler_pushed" status varuiables
+CREATE TABLE t1 (
+c1 CHAR(1),
+c2 CHAR(1),
+KEY (c1)
+);
+INSERT INTO t1 VALUES ('3', '3'),('4','4'),('5','5');
+flush status;
+show status like "Handler_icp%";
+Variable_name Value
+Handler_icp_attempts 0
+Handler_icp_match 0
+SELECT * FROM t1 FORCE INDEX(c1) WHERE (c1='3' or c1='4') and c1 % 2 = 0 ;
+c1 c2
+4 4
+show status like "Handler_icp%";
+Variable_name Value
+Handler_icp_attempts 2
+Handler_icp_match 1
+SELECT * FROM t1 WHERE (c2='3' or c2='4') and c2 % 2 = 0 ;
+c1 c2
+4 4
+show status like "Handler_icp%";
+Variable_name Value
+Handler_icp_attempts 2
+Handler_icp_match 1
+DROP TABLE t1;
+set storage_engine= @save_storage_engine;
+set optimizer_switch=@maria_icp_tmp;
diff --git a/mysql-test/suite/maria/icp.test b/mysql-test/suite/maria/icp.test
new file mode 100644
index 00000000000..d8af34daf2e
--- /dev/null
+++ b/mysql-test/suite/maria/icp.test
@@ -0,0 +1,17 @@
+#
+# ICP/Maria tests (Index Condition Pushdown)
+#
+
+--source include/have_maria.inc
+
+set @save_storage_engine= @@storage_engine;
+set storage_engine=Maria;
+set @maria_icp_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
+
+--source include/icp_tests.inc
+
+set storage_engine= @save_storage_engine;
+set optimizer_switch=@maria_icp_tmp;
+
+
diff --git a/mysql-test/suite/maria/lock.result b/mysql-test/suite/maria/lock.result
new file mode 100644
index 00000000000..101347c7d4c
--- /dev/null
+++ b/mysql-test/suite/maria/lock.result
@@ -0,0 +1,29 @@
+drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+DROP TABLE t1;
+UNLOCK TABLES;
+DROP TABLE t2;
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+FLUSH TABLE t1;
+select * from t1;
+i
+unlock tables;
+drop table t1,t2;
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+repair table t1 use_frm;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+select * from t1;
+i
+drop table t2;
+unlock tables;
+drop table t1;
diff --git a/mysql-test/suite/maria/lock.test b/mysql-test/suite/maria/lock.test
new file mode 100644
index 00000000000..6116f0b5f08
--- /dev/null
+++ b/mysql-test/suite/maria/lock.test
@@ -0,0 +1,44 @@
+#
+# Testing of potential problems in Aria with locking
+#
+
+-- source include/have_maria.inc
+
+drop table if exists t1,t2;
+
+#
+# Test for Bug#973039
+# Assertion `share->in_trans == 0' failed in maria_close on DROP TABLE
+# under LOCK
+#
+
+# Test DROP TABLE
+
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+# Also fails with FLUSH TABLE t1 and with REPAIR TABLE t1 USE_FRM
+DROP TABLE t1;
+UNLOCK TABLES;
+DROP TABLE t2;
+
+#Test FLUSH TABLE
+
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+FLUSH TABLE t1;
+select * from t1;
+unlock tables;
+drop table t1,t2;
+
+# Test REPAIR ... USE_FRM and unlock tables last
+
+CREATE TABLE t1 (i INT) ENGINE=Aria;
+CREATE TABLE t2 (i INT) ENGINE=Aria;
+LOCK TABLE t1 WRITE, t2 WRITE;
+repair table t1 use_frm;
+select * from t1;
+drop table t2;
+unlock tables;
+drop table t1;
diff --git a/mysql-test/suite/maria/r/locking.result b/mysql-test/suite/maria/locking.result
index 772e43f5983..772e43f5983 100644
--- a/mysql-test/suite/maria/r/locking.result
+++ b/mysql-test/suite/maria/locking.result
diff --git a/mysql-test/suite/maria/t/locking.test b/mysql-test/suite/maria/locking.test
index c20ca33e162..c20ca33e162 100644
--- a/mysql-test/suite/maria/t/locking.test
+++ b/mysql-test/suite/maria/locking.test
diff --git a/mysql-test/suite/maria/r/maria-autozerofill.result b/mysql-test/suite/maria/maria-autozerofill.result
index 22856fe54b0..22856fe54b0 100644
--- a/mysql-test/suite/maria/r/maria-autozerofill.result
+++ b/mysql-test/suite/maria/maria-autozerofill.result
diff --git a/mysql-test/suite/maria/t/maria-autozerofill.test b/mysql-test/suite/maria/maria-autozerofill.test
index 9bb2782105a..9bb2782105a 100644
--- a/mysql-test/suite/maria/t/maria-autozerofill.test
+++ b/mysql-test/suite/maria/maria-autozerofill.test
diff --git a/mysql-test/suite/maria/r/maria-big.result b/mysql-test/suite/maria/maria-big.result
index cb6e02df00e..cb6e02df00e 100644
--- a/mysql-test/suite/maria/r/maria-big.result
+++ b/mysql-test/suite/maria/maria-big.result
diff --git a/mysql-test/suite/maria/t/maria-big.test b/mysql-test/suite/maria/maria-big.test
index 5b4b6c4defe..5b4b6c4defe 100644
--- a/mysql-test/suite/maria/t/maria-big.test
+++ b/mysql-test/suite/maria/maria-big.test
diff --git a/mysql-test/suite/maria/r/maria-big2.result b/mysql-test/suite/maria/maria-big2.result
index 3e4c6973997..3e4c6973997 100644
--- a/mysql-test/suite/maria/r/maria-big2.result
+++ b/mysql-test/suite/maria/maria-big2.result
diff --git a/mysql-test/suite/maria/t/maria-big2.test b/mysql-test/suite/maria/maria-big2.test
index d138892fe3c..d138892fe3c 100644
--- a/mysql-test/suite/maria/t/maria-big2.test
+++ b/mysql-test/suite/maria/maria-big2.test
diff --git a/mysql-test/suite/maria/r/maria-connect.result b/mysql-test/suite/maria/maria-connect.result
index ed626a003f5..ed626a003f5 100644
--- a/mysql-test/suite/maria/r/maria-connect.result
+++ b/mysql-test/suite/maria/maria-connect.result
diff --git a/mysql-test/suite/maria/t/maria-connect.test b/mysql-test/suite/maria/maria-connect.test
index a1e9bbce4f2..a1e9bbce4f2 100644
--- a/mysql-test/suite/maria/t/maria-connect.test
+++ b/mysql-test/suite/maria/maria-connect.test
diff --git a/mysql-test/suite/maria/t/maria-gis-recovery.opt b/mysql-test/suite/maria/maria-gis-recovery.opt
index 58d0d012c54..58d0d012c54 100644
--- a/mysql-test/suite/maria/t/maria-gis-recovery.opt
+++ b/mysql-test/suite/maria/maria-gis-recovery.opt
diff --git a/mysql-test/suite/maria/r/maria-gis-recovery.result b/mysql-test/suite/maria/maria-gis-recovery.result
index d1088dd1ba0..d1088dd1ba0 100644
--- a/mysql-test/suite/maria/r/maria-gis-recovery.result
+++ b/mysql-test/suite/maria/maria-gis-recovery.result
diff --git a/mysql-test/suite/maria/t/maria-gis-recovery.test b/mysql-test/suite/maria/maria-gis-recovery.test
index c40cc3788de..c40cc3788de 100644
--- a/mysql-test/suite/maria/t/maria-gis-recovery.test
+++ b/mysql-test/suite/maria/maria-gis-recovery.test
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result b/mysql-test/suite/maria/maria-gis-rtree-dynamic.result
index 843e5ae3d37..843e5ae3d37 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result
+++ b/mysql-test/suite/maria/maria-gis-rtree-dynamic.result
diff --git a/mysql-test/suite/maria/t/maria-gis-rtree-dynamic.test b/mysql-test/suite/maria/maria-gis-rtree-dynamic.test
index 166c88cab36..166c88cab36 100644
--- a/mysql-test/suite/maria/t/maria-gis-rtree-dynamic.test
+++ b/mysql-test/suite/maria/maria-gis-rtree-dynamic.test
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree-trans.result b/mysql-test/suite/maria/maria-gis-rtree-trans.result
index 8ccc1f5bfdf..8ccc1f5bfdf 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree-trans.result
+++ b/mysql-test/suite/maria/maria-gis-rtree-trans.result
diff --git a/mysql-test/suite/maria/t/maria-gis-rtree-trans.test b/mysql-test/suite/maria/maria-gis-rtree-trans.test
index ec1573c3e29..ec1573c3e29 100644
--- a/mysql-test/suite/maria/t/maria-gis-rtree-trans.test
+++ b/mysql-test/suite/maria/maria-gis-rtree-trans.test
diff --git a/mysql-test/suite/maria/r/maria-gis-rtree.result b/mysql-test/suite/maria/maria-gis-rtree.result
index 9945daae75e..9945daae75e 100644
--- a/mysql-test/suite/maria/r/maria-gis-rtree.result
+++ b/mysql-test/suite/maria/maria-gis-rtree.result
diff --git a/mysql-test/suite/maria/t/maria-gis-rtree.test b/mysql-test/suite/maria/maria-gis-rtree.test
index beffbfc99fe..beffbfc99fe 100644
--- a/mysql-test/suite/maria/t/maria-gis-rtree.test
+++ b/mysql-test/suite/maria/maria-gis-rtree.test
diff --git a/mysql-test/suite/maria/r/maria-mvcc.result b/mysql-test/suite/maria/maria-mvcc.result
index 671b1bbf53c..671b1bbf53c 100644
--- a/mysql-test/suite/maria/r/maria-mvcc.result
+++ b/mysql-test/suite/maria/maria-mvcc.result
diff --git a/mysql-test/suite/maria/t/maria-mvcc.test b/mysql-test/suite/maria/maria-mvcc.test
index 8be8e2ea630..8be8e2ea630 100644
--- a/mysql-test/suite/maria/t/maria-mvcc.test
+++ b/mysql-test/suite/maria/maria-mvcc.test
diff --git a/mysql-test/suite/maria/r/maria-no-logging.result b/mysql-test/suite/maria/maria-no-logging.result
index 9c50245d05d..9c50245d05d 100644
--- a/mysql-test/suite/maria/r/maria-no-logging.result
+++ b/mysql-test/suite/maria/maria-no-logging.result
diff --git a/mysql-test/suite/maria/t/maria-no-logging.test b/mysql-test/suite/maria/maria-no-logging.test
index 7055a842510..7055a842510 100644
--- a/mysql-test/suite/maria/t/maria-no-logging.test
+++ b/mysql-test/suite/maria/maria-no-logging.test
diff --git a/mysql-test/suite/maria/r/maria-page-checksum.result b/mysql-test/suite/maria/maria-page-checksum.result
index c4d1b71e33a..c4d1b71e33a 100644
--- a/mysql-test/suite/maria/r/maria-page-checksum.result
+++ b/mysql-test/suite/maria/maria-page-checksum.result
diff --git a/mysql-test/suite/maria/t/maria-page-checksum.test b/mysql-test/suite/maria/maria-page-checksum.test
index 8dd68fce245..8dd68fce245 100644
--- a/mysql-test/suite/maria/t/maria-page-checksum.test
+++ b/mysql-test/suite/maria/maria-page-checksum.test
diff --git a/mysql-test/suite/maria/r/maria-partitioning.result b/mysql-test/suite/maria/maria-partitioning.result
index 840c7c0b3b4..bcb88626ff7 100644
--- a/mysql-test/suite/maria/r/maria-partitioning.result
+++ b/mysql-test/suite/maria/maria-partitioning.result
@@ -28,3 +28,7 @@ insert into t1 values (2);
select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb';
a a
drop table t1,t2;
+CREATE TABLE t1 ( i INT ) ENGINE=Aria
+PARTITION BY HASH(i) PARTITIONS 2;
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+drop table t1;
diff --git a/mysql-test/suite/maria/t/maria-partitioning.test b/mysql-test/suite/maria/maria-partitioning.test
index 612c44be57e..446cfed770b 100644
--- a/mysql-test/suite/maria/t/maria-partitioning.test
+++ b/mysql-test/suite/maria/maria-partitioning.test
@@ -34,6 +34,15 @@ insert into t1 values (2);
select * from t2 left join t1 on (t2.a=t1.a) where t2.a='bbb';
drop table t1,t2;
+#
+# LP:990187
+# Assertion `share->reopen == 1' failed at maria_extra on ADD PARTITION
+#
+CREATE TABLE t1 ( i INT ) ENGINE=Aria
+ PARTITION BY HASH(i) PARTITIONS 2;
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+drop table t1;
+
# Set defaults back
--disable_result_log
--disable_query_log
diff --git a/mysql-test/suite/maria/r/maria-preload.result b/mysql-test/suite/maria/maria-preload.result
index a693b6768ac..a693b6768ac 100644
--- a/mysql-test/suite/maria/r/maria-preload.result
+++ b/mysql-test/suite/maria/maria-preload.result
diff --git a/mysql-test/suite/maria/t/maria-preload.test b/mysql-test/suite/maria/maria-preload.test
index efac10ecbec..efac10ecbec 100644
--- a/mysql-test/suite/maria/t/maria-preload.test
+++ b/mysql-test/suite/maria/maria-preload.test
diff --git a/mysql-test/suite/maria/r/maria-purge.result b/mysql-test/suite/maria/maria-purge.result
index 382f8aedf89..382f8aedf89 100644
--- a/mysql-test/suite/maria/r/maria-purge.result
+++ b/mysql-test/suite/maria/maria-purge.result
diff --git a/mysql-test/suite/maria/t/maria-purge.test b/mysql-test/suite/maria/maria-purge.test
index ad41fa0f5d0..ad41fa0f5d0 100644
--- a/mysql-test/suite/maria/t/maria-purge.test
+++ b/mysql-test/suite/maria/maria-purge.test
diff --git a/mysql-test/suite/maria/t/maria-recover-master.opt b/mysql-test/suite/maria/maria-recover-master.opt
index 7582a381a32..7582a381a32 100644
--- a/mysql-test/suite/maria/t/maria-recover-master.opt
+++ b/mysql-test/suite/maria/maria-recover-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recover.result b/mysql-test/suite/maria/maria-recover.result
index 9b84c47720a..9b84c47720a 100644
--- a/mysql-test/suite/maria/r/maria-recover.result
+++ b/mysql-test/suite/maria/maria-recover.result
diff --git a/mysql-test/suite/maria/t/maria-recover.test b/mysql-test/suite/maria/maria-recover.test
index 56259ad9a31..56259ad9a31 100644
--- a/mysql-test/suite/maria/t/maria-recover.test
+++ b/mysql-test/suite/maria/maria-recover.test
diff --git a/mysql-test/suite/maria/t/maria-recovery-big-master.opt b/mysql-test/suite/maria/maria-recovery-big-master.opt
index d24a11c924f..d24a11c924f 100644
--- a/mysql-test/suite/maria/t/maria-recovery-big-master.opt
+++ b/mysql-test/suite/maria/maria-recovery-big-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recovery-big.result b/mysql-test/suite/maria/maria-recovery-big.result
index ae4010c7a86..ae4010c7a86 100644
--- a/mysql-test/suite/maria/r/maria-recovery-big.result
+++ b/mysql-test/suite/maria/maria-recovery-big.result
diff --git a/mysql-test/suite/maria/t/maria-recovery-big.test b/mysql-test/suite/maria/maria-recovery-big.test
index 4bad3913e58..4bad3913e58 100644
--- a/mysql-test/suite/maria/t/maria-recovery-big.test
+++ b/mysql-test/suite/maria/maria-recovery-big.test
diff --git a/mysql-test/suite/maria/t/maria-recovery-bitmap-master.opt b/mysql-test/suite/maria/maria-recovery-bitmap-master.opt
index 425fda95086..425fda95086 100644
--- a/mysql-test/suite/maria/t/maria-recovery-bitmap-master.opt
+++ b/mysql-test/suite/maria/maria-recovery-bitmap-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recovery-bitmap.result b/mysql-test/suite/maria/maria-recovery-bitmap.result
index e3697334239..e3697334239 100644
--- a/mysql-test/suite/maria/r/maria-recovery-bitmap.result
+++ b/mysql-test/suite/maria/maria-recovery-bitmap.result
diff --git a/mysql-test/suite/maria/t/maria-recovery-bitmap.test b/mysql-test/suite/maria/maria-recovery-bitmap.test
index 4c7956fbc30..4c7956fbc30 100644
--- a/mysql-test/suite/maria/t/maria-recovery-bitmap.test
+++ b/mysql-test/suite/maria/maria-recovery-bitmap.test
diff --git a/mysql-test/suite/maria/t/maria-recovery-master.opt b/mysql-test/suite/maria/maria-recovery-master.opt
index 58d0d012c54..58d0d012c54 100644
--- a/mysql-test/suite/maria/t/maria-recovery-master.opt
+++ b/mysql-test/suite/maria/maria-recovery-master.opt
diff --git a/mysql-test/suite/maria/t/maria-recovery-rtree-ft-master.opt b/mysql-test/suite/maria/maria-recovery-rtree-ft-master.opt
index 425fda95086..425fda95086 100644
--- a/mysql-test/suite/maria/t/maria-recovery-rtree-ft-master.opt
+++ b/mysql-test/suite/maria/maria-recovery-rtree-ft-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recovery-rtree-ft.result b/mysql-test/suite/maria/maria-recovery-rtree-ft.result
index 030421ae06a..030421ae06a 100644
--- a/mysql-test/suite/maria/r/maria-recovery-rtree-ft.result
+++ b/mysql-test/suite/maria/maria-recovery-rtree-ft.result
diff --git a/mysql-test/suite/maria/t/maria-recovery-rtree-ft.test b/mysql-test/suite/maria/maria-recovery-rtree-ft.test
index 11050ad676a..11050ad676a 100644
--- a/mysql-test/suite/maria/t/maria-recovery-rtree-ft.test
+++ b/mysql-test/suite/maria/maria-recovery-rtree-ft.test
diff --git a/mysql-test/suite/maria/r/maria-recovery.result b/mysql-test/suite/maria/maria-recovery.result
index 86e756badec..86e756badec 100644
--- a/mysql-test/suite/maria/r/maria-recovery.result
+++ b/mysql-test/suite/maria/maria-recovery.result
diff --git a/mysql-test/suite/maria/t/maria-recovery.test b/mysql-test/suite/maria/maria-recovery.test
index b0f01f37d0d..b0f01f37d0d 100644
--- a/mysql-test/suite/maria/t/maria-recovery.test
+++ b/mysql-test/suite/maria/maria-recovery.test
diff --git a/mysql-test/suite/maria/t/maria-recovery2-master.opt b/mysql-test/suite/maria/maria-recovery2-master.opt
index 9b232472a24..9b232472a24 100644
--- a/mysql-test/suite/maria/t/maria-recovery2-master.opt
+++ b/mysql-test/suite/maria/maria-recovery2-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recovery2.result b/mysql-test/suite/maria/maria-recovery2.result
index 149ce5a01af..149ce5a01af 100644
--- a/mysql-test/suite/maria/r/maria-recovery2.result
+++ b/mysql-test/suite/maria/maria-recovery2.result
diff --git a/mysql-test/suite/maria/t/maria-recovery2.test b/mysql-test/suite/maria/maria-recovery2.test
index 8d27d9aaaac..8d27d9aaaac 100644
--- a/mysql-test/suite/maria/t/maria-recovery2.test
+++ b/mysql-test/suite/maria/maria-recovery2.test
diff --git a/mysql-test/suite/maria/t/maria-recovery3-master.opt b/mysql-test/suite/maria/maria-recovery3-master.opt
index 58d0d012c54..58d0d012c54 100644
--- a/mysql-test/suite/maria/t/maria-recovery3-master.opt
+++ b/mysql-test/suite/maria/maria-recovery3-master.opt
diff --git a/mysql-test/suite/maria/r/maria-recovery3.result b/mysql-test/suite/maria/maria-recovery3.result
index d71a3f6c00a..d71a3f6c00a 100644
--- a/mysql-test/suite/maria/r/maria-recovery3.result
+++ b/mysql-test/suite/maria/maria-recovery3.result
diff --git a/mysql-test/suite/maria/t/maria-recovery3.test b/mysql-test/suite/maria/maria-recovery3.test
index e4bc73edc57..e4bc73edc57 100644
--- a/mysql-test/suite/maria/t/maria-recovery3.test
+++ b/mysql-test/suite/maria/maria-recovery3.test
diff --git a/mysql-test/suite/maria/r/maria-ucs2.result b/mysql-test/suite/maria/maria-ucs2.result
index e7258f21d4f..e7258f21d4f 100644
--- a/mysql-test/suite/maria/r/maria-ucs2.result
+++ b/mysql-test/suite/maria/maria-ucs2.result
diff --git a/mysql-test/suite/maria/t/maria-ucs2.test b/mysql-test/suite/maria/maria-ucs2.test
index fed67d780e9..fed67d780e9 100644
--- a/mysql-test/suite/maria/t/maria-ucs2.test
+++ b/mysql-test/suite/maria/maria-ucs2.test
diff --git a/mysql-test/suite/maria/r/maria.result b/mysql-test/suite/maria/maria.result
index c68a8871f83..c68a8871f83 100644
--- a/mysql-test/suite/maria/r/maria.result
+++ b/mysql-test/suite/maria/maria.result
diff --git a/mysql-test/suite/maria/t/maria.test b/mysql-test/suite/maria/maria.test
index b371394b2b3..b371394b2b3 100644
--- a/mysql-test/suite/maria/t/maria.test
+++ b/mysql-test/suite/maria/maria.test
diff --git a/mysql-test/suite/maria/r/maria2.result b/mysql-test/suite/maria/maria2.result
index a0ec440b662..a0ec440b662 100644
--- a/mysql-test/suite/maria/r/maria2.result
+++ b/mysql-test/suite/maria/maria2.result
diff --git a/mysql-test/suite/maria/t/maria2.test b/mysql-test/suite/maria/maria2.test
index df691569e05..df691569e05 100644
--- a/mysql-test/suite/maria/t/maria2.test
+++ b/mysql-test/suite/maria/maria2.test
diff --git a/mysql-test/suite/maria/r/maria3.result b/mysql-test/suite/maria/maria3.result
index 37613875f38..37613875f38 100644
--- a/mysql-test/suite/maria/r/maria3.result
+++ b/mysql-test/suite/maria/maria3.result
diff --git a/mysql-test/suite/maria/t/maria3.test b/mysql-test/suite/maria/maria3.test
index f1d95a15ba5..f1d95a15ba5 100644
--- a/mysql-test/suite/maria/t/maria3.test
+++ b/mysql-test/suite/maria/maria3.test
diff --git a/mysql-test/suite/maria/r/maria_notembedded.result b/mysql-test/suite/maria/maria_notembedded.result
index f9d8bbfedc8..f9d8bbfedc8 100644
--- a/mysql-test/suite/maria/r/maria_notembedded.result
+++ b/mysql-test/suite/maria/maria_notembedded.result
diff --git a/mysql-test/suite/maria/t/maria_notembedded.test b/mysql-test/suite/maria/maria_notembedded.test
index f1d71e90354..f1d71e90354 100644
--- a/mysql-test/suite/maria/t/maria_notembedded.test
+++ b/mysql-test/suite/maria/maria_notembedded.test
diff --git a/mysql-test/suite/maria/r/maria_partition.result b/mysql-test/suite/maria/maria_partition.result
index 372230c0b71..372230c0b71 100644
--- a/mysql-test/suite/maria/r/maria_partition.result
+++ b/mysql-test/suite/maria/maria_partition.result
diff --git a/mysql-test/suite/maria/t/maria_partition.test b/mysql-test/suite/maria/maria_partition.test
index 47571c7a4be..47571c7a4be 100644
--- a/mysql-test/suite/maria/t/maria_partition.test
+++ b/mysql-test/suite/maria/maria_partition.test
diff --git a/mysql-test/suite/maria/r/maria_showlog_error.result b/mysql-test/suite/maria/maria_showlog_error.result
index e2434efec28..e2434efec28 100644
--- a/mysql-test/suite/maria/r/maria_showlog_error.result
+++ b/mysql-test/suite/maria/maria_showlog_error.result
diff --git a/mysql-test/suite/maria/t/maria_showlog_error.test b/mysql-test/suite/maria/maria_showlog_error.test
index d6c59c5a0a6..d6c59c5a0a6 100644
--- a/mysql-test/suite/maria/t/maria_showlog_error.test
+++ b/mysql-test/suite/maria/maria_showlog_error.test
diff --git a/mysql-test/suite/maria/r/max_length.result b/mysql-test/suite/maria/max_length.result
index 6db58622698..6db58622698 100644
--- a/mysql-test/suite/maria/r/max_length.result
+++ b/mysql-test/suite/maria/max_length.result
diff --git a/mysql-test/suite/maria/t/max_length.test b/mysql-test/suite/maria/max_length.test
index 68ad1e22aa9..68ad1e22aa9 100644
--- a/mysql-test/suite/maria/t/max_length.test
+++ b/mysql-test/suite/maria/max_length.test
diff --git a/mysql-test/suite/maria/mrr.result b/mysql-test/suite/maria/mrr.result
new file mode 100644
index 00000000000..af7789eebff
--- /dev/null
+++ b/mysql-test/suite/maria/mrr.result
@@ -0,0 +1,443 @@
+drop table if exists t1,t2,t3,t4;
+set @maria_mrr_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
+set @mrr_buffer_size_save= @@mrr_buffer_size;
+set @save_storage_engine= @@storage_engine;
+set storage_engine=aria;
+create table t1(a int);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2(a int);
+insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
+create table t3 (
+a char(8) not null, b char(8) not null, filler char(200),
+key(a)
+);
+insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A;
+insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'),
+'filler-1' from t2 A;
+insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'),
+'filler-2' from t2 A;
+select a,filler from t3 where a >= 'c-9011=w';
+a filler
+select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w';
+a filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1011=w filler-1
+c-1012=w filler-1
+c-1013=w filler-1
+c-1014=w filler-1
+c-1015=w filler-1
+c-1011=w filler-2
+c-1012=w filler-2
+c-1013=w filler-2
+c-1014=w filler-2
+c-1015=w filler-2
+select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
+(a>='c-1014=w' and a <= 'c-1015=w');
+a filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1011=w filler-1
+c-1012=w filler-1
+c-1013=w filler-1
+c-1014=w filler-1
+c-1015=w filler-1
+c-1011=w filler-2
+c-1012=w filler-2
+c-1013=w filler-2
+c-1014=w filler-2
+c-1015=w filler-2
+insert into t3 values ('c-1013=z', 'c-1013=z', 'err');
+insert into t3 values ('a-1014=w', 'a-1014=w', 'err');
+select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
+(a>='c-1014=w' and a <= 'c-1015=w');
+a filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1011=w filler-1
+c-1012=w filler-1
+c-1013=w filler-1
+c-1014=w filler-1
+c-1015=w filler-1
+c-1011=w filler-2
+c-1012=w filler-2
+c-1013=w filler-2
+c-1014=w filler-2
+c-1015=w filler-2
+delete from t3 where b in ('c-1013=z', 'a-1014=w');
+select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
+a='c-1014=w' or a='c-1015=w';
+a filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1011=w filler-1
+c-1012=w filler-1
+c-1013=w filler-1
+c-1014=w filler-1
+c-1015=w filler-1
+c-1011=w filler-2
+c-1012=w filler-2
+c-1013=w filler-2
+c-1014=w filler-2
+c-1015=w filler-2
+insert into t3 values ('c-1013=w', 'del-me', 'inserted');
+select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
+a='c-1014=w' or a='c-1015=w';
+a filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1011=w filler-1
+c-1012=w filler-1
+c-1013=w filler-1
+c-1014=w filler-1
+c-1015=w filler-1
+c-1011=w filler-2
+c-1012=w filler-2
+c-1013=w filler-2
+c-1014=w filler-2
+c-1015=w filler-2
+c-1013=w inserted
+delete from t3 where b='del-me';
+alter table t3 add primary key(b);
+select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
+b IN ('c-1019=w', 'c-1020=w', 'c-1021=w',
+'c-1022=w', 'c-1023=w', 'c-1024=w');
+b filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1016=w filler
+c-1017=w filler
+c-1018=w filler
+c-1019=w filler
+c-1020=w filler
+c-1021=w filler
+c-1022=w filler
+c-1023=w filler
+c-1024=w filler
+select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or
+b IN ('c-1021=w', 'c-1022=w', 'c-1023=w');
+b filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1016=w filler
+c-1017=w filler
+c-1018=w filler
+c-1019=w filler
+c-1020=w filler
+c-1021=w filler
+c-1022=w filler
+c-1023=w filler
+select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or
+b IN ('c-1019=w', 'c-1020=w') or
+(b>='c-1021=w' and b<= 'c-1023=w');
+b filler
+c-1011=w filler
+c-1012=w filler
+c-1013=w filler
+c-1014=w filler
+c-1015=w filler
+c-1016=w filler
+c-1017=w filler
+c-1018=w filler
+c-1019=w filler
+c-1020=w filler
+c-1021=w filler
+c-1022=w filler
+c-1023=w filler
+drop table if exists t4;
+create table t4 (a varchar(10), b int, c char(10), filler char(200),
+key idx1 (a, b, c));
+insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15;
+insert into t4 (a,b,c,filler)
+select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15;
+insert into t4 (a,b,c,filler)
+select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15;
+insert into t4 (a,b,c,filler)
+select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15;
+insert into t4 (a,b,c,filler)
+select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500;
+explain
+select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
+ or c='no-such-row2');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 range idx1 idx1 29 NULL 16 Using index condition; Using where; Rowid-ordered scan
+select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
+ or c='no-such-row2');
+a b c filler
+NULL NULL NULL NULL-15
+NULL NULL NULL NULL-14
+NULL NULL NULL NULL-13
+NULL NULL NULL NULL-12
+NULL NULL NULL NULL-11
+NULL NULL NULL NULL-10
+NULL NULL NULL NULL-9
+NULL NULL NULL NULL-8
+NULL NULL NULL NULL-7
+NULL NULL NULL NULL-6
+NULL NULL NULL NULL-5
+NULL NULL NULL NULL-4
+NULL NULL NULL NULL-3
+NULL NULL NULL NULL-2
+NULL NULL NULL NULL-1
+explain
+select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 range idx1 idx1 29 NULL 32 Using index condition; Using where; Rowid-ordered scan
+select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
+a b c filler
+b-1 NULL c-1 NULL-15
+b-1 NULL c-1 NULL-14
+b-1 NULL c-1 NULL-13
+b-1 NULL c-1 NULL-12
+b-1 NULL c-1 NULL-11
+b-1 NULL c-1 NULL-10
+b-1 NULL c-1 NULL-9
+b-1 NULL c-1 NULL-8
+b-1 NULL c-1 NULL-7
+b-1 NULL c-1 NULL-6
+b-1 NULL c-1 NULL-5
+b-1 NULL c-1 NULL-4
+b-1 NULL c-1 NULL-3
+b-1 NULL c-1 NULL-2
+b-1 NULL c-1 NULL-1
+bb-1 NULL cc-2 NULL-15
+bb-1 NULL cc-2 NULL-14
+bb-1 NULL cc-2 NULL-13
+bb-1 NULL cc-2 NULL-12
+bb-1 NULL cc-2 NULL-11
+bb-1 NULL cc-2 NULL-10
+bb-1 NULL cc-2 NULL-9
+bb-1 NULL cc-2 NULL-8
+bb-1 NULL cc-2 NULL-7
+bb-1 NULL cc-2 NULL-6
+bb-1 NULL cc-2 NULL-5
+bb-1 NULL cc-2 NULL-4
+bb-1 NULL cc-2 NULL-3
+bb-1 NULL cc-2 NULL-2
+bb-1 NULL cc-2 NULL-1
+select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
+a b c filler
+b-1 NULL c-1 NULL-15
+b-1 NULL c-1 NULL-14
+b-1 NULL c-1 NULL-13
+b-1 NULL c-1 NULL-12
+b-1 NULL c-1 NULL-11
+b-1 NULL c-1 NULL-10
+b-1 NULL c-1 NULL-9
+b-1 NULL c-1 NULL-8
+b-1 NULL c-1 NULL-7
+b-1 NULL c-1 NULL-6
+b-1 NULL c-1 NULL-5
+b-1 NULL c-1 NULL-4
+b-1 NULL c-1 NULL-3
+b-1 NULL c-1 NULL-2
+b-1 NULL c-1 NULL-1
+bb-1 NULL cc-2 NULL-15
+bb-1 NULL cc-2 NULL-14
+bb-1 NULL cc-2 NULL-13
+bb-1 NULL cc-2 NULL-12
+bb-1 NULL cc-2 NULL-11
+bb-1 NULL cc-2 NULL-10
+bb-1 NULL cc-2 NULL-9
+bb-1 NULL cc-2 NULL-8
+bb-1 NULL cc-2 NULL-7
+bb-1 NULL cc-2 NULL-6
+bb-1 NULL cc-2 NULL-5
+bb-1 NULL cc-2 NULL-4
+bb-1 NULL cc-2 NULL-3
+bb-1 NULL cc-2 NULL-2
+bb-1 NULL cc-2 NULL-1
+drop table t1, t2, t3, t4;
+create table t1 (a int, b int not null,unique key (a,b),index(b));
+insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
+create table t2 like t1;
+insert into t2 select * from t1;
+alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
+select * from t1 where a is null;
+a b c
+NULL 7 0
+NULL 9 0
+NULL 9 0
+select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
+a b c
+NULL 9 0
+NULL 9 0
+select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
+a b c
+NULL 7 0
+NULL 9 0
+NULL 9 0
+drop table t1, t2;
+set storage_engine= @save_storage_engine;
+set @@mrr_buffer_size= @mrr_buffer_size_save;
+#
+# Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk with join_cache_level = {8,1}
+#
+set @save_join_cache_level= @@join_cache_level;
+SET SESSION join_cache_level = 8;
+CREATE TABLE `t1` (
+`col_int_key` int(11) DEFAULT NULL,
+`col_datetime_key` datetime DEFAULT NULL,
+`col_varchar_key` varchar(1) DEFAULT NULL,
+`col_varchar_nokey` varchar(1) DEFAULT NULL,
+KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
+INSERT INTO `t1` VALUES (6,'2005-10-07 00:00:00','e','e');
+INSERT INTO `t1` VALUES (51,'2000-07-15 05:00:34','f','f');
+CREATE TABLE `t2` (
+`col_int_key` int(11) DEFAULT NULL,
+`col_datetime_key` datetime DEFAULT NULL,
+`col_varchar_key` varchar(1) DEFAULT NULL,
+`col_varchar_nokey` varchar(1) DEFAULT NULL,
+KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
+INSERT INTO `t2` VALUES (2,'2004-10-11 18:13:16','w','w');
+INSERT INTO `t2` VALUES (2,'1900-01-01 00:00:00','d','d');
+SELECT table2 .`col_datetime_key`
+FROM t2 JOIN ( t1 table2 JOIN t2 table3 ON table3 .`col_varchar_key` < table2 .`col_varchar_key` ) ON table3 .`col_varchar_nokey` ;
+col_datetime_key
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: 'd'
+Warning 1292 Truncated incorrect DOUBLE value: 'd'
+Warning 1292 Truncated incorrect DOUBLE value: 'd'
+Warning 1292 Truncated incorrect DOUBLE value: 'd'
+drop table t1, t2;
+set join_cache_level=@save_join_cache_level;
+CREATE TABLE t1(
+pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t1 VALUES
+(1,9,'x'), (2,5,'g'), (3,1,'o'), (4,0,'g'), (5,1,'v'),
+(6,190,'m'), (7,6,'x'), (8,3,'c'), (9,4,'z'), (10,3,'i'),
+(11,186,'x'), (12,1,'g'), (13,8,'q'), (14,226,'m'), (15,133,'p');
+CREATE TABLE t2(
+pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 VALUES (77, 333, 'z');
+CREATE TABLE t3(
+pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t3 SELECT * FROM t1;
+INSERT INTO t3 VALUES
+(88, 442, 'y'), (99, 445, 'w'), (87, 442, 'z'), (98, 445, 'v'), (86, 442, 'x'),
+(97, 445, 't'), (85, 442, 'b'), (96, 445, 'l'), (84, 442, 'a'), (95, 445, 'k');
+set @save_join_cache_level=@@join_cache_level;
+set join_cache_level=1;
+SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx)
+WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+COUNT(t1.v)
+120
+EXPLAIN
+SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx)
+WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx 7 NULL 15 Using index
+1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 16 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 25 Using where; Using join buffer (flat, BNL join)
+SELECT COUNT(t1.v) FROM t1, t2, t3
+WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+COUNT(t1.v)
+120
+EXPLAIN
+SELECT COUNT(t1.v) FROM t1, t2, t3
+WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL idx 7 NULL 15 Using index
+1 SIMPLE t2 ALL PRIMARY,idx NULL NULL NULL 16 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ref PRIMARY,idx idx 3 test.t2.v 2 Using index condition; Using where
+set join_cache_level=@save_join_cache_level;
+DROP TABLE t1,t2,t3;
+#
+# BUG#671361: virtual int Mrr_ordered_index_reader::refill_buffer(): Assertion `!know_key_tuple_params
+# (works only on Maria because we need 1024-byte long key)
+#
+SET SESSION join_cache_level = 6;
+SET SESSION join_buffer_size = 1024;
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY col_varchar_1024_latin1_key (col_varchar_1024_latin1_key)
+) ENGINE=Aria;
+Warnings:
+Warning 1071 Specified key was too long; max key length is 1000 bytes
+INSERT INTO t1 VALUES
+(1,'z'), (2,'abcdefjhjkl'), (3,'in'), (4,'abcdefjhjkl'), (6,'abcdefjhjkl'),
+(11,'zx'), (12,'abcdefjhjm'), (13,'jn'), (14,'abcdefjhjp'), (16,'abcdefjhjr');
+CREATE TABLE t2 (
+col_varchar_10_latin1 varchar(10) DEFAULT NULL
+) ENGINE=Aria;
+INSERT INTO t2 VALUES ('foo'), ('foo');
+EXPLAIN SELECT count(*)
+FROM t1 AS table1, t2 AS table2
+WHERE
+table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE table2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE table1 ref PRIMARY,col_varchar_1024_latin1_key col_varchar_1024_latin1_key 1003 test.table2.col_varchar_10_latin1 2 Using where
+SELECT count(*)
+FROM t1 AS table1, t2 AS table2
+WHERE
+table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ;
+count(*)
+0
+drop table t1, t2;
+#
+# BUG#693747: Assertion multi_range_read.cc:908: int DsMrr_impl::dsmrr_init(
+#
+set @_save_join_cache_level= @@join_cache_level;
+set @_save_join_buffer_size= @@join_buffer_size;
+set join_cache_level=8;
+set join_buffer_size=10240;
+CREATE TABLE t1 (
+f2 varchar(32) COLLATE latin1_swedish_ci,
+f3 int(11),
+f4 varchar(1024) COLLATE utf8_bin,
+f5 varchar(1024) COLLATE latin1_bin,
+KEY (f5)
+) ENGINE=Aria TRANSACTIONAL=0 ;
+Warnings:
+Warning 1071 Specified key was too long; max key length is 1000 bytes
+# Fill the table with some data
+SELECT alias2.* , alias1.f2
+FROM
+t1 AS alias1
+LEFT JOIN t1 AS alias2 ON alias1.f2 = alias2.f5
+WHERE
+alias2.f3 < 0;
+f2 f3 f4 f5 f2
+set join_cache_level=@_save_join_cache_level;
+set join_buffer_size=@_save_join_buffer_size;
+set optimizer_switch=@maria_mrr_tmp;
+drop table t1;
diff --git a/mysql-test/suite/maria/mrr.test b/mysql-test/suite/maria/mrr.test
new file mode 100644
index 00000000000..6c6a8c4e7b6
--- /dev/null
+++ b/mysql-test/suite/maria/mrr.test
@@ -0,0 +1,213 @@
+-- source include/have_maria.inc
+#
+# MRR/Maria tests.
+#
+
+--disable_warnings
+drop table if exists t1,t2,t3,t4;
+--enable_warnings
+
+set @maria_mrr_tmp=@@optimizer_switch;
+set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
+
+set @mrr_buffer_size_save= @@mrr_buffer_size;
+
+set @save_storage_engine= @@storage_engine;
+set storage_engine=aria;
+
+--source include/mrr_tests.inc
+set storage_engine= @save_storage_engine;
+
+set @@mrr_buffer_size= @mrr_buffer_size_save;
+
+--echo #
+--echo # Crash in quick_range_seq_next() in maria-5.3-dsmrr-cpk with join_cache_level = {8,1}
+--echo #
+set @save_join_cache_level= @@join_cache_level;
+SET SESSION join_cache_level = 8;
+CREATE TABLE `t1` (
+ `col_int_key` int(11) DEFAULT NULL,
+ `col_datetime_key` datetime DEFAULT NULL,
+ `col_varchar_key` varchar(1) DEFAULT NULL,
+ `col_varchar_nokey` varchar(1) DEFAULT NULL,
+ KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
+INSERT INTO `t1` VALUES (6,'2005-10-07 00:00:00','e','e');
+INSERT INTO `t1` VALUES (51,'2000-07-15 05:00:34','f','f');
+CREATE TABLE `t2` (
+ `col_int_key` int(11) DEFAULT NULL,
+ `col_datetime_key` datetime DEFAULT NULL,
+ `col_varchar_key` varchar(1) DEFAULT NULL,
+ `col_varchar_nokey` varchar(1) DEFAULT NULL,
+ KEY `col_varchar_key` (`col_varchar_key`,`col_int_key`)
+) ENGINE=MARIA DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1;
+INSERT INTO `t2` VALUES (2,'2004-10-11 18:13:16','w','w');
+INSERT INTO `t2` VALUES (2,'1900-01-01 00:00:00','d','d');
+SELECT table2 .`col_datetime_key`
+FROM t2 JOIN ( t1 table2 JOIN t2 table3 ON table3 .`col_varchar_key` < table2 .`col_varchar_key` ) ON table3 .`col_varchar_nokey` ;
+
+drop table t1, t2;
+set join_cache_level=@save_join_cache_level;
+
+#
+# Bug #665049: index condition pushdown with Maria
+#
+
+CREATE TABLE t1(
+ pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+ PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t1 VALUES
+ (1,9,'x'), (2,5,'g'), (3,1,'o'), (4,0,'g'), (5,1,'v'),
+ (6,190,'m'), (7,6,'x'), (8,3,'c'), (9,4,'z'), (10,3,'i'),
+ (11,186,'x'), (12,1,'g'), (13,8,'q'), (14,226,'m'), (15,133,'p');
+
+CREATE TABLE t2(
+ pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+ PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 VALUES (77, 333, 'z');
+
+CREATE TABLE t3(
+ pk int NOT NULL, i int NOT NULL, v varchar(1) NOT NULL,
+ PRIMARY KEY (pk), INDEX idx (v, i)
+) ENGINE=ARIA;
+INSERT INTO t3 SELECT * FROM t1;
+INSERT INTO t3 VALUES
+ (88, 442, 'y'), (99, 445, 'w'), (87, 442, 'z'), (98, 445, 'v'), (86, 442, 'x'),
+ (97, 445, 't'), (85, 442, 'b'), (96, 445, 'l'), (84, 442, 'a'), (95, 445, 'k');
+
+set @save_join_cache_level=@@join_cache_level;
+set join_cache_level=1;
+
+SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx)
+ WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+EXPLAIN
+SELECT COUNT(t1.v) FROM t1, t2 IGNORE INDEX (idx), t3 IGNORE INDEX (idx)
+ WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+
+SELECT COUNT(t1.v) FROM t1, t2, t3
+ WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+EXPLAIN
+ SELECT COUNT(t1.v) FROM t1, t2, t3
+ WHERE t3.v = t2.v AND t3.i < t2.i AND t3.pk > 0 AND t2.pk > 0;
+
+set join_cache_level=@save_join_cache_level;
+
+DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # BUG#671361: virtual int Mrr_ordered_index_reader::refill_buffer(): Assertion `!know_key_tuple_params
+--echo # (works only on Maria because we need 1024-byte long key)
+--echo #
+
+SET SESSION join_cache_level = 6;
+SET SESSION join_buffer_size = 1024;
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ col_varchar_1024_latin1_key varchar(1024) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY col_varchar_1024_latin1_key (col_varchar_1024_latin1_key)
+) ENGINE=Aria;
+
+INSERT INTO t1 VALUES
+ (1,'z'), (2,'abcdefjhjkl'), (3,'in'), (4,'abcdefjhjkl'), (6,'abcdefjhjkl'),
+ (11,'zx'), (12,'abcdefjhjm'), (13,'jn'), (14,'abcdefjhjp'), (16,'abcdefjhjr');
+
+CREATE TABLE t2 (
+ col_varchar_10_latin1 varchar(10) DEFAULT NULL
+) ENGINE=Aria;
+INSERT INTO t2 VALUES ('foo'), ('foo');
+
+EXPLAIN SELECT count(*)
+FROM t1 AS table1, t2 AS table2
+WHERE
+ table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ;
+
+SELECT count(*)
+FROM t1 AS table1, t2 AS table2
+WHERE
+ table1.col_varchar_1024_latin1_key = table2.col_varchar_10_latin1 AND table1.pk<>0 ;
+
+drop table t1, t2;
+
+--echo #
+--echo # BUG#693747: Assertion multi_range_read.cc:908: int DsMrr_impl::dsmrr_init(
+--echo #
+set @_save_join_cache_level= @@join_cache_level;
+set @_save_join_buffer_size= @@join_buffer_size;
+
+set join_cache_level=8;
+set join_buffer_size=10240;
+
+CREATE TABLE t1 (
+ f2 varchar(32) COLLATE latin1_swedish_ci,
+ f3 int(11),
+ f4 varchar(1024) COLLATE utf8_bin,
+ f5 varchar(1024) COLLATE latin1_bin,
+ KEY (f5)
+) ENGINE=Aria TRANSACTIONAL=0 ;
+
+--echo # Fill the table with some data
+--disable_query_log
+INSERT IGNORE INTO t1 VALUES
+('cueikuirqr','0','f4-data','hcueikuirqrzflno'),('her','0','f4-data','ehcueikuirqrzfln'),
+('YKAOE','0','f4-data','qieehcueikuirqrz'),('youre','0','f4-data','nkqieehcueikuirq'),
+('b','0','f4-data','the'),('MGUDG','0','f4-data','m'),
+('UXAGU','0','f4-data','HZXVA'),('bwbgsnkqie','0','f4-data','something'),
+('s','0','f4-data','slelfhjawbwbgsnk'),('the','0','f4-data','if'),
+('TDLKE','0','f4-data','MGWNJ'),('do','0','f4-data','see'),
+('why','0','f4-data','mean'),('THKCG','0','f4-data','YFLDY'),
+('x','0','f4-data','e'),('yncitaeysb','0','f4-data','tgyncitaeysbgucs'),
+('ZEOXX','0','f4-data','jawbwbgsnkqieehc'),('hjawbwbgsn','0','f4-data','fhjawbwbgsnkqiee'),
+('all','0','f4-data','sbgucsgqslelfhja'),('the','0','f4-data','would'),
+('mtgyncitae','0','f4-data','ISNQQ'),('KNCUI','0','f4-data','want'),
+('is','0','f4-data','i'),('out','0','f4-data','jvcmjlmtgyncitae'),
+('it','0','f4-data','you'),('LHDIH','0','f4-data','txmtxyjvcmjlmtgy'),
+('z','0','f4-data','ntxmtxyjvcmjlmtg'),('vyhnmvgmcn','0','f4-data','AIGQK'),
+('ytvyhnmvgm','0','f4-data','z'),('t','0','f4-data','on'),
+('xqegbytvyh','0','f4-data','ixqegbytvyhnmvgm'),('WGVRU','0','f4-data','h'),
+('b','0','f4-data','z'),('who','0','f4-data','gddixqegbytvy'),
+('PMLFL','0','f4-data','vgmcntxmtxyjvcmj'),('back','0','f4-data','n'),
+('i','0','f4-data','PZGUB'),('f','0','f4-data','the'),
+('PNXVP','0','f4-data','v'),('MAKKL','0','f4-data','CGCWF'),
+('RMDAV','0','f4-data','v'),('l','0','f4-data','n'),
+('rhnoypgddi','0','f4-data','VIZNE'),('t','0','f4-data','a'),
+('like','0','f4-data','JSHPZ'),('pskeywslmk','0','f4-data','q'),
+('QZZJJ','0','f4-data','c'),('atlxepskey','0','f4-data','YJRMA'),
+('YUVOU','0','f4-data','eywslmkdrhnoypgd'),('some','0','f4-data','r'),
+('c','0','f4-data','her'),('o','0','f4-data','EMURT'),
+('if','0','f4-data','had'),('when','0','f4-data','CLVWT'),
+('blfufrcdjm','0','f4-data','IZCZN'),('vutblfufrc','0','f4-data','how'),
+('why','0','f4-data','I'),('IXLYQ','0','f4-data','weuwuvutblfufrcd'),
+('here','0','f4-data','m'),('ZOCTJ','0','f4-data','IDSFD'),
+('kqsweuwuvu','0','f4-data','oh'),('ykqsweuwuv','0','f4-data','zykqsweuwuvutblf'),
+('zezykqsweu','0','f4-data','t'),('q','0','f4-data','o'),
+('IBKAU','0','f4-data','oh'),('ivjisuzezy','0','f4-data','XHXKE'),
+('xsivjisuze','0','f4-data','plxsivjisuzezykq'),('have','0','f4-data','uvplxsivjisuzezy'),
+('on','0','f4-data','me'),('ijkfuvplxs','0','f4-data','OGEHV'),
+('u','0','f4-data','okay'),('i','0','f4-data','pajzbbojshnijkfu'),
+('of','0','f4-data','g'),('for','0','f4-data','Im'),
+('or','0','f4-data','ZOJHX'),('n','0','f4-data','you'),
+('that','0','f4-data','just'),('bbojshnijk','0','f4-data','JYGSJ'),
+('k','0','f4-data','y'),('k','0','f4-data','y'),
+('be','0','f4-data','m'),('fnbmxwicrk','0','f4-data','t'),
+('yaffpegvav','0','f4-data','have'),('crkdymahya','0','f4-data','QQWQI'),
+('t','0','f4-data','hnijkfuvplxsivji'),('dgxpajzbbo','0','f4-data','vavdgxpajzbbojsh'),
+('g','0','f4-data','pegvavdgxpajzbbo'),('Im','0','f4-data','ffpegvavdgxpajzb');
+--enable_query_log
+
+
+SELECT alias2.* , alias1.f2
+FROM
+ t1 AS alias1
+ LEFT JOIN t1 AS alias2 ON alias1.f2 = alias2.f5
+WHERE
+ alias2.f3 < 0;
+
+set join_cache_level=@_save_join_cache_level;
+set join_buffer_size=@_save_join_buffer_size;
+set optimizer_switch=@maria_mrr_tmp;
+
+drop table t1;
diff --git a/mysql-test/suite/maria/r/optimize.result b/mysql-test/suite/maria/optimize.result
index 9cce55d6199..9cce55d6199 100644
--- a/mysql-test/suite/maria/r/optimize.result
+++ b/mysql-test/suite/maria/optimize.result
diff --git a/mysql-test/suite/maria/t/optimize.test b/mysql-test/suite/maria/optimize.test
index 6b310b1d1a6..6b310b1d1a6 100644
--- a/mysql-test/suite/maria/t/optimize.test
+++ b/mysql-test/suite/maria/optimize.test
diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/ps_maria.result
index 6c1b40302ec..6c1b40302ec 100644
--- a/mysql-test/suite/maria/r/ps_maria.result
+++ b/mysql-test/suite/maria/ps_maria.result
diff --git a/mysql-test/suite/maria/t/ps_maria.test b/mysql-test/suite/maria/ps_maria.test
index d3623314631..d3623314631 100644
--- a/mysql-test/suite/maria/t/ps_maria.test
+++ b/mysql-test/suite/maria/ps_maria.test
diff --git a/mysql-test/suite/maria/t/small_blocksize-master.opt b/mysql-test/suite/maria/small_blocksize-master.opt
index 59fd35a7846..59fd35a7846 100644
--- a/mysql-test/suite/maria/t/small_blocksize-master.opt
+++ b/mysql-test/suite/maria/small_blocksize-master.opt
diff --git a/mysql-test/suite/maria/r/small_blocksize.result b/mysql-test/suite/maria/small_blocksize.result
index f418a1f92ef..f418a1f92ef 100644
--- a/mysql-test/suite/maria/r/small_blocksize.result
+++ b/mysql-test/suite/maria/small_blocksize.result
diff --git a/mysql-test/suite/maria/t/small_blocksize.test b/mysql-test/suite/maria/small_blocksize.test
index 0acf8df6e66..0acf8df6e66 100644
--- a/mysql-test/suite/maria/t/small_blocksize.test
+++ b/mysql-test/suite/maria/small_blocksize.test