Skip to content

Commit 08ba474

Browse files
committed
Fixed bug mdev-10783.
Do not push conditions into materialized views/derived tables marked with the flag 'fill_me'.
1 parent 54b81ac commit 08ba474

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

mysql-test/r/derived_cond_pushdown.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,3 +7007,12 @@ WHERE f = 1;
70077007
f
70087008
1
70097009
DROP TABLE t1;
7010+
#
7011+
# MDEV-10783: pushdown into constant view
7012+
#
7013+
CREATE TABLE t1 (i int) ENGINE=MyISAM;
7014+
CREATE VIEW v AS SELECT 5;
7015+
SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
7016+
i
7017+
DROP VIEW v;
7018+
DROP TABLE t1;

mysql-test/t/derived_cond_pushdown.test

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,5 +898,13 @@ SELECT *
898898
WHERE f = 1;
899899
DROP TABLE t1;
900900

901+
--echo #
902+
--echo # MDEV-10783: pushdown into constant view
903+
--echo #
901904

902-
905+
CREATE TABLE t1 (i int) ENGINE=MyISAM;
906+
CREATE VIEW v AS SELECT 5;
907+
SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
908+
DROP VIEW v;
909+
DROP TABLE t1;
910+

sql/sql_derived.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,10 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
11441144
if (!any_select_allows_cond_pushdown)
11451145
return false;
11461146

1147+
/* Do not push conditions into constant derived */
1148+
if (derived->fill_me)
1149+
return false;
1150+
11471151
/* Do not push conditions into recursive with tables */
11481152
if (derived->is_recursive_with_table())
11491153
return false;

0 commit comments

Comments
 (0)