summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.(none)>2006-06-12 08:54:45 -0400
committerunknown <cmiller@zippy.(none)>2006-06-12 08:54:45 -0400
commit1c1570940feccf6ed3249c643f7968be1563f7b6 (patch)
treeb71c8e383c0806357a95ccd2fec43a371a133ceb /sql/log.cc
parent168cad46ab6a4fd8b59ebc4918ed17a5a2942e58 (diff)
downloadmariadb-git-1c1570940feccf6ed3249c643f7968be1563f7b6.tar.gz
Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit
mode This is a modification of serg's and guilhem's suggestion in the bug report, in that it also causes the transaction log to be written to disc. mysql-test/r/bdb.result: Add result. mysql-test/t/bdb.test: Add test sql/log.cc: Create a log-committing event that itself won't be written to the log when we're in autocommit mode. sql/log_event.cc: Add a new subclass of Query_log_event that doesn't write itself to the log, for cases where we only want to flush out the transaction and not also write about this event. sql/log_event.h: Add a new subclass of Query_log_event that doesn't write itself to the log, for cases where we only want to flush out the transaction and not also write about this event.
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc22
1 files changed, 17 insertions, 5 deletions
diff --git a/sql/log.cc b/sql/log.cc
index ba02c9ba082..cfb90d398e6 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -36,6 +36,8 @@
MYSQL_LOG mysql_log, mysql_slow_log, mysql_bin_log;
ulong sync_binlog_counter= 0;
+static Muted_query_log_event invisible_commit;
+
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
static bool binlog_init();
@@ -94,7 +96,9 @@ static int binlog_end_trans(THD *thd, IO_CACHE *trans_log, Log_event *end_ev)
{
int error=0;
DBUG_ENTER("binlog_end_trans");
- if (end_ev)
+
+ /* NULL denotes ROLLBACK with nothing to replicate */
+ if (end_ev != NULL)
error= mysql_bin_log.write(thd, trans_log, end_ev);
statistic_increment(binlog_cache_use, &LOCK_status);
@@ -126,14 +130,19 @@ static int binlog_commit(THD *thd, bool all)
DBUG_ASSERT(mysql_bin_log.is_open() &&
(all || !(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))));
- if (!my_b_tell(trans_log))
+ if (my_b_tell(trans_log) == 0)
{
// we're here because trans_log was flushed in MYSQL_LOG::log()
DBUG_RETURN(0);
}
- Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
- qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
- DBUG_RETURN(binlog_end_trans(thd, trans_log, &qev));
+ if (all)
+ {
+ Query_log_event qev(thd, STRING_WITH_LEN("COMMIT"), TRUE, FALSE);
+ qev.error_code= 0; // see comment in MYSQL_LOG::write(THD, IO_CACHE)
+ DBUG_RETURN(binlog_end_trans(thd, trans_log, &qev));
+ }
+ else
+ DBUG_RETURN(binlog_end_trans(thd, trans_log, &invisible_commit));
}
static int binlog_rollback(THD *thd, bool all)
@@ -1813,6 +1822,9 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, Log_event *commit_event)
DBUG_ENTER("MYSQL_LOG::write(THD *, IO_CACHE *, Log_event *)");
VOID(pthread_mutex_lock(&LOCK_log));
+ /* NULL would represent nothing to replicate after ROLLBACK */
+ DBUG_ASSERT(commit_event != NULL);
+
if (likely(is_open())) // Should always be true
{
uint length;