diff options
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index eb22534f4fb..c21a5dee088 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -7598,6 +7598,13 @@ Item *LEX::create_item_ident_sp(THD *thd, Lex_ident_sys_st *name, return new (thd->mem_root) Item_func_sqlerrm(thd); } + if (!current_select) + { + // we are out of SELECT or FOR so it is syntax error + my_error(ER_SP_UNDECLARED_VAR, MYF(0), name->str); + return NULL; + } + if (current_select->parsing_place == FOR_LOOP_BOUND) return create_item_for_loop_bound(thd, &null_clex_str, &null_clex_str, name); |