Commit 3345e756 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4335: Unexpected results when selecting on information_schema

- When converting a subquery to a semi-join, propagate OPTION_SCHEMA_TABLE.
parent d4de82d9
......@@ -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;
......@@ -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
......
......@@ -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;
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment