diff options
author | unknown <timour@askmonty.org> | 2011-05-13 18:37:28 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-05-13 18:37:28 +0300 |
commit | b757f734925c80343c262e6ddf8379cc665e7103 (patch) | |
tree | 70e6f4324475ea8cbaba4aa360fdce6371ec372c /mysql-test/t/subselect4.test | |
parent | 8840823369ac7691d5d5e9792458981a4cfd6e45 (diff) | |
download | mariadb-git-b757f734925c80343c262e6ddf8379cc665e7103.tar.gz |
Fix LP BUG#777597
Analysis:
During optimization of the subquery, in the call chain:
update_ref_and_keys -> add_key_fields ->
merge_key_fields -> Item_direct_ref::is_null -> Item_cache::is_null
The call to Item_cache::is_null() returns TRUE, which is wrong.
This results in Item_null replacing the field 'f3' in the KEY_FIELD,
then this Item_null is used for index access, producing a wrong result.
The reason why Item_cache::is_null returns wrong result is that
this Item_cache object is a cache of the left operand of IN, and was
updated in Item_in_optimizer::val_int. In MWL#89 the latter method is
called during the execution phase, which is after we optimize the subquery.
Therefore during the optization phase the left operand cache of IN was
not updated.
Solution:
Update the left operand cache during optimization if it is a constant.
This bug fix also discoveres and fixes a wrong IF statement in
convert_constant_item().
Diffstat (limited to 'mysql-test/t/subselect4.test')
-rw-r--r-- | mysql-test/t/subselect4.test | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index c57cdf27444..a6baa02bc93 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -1412,3 +1412,25 @@ SELECT STRAIGHT_JOIN ( ); drop table t1, t2, t3; + + +--echo # +--echo # LP BUG#777597 Wrong result with multipart keys, in_to_exists=on, NOT IN in MWL#89 +--echo # + +CREATE TABLE t1 ( f4 int); +INSERT IGNORE INTO t1 VALUES (2),(2); + +CREATE TABLE t2 ( f3 int, f10 int, KEY (f10,f3) ); +INSERT IGNORE INTO t2 VALUES (6, 1), (6, 1); + +CREATE TABLE t3 ( f10 int ); +INSERT IGNORE INTO t3 VALUES (1); + +SET SESSION optimizer_switch='in_to_exists=on,materialization=off'; + +EXPLAIN +SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10); +SELECT * FROM t1 WHERE ( 6 ) NOT IN ( SELECT t2.f3 FROM t2 JOIN t3 ON t3.f10 = t2.f10); + +drop table t1,t2,t3; |