From f6d8640d678799244cd9aede6abfd4493e139665 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 3 Dec 2019 21:26:44 +0300 Subject: [PATCH] MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONED Related to 87731177 and Bug#47649. Don't set Query_arena::STMT_EXECUTED for any error code. skip_setup_conds() depends on STMT_INITIALIZED_FOR_SP, but sp_lex_keeper::reset_lex_and_exec_core() sets it to STMT_EXECUTED on ER_TABLE_NOT_LOCKED_FOR_WRITE. There are other error codes that can break skip_setup_conds() (ER_IT_IS_A_VIEW, ER_NON_UPDATABLE_TABLE, etc). --- sql/sp_head.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 48166fac4c6..ab7faf51849 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3379,11 +3379,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, Update the state of the active arena if no errors on open_tables stage. */ - if (likely(!res) || likely(!thd->is_error()) || - (thd->get_stmt_da()->sql_errno() != ER_CANT_REOPEN_TABLE && - thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE && - thd->get_stmt_da()->sql_errno() != ER_NO_SUCH_TABLE_IN_ENGINE && - thd->get_stmt_da()->sql_errno() != ER_UPDATE_TABLE_USED)) + if (likely(!res) || likely(!thd->is_error())) thd->stmt_arena->state= Query_arena::STMT_EXECUTED; /*