diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2003-08-22 18:43:46 +0300 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2003-08-22 18:43:46 +0300 |
commit | 484a7f61a84912e8506772ae4cbee3880e140b70 (patch) | |
tree | 6116b622fcbb528013b9fec903f0efd6927f75e2 /sql/log.cc | |
parent | bd6347df9318f46f715615e2a33ff9ba2d9dbb59 (diff) | |
parent | f300d40aa74525cd4ef2d434f396d70a253fe211 (diff) | |
download | mariadb-git-484a7f61a84912e8506772ae4cbee3880e140b70.tar.gz |
After merge fixes
mysql-test/r/func_test.result:
Auto merged
mysql-test/r/grant.result:
Auto merged
mysql-test/t/func_test.test:
Auto merged
mysql-test/t/grant.test:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/item_cmpfunc.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/sql/log.cc b/sql/log.cc index 17715620950..6e9fa38c407 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -263,7 +263,8 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, an extension for the binary log files. In this case we write a standard header to it. */ - if (my_b_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) + if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, + BIN_LOG_HEADER_SIZE)) goto err; bytes_written += BIN_LOG_HEADER_SIZE; write_file_name_to_index_file=1; @@ -1061,12 +1062,23 @@ bool MYSQL_LOG::write(Log_event* event_info) bool should_rotate = 0; const char *local_db = event_info->get_db(); #ifdef USING_TRANSACTIONS - IO_CACHE *file = ((event_info->get_cache_stmt()) ? + /* + Should we write to the binlog cache or to the binlog on disk? + Write to the binlog cache if: + - it is already not empty (meaning we're in a transaction; note that the + present event could be about a non-transactional table, but still we need + to write to the binlog cache in that case to handle updates to mixed + trans/non-trans table types the best possible in binlogging) + - or if the event asks for it (cache_stmt == true). + */ + IO_CACHE *file = ((event_info->get_cache_stmt() || + my_b_tell(&thd->transaction.trans_log)) ? &thd->transaction.trans_log : &log_file); #else IO_CACHE *file = &log_file; #endif + DBUG_PRINT("info",("event type=%d",event_info->get_type_code())); /* In the future we need to add to the following if tests like "do the involved tables match (to be implemented) @@ -1256,6 +1268,13 @@ uint MYSQL_LOG::next_file_id() /* Write a cached log entry to the binary log + SYNOPSIS + write() + thd + cache The cache to copy to the binlog + commit_or_rollback If true, will write "COMMIT" in the end, if false will + write "ROLLBACK". + NOTE - We only come here if there is something in the cache. - The thing in the cache is always a complete transaction @@ -1263,10 +1282,13 @@ uint MYSQL_LOG::next_file_id() IMPLEMENTATION - To support transaction over replication, we wrap the transaction - with BEGIN/COMMIT in the binary log. + with BEGIN/COMMIT or BEGIN/ROLLBACK in the binary log. + We want to write a BEGIN/ROLLBACK block when a non-transactional table was + updated in a transaction which was rolled back. This is to ensure that the + same updates are run on the slave. */ -bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) +bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback) { VOID(pthread_mutex_lock(&LOCK_log)); DBUG_ENTER("MYSQL_LOG::write(cache"); @@ -1320,7 +1342,10 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) */ { - Query_log_event qinfo(thd, "COMMIT", 6, TRUE); + Query_log_event qinfo(thd, + commit_or_rollback ? "COMMIT" : "ROLLBACK", + commit_or_rollback ? 6 : 8, + TRUE); qinfo.set_log_pos(this); if (qinfo.write(&log_file) || flush_io_cache(&log_file)) goto err; |