diff options
author | unknown <timour@askmonty.org> | 2011-08-23 00:00:13 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-08-23 00:00:13 +0300 |
commit | 9e60b55fd0ff37527ca83e590d1c5386dfa788d6 (patch) | |
tree | b94b534841c0b945301cc410863331323f092645 /mysql-test/t/subselect_mat.test | |
parent | aab970f5e16a1dbb308cfc13d47d3b863143811f (diff) | |
download | mariadb-git-9e60b55fd0ff37527ca83e590d1c5386dfa788d6.tar.gz |
Fix bug lp:825095
Analysis:
Partial matching is used even when there are no NULLs in
a materialized subquery, as long as the left NOT IN operand
may contain NULL values.
This case was not handled correctly in two different places.
First, the implementation of parital matching did not clear
the set of matching columns when the merge process advanced
to the next row.
Second, there is no need to perform partial matching at all
when the left operand has no NULLs.
Solution:
First fix subselect_rowid_merge_engine::partial_match() to
properly cleanup the bitmap of matching keys when advancing
to the next row.
Second, change subselect_partial_match_engine::exec() so
that when the materialized subquery doesn't contain any
NULLs, and the left operand of [NOT] IN doesn't contain
NULLs either, the method returns without doing any
unnecessary partial matching. The correct result in this
case is in Item::in_value.
Diffstat (limited to 'mysql-test/t/subselect_mat.test')
-rw-r--r-- | mysql-test/t/subselect_mat.test | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/subselect_mat.test b/mysql-test/t/subselect_mat.test index a70fb4783c5..09c6b3e1747 100644 --- a/mysql-test/t/subselect_mat.test +++ b/mysql-test/t/subselect_mat.test @@ -226,3 +226,31 @@ SELECT MAX(t1.b) AS max_res FROM t1 WHERE (9) IN (SELECT a FROM t2); DROP TABLE t1,t2; +--echo # +--echo # LPBUG#825095: Wrong result with materialization and NOT IN with 2 expressions +--echo # + +CREATE TABLE t1 (a int,b int); +INSERT INTO t1 VALUES (4,4),(4,2); + +CREATE TABLE t2 (b int, a int); +INSERT INTO t2 VALUES (4,3),(8,4); + +set @@optimizer_switch='semijoin=off,in_to_exists=off,materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off'; + +EXPLAIN SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); + +SELECT * +FROM t1 +WHERE (a, b) NOT IN (SELECT a, b FROM t2); + +EXPLAIN +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; + +SELECT a, b, (a, b) NOT IN (SELECT a, b FROM t2) as sq +FROM t1; + +drop table t1, t2; |