summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2007-07-30 17:14:34 +0400
committerevgen@moonbone.local <>2007-07-30 17:14:34 +0400
commit8de5603d1d4678c9c6fbe0381674fd916fb2baef (patch)
treedc7b91c527bfb6365e1346469426291cfcaae04e /sql/sql_class.h
parentdebb054d4a155a8d70f3431cd281901fd210a98e (diff)
downloadmariadb-git-8de5603d1d4678c9c6fbe0381674fd916fb2baef.tar.gz
Bug#24989: The DEADLOCK error is improperly handled by InnoDB.
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.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 5f813e82307..674409d6f08 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1406,7 +1406,33 @@ public:
bool slave_thread, one_shot_set;
bool locked, some_tables_deleted;
bool last_cuted_field;
- bool no_errors, password, is_fatal_error;
+ bool no_errors, password;
+ /**
+ Set to TRUE if execution of the current compound statement
+ can not continue. In particular, disables activation of
+ CONTINUE or EXIT handlers of stored routines.
+ Reset in the end of processing of the current user request, in
+ @see mysql_reset_thd_for_next_command().
+ */
+ bool is_fatal_error;
+ /**
+ Set by a storage engine to request the entire
+ transaction (that possibly spans multiple engines) to
+ rollback. Reset in ha_rollback.
+ */
+ bool transaction_rollback_request;
+ /**
+ TRUE if we are in a sub-statement and the current error can
+ not be safely recovered until we left the sub-statement mode.
+ In particular, disables activation of CONTINUE and EXIT
+ handlers inside sub-statements. E.g. if it is a deadlock
+ error and requires a transaction-wide rollback, this flag is
+ raised (traditionally, MySQL first has to close all the reads
+ via @see handler::ha_index_or_rnd_end() and only then perform
+ the rollback).
+ Reset to FALSE when we leave the sub-statement mode.
+ */
+ bool is_fatal_sub_stmt_error;
bool query_start_used, rand_used, time_zone_used;
/*
@@ -2338,3 +2364,5 @@ public:
/* Functions in sql_class.cc */
void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var);
+void mark_transaction_to_rollback(THD *thd, bool all);
+