mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Fix bug lp:856152
Analysis: The cause of the bug was that the method subselect_rowid_merge_engine::partial_match() was not designed for re-execution within the same query. Specifically, it didn't cleanup the bitmap of matching keys after completion. The test query requires double execution of the IN predicate because it first checks the predicate as a constant condition. The second execution during regular execution used the bitmap of matching keys produced by the first execution instead of starting with a clean one. Solution: Cleanup the bitmap of matching keys at the end of the partial matching procedure.
This commit is contained in:
parent
1c47e1ca0d
commit
f40f0ff679
3 changed files with 46 additions and 0 deletions
|
@ -348,4 +348,28 @@ c
|
|||
0
|
||||
0
|
||||
drop table t1, t2;
|
||||
#
|
||||
# LP BUG#856152 Wrong result with NOT IN subquery and partial_match_rowid_merge
|
||||
#
|
||||
CREATE TABLE t1 ( f1 integer NOT NULL , f2 integer) ;
|
||||
INSERT INTO t1 VALUES (3,3),(48,NULL),(49,1);
|
||||
CREATE TABLE t2 ( f3 int) ;
|
||||
INSERT INTO t2 VALUES (5);
|
||||
set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
|
||||
EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
f3
|
||||
5
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off';
|
||||
EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t2 system NULL NULL NULL NULL 1
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
|
||||
SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
f3
|
||||
5
|
||||
drop table t1, t2;
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -354,4 +354,24 @@ SELECT * FROM t1 WHERE (6, 4 ) NOT IN (SELECT a, b FROM t2);
|
|||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # LP BUG#856152 Wrong result with NOT IN subquery and partial_match_rowid_merge
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 ( f1 integer NOT NULL , f2 integer) ;
|
||||
INSERT INTO t1 VALUES (3,3),(48,NULL),(49,1);
|
||||
|
||||
CREATE TABLE t2 ( f3 int) ;
|
||||
INSERT INTO t2 VALUES (5);
|
||||
|
||||
set @@optimizer_switch='in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off';
|
||||
EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
|
||||
set @@optimizer_switch='in_to_exists=on,materialization=off';
|
||||
EXPLAIN SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
SELECT * FROM t2 WHERE ( 3 , 1 ) NOT IN ( SELECT f1 , f2 FROM t1 );
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
set @@optimizer_switch=@save_optimizer_switch;
|
||||
|
|
|
@ -5674,6 +5674,8 @@ bool subselect_rowid_merge_engine::partial_match()
|
|||
DBUG_ASSERT(FALSE);
|
||||
|
||||
end:
|
||||
if (!has_covering_null_columns)
|
||||
bitmap_clear_all(&matching_keys);
|
||||
queue_remove_all(&pq);
|
||||
tmp_table->file->ha_rnd_end();
|
||||
return res;
|
||||
|
|
Loading…
Reference in a new issue