diff options
author | unknown <sanja@askmonty.org> | 2012-12-28 14:41:46 +0200 |
---|---|---|
committer | unknown <sanja@askmonty.org> | 2012-12-28 14:41:46 +0200 |
commit | 6f26aac9409e3456798e58a4ee4306e43c7ebf7b (patch) | |
tree | df8ad17736247d1493460205865fb75757a00ae1 /mysql-test/t | |
parent | e99aa91e90adfd54cc1f460dd8cdd19614f30abc (diff) | |
download | mariadb-git-6f26aac9409e3456798e58a4ee4306e43c7ebf7b.tar.gz |
MDEV-3873 & MDEV-3876 & MDEV-3912 : Wrong result (extra rows) with ALL subquery
from a MERGE view.
The problem was in the lost ability to be null for the table of a left join if it
is a view/derived table.
It hapenned because setup_table_map(), was called earlier then we merged
the view or derived.
Fixed by propagating new maybe_null flag during Item::update_used_tables().
Change in join_outer.test and join_outer_jcl6.test appeared because
IS NULL reported no used tables (i.e. constant) for argument which could not be
NULL and new maybe_null flag was propagated for IS NULL argument (Item_field)
because table the Item_field belonged to changed its maybe_null status.
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/derived_view.test | 61 | ||||
-rw-r--r-- | mysql-test/t/view.test | 21 |
2 files changed, 82 insertions, 0 deletions
diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 30811be2934..c7705294ef2 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -1451,6 +1451,67 @@ select * from t1; drop table t1,t2; --echo # +--echo # MDEV-3873: Wrong result (extra rows) with NOT IN and +--echo # a subquery from a MERGE view +--echo # + +CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(7),(0); + +CREATE TABLE t2 (b INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(2); + +CREATE TABLE t3 (c INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t3 VALUES (4),(6),(3); + +CREATE TABLE t4 (d INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t4 VALUES (4),(5),(3); + +CREATE TABLE tv (e INT NOT NULL) ENGINE=MyISAM; +INSERT INTO tv VALUES (1),(3); + +CREATE ALGORITHM=TEMPTABLE VIEW v_temptable AS SELECT * FROM tv; +CREATE ALGORITHM=MERGE VIEW v_merge AS SELECT * FROM tv; + +SELECT * FROM t1, t2 +WHERE a NOT IN ( SELECT e FROM t3 LEFT JOIN v_temptable ON (c = e) WHERE c <> b ) AND a < b; + +SELECT * FROM t1, t2 +WHERE a NOT IN ( SELECT e FROM t3 LEFT JOIN v_merge ON (c = e) WHERE c <> b ) AND a < b; + +SELECT * FROM t1, t2 +WHERE a NOT IN ( SELECT e FROM t3 LEFT JOIN (SELECT * FROM tv) as derived ON (c = e) WHERE c <> b ) AND a < b; + +drop view v_temptable, v_merge; +drop table t1,t2,t3,t4,tv; + +--echo # +--echo # MDEV-3912: Wrong result (extra rows) with FROM subquery inside +--echo # ALL subquery, LEFT JOIN, derived_merge. +--echo # (duplicate of MDEV-3873 (above)) +--echo # + +SET @save3912_optimizer_switch=@@optimizer_switch; +SET optimizer_switch = 'derived_merge=on,in_to_exists=on'; + +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (4),(8); + +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (7),(0); + +CREATE TABLE t3 (c INT, d INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t3 VALUES (0,4),(8,6); + +SELECT * FROM t1 +WHERE a >= ALL ( +SELECT d FROM t2 LEFT JOIN ( SELECT * FROM t3 ) AS alias ON ( c = b ) +WHERE b >= a +); +set optimizer_switch=@save3912_optimizer_switch; +drop table t1, t2, t3; + +--echo # --echo # end of 5.3 tests --echo # diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5f3bf031f8c..2a230e65493 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4575,6 +4575,27 @@ SELECT * FROM ( drop tables t1,t2; +--echo # +--echo # MDEV-3876 Wrong result (extra rows) with ALL subquery +--echo # from a MERGE view (duplicate of MDEV-3873) +--echo # + +CREATE TABLE t1 (a INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (b INT NOT NULL) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(3); + +CREATE OR REPLACE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t2; + +SELECT a FROM t1 AS alias +WHERE a >= ALL ( +SELECT b FROM t1 LEFT JOIN v1 ON (a = b) +WHERE a = alias.a ); + +drop view v1; +drop table t1,t2; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.3 tests. --echo # ----------------------------------------------------------------- |