-
unknown authored
When innodb detects a deadlock it calls ha_rollback_trans() to rollback the main transaction. But such action isn't allowed from inside of triggers and functions. When it happen the 'Explicit or implicit commit' error is thrown even if there is no commit/rollback statements in the trigger/function. This leads to the user confusion. Now the convert_error_code_to_mysql() function doesn't call the ha_rollback_trans() function directly but rather calls the mark_transaction_to_rollback function and returns an error. The sp_rcontext::find_handler() now doesn't allow errors to be caught by the trigger/function error handlers when the thd->is_fatal_sub_stmt_error flag is set. Procedures are still allowed to catch such errors. The sp_rcontext::find_handler function now accepts a THD handle as a parameter. The transaction_rollback_request and the is_fatal_sub_stmt_error flags are added to the THD class. The are initialized by the THD class constructor. Now the ha_autocommit_or_rollback function rolls back main transaction when not in a sub statement and the thd->transaction_rollback_request is set. The THD::restore_sub_statement_state function now resets the thd->is_fatal_sub_stmt_error flag on exit from a sub-statement. sql/ha_innodb.cc: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. Now the convert_error_code_to_mysql() function doesn't call the ha_rollback_trans() function directly but rather calls the mark_transaction_to_rollback function and returns an error. sql/handler.cc: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. Now the ha_autocommit_or_rollback function rolls back main transaction when not in a sub statement and the thd->transaction_rollback_request is set. mysql-test/r/innodb-big.result: Added a test case for the bug#24989: The DEADLOCK error is improperly handled by InnoDB. mysql-test/t/innodb-big.test: Added a test case for the bug#24989: The DEADLOCK error is improperly handled by InnoDB. sql/sql_class.h: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. The transaction_rollback_request and the is_fatal_sub_stmt_error flags are added to the THD class. sql/sql_class.cc: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. Initialization of the transaction_rollback_request and the is_fatal_sub_stmt_error flags are added to the THD class constructor. The mark_transaction_to_rollback function is added. The THD::restore_sub_statement_state function now resets the thd->is_fatal_sub_stmt_error flag on exit from a sub-statement. sql/sp_rcontext.h: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. The sp_rcontext::find_handler function now accepts a THD handle as a parameter. The in_sub_stmt flag is added to the sp_rcontext class. sql/sp_rcontext.cc: Bug#24989: The DEADLOCK error is improperly handled by InnoDB. The sp_rcontext::find_handler() now doesn't allow errors to be caught by the trigger/function error handlers when the thd->is_fatal_sub_stmt_error flag is set. Instead it tries to find a most inner procedure that isn't called directly or indirectly from any function/trigger. Procedures are still allowed to catch such errors. The sp_rcontext::find_handler function now accepts a THD handle as a parameter.
9246c372