summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index a1e738583fd..9eb129fab45 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -342,17 +342,30 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
#ifdef USING_TRANSACTIONS
if (opt_using_transactions)
{
- bool operation_done= 0;
+ bool operation_done= 0, need_start_waiters= 0;
bool transaction_commited= 0;
-
- /* Update the binary log if we have cached some queries */
- if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
+ /* If transaction has done some updates to tables */
+ if (trans == &thd->transaction.all &&
my_b_tell(&thd->transaction.trans_log))
{
- mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
- reinit_io_cache(&thd->transaction.trans_log,
- WRITE_CACHE, (my_off_t) 0, 0, 1);
- thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
+ if (error= wait_if_global_read_lock(thd, 0, 0))
+ {
+ /*
+ Note that ROLLBACK [TO SAVEPOINT] does not have this test; it's
+ because ROLLBACK never updates data, so needn't wait on the lock.
+ */
+ my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
+ error= 1;
+ }
+ else
+ need_start_waiters= 1;
+ if (mysql_bin_log.is_open())
+ {
+ mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
+ reinit_io_cache(&thd->transaction.trans_log,
+ WRITE_CACHE, (my_off_t) 0, 0, 1);
+ thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
+ }
}
#ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid)
@@ -393,6 +406,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
statistic_increment(ha_commit_count,&LOCK_status);
thd->transaction.cleanup();
}
+ if (need_start_waiters)
+ start_waiting_global_read_lock(thd);
}
#endif // using transactions
DBUG_RETURN(error);