From 1869cd9f837e58adc709514d0133fd5c6323aa9b Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Thu, 4 Nov 2004 19:19:23 +0100 Subject: Fix for BUG##5714 "Insert into MyISAM table and select ... for update]": the fact that the transaction log is empty does not mean we're not in a transaction (it could be BEGIN; SELECT * FOR UPDATE FROM ibtable: then we don't want to commit now, even if the statement is a MyISAM update). With a testcase. --- sql/log.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql/log.cc') diff --git a/sql/log.cc b/sql/log.cc index fee77b38f21..aa5d9d8753b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1254,7 +1254,8 @@ bool MYSQL_LOG::write(Log_event* event_info) if (flush_io_cache(file)) goto err; - if (opt_using_transactions && !my_b_tell(&thd->transaction.trans_log)) + if (opt_using_transactions && + !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { /* LOAD DATA INFILE in AUTOCOMMIT=1 mode writes to the binlog -- cgit v1.2.1 From 0c4363b6d0257d4234b12367c7746257f9472f17 Mon Sep 17 00:00:00 2001 From: "guilhem@mysql.com" <> Date: Wed, 10 Nov 2004 15:07:55 +0100 Subject: Fix for BUG#6522 "Replication fails due to a rolled back transaction in the binlog" When we are writing a transaction to the binlog, we log BEGIN/COMMIT with zero error code. Example: all statements of trans succeeded, connection lost and so implicit rollback: we don't want ER_NET* errors to be logged in the BEGIN/ROLLBACK events, while statement events have 0. If there was really a serious error code, it's already in the statement events. --- sql/log.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sql/log.cc') diff --git a/sql/log.cc b/sql/log.cc index aa5d9d8753b..b2d015c1a14 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1370,6 +1370,14 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback) */ { Query_log_event qinfo(thd, "BEGIN", 5, TRUE); + /* + Imagine this is rollback due to net timeout, after all statements of + the transaction succeeded. Then we want a zero-error code in BEGIN. + In other words, if there was a really serious error code it's already + in the statement's events. + This is safer than thd->clear_error() against kills at shutdown. + */ + qinfo.error_code= 0; /* Now this Query_log_event has artificial log_pos 0. It must be adjusted to reflect the real position in the log. Not doing it would confuse the @@ -1403,6 +1411,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback) commit_or_rollback ? "COMMIT" : "ROLLBACK", commit_or_rollback ? 6 : 8, TRUE); + qinfo.error_code= 0; qinfo.set_log_pos(this); if (qinfo.write(&log_file) || flush_io_cache(&log_file)) goto err; -- cgit v1.2.1