summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2003-07-06 18:01:39 +0200
committerunknown <guilhem@mysql.com>2003-07-06 18:01:39 +0200
commitdfa08e3a8e148da73a8f6d871299a5da1b8130f9 (patch)
tree155964e7db5b390bb1ec5071a59f1279b5f2eeb1 /sql
parentb1b806af09065c5f6a6be26bff8b471333e79ab1 (diff)
parentc22f493a4f4f0d864eb1440a5c9aaf247f446817 (diff)
downloadmariadb-git-dfa08e3a8e148da73a8f6d871299a5da1b8130f9.tar.gz
Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/mysql_src/mysql-4.0 sql/mysql_priv.h: Auto merged sql/slave.h: Auto merged sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc72
-rw-r--r--sql/mysql_priv.h7
-rw-r--r--sql/mysqld.cc30
-rw-r--r--sql/set_var.cc30
-rw-r--r--sql/slave.cc52
-rw-r--r--sql/slave.h1
-rw-r--r--sql/sql_class.h18
-rw-r--r--sql/sql_parse.cc8
8 files changed, 184 insertions, 34 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 99bc6ee32b4..ef7cdd0dbd5 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -133,11 +133,15 @@ int MYSQL_LOG::generate_new_name(char *new_name, const char *log_name)
void MYSQL_LOG::init(enum_log_type log_type_arg,
enum cache_type io_cache_type_arg,
- bool no_auto_events_arg)
+ bool no_auto_events_arg,
+ ulong max_size_arg)
{
+ DBUG_ENTER("MYSQL_LOG::init");
log_type = log_type_arg;
io_cache_type = io_cache_type_arg;
no_auto_events = no_auto_events_arg;
+ max_size=max_size_arg;
+ DBUG_PRINT("info",("log_type=%d max_size=%lu", log_type, max_size));
if (!inited)
{
inited= 1;
@@ -145,6 +149,7 @@ void MYSQL_LOG::init(enum_log_type log_type_arg,
(void) pthread_mutex_init(&LOCK_index, MY_MUTEX_INIT_SLOW);
(void) pthread_cond_init(&update_cond, 0);
}
+ DBUG_VOID_RETURN;
}
@@ -165,7 +170,8 @@ void MYSQL_LOG::init(enum_log_type log_type_arg,
bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
const char *new_name, const char *index_file_name_arg,
enum cache_type io_cache_type_arg,
- bool no_auto_events_arg)
+ bool no_auto_events_arg,
+ ulong max_size)
{
char buff[512];
File file= -1, index_file_nr= -1;
@@ -178,7 +184,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
if (!inited && log_type_arg == LOG_BIN && *fn_ext(log_name))
no_rotate = 1;
- init(log_type_arg,io_cache_type_arg,no_auto_events_arg);
+ init(log_type_arg,io_cache_type_arg,no_auto_events_arg,max_size);
if (!(name=my_strdup(log_name,MYF(MY_WME))))
goto err;
@@ -577,7 +583,7 @@ bool MYSQL_LOG::reset_logs(THD* thd)
if (!thd->slave_thread)
need_start_event=1;
open(save_name, save_log_type, 0, index_file_name,
- io_cache_type, no_auto_events);
+ io_cache_type, no_auto_events, max_size);
my_free((gptr) save_name, MYF(0));
err:
@@ -802,8 +808,12 @@ void MYSQL_LOG::new_file(bool need_lock)
char new_name[FN_REFLEN], *new_name_ptr, *old_name;
enum_log_type save_log_type;
+ DBUG_ENTER("MYSQL_LOG::new_file");
if (!is_open())
- return; // Should never happen
+ {
+ DBUG_PRINT("info",("log is closed"));
+ DBUG_VOID_RETURN;
+ }
if (need_lock)
{
@@ -865,8 +875,16 @@ void MYSQL_LOG::new_file(bool need_lock)
save_log_type=log_type;
name=0; // Don't free name
close();
+/*
+ if (save_log_type == LOG_BIN)
+ {
+ printf("after close, before open; I wait for 20 seconds\n");
+ sleep(20);
+ printf("sleep finished, opening\n");
+ }
+*/
open(old_name, save_log_type, new_name_ptr, index_file_name, io_cache_type,
- no_auto_events);
+ no_auto_events, max_size);
my_free(old_name,MYF(0));
end:
@@ -875,6 +893,7 @@ end:
pthread_mutex_unlock(&LOCK_index);
pthread_mutex_unlock(&LOCK_log);
}
+ DBUG_VOID_RETURN;
}
@@ -882,7 +901,8 @@ bool MYSQL_LOG::append(Log_event* ev)
{
bool error = 0;
pthread_mutex_lock(&LOCK_log);
-
+ DBUG_ENTER("MYSQL_LOG::append");
+
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
/*
Log_event::write() is smart enough to use my_b_write() or
@@ -894,7 +914,8 @@ bool MYSQL_LOG::append(Log_event* ev)
goto err;
}
bytes_written += ev->get_event_len();
- if ((uint) my_b_append_tell(&log_file) > max_binlog_size)
+ DBUG_PRINT("info",("max_size=%lu",max_size));
+ if ((uint) my_b_append_tell(&log_file) > max_size)
{
pthread_mutex_lock(&LOCK_index);
new_file(0);
@@ -904,13 +925,14 @@ bool MYSQL_LOG::append(Log_event* ev)
err:
pthread_mutex_unlock(&LOCK_log);
signal_update(); // Safe as we don't call close
- return error;
+ DBUG_RETURN(error);
}
bool MYSQL_LOG::appendv(const char* buf, uint len,...)
{
bool error= 0;
+ DBUG_ENTER("MYSQL_LOG::appendv");
va_list(args);
va_start(args,len);
@@ -926,8 +948,8 @@ bool MYSQL_LOG::appendv(const char* buf, uint len,...)
}
bytes_written += len;
} while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint)));
-
- if ((uint) my_b_append_tell(&log_file) > max_binlog_size)
+ DBUG_PRINT("info",("max_size=%lu",max_size));
+ if ((uint) my_b_append_tell(&log_file) > max_size)
{
pthread_mutex_lock(&LOCK_index);
new_file(0);
@@ -938,7 +960,7 @@ err:
pthread_mutex_unlock(&LOCK_log);
if (!error)
signal_update();
- return error;
+ DBUG_RETURN(error);
}
@@ -1188,8 +1210,9 @@ bool MYSQL_LOG::write(Log_event* event_info)
called_handler_commit=1;
}
}
- /* we wrote to the real log, check automatic rotation */
- should_rotate= (my_b_tell(file) >= (my_off_t) max_binlog_size);
+ /* We wrote to the real log, check automatic rotation; */
+ DBUG_PRINT("info",("max_size=%lu",max_size));
+ should_rotate= (my_b_tell(file) >= (my_off_t) max_size);
}
error=0;
@@ -1319,7 +1342,8 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
log_file.pos_in_file)))
goto err;
signal_update();
- if (my_b_tell(&log_file) >= (my_off_t) max_binlog_size)
+ DBUG_PRINT("info",("max_size=%lu",max_size));
+ if (my_b_tell(&log_file) >= (my_off_t) max_size)
{
pthread_mutex_lock(&LOCK_index);
new_file(0); // inside mutex
@@ -1563,6 +1587,24 @@ void MYSQL_LOG::close(bool exiting)
DBUG_VOID_RETURN;
}
+void MYSQL_LOG::set_max_size(ulong max_size_arg)
+{
+ /*
+ We need to take locks, otherwise this may happen:
+ new_file() is called, calls open(old_max_size), then before open() starts,
+ set_max_size() sets max_size to max_size_arg, then open() starts and
+ uses the old_max_size argument, so max_size_arg has been overwritten and
+ it's like if the SET command was never run.
+ */
+ if (is_open())
+ {
+ pthread_mutex_lock(&LOCK_log);
+ pthread_mutex_lock(&LOCK_index);
+ max_size= max_size_arg;
+ pthread_mutex_unlock(&LOCK_index);
+ pthread_mutex_unlock(&LOCK_log);
+ }
+}
/*
Check if a string is a valid number
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index ce23abb6b2c..0a4728ef325 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -618,8 +618,8 @@ bool fn_format_relative_to_data_home(my_string to, const char *name,
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
- enum_log_type type, bool read_append = 0,
- bool no_auto_events = 0);
+ enum_log_type type, bool read_append,
+ bool no_auto_events, ulong max_size);
/* mysqld.cc */
void clear_error_message(THD *thd);
@@ -666,7 +666,8 @@ extern ulong max_insert_delayed_threads, max_user_connections;
extern ulong long_query_count, what_to_log,flush_time,opt_sql_mode;
extern ulong query_buff_size, thread_stack,thread_stack_min;
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
-extern ulong max_binlog_size, rpl_recovery_rank, thread_cache_size;
+extern ulong max_binlog_size, max_relay_log_size;
+extern ulong rpl_recovery_rank, thread_cache_size;
extern ulong com_stat[(uint) SQLCOM_END], com_other, back_log;
extern ulong specialflag, current_pid;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4f6f55bce0b..c45b3184f16 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -354,7 +354,7 @@ ulong table_cache_size,
query_buff_size,
slow_launch_time = 2L,
slave_open_temp_tables=0,
- open_files_limit=0, max_binlog_size;
+ open_files_limit=0, max_binlog_size, max_relay_log_size;
ulong com_stat[(uint) SQLCOM_END], com_other;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
@@ -1950,7 +1950,7 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
const char *index_file_name,
enum_log_type type, bool read_append,
- bool no_auto_events)
+ bool no_auto_events, ulong max_size)
{
char tmp[FN_REFLEN];
if (!opt_name || !opt_name[0])
@@ -1976,7 +1976,7 @@ bool open_log(MYSQL_LOG *log, const char *hostname,
}
return log->open(opt_name, type, 0, index_file_name,
(read_append) ? SEQ_READ_APPEND : WRITE_CACHE,
- no_auto_events);
+ no_auto_events, max_size);
}
@@ -2196,17 +2196,17 @@ int main(int argc, char **argv)
/* Setup log files */
if (opt_log)
open_log(&mysql_log, glob_hostname, opt_logname, ".log", NullS,
- LOG_NORMAL);
+ LOG_NORMAL, 0, 0, 0);
if (opt_update_log)
{
open_log(&mysql_update_log, glob_hostname, opt_update_logname, "",
- NullS, LOG_NEW);
+ NullS, LOG_NEW, 0, 0, 0);
using_update_log=1;
}
if (opt_slow_log)
open_log(&mysql_slow_log, glob_hostname, opt_slow_logname, "-slow.log",
- NullS, LOG_NORMAL);
+ NullS, LOG_NORMAL, 0, 0, 0);
if (opt_error_log)
{
@@ -2321,7 +2321,7 @@ The server will not act as a slave.");
if (opt_bin_log)
{
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
- opt_binlog_index_name,LOG_BIN);
+ opt_binlog_index_name, LOG_BIN, 0, 0, max_binlog_size);
using_update_log=1;
}
else if (opt_log_slave_updates)
@@ -3156,8 +3156,8 @@ enum options {
OPT_MAX_BINLOG_CACHE_SIZE, OPT_MAX_BINLOG_SIZE,
OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
OPT_MAX_DELAYED_THREADS, OPT_MAX_HEP_TABLE_SIZE,
- OPT_MAX_JOIN_SIZE, OPT_MAX_SORT_LENGTH, OPT_MAX_SEEKS_FOR_KEY,
- OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
+ OPT_MAX_JOIN_SIZE, OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH,
+ OPT_MAX_SEEKS_FOR_KEY, OPT_MAX_TMP_TABLES, OPT_MAX_USER_CONNECTIONS,
OPT_MAX_WRITE_LOCK_COUNT, OPT_BULK_INSERT_BUFFER_SIZE,
OPT_MYISAM_BLOCK_SIZE, OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
@@ -3809,9 +3809,11 @@ replicating a LOAD DATA INFILE command",
(gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0,
GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0},
{"max_binlog_size", OPT_MAX_BINLOG_SIZE,
- "Binary log will be rotated automatically when the size crosses the limit.",
+ "Binary log will be rotated automatically when the size exceeds this \
+value. Will also apply to relay logs if max_relay_log_size is 0. \
+The minimum value for this variable is 4096.",
(gptr*) &max_binlog_size, (gptr*) &max_binlog_size, 0, GET_ULONG,
- REQUIRED_ARG, 1024*1024L*1024L, 1024, 1024*1024L*1024L, 0, 1, 0},
+ REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0},
{"max_connections", OPT_MAX_CONNECTIONS,
"The number of simultaneous clients allowed.", (gptr*) &max_connections,
(gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
@@ -3834,6 +3836,12 @@ replicating a LOAD DATA INFILE command",
(gptr*) &global_system_variables.max_join_size,
(gptr*) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG,
~0L, 1, ~0L, 0, 1, 0},
+ {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE,
+ "If non-zero: relay log will be rotated automatically when the size exceeds \
+this value; if zero (the default): when the size exceeds max_binlog_size. \
+0 expected, the minimum value for this variable is 4096.",
+ (gptr*) &max_relay_log_size, (gptr*) &max_relay_log_size, 0, GET_ULONG,
+ REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0},
{ "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY,
"Limit assumed max number of seeks when looking up rows based on a key",
(gptr*) &global_system_variables.max_seeks_for_key,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index b66c410c6d5..b3238d1c0ec 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -84,6 +84,8 @@ static void fix_query_cache_size(THD *thd, enum_var_type type);
static void fix_key_buffer_size(THD *thd, enum_var_type type);
static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
+static void fix_max_binlog_size(THD *thd, enum_var_type type);
+static void fix_max_relay_log_size(THD *thd, enum_var_type type);
/*
Variable definition list
@@ -142,7 +144,8 @@ sys_var_thd_ulong sys_max_allowed_packet("max_allowed_packet",
sys_var_long_ptr sys_max_binlog_cache_size("max_binlog_cache_size",
&max_binlog_cache_size);
sys_var_long_ptr sys_max_binlog_size("max_binlog_size",
- &max_binlog_size);
+ &max_binlog_size,
+ fix_max_binlog_size);
sys_var_long_ptr sys_max_connections("max_connections",
&max_connections);
sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
@@ -161,6 +164,9 @@ sys_var_thd_ha_rows sys_sql_max_join_size("sql_max_join_size",
&SV::max_join_size,
fix_max_join_size);
#endif
+sys_var_long_ptr sys_max_relay_log_size("max_relay_log_size",
+ &max_relay_log_size,
+ fix_max_relay_log_size);
sys_var_thd_ulong sys_max_sort_length("max_sort_length",
&SV::max_sort_length);
sys_var_long_ptr sys_max_user_connections("max_user_connections",
@@ -350,6 +356,7 @@ sys_var *sys_variables[]=
&sys_max_delayed_threads,
&sys_max_heap_table_size,
&sys_max_join_size,
+ &sys_max_relay_log_size,
&sys_max_seeks_for_key,
&sys_max_sort_length,
&sys_max_tmp_tables,
@@ -495,6 +502,7 @@ struct show_var_st init_vars[]= {
{sys_max_delayed_threads.name,(char*) &sys_max_delayed_threads, SHOW_SYS},
{sys_max_heap_table_size.name,(char*) &sys_max_heap_table_size, SHOW_SYS},
{sys_max_join_size.name, (char*) &sys_max_join_size, SHOW_SYS},
+ {sys_max_relay_log_size.name, (char*) &sys_max_relay_log_size, SHOW_SYS},
{sys_max_seeks_for_key.name, (char*) &sys_max_seeks_for_key, SHOW_SYS},
{sys_max_sort_length.name, (char*) &sys_max_sort_length, SHOW_SYS},
{sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
@@ -697,6 +705,26 @@ void fix_delay_key_write(THD *thd, enum_var_type type)
}
}
+void fix_max_binlog_size(THD *thd, enum_var_type type)
+{
+ DBUG_ENTER("fix_max_binlog_size");
+ DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
+ max_binlog_size, max_relay_log_size));
+ mysql_bin_log.set_max_size(max_binlog_size);
+ if (!max_relay_log_size)
+ active_mi->rli.relay_log.set_max_size(max_binlog_size);
+ DBUG_VOID_RETURN;
+}
+
+void fix_max_relay_log_size(THD *thd, enum_var_type type)
+{
+ DBUG_ENTER("fix_max_relay_log_size");
+ DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
+ max_binlog_size, max_relay_log_size));
+ active_mi->rli.relay_log.set_max_size(max_relay_log_size ?
+ max_relay_log_size: max_binlog_size);
+ DBUG_VOID_RETURN;
+}
bool sys_var_long_ptr::update(THD *thd, set_var *var)
{
diff --git a/sql/slave.cc b/sql/slave.cc
index aa9dd14b1c7..f004ed538b0 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1235,7 +1235,17 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
if (open_log(&rli->relay_log, glob_hostname, opt_relay_logname,
"-relay-bin", opt_relaylog_index_name,
LOG_BIN, 1 /* read_append cache */,
- 1 /* no auto events */))
+ 1 /* no auto events */,
+ /*
+ For the maximum size, we choose max_relay_log_size if it is
+ non-zero, max_binlog_size otherwise. If later the user does SET
+ GLOBAL on one of these variables, fix_max_binlog_size and
+ fix_max_relay_log_size will reconsider the choice (for example
+ if the user changes max_relay_log_size to zero, we have to
+ switch to using max_binlog_size for the relay log) and update
+ rli->relay_log.max_size (and mysql_bin_log.max_size).
+ */
+ max_relay_log_size ? max_relay_log_size : max_binlog_size))
{
sql_print_error("Failed in open_log() called from init_relay_log_info()");
DBUG_RETURN(1);
@@ -3421,6 +3431,46 @@ err:
DBUG_RETURN(0);
}
+/*
+ Rotate a relay log (this is used only by FLUSH LOGS; the automatic rotation
+ because of size is simpler because when we do it we already have all relevant
+ locks; here we don't, so this function is mainly taking locks).
+ Returns nothing as we cannot catch any error (MYSQL_LOG::new_file() is void).
+*/
+
+void rotate_relay_log(MASTER_INFO* mi)
+{
+ DBUG_ENTER("rotate_relay_log");
+ RELAY_LOG_INFO* rli= &mi->rli;
+ /* If this server is not a slave (or RESET SLAVE has just been run) */
+ if (!rli->inited)
+ {
+ DBUG_PRINT("info", ("rli->inited=0"));
+ DBUG_VOID_RETURN;
+ }
+ lock_slave_threads(mi);
+ pthread_mutex_lock(&rli->data_lock);
+ /* If the relay log is closed, new_file() will do nothing. */
+ rli->relay_log.new_file(1);
+ /*
+ We harvest now, because otherwise BIN_LOG_HEADER_SIZE will not immediately
+ be counted, so imagine a succession of FLUSH LOGS and assume the slave
+ threads are started:
+ relay_log_space decreases by the size of the deleted relay log, but does not
+ increase, so flush-after-flush we may become negative, which is wrong.
+ Even if this will be corrected as soon as a query is replicated on the slave
+ (because the I/O thread will then call harvest_bytes_written() which will
+ harvest all these BIN_LOG_HEADER_SIZE we forgot), it may give strange output
+ in SHOW SLAVE STATUS meanwhile. So we harvest now.
+ If the log is closed, then this will just harvest the last writes, probably
+ 0 as they probably have been harvested.
+ */
+ rli->relay_log.harvest_bytes_written(&rli->log_space_total);
+ pthread_mutex_unlock(&rli->data_lock);
+ unlock_slave_threads(mi);
+ DBUG_VOID_RETURN;
+}
+
#ifdef __GNUC__
template class I_List_iterator<i_string>;
diff --git a/sql/slave.h b/sql/slave.h
index cae8c6ae241..842ddca75f4 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -402,6 +402,7 @@ int init_relay_log_pos(RELAY_LOG_INFO* rli,const char* log,ulonglong pos,
int purge_relay_logs(RELAY_LOG_INFO* rli, THD *thd, bool just_reset,
const char** errmsg);
+void rotate_relay_log(MASTER_INFO* mi);
extern "C" pthread_handler_decl(handle_slave_io,arg);
extern "C" pthread_handler_decl(handle_slave_sql,arg);
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d1b2ef82ccb..71b943b5d26 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -84,6 +84,17 @@ class MYSQL_LOG {
bool no_rotate;
bool need_start_event;
bool no_auto_events; // for relay binlog
+ /*
+ The max size before rotation (usable only if log_type == LOG_BIN: binary
+ logs and relay logs).
+ For a binlog, max_size should be max_binlog_size.
+ For a relay log, it should be max_relay_log_size if this is non-zero,
+ max_binlog_size otherwise.
+ max_size is set in init(), and dynamically changed (when one does SET
+ GLOBAL MAX_BINLOG_SIZE|MAX_RELAY_LOG_SIZE) by fix_max_binlog_size and
+ fix_max_relay_log_size).
+ */
+ ulong max_size;
friend class Log_event;
public:
@@ -105,17 +116,18 @@ public:
bytes_written=0;
DBUG_VOID_RETURN;
}
+ void set_max_size(ulong max_size_arg);
void signal_update() { pthread_cond_broadcast(&update_cond);}
void wait_for_update(THD* thd);
void set_need_start_event() { need_start_event = 1; }
void init(enum_log_type log_type_arg,
- enum cache_type io_cache_type_arg = WRITE_CACHE,
- bool no_auto_events_arg = 0);
+ enum cache_type io_cache_type_arg,
+ bool no_auto_events_arg, ulong max_size);
void cleanup();
bool open(const char *log_name,enum_log_type log_type,
const char *new_name, const char *index_file_name_arg,
enum cache_type io_cache_type_arg,
- bool no_auto_events_arg);
+ bool no_auto_events_arg, ulong max_size);
void new_file(bool need_lock= 1);
bool write(THD *thd, enum enum_server_command command,
const char *format,...);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 625957027af..4db802ffbcc 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3574,10 +3574,18 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
}
if (options & REFRESH_LOG)
{
+ /*
+ Flush the normal query log, the update log, the binary log, the slow query
+ log, and the relay log (if it exists).
+ */
mysql_log.new_file(1);
mysql_update_log.new_file(1);
mysql_bin_log.new_file(1);
mysql_slow_log.new_file(1);
+ LOCK_ACTIVE_MI;
+ rotate_relay_log(active_mi);
+ UNLOCK_ACTIVE_MI;
+
if (ha_flush_logs())
result=1;
if (flush_error_log())