summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect_sj2.test
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2012-03-26 21:34:24 +0400
committerSergey Petrunya <psergey@askmonty.org>2012-03-26 21:34:24 +0400
commitf2947f97a64e6af7e849caef415161b91803e241 (patch)
tree47e35dda0fccde4ab28bab79ff3306bb4f7d2ce9 /mysql-test/t/subselect_sj2.test
parent6fcd19454a090714680743e989f92ac3826da03c (diff)
downloadmariadb-git-f2947f97a64e6af7e849caef415161b91803e241.tar.gz
BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
- The problem was with execution strategy for cases where FirstMatch's inner tables were interleaved with outer-uncorrelated tables. - I was unable to find any cases where such join orders would be practically useful, so fixed it by disabling them.
Diffstat (limited to 'mysql-test/t/subselect_sj2.test')
-rw-r--r--mysql-test/t/subselect_sj2.test44
1 files changed, 44 insertions, 0 deletions
diff --git a/mysql-test/t/subselect_sj2.test b/mysql-test/t/subselect_sj2.test
index 3dd75cc1819..a5ccd58c4a1 100644
--- a/mysql-test/t/subselect_sj2.test
+++ b/mysql-test/t/subselect_sj2.test
@@ -1172,5 +1172,49 @@ SELECT * FROM t2
DROP VIEW v1;
DROP TABLE t1, t2;
+
+--echo #
+--echo # BUG#951283: Wrong result (missing rows) with semijoin+firstmatch, IN/ANY subquery
+--echo #
+set @tmp_951283=@@optimizer_prune_level;
+SET optimizer_prune_level=0;
+
+CREATE TABLE t1 ( a INT ) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+ (10),(11),(12),(13),(14),(15),(16),
+ (17),(18),(19),(20),(21),(22),(23);
+
+CREATE TABLE t2 (
+ b INT PRIMARY KEY,
+ c VARCHAR(1),
+ d VARCHAR(1),
+ KEY(c)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES
+ (1,'j','j'),(2,'v','v'),(3,'c','c'),(4,'m','m'),
+ (5,'d','d'),(6,'d','d'),(7,'y','y'),(8,'t','t'),
+ (9,'d','d'),(10,'s','s'),(11,'r','r'),(12,'m','m'),
+ (13,'b','b'),(14,'x','x'),(15,'g','g'),(16,'p','p'),
+ (17,'q','q'),(18,'w','w'),(19,'d','d');
+
+EXPLAIN
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+ SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+ WHERE alias5.b = alias4.b
+ AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+
+SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3
+WHERE alias3.d IN (
+ SELECT alias4.c FROM t2 AS alias4, t2 AS alias5
+ WHERE alias5.b = alias4.b
+ AND ( alias5.b >= alias3.b OR alias5.c != alias3.c )
+);
+
+set optimizer_prune_level=@tmp_951283;
+DROP TABLE t1,t2;
+
--echo # This must be the last in the file:
set optimizer_switch=@subselect_sj2_tmp;