diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2020-07-21 10:31:10 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2020-07-22 15:03:22 +0200 |
commit | ddb8309e8c1bac8d419fe5c224665c6dca1e2878 (patch) | |
tree | 7a613bcdf5a2a2d6da331f05662abecd08cc0e88 /sql/sql_lex.cc | |
parent | 1ca52b969aeb704337747432e33e3a942146b6dd (diff) | |
download | mariadb-git-ddb8309e8c1bac8d419fe5c224665c6dca1e2878.tar.gz |
MDEV-21997 Server crashes in LEX::create_item_ident_sp upon use of unknown identifier
If there is no current_select and variable is not found among SP variables it can be only an error.
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); |