summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-02-22 21:25:16 +0100
committerSergei Golubchik <serg@mariadb.org>2021-02-22 22:42:27 +0100
commit0ab1e3914c78e4a82a8e4502b58b20e5598727ab (patch)
tree403a06406bd6998e588cb51a0f058cfa668e96da /sql/sql_select.cc
parentca126d96f5175ba03c32ea79774075d6d42c98cb (diff)
parent3c021485c913828b83510967c1ff277011a9d59a (diff)
downloadmariadb-git-0ab1e3914c78e4a82a8e4502b58b20e5598727ab.tar.gz
Merge branch '10.2' into 10.3
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc33
1 files changed, 17 insertions, 16 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7e084cafa05..c802aa9c18e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1063,22 +1063,6 @@ JOIN::prepare(TABLE_LIST *tables_init,
FALSE, SELECT_ACL, SELECT_ACL, FALSE))
DBUG_RETURN(-1);
- /*
- Permanently remove redundant parts from the query if
- 1) This is a subquery
- 2) This is the first time this query is optimized (since the
- transformation is permanent
- 3) Not normalizing a view. Removal should take place when a
- query involving a view is optimized, not when the view
- is created
- */
- if (select_lex->master_unit()->item && // 1)
- select_lex->first_cond_optimization && // 2)
- !thd->lex->is_view_context_analysis()) // 3)
- {
- remove_redundant_subquery_clauses(select_lex);
- }
-
/* System Versioning: handle FOR SYSTEM_TIME clause. */
if (select_lex->vers_setup_conds(thd, tables_list) < 0)
DBUG_RETURN(-1);
@@ -1161,6 +1145,23 @@ JOIN::prepare(TABLE_LIST *tables_init,
&hidden_group_fields,
&select_lex->select_n_reserved))
DBUG_RETURN(-1);
+
+ /*
+ Permanently remove redundant parts from the query if
+ 1) This is a subquery
+ 2) This is the first time this query is optimized (since the
+ transformation is permanent
+ 3) Not normalizing a view. Removal should take place when a
+ query involving a view is optimized, not when the view
+ is created
+ */
+ if (select_lex->master_unit()->item && // 1)
+ select_lex->first_cond_optimization && // 2)
+ !thd->lex->is_view_context_analysis()) // 3)
+ {
+ remove_redundant_subquery_clauses(select_lex);
+ }
+
/* Resolve the ORDER BY that was skipped, then remove it. */
if (skip_order_by && select_lex !=
select_lex->master_unit()->global_parameters())