Skip to content

Commit 576ed18

Browse files
committed
Merge branch 'mysql-8.4' into mysql-trunk
Change-Id: Id51b9f6b08584e0511b6c32d5a6bce60775ce22e
2 parents 10a082b + 99c3792 commit 576ed18

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
@@ -806,17 +806,22 @@ bool Query_block::apply_local_transforms(THD *thd, bool prune) {
806806
DBUG_TRACE;
807807

808808
assert(first_execution);
809-
809+
assert(thd->lex->current_query_block() == this);
810810
/*
811811
If query block contains one or more merged derived tables/views,
812812
walk through lists of columns in select lists and remove unused columns.
813813
*/
814-
if (derived_table_count) delete_unused_merged_columns(&m_table_nest);
815-
814+
if (derived_table_count != 0) {
815+
delete_unused_merged_columns(&m_table_nest);
816+
}
816817
for (Query_expression *unit = first_inner_query_expression(); unit;
817-
unit = unit->next_query_expression())
818-
for (auto qt : unit->query_terms<>())
818+
unit = unit->next_query_expression()) {
819+
for (auto qt : unit->query_terms<>()) {
820+
thd->lex->set_current_query_block(qt->query_block());
819821
if (qt->query_block()->apply_local_transforms(thd, true)) return true;
822+
}
823+
}
824+
thd->lex->set_current_query_block(this);
820825

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

0 commit comments

Comments
 (0)