summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-03-04 23:02:47 -0800
committerIgor Babaev <igor@askmonty.org>2021-03-09 00:25:28 -0800
commit4020e4aee0b3477f31d1fb0d797b84171b22d483 (patch)
tree0c987c7e01171a8e8e9d7f3a5c25b3ad4e0e175f /sql
parentdc6667805dd4567693fcc01666da7d1277050097 (diff)
downloadmariadb-git-4020e4aee0b3477f31d1fb0d797b84171b22d483.tar.gz
MDEV-25002 ON expressions cannot contain outer references
A bogus error message was issued for any outer references occurred in ON expressions used in subqueries. This prevented execution of queries containing subqueries as soon as they used outer references in their ON clauses. This happened because the Name_resolution_context structure created for any ON expression erroneously had the field outer_context set to NULL. The fields select_lex of this structure was not set correctly either. The idea of the fix was taken from mysql code of the function push_new_name_resolution_context(). Approved by dmitry.shulga@mariadb.com
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_parse.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 7f756245c83..e8ab9a2511c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -8774,6 +8774,8 @@ push_new_name_resolution_context(THD *thd,
left_op->first_leaf_for_name_resolution();
on_context->last_name_resolution_table=
right_op->last_leaf_for_name_resolution();
+ on_context->select_lex = thd->lex->current_select;
+ on_context->outer_context = thd->lex->current_context()->outer_context;
return thd->lex->push_context(on_context, thd->mem_root);
}