summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-07-21 10:31:10 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-07-21 10:31:10 +0200
commitec20992e1ecd928be5dee65c272e54de369c0c48 (patch)
treed608082bcea5bbd087ad5d548659d9b770491ed7 /sql/sql_lex.cc
parentc4d5b6b157b06fe22fd7e01967d7a0194c3686a2 (diff)
downloadmariadb-git-bb-10.4-MDEV-21997.tar.gz
MDEV-21997 Server crashes in LEX::create_item_ident_sp upon use of unknown identifierbb-10.4-MDEV-21997
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.cc7
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);