summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2022-03-18 11:13:09 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2022-03-21 07:55:57 +0100
commitfbc1cc974e433ad4ee77ef19a2ea199537686a98 (patch)
treecbd90155899e3a561b418c414f8eccc76474cd40 /sql/sp_head.cc
parentcf86580f2b4ca2b7bd337d27af22b46c82bb25df (diff)
downloadmariadb-git-fbc1cc974e433ad4ee77ef19a2ea199537686a98.tar.gz
MDEV-26009 Server crash when calling twice procedure using FOR-loop
The problem was that instructions sp_instr_cursor_copy_struct and sp_instr_copen uses the same lex, adding and removing "tail" of prelocked tables and forgetting that tail of all tables is kept in LEX::query_tables_last. If the LEX used only by one instruction or the query do not have prelocked tables it is not important. But to work correctly in all cases LEX::query_tables_last should be reset to make new tables added in the correct list (after last table in the LEX instead after last table of the prelocking "tail" which was cut).
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 57ab31d9edf..1d1199aaa62 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -3486,6 +3486,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
lex_query_tables_own_last= m_lex->query_tables_own_last;
prelocking_tables= *lex_query_tables_own_last;
*lex_query_tables_own_last= NULL;
+ m_lex->query_tables_last= m_lex->query_tables_own_last;
m_lex->mark_as_requiring_prelocking(NULL);
}
thd->rollback_item_tree_changes();