summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect_innodb.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/subselect_innodb.test')
-rw-r--r--mysql-test/t/subselect_innodb.test41
1 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test
index fc07a088a15..bd4f3a3c2d8 100644
--- a/mysql-test/t/subselect_innodb.test
+++ b/mysql-test/t/subselect_innodb.test
@@ -439,4 +439,45 @@ select distinct (1 + (select 1 from `t2` where `a`)) `d2` from `t1`;
drop table t1,t2;
+--echo #
+--echo # MDEV-4042: Assertion `table->key_read == 0' fails in close_thread_table on EXPLAIN with GROUP BY and HAVING in EXISTS SQ,
+--echo # MDEV-4536: ...sql/sql_base.cc:1598: bool close_thread_table(THD*, TABLE**): Assertion `table->key_read == 0' failed.
+CREATE TABLE t1 (a INT) ENGINE=InnoDB;
+CREATE TABLE t2 (b INT PRIMARY KEY, c INT) ENGINE=InnoDB;
+CREATE TABLE t3 (d INT) ENGINE=InnoDB;
+
+EXPLAIN
+SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 );
+SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 );
+
+DROP TABLE t1,t2,t3;
+
+CREATE TABLE t1 (
+ pk int auto_increment primary key,
+ col_int_key int(11),
+ key col_int_key (col_int_key),col_varchar_key varchar(128),
+ key (col_varchar_key)
+) engine=innodb;
+
+EXPLAIN
+SELECT 1 FROM t1 AS alias1
+WHERE EXISTS ( SELECT SQ2_alias1 . col_int_key AS SQ2_field1
+ FROM ( t1 AS SQ2_alias1 RIGHT OUTER JOIN
+ t1 AS SQ2_alias2 ON (SQ2_alias2 . col_int_key = SQ2_alias1 . col_int_key )
+ )
+ GROUP BY SQ2_field1
+ HAVING SQ2_alias1 . col_int_key >= 7
+ );
+
+SELECT 1 FROM t1 AS alias1
+WHERE EXISTS ( SELECT SQ2_alias1 . col_int_key AS SQ2_field1
+ FROM ( t1 AS SQ2_alias1 RIGHT OUTER JOIN
+ t1 AS SQ2_alias2 ON (SQ2_alias2 . col_int_key = SQ2_alias1 . col_int_key )
+ )
+ GROUP BY SQ2_field1
+ HAVING SQ2_alias1 . col_int_key >= 7
+ );
+drop table t1;
+
+
set optimizer_switch=@subselect_innodb_tmp;