Commit c1a60342 authored by guilhem@mysql.com's avatar guilhem@mysql.com

-- already approved; it would be nice if it goes into 3.23.57 --

Fix for bug 254 : the first Start_log_event after server startup will
have created=now(), whereas the next ones (FLUSH LOGS, auto rotation)
will have created=0. Before this, it was always now().
This way, slaves >=4.0.14 will know when they must
drop stale temp tables or not. The next task is now modify 4.0.14 to
implement this.
parent de0a3d30
...@@ -157,7 +157,7 @@ void MYSQL_LOG::close_index() ...@@ -157,7 +157,7 @@ void MYSQL_LOG::close_index()
} }
void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
const char *new_name) const char *new_name, bool null_created)
{ {
MY_STAT tmp_stat; MY_STAT tmp_stat;
char buff[512]; char buff[512];
...@@ -230,8 +230,10 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, ...@@ -230,8 +230,10 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
if ((do_magic && my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4)) || if ((do_magic && my_b_write(&log_file, (byte*) BINLOG_MAGIC, 4)) ||
open_index(O_APPEND | O_RDWR | O_CREAT)) open_index(O_APPEND | O_RDWR | O_CREAT))
goto err; goto err;
Start_log_event s;
bool error; bool error;
Start_log_event s;
if (null_created)
s.created= 0;
s.write(&log_file); s.write(&log_file);
flush_io_cache(&log_file); flush_io_cache(&log_file);
pthread_mutex_lock(&LOCK_index); pthread_mutex_lock(&LOCK_index);
...@@ -548,7 +550,15 @@ void MYSQL_LOG::new_file(bool inside_mutex) ...@@ -548,7 +550,15 @@ void MYSQL_LOG::new_file(bool inside_mutex)
strmov(new_name, old_name); // Reopen old file name strmov(new_name, old_name); // Reopen old file name
name=0; name=0;
close(); close();
open(old_name, log_type, new_name); /*
new_file() is only used for rotation (in FLUSH LOGS or because size >
max_binlog_size).
If this is a binary log, the Start_log_event at the beginning of
the new file should have created=0 (to distinguish with the Start_log_event
written at server startup, which should trigger temp tables deletion on
>=4.0.14 slaves).
*/
open(old_name, log_type, new_name, 1);
my_free(old_name,MYF(0)); my_free(old_name,MYF(0));
last_time=query_start=0; last_time=query_start=0;
write_error=0; write_error=0;
......
...@@ -327,6 +327,15 @@ extern char server_version[SERVER_VERSION_LENGTH]; ...@@ -327,6 +327,15 @@ extern char server_version[SERVER_VERSION_LENGTH];
class Start_log_event: public Log_event class Start_log_event: public Log_event
{ {
public: public:
/*
If this event is at the start of the first binary log since server startup
'created' should be the timestamp when the event (and the binary log) was
created.
In the other case (i.e. this event is at the start of a binary log created
by FLUSH LOGS or automatic rotation), 'created' should be 0.
This "trick" is used by MySQL >=4.0.14 slaves to know if they must drop the
stale temporary tables or not.
*/
time_t created; time_t created;
uint16 binlog_version; uint16 binlog_version;
char server_version[50]; char server_version[50];
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
void set_index_file_name(const char* index_file_name = 0); void set_index_file_name(const char* index_file_name = 0);
void init(enum_log_type log_type_arg); void init(enum_log_type log_type_arg);
void open(const char *log_name,enum_log_type log_type, void open(const char *log_name,enum_log_type log_type,
const char *new_name=0); const char *new_name=0, bool null_created= 0);
void new_file(bool inside_mutex = 0); void new_file(bool inside_mutex = 0);
bool open_index(int options); bool open_index(int options);
void close_index(); void close_index();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment