diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2018-11-01 11:35:28 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2018-11-05 21:10:15 +0300 |
commit | e058a251c10350f3727ca1df022dc5786933535b (patch) | |
tree | 6b8a46552a2c70e602e6f39c67d1936fb917edab /mysql-test/main | |
parent | f0cf85fd15509179bf6e33176cb89761fc89e5a9 (diff) | |
download | mariadb-git-e058a251c10350f3727ca1df022dc5786933535b.tar.gz |
MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
Part#2: take into account that join nest that we are marking as constant
might already have constant tables in it. Don't count these tables twice.
Diffstat (limited to 'mysql-test/main')
-rw-r--r-- | mysql-test/main/join_outer.result | 15 | ||||
-rw-r--r-- | mysql-test/main/join_outer.test | 17 | ||||
-rw-r--r-- | mysql-test/main/join_outer_jcl6.result | 15 |
3 files changed, 47 insertions, 0 deletions
diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index aa9f30885a9..6b671a0759f 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -2564,4 +2564,19 @@ drop table t1,t2,t3; set optimizer_use_condition_selectivity= @tmp1; set use_stat_tables= @tmp2; set histogram_size= @tmp3; +# Another test +CREATE TABLE t1 (i1 int) ; +CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ; +CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ; +INSERT INTO t3 VALUES (2, NULL); +CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ; +CREATE VIEW v4 AS SELECT * FROM t4; +SELECT 1 +FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1 +LEFT JOIN v4 +RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk +WHERE t3.pk IN (2); +1 +drop view v4; +drop table t1,t2,t3,t4; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test index 9118febc800..82127397bee 100644 --- a/mysql-test/main/join_outer.test +++ b/mysql-test/main/join_outer.test @@ -2084,5 +2084,22 @@ set optimizer_use_condition_selectivity= @tmp1; set use_stat_tables= @tmp2; set histogram_size= @tmp3; +--echo # Another test +CREATE TABLE t1 (i1 int) ; +CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ; +CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ; +INSERT INTO t3 VALUES (2, NULL); + +CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ; +CREATE VIEW v4 AS SELECT * FROM t4; + +SELECT 1 +FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1 + LEFT JOIN v4 + RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk +WHERE t3.pk IN (2); + +drop view v4; +drop table t1,t2,t3,t4; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 6f5e4b3e85e..f46f3e2df21 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -2575,6 +2575,21 @@ drop table t1,t2,t3; set optimizer_use_condition_selectivity= @tmp1; set use_stat_tables= @tmp2; set histogram_size= @tmp3; +# Another test +CREATE TABLE t1 (i1 int) ; +CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ; +CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ; +INSERT INTO t3 VALUES (2, NULL); +CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ; +CREATE VIEW v4 AS SELECT * FROM t4; +SELECT 1 +FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1 +LEFT JOIN v4 +RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk +WHERE t3.pk IN (2); +1 +drop view v4; +drop table t1,t2,t3,t4; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; |