summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1208ed536e1..079874f2f5d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -7493,6 +7493,7 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
THD *thd= lex->thd;
bool new_select= select_lex == NULL;
DBUG_ENTER("mysql_new_select");
+ Name_resolution_context *curr_context;
if (new_select)
{
@@ -7500,9 +7501,13 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
DBUG_RETURN(1);
select_lex->select_number= ++thd->lex->stmt_lex->current_select_number;
select_lex->parent_lex= lex; /* Used in init_query. */
+ curr_context= lex->context_stack.head();
select_lex->init_query();
select_lex->init_select();
}
+ else
+ curr_context= select_lex->parent_lex->context_stack.head();
+
lex->nest_level++;
if (lex->nest_level > (int) MAX_SELECT_NESTING)
{
@@ -7529,7 +7534,8 @@ mysql_new_select(LEX *lex, bool move_down, SELECT_LEX *select_lex)
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
{