summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect_sj2.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2011-10-25 14:18:19 -0700
committerIgor Babaev <igor@askmonty.org>2011-10-25 14:18:19 -0700
commita8f7c03c1e46dd556aa57d45bbd078101c68ec9e (patch)
treeee053f0bcb2ace114196d49125dfc87517c1497a /mysql-test/t/subselect_sj2.test
parentc0a1bd1ed63bb9e0064e99e654b3b57dd3f0c5f4 (diff)
downloadmariadb-git-a8f7c03c1e46dd556aa57d45bbd078101c68ec9e.tar.gz
Fixed LP bug #881318.
If a materialized derived table / view is empty then for this table the value of file->ref is 0. This was not taken into account by the function JOIN_CACHE::write_record_data. As a result a query using an empty materialized derived tables as inner tables of outer joins and IN subqueries in WHERE conditions could cause server crashes when the optimizer employed join caches and duplicate elimination for semi-joins.
Diffstat (limited to 'mysql-test/t/subselect_sj2.test')
-rw-r--r--mysql-test/t/subselect_sj2.test26
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test
index 62fb4e27682..b2721574deb 100644
--- a/mysql-test/t/subselect_sj2.test
+++ b/mysql-test/t/subselect_sj2.test
@@ -1039,6 +1039,32 @@ DROP TABLE t1, t2, t3, t4;
set join_cache_level= @tmp869001_jcl;
set optimizer_switch= @tmp869001_os;
+--echo #
+--echo # Bug #881318: join cache + duplicate elimination + left join
+--echo # with empty materialized derived inner table
+--echo #
+
+CREATE TABLE t1 (b varchar(1)) ENGINE=InnoDB;
+
+CREATE TABLE t2 (a varchar(1)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES ('a');
+
+CREATE TABLE t3 (a varchar(1), b varchar(1)) ENGINE=InnoDB;
+INSERT INTO t3 VALUES ('c','c');
+
+CREATE TABLE t4 (b varchar(1)) ENGINE=InnoDB;
+INSERT INTO t4 VALUES ('c'), ('b');
+
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+EXPLAIN
+SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a
+ WHERE t3.b IN (SELECT b FROM t4);
+SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a
+ WHERE t3.b IN (SELECT b FROM t4);
+
+DROP VIEW v1;
+DROP TABLE t1,t2,t3,t4;
--echo # This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;