summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2002-06-22 20:05:30 +0300
committerunknown <heikki@hundin.mysql.fi>2002-06-22 20:05:30 +0300
commit4237b04189903ad3a4e01e2edecbfbb082b73924 (patch)
tree6b7b500affba53374345167f438d7c7f8f94ab5a /sql/handler.cc
parent23dbcb0fa4f8904c43761791c0c852a368cfa753 (diff)
downloadmariadb-git-4237b04189903ad3a4e01e2edecbfbb082b73924.tar.gz
log.cc, handler.cc:
Add BEGIN andd COMMIT around transactions in the binlog sql/handler.cc: Add BEGIN andd COMMIT around transactions in the binlog sql/log.cc: Add BEGIN andd COMMIT around transactions in the binlog
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 098c3130de2..564d91aa887 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -251,6 +251,7 @@ int ha_autocommit_or_rollback(THD *thd, int error)
}
else
(void) ha_rollback_stmt(thd);
+
thd->tx_isolation=thd->session_tx_isolation;
}
#endif
@@ -309,6 +310,36 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log))
{
+ /* We write the command "COMMIT" as the last SQL command in the
+ binlog segment cached for this transaction */
+
+ int save_query_length = thd->query_length;
+
+ thd->query_length = 6; /* length of 'COMMIT'; note that we may come
+ here because a DROP TABLE, for instance,
+ makes an implicit commit, and then
+ thd->query is not 'COMMIT'! */
+
+ Query_log_event qinfo(thd, "COMMIT", TRUE);
+
+ /* When we come here, and the user wrapped the transaction into
+ BEGIN and COMMIT, then qinfo got above the field cache_stmt
+ erroneously set to 0. Let us set it to 1: */
+
+ qinfo.cache_stmt = 1;
+
+ /* Write the 'COMMIT' entry to the cache */
+
+ if (mysql_bin_log.write(&qinfo)) {
+ my_error(ER_ERROR_DURING_COMMIT, MYF(0), 5000);
+ error=1;
+ }
+
+ thd->query_length = save_query_length;
+
+ /* Now we write the binlog segment cached for this transaction to
+ the real binlog */
+
mysql_bin_log.write(thd, &thd->transaction.trans_log);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);