diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-03-29 19:27:06 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-03-29 19:27:06 +0400 |
commit | 3345e7564d033313ac54ca34d1505d6a2e78cdad (patch) | |
tree | e1fabb2571e0459524c503ca55214966be0192a3 | |
parent | d4de82d93e58a74172960853b07c717377f57e6b (diff) | |
download | mariadb-git-3345e7564d033313ac54ca34d1505d6a2e78cdad.tar.gz |
MDEV-4335: Unexpected results when selecting on information_schema
- When converting a subquery to a semi-join, propagate OPTION_SCHEMA_TABLE.
-rw-r--r-- | mysql-test/r/subselect_sj.result | 10 | ||||
-rw-r--r-- | mysql-test/r/subselect_sj_jcl6.result | 10 | ||||
-rw-r--r-- | mysql-test/t/subselect_sj.test | 7 | ||||
-rw-r--r-- | sql/opt_subselect.cc | 6 |
4 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 2f9f3da3cfd..d32cba1952b 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2772,4 +2772,14 @@ execute stmt; a b deallocate prepare stmt; drop table t1,t2; +# +# MDEV-4335: Unexpected results when selecting on information_schema +# +CREATE TABLE t1 (db VARCHAR(64) DEFAULT NULL); +INSERT INTO t1 VALUES ('mysql'),('information_schema'); +SELECT * FROM t1 WHERE db IN (SELECT `SCHEMA_NAME` FROM information_schema.SCHEMATA); +db +mysql +information_schema +DROP TABLE t1; set optimizer_switch=@subselect_sj_tmp; diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index de95dd80529..55068ce257a 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2786,6 +2786,16 @@ execute stmt; a b deallocate prepare stmt; drop table t1,t2; +# +# MDEV-4335: Unexpected results when selecting on information_schema +# +CREATE TABLE t1 (db VARCHAR(64) DEFAULT NULL); +INSERT INTO t1 VALUES ('mysql'),('information_schema'); +SELECT * FROM t1 WHERE db IN (SELECT `SCHEMA_NAME` FROM information_schema.SCHEMATA); +db +information_schema +mysql +DROP TABLE t1; set optimizer_switch=@subselect_sj_tmp; # # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off diff --git a/mysql-test/t/subselect_sj.test b/mysql-test/t/subselect_sj.test index 650c9d73893..c05896fadda 100644 --- a/mysql-test/t/subselect_sj.test +++ b/mysql-test/t/subselect_sj.test @@ -2481,6 +2481,13 @@ execute stmt; deallocate prepare stmt; drop table t1,t2; +--echo # +--echo # MDEV-4335: Unexpected results when selecting on information_schema +--echo # +CREATE TABLE t1 (db VARCHAR(64) DEFAULT NULL); +INSERT INTO t1 VALUES ('mysql'),('information_schema'); +SELECT * FROM t1 WHERE db IN (SELECT `SCHEMA_NAME` FROM information_schema.SCHEMATA); +DROP TABLE t1; # The following command must be the last one the file set optimizer_switch=@subselect_sj_tmp; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 568297ba277..149d395a25d 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -1493,6 +1493,9 @@ static bool convert_subq_to_sj(JOIN *parent_join, Item_in_subselect *subq_pred) */ parent_lex->leaf_tables.concat(&subq_lex->leaf_tables); + if (subq_lex->options & OPTION_SCHEMA_TABLE) + parent_lex->options |= OPTION_SCHEMA_TABLE; + /* Same as above for next_local chain (a theory: a next_local chain always starts with ::leaf_tables @@ -1709,6 +1712,9 @@ static bool convert_subq_to_jtbm(JOIN *parent_join, */ parent_lex->leaf_tables.push_back(jtbm); + if (subq_pred->unit->first_select()->options & OPTION_SCHEMA_TABLE) + parent_lex->options |= OPTION_SCHEMA_TABLE; + /* Same as above for TABLE_LIST::next_local chain (a theory: a next_local chain always starts with ::leaf_tables |