Skip to content

Commit 99c3792

Browse files
committed
Merge branch 'mysql-8.0' into mysql-8.4
Change-Id: I6242989a9132dbd09ad98102632aa787f36d0062
2 parents 1f4a959 + 5c09ff3 commit 99c3792

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sql/sql_resolver.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -811,17 +811,22 @@ bool Query_block::apply_local_transforms(THD *thd, bool prune) {
811811
DBUG_TRACE;
812812

813813
assert(first_execution);
814-
814+
assert(thd->lex->current_query_block() == this);
815815
/*
816816
If query block contains one or more merged derived tables/views,
817817
walk through lists of columns in select lists and remove unused columns.
818818
*/
819-
if (derived_table_count) delete_unused_merged_columns(&m_table_nest);
820-
819+
if (derived_table_count != 0) {
820+
delete_unused_merged_columns(&m_table_nest);
821+
}
821822
for (Query_expression *unit = first_inner_query_expression(); unit;
822-
unit = unit->next_query_expression())
823-
for (auto qt : unit->query_terms<>())
823+
unit = unit->next_query_expression()) {
824+
for (auto qt : unit->query_terms<>()) {
825+
thd->lex->set_current_query_block(qt->query_block());
824826
if (qt->query_block()->apply_local_transforms(thd, true)) return true;
827+
}
828+
}
829+
thd->lex->set_current_query_block(this);
825830

826831
// Convert all outer joins to inner joins if possible
827832
if (simplify_joins(thd, &m_table_nest, true, false, &m_where_cond))

0 commit comments

Comments
 (0)