summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-01-24 09:15:34 -0700
committerunknown <sasha@mysql.sashanet.com>2001-01-24 09:15:34 -0700
commit262a9e41e164b1ddbb1763622bf5617d3685f74a (patch)
tree389b1cade6be60d713c322e9f923adb3578a60d6 /sql/log.cc
parent32250dfcedc1aad01da5ba7658fed1398737bedd (diff)
downloadmariadb-git-262a9e41e164b1ddbb1763622bf5617d3685f74a.tar.gz
Added last_errno and last_error to show slave status
slave will skip the first SQL_SLAVE_SKIP_COUNTER events on start - this is needed to recover from broken replication when the next log event(s) should just be skipped. Rotate binlogs when max_binlog_size is reached include/my_sys.h: added my_snprintf() include/mysqld_error.h: more error messages mysql-test/r/rpl000014.result: updated results for new SHOW SLAVE STATUS format mysql-test/r/rpl000015.result: update for SHOW SLAVE STATUS mysql-test/r/rpl000016.result: update for additions to the test mysql-test/t/rpl000016.test: test max_binlog_size and slave_skip_counter mysys/my_vsnprintf.c: added my_snprintf() sql/gen_lex_hash.cc: old values could not do it sql/lex.h: updates for SQL_SLAVE_SKIP_COUNTER sql/log.cc: rotate binlogs when max_binlog_size is reached sql/mysqld.cc: added max_binlog_size sql/share/czech/errmsg.txt: new errors sql/share/danish/errmsg.txt: new errors sql/share/dutch/errmsg.txt: new errors sql/share/english/errmsg.txt: new errors sql/share/estonian/errmsg.txt: new errors sql/share/french/errmsg.txt: new errors sql/share/german/errmsg.txt: new errors sql/share/greek/errmsg.txt: new errors sql/share/hungarian/errmsg.txt: new errors sql/share/italian/errmsg.txt: new errors sql/share/japanese/errmsg.txt: new errors sql/share/korean/errmsg.txt: new errors sql/share/norwegian-ny/errmsg.txt: new errors sql/share/norwegian/errmsg.txt: new errors sql/share/polish/errmsg.txt: new errors sql/share/portuguese/errmsg.txt: new errors sql/share/romanian/errmsg.txt: new errors sql/share/russian/errmsg.txt: new errors, translated untranslated messages sql/share/slovak/errmsg.txt: new errors sql/share/spanish/errmsg.txt: new errors sql/share/swedish/errmsg.txt: new errors sql/slave.cc: updates for slave_skip_counter and extension to show slave status sql/slave.h: slave_skip_counter sql/sql_repl.cc: use error messages from errmsg.txt sql/sql_yacc.yy: skip_slave_counter
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 5ce9a7a4deb..80001acacd2 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -28,6 +28,7 @@
MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
extern I_List<i_string> binlog_do_db, binlog_ignore_db;
+extern ulong max_binlog_size;
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
@@ -609,6 +610,8 @@ bool MYSQL_LOG::write(Query_log_event* event_info)
{
/* In most cases this is only called if 'is_open()' is true */
bool error=0;
+ bool should_rotate = 0;
+
if (!inited) // Can't use mutex if not init
return 0;
VOID(pthread_mutex_lock(&LOCK_log));
@@ -655,7 +658,7 @@ bool MYSQL_LOG::write(Query_log_event* event_info)
file == &log_file && flush_io_cache(file))
goto err;
error=0;
-
+ should_rotate = (file == &log_file && my_b_tell(file) >= max_binlog_size);
err:
if (error)
{
@@ -669,6 +672,8 @@ err:
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
VOID(pthread_mutex_unlock(&LOCK_log));
+ if(should_rotate)
+ new_file();
return error;
}
@@ -682,6 +687,7 @@ bool MYSQL_LOG::write(IO_CACHE *cache)
{
VOID(pthread_mutex_lock(&LOCK_log));
bool error=1;
+
if (is_open())
{
uint length;
@@ -722,7 +728,8 @@ err:
else
VOID(pthread_cond_broadcast(&COND_binlog_update));
- VOID(pthread_mutex_unlock(&LOCK_log));
+ VOID(pthread_mutex_unlock(&LOCK_log));
+
return error;
}
@@ -730,6 +737,8 @@ err:
bool MYSQL_LOG::write(Load_log_event* event_info)
{
bool error=0;
+ bool should_rotate = 0;
+
if (inited)
{
VOID(pthread_mutex_lock(&LOCK_log));
@@ -745,11 +754,16 @@ bool MYSQL_LOG::write(Load_log_event* event_info)
sql_print_error(ER(ER_ERROR_ON_WRITE), name, errno);
error=write_error=1;
}
+ should_rotate = (my_b_tell(&log_file) >= max_binlog_size);
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
}
VOID(pthread_mutex_unlock(&LOCK_log));
}
+
+ if(should_rotate)
+ new_file();
+
return error;
}