summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2005-04-12 17:22:14 +0200
committerunknown <serg@serg.mylan>2005-04-12 17:22:14 +0200
commitb59dc1e86002db8db15ed0ae48d856cee303e0b9 (patch)
tree23f4bd12bcf862b871219abb9998ca4a083e85c3 /sql/handler.cc
parent3767fb0118eb8b2bfb5a24564d695c4d39ce30d8 (diff)
parent859b3e16ac0af20950bb2e0ac4d1fc7c6fb96fe0 (diff)
downloadmariadb-git-b59dc1e86002db8db15ed0ae48d856cee303e0b9.tar.gz
Merge bk-internal:/home/bk/mysql-5.0
into serg.mylan:/usr/home/serg/Abk/mysql-5.0 sql/handler.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index dc63b4b038f..8315ec6bb1a 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -587,6 +587,11 @@ int ha_commit_trans(THD *thd, bool all)
#ifdef USING_TRANSACTIONS
if (trans->nht)
{
+ if (is_real_trans && wait_if_global_read_lock(thd, 0, 0))
+ {
+ ha_rollback_trans(thd, all);
+ DBUG_RETURN(1);
+ }
DBUG_EXECUTE_IF("crash_commit_before", abort(););
if (!trans->no_2pc && trans->nht > 1)
{
@@ -596,7 +601,7 @@ int ha_commit_trans(THD *thd, bool all)
if ((err= (*(*ht)->prepare)(thd, all)))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
- error=1;
+ error= 1;
}
statistic_increment(thd->status_var.ha_prepare_count,&LOCK_status);
}
@@ -605,20 +610,28 @@ int ha_commit_trans(THD *thd, bool all)
(error= !(cookie= tc_log->log(thd, xid)))))
{
ha_rollback_trans(thd, all);
- return 1;
+ error= 1;
+ goto end;
}
- DBUG_EXECUTE_IF("crash_commit_after_log", abort(););
+ DBUG_EXECUTE_IF("crash_commit_after_log", abort(););
}
error=ha_commit_one_phase(thd, all) ? cookie ? 2 : 1 : 0;
DBUG_EXECUTE_IF("crash_commit_before_unlog", abort(););
if (cookie)
tc_log->unlog(cookie, xid);
DBUG_EXECUTE_IF("crash_commit_after", abort(););
+end:
+ if (is_real_trans)
+ start_waiting_global_read_lock(thd);
}
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
}
+/*
+ NOTE - this function does not care about global read lock.
+ A caller should.
+*/
int ha_commit_one_phase(THD *thd, bool all)
{
int error=0;
@@ -629,18 +642,6 @@ int ha_commit_one_phase(THD *thd, bool all)
#ifdef USING_TRANSACTIONS
if (trans->nht)
{
- bool need_start_waiters= 0;
- if (is_real_trans)
- {
- if ((error= wait_if_global_read_lock(thd, 0, 0)))
- {
- my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
- error= 1;
- }
- else
- need_start_waiters= 1;
- }
-
for (ht=trans->ht; *ht; ht++)
{
int err;
@@ -665,8 +666,6 @@ int ha_commit_one_phase(THD *thd, bool all)
thd->variables.tx_isolation=thd->session_tx_isolation;
thd->transaction.cleanup();
}
- if (need_start_waiters)
- start_waiting_global_read_lock(thd);
}
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);