summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-04-16 09:53:16 -0700
committerIgor Babaev <igor@askmonty.org>2021-04-17 11:02:29 -0700
commit635b5ce355473167af64e116e403a51bfaed184b (patch)
tree303ef52ff91f59d9593176db071f4ae457b6d243 /sql/sql_parse.cc
parent73bf62469e0124a088bfddd838a68714ce7d79ea (diff)
downloadmariadb-git-prot-10.2.tar.gz
MDEV-25362 Incorrect name resolution for subqueries in ON expressionsprot-10.2
This patch sets the proper name resolution context for outer references used in a subquery from an ON clause. Usually this context is more narrow than the name resolution context of the parent select that were used before this fix. This fix revealed another problem that concerned ON expressions used in from clauses of specifications of derived tables / views / CTEs. The name resolution outer context for such ON expression must be set to NULL to prevent name resolution beyond the derived table where it is used. The solution to resolve this problem applied in sql_derived.cc was provided by Sergei Petrunia <sergey@mariadb.com>. The change in sql_parse.cc is not good for 10.4+. A corresponding diff for 10.4+ will be provided in JIRA entry for this bug. Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 573df24cb33..9436e111043 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7418,6 +7418,7 @@ mysql_new_select(LEX *lex, bool move_down)
DBUG_RETURN(1);
select_lex->select_number= ++thd->lex->stmt_lex->current_select_number;
select_lex->parent_lex= lex; /* Used in init_query. */
+ Name_resolution_context *curr_context= lex->context_stack.head();
select_lex->init_query();
select_lex->init_select();
lex->nest_level++;
@@ -7448,7 +7449,8 @@ mysql_new_select(LEX *lex, bool move_down)
By default we assume that it is usual subselect and we have outer name
resolution context, if no we will assign it to 0 later
*/
- select_lex->context.outer_context= &select_lex->outer_select()->context;
+
+ select_lex->context.outer_context= curr_context;
}
else
{