summaryrefslogtreecommitdiff
path: root/sql/sql_derived.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2016-09-25 17:28:49 -0700
committerIgor Babaev <igor@askmonty.org>2016-09-25 17:29:10 -0700
commit1f1990a1612669af731363b4d0bacf2d2ce5adbd (patch)
tree2910046747e47a32857f4ab57cba7705ef17dfd5 /sql/sql_derived.cc
parent09cbb772ebf6bdf10ea7e2bd4ba833d36e7e5b8f (diff)
downloadmariadb-git-1f1990a1612669af731363b4d0bacf2d2ce5adbd.tar.gz
Fixed bug mdev-10884.mariadb-10.2.2
If a materialized derived table / view is specified by a unit with SELECTs containing ORDER BY ... LIMIT then condition pushdown cannot be done for these SELECTs. If a materialized derived table / view is specified by a unit containing global ORDER BY ... LIMIT then condition pushdown cannot be done for this unit.
Diffstat (limited to 'sql/sql_derived.cc')
-rw-r--r--sql/sql_derived.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 85a85b9c3b2..0b67b952056 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -1131,27 +1131,31 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived)
st_select_lex_unit *unit= derived->get_unit();
st_select_lex *sl= unit->first_select();
+ /* Do not push conditions into constant derived */
+ if (unit->executed)
+ return false;
+
+ /* Do not push conditions into recursive with tables */
+ if (derived->is_recursive_with_table())
+ return false;
+
+ /* Do not push conditions into unit with global ORDER BY ... LIMIT */
+ if (unit->fake_select_lex && unit->fake_select_lex->explicit_limit)
+ return false;
+
/* Check whether any select of 'unit' allows condition pushdown */
- bool any_select_allows_cond_pushdown= false;
+ bool some_select_allows_cond_pushdown= false;
for (; sl; sl= sl->next_select())
{
if (sl->cond_pushdown_is_allowed())
{
- any_select_allows_cond_pushdown= true;
+ some_select_allows_cond_pushdown= true;
break;
}
}
- if (!any_select_allows_cond_pushdown)
+ if (!some_select_allows_cond_pushdown)
return false;
- /* Do not push conditions into constant derived */
- if (unit->executed)
- return false;
-
- /* Do not push conditions into recursive with tables */
- if (derived->is_recursive_with_table())
- return false;
-
/*
Build the most restrictive condition extractable from 'cond'
that can be pushed into the derived table 'derived'.