[Commits] 08ba474174c6d8eb8668488110e3949cb82c50d7 Fixed bug mdev-10783. Do not push conditions into materialized views/derived tables marked with the flag 'fill_me'.

Igor Babaev igor at askmonty.org
Tue Sep 13 21:58:35 EEST 2016


commit 08ba474174c6d8eb8668488110e3949cb82c50d7
Author: Igor Babaev <igor at askmonty.org>
Commit: Igor Babaev <igor at askmonty.org>

    Fixed bug mdev-10783.
    Do not push conditions into materialized views/derived tables
    marked with the flag 'fill_me'.
---
 mysql-test/r/derived_cond_pushdown.result |    9 +++++++++
 mysql-test/t/derived_cond_pushdown.test   |   10 +++++++++-
 sql/sql_derived.cc                        |    4 ++++
 3 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result
index 3b7eb58..9401a03 100644
--- a/mysql-test/r/derived_cond_pushdown.result
+++ b/mysql-test/r/derived_cond_pushdown.result
@@ -7007,3 +7007,12 @@ WHERE f = 1;
 f
 1
 DROP TABLE t1;
+#
+# MDEV-10783: pushdown into constant view
+#
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+CREATE VIEW v AS SELECT 5;
+SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
+i
+DROP VIEW v;
+DROP TABLE t1;
diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test
index 7a85c53..cfd73bd 100644
--- a/mysql-test/t/derived_cond_pushdown.test
+++ b/mysql-test/t/derived_cond_pushdown.test
@@ -898,5 +898,13 @@ SELECT *
     WHERE f = 1;
 DROP TABLE t1;
 
+--echo #
+--echo # MDEV-10783: pushdown into constant view
+--echo #
 
-  
\ No newline at end of file
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+CREATE VIEW v AS SELECT 5;
+SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
+DROP VIEW v;
+DROP TABLE t1; 
+ 
\ No newline at end of file
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index b0d505b..a743511 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -1144,6 +1144,10 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
   if (!any_select_allows_cond_pushdown)
     return false; 
 
+  /* Do not push conditions into constant derived */
+  if (derived->fill_me)
+    return false;
+
   /* Do not push conditions into recursive with tables */
   if (derived->is_recursive_with_table())
     return false;


More information about the commits mailing list