diff options
author | Alexander Barkov <bar@mariadb.com> | 2018-06-20 13:29:11 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2018-06-20 13:29:11 +0400 |
commit | 9c53cbdd8887f0f8bcdade24a4be183a3b354bc9 (patch) | |
tree | 0301dfd03a919bb961f021df0eb2e37b817aaa9d /sql/sql_lex.cc | |
parent | b534a7b89ef39cd75bfe09524be044bc16ea2f48 (diff) | |
download | mariadb-git-9c53cbdd8887f0f8bcdade24a4be183a3b354bc9.tar.gz |
MDEV-15941 Explicit cursor FOR loop does not close the cursor
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index cb6edc4a788..7a8cd410e86 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -5891,6 +5891,26 @@ bool LEX::sp_for_loop_cursor_finalize(THD *thd, const Lex_for_loop_st &loop) return sp_while_loop_finalize(thd); } +bool LEX::sp_for_loop_outer_block_finalize(THD *thd, + const Lex_for_loop_st &loop) +{ + Lex_spblock tmp; + tmp.curs= MY_TEST(loop.m_implicit_cursor); + if (unlikely(sp_block_finalize(thd, tmp))) // The outer DECLARE..BEGIN..END + return true; + if (!loop.is_for_loop_explicit_cursor()) + return false; + /* + Explicit cursor FOR loop must close the cursor automatically. + Note, implicit cursor FOR loop does not need to close the cursor, + it's closed by sp_instr_cpop. + */ + sp_instr_cclose *ic= new (thd->mem_root) + sp_instr_cclose(sphead->instructions(), spcont, + loop.m_cursor_offset); + return ic == NULL || sphead->add_instr(ic); +} + /***************************************************************************/ bool LEX::sp_declare_cursor(THD *thd, const LEX_CSTRING *name, |