1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...

- Disable use of join cache when we're using FirstMatch strategy, and the join
  order is such that subquery's inner tables are interleaved with outer.  Join 
  buffering code is incapable of handling such join orders.

- The testcase requires use of @@debug_optimizer_prefer_join_prefix to hit the bug, 
  but I'm pushing it anyway (including the mention of the variable in .test file), 
  so that it can be found and enabled when/if we get something comparable in the 
  main tree.
This commit is contained in:
Sergey Petrunya
2012-01-25 22:05:20 +04:00
parent 364c07934c
commit 424f56b3ba
6 changed files with 99 additions and 5 deletions

View File

@ -2509,4 +2509,31 @@ a b d
8 4 2
5 5 5
DROP TABLE t1, t2;
#
# BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
#
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
INSERT INTO t2 VALUES (0,'j'),(8,'v');
SELECT * FROM t1 alias1, t2 alias2
WHERE alias2.c IN (
SELECT alias4.c FROM t1 alias3, t2 alias4
);
a b c
e 0 j
e 8 v
w 0 j
w 8 v
a 0 j
a 8 v
h 0 j
h 8 v
x 0 j
x 8 v
k 0 j
k 8 v
g 0 j
g 8 v
DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp;

View File

@ -2523,6 +2523,33 @@ a b d
10 2 1
10 2 1
DROP TABLE t1, t2;
#
# BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
#
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
INSERT INTO t2 VALUES (0,'j'),(8,'v');
SELECT * FROM t1 alias1, t2 alias2
WHERE alias2.c IN (
SELECT alias4.c FROM t1 alias3, t2 alias4
);
a b c
e 0 j
e 8 v
w 0 j
w 8 v
a 0 j
a 8 v
h 0 j
h 8 v
x 0 j
x 8 v
k 0 j
k 8 v
g 0 j
g 8 v
DROP TABLE t1, t2;
set optimizer_switch=@subselect_sj_tmp;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off

View File

@ -2252,6 +2252,23 @@ WHERE ( b, d ) IN
DROP TABLE t1, t2;
--echo #
--echo # BUG#920713: Wrong result (missing rows) with firstmatch+BNL, IN subquery, ...
--echo #
# t1 should be MyISAM or InnoDB
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('e'),('w'),('a'),('h'),('x'),('k'),('g');
CREATE TABLE t2 ( b INT, c VARCHAR(1) );
INSERT INTO t2 VALUES (0,'j'),(8,'v');
#SET debug_optimizer_prefer_join_prefix= 'alias2,alias4,alias1,alias3';
SELECT * FROM t1 alias1, t2 alias2
WHERE alias2.c IN (
SELECT alias4.c FROM t1 alias3, t2 alias4
);
DROP TABLE t1, t2;
# The following command must be the last one the file
set optimizer_switch=@subselect_sj_tmp;