From b22285e4821b49546de9b88990bbc9c453dc14b2 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 19 Jan 2021 08:02:37 -0800 Subject: MDEV-16940 Server crashes in unsafe_key_update upon attempt to update view through 2nd execution of SP This bug caused a server crash on the second call of any stored procedure that contained an UPDATE statement over a multi-table view reporting an error message at the prepare stage. On the first call of the stored procedure after reporting an error at the preparation stage of the UPDATE statement finished without calling the function SELECT_LEX::save_prep_leaf_tables() for the SELECT used as the definition of the view. This left the SELECT_LEX structure used by the UPDATE statement in an inconsistent state for second call of the stored procedure. Approved by Oleksandr Byelkin --- sql/sql_lex.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/sql_lex.cc') diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 77e6b2b6571..5059e4f656e 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4585,6 +4585,9 @@ bool LEX::save_prep_leaf_tables() bool st_select_lex::save_prep_leaf_tables(THD *thd) { + if (prep_leaf_list_state == SAVED) + return FALSE; + List_iterator_fast li(leaf_tables); TABLE_LIST *table; -- cgit v1.2.1