Commit 3593bb4f authored by unknown's avatar unknown

Fixed problem that Start_log_event_v3::created was not set properly

(This is becasue 'when' is not anymore set in constructor)


client/mysqlbinlog.cc:
  strcpy -> strmov
sql/log.cc:
  Added flag dont_set_created
sql/log_event.cc:
  Moved time handling to inline function.
  Moved setting of 'created' to ::write() function.
  Added flag dont_set_created to define if 'created' should be set or not.
  This was needed as 'when' is not set in Log_event() anymore.
  Fixed some missed thd -> thd_arg
sql/log_event.h:
  Indentation fixed
  Added inline get_time() function.
  Added dont_set_created flag to Start_log_event_v3
parent c5f0611f
...@@ -1030,14 +1030,14 @@ static int dump_log_entries(const char* logname) ...@@ -1030,14 +1030,14 @@ static int dump_log_entries(const char* logname)
like CREATE PROCEDURE safely like CREATE PROCEDURE safely
*/ */
fprintf(result_file, "DELIMITER /*!*/;\n"); fprintf(result_file, "DELIMITER /*!*/;\n");
strcpy(print_event_info.delimiter, "/*!*/;"); strmov(print_event_info.delimiter, "/*!*/;");
rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) : rc= (remote_opt ? dump_remote_log_entries(&print_event_info, logname) :
dump_local_log_entries(&print_event_info, logname)); dump_local_log_entries(&print_event_info, logname));
/* Set delimiter back to semicolon */ /* Set delimiter back to semicolon */
fprintf(result_file, "DELIMITER ;\n"); fprintf(result_file, "DELIMITER ;\n");
strcpy(print_event_info.delimiter, ";"); strmov(print_event_info.delimiter, ";");
return rc; return rc;
} }
......
...@@ -2346,8 +2346,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, ...@@ -2346,8 +2346,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name,
s.flags|= LOG_EVENT_BINLOG_IN_USE_F; s.flags|= LOG_EVENT_BINLOG_IN_USE_F;
if (!s.is_valid()) if (!s.is_valid())
goto err; goto err;
if (null_created_arg) s.dont_set_created= null_created_arg;
s.created= 0;
if (s.write(&log_file)) if (s.write(&log_file))
goto err; goto err;
bytes_written+= s.data_written; bytes_written+= s.data_written;
......
...@@ -692,13 +692,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) ...@@ -692,13 +692,7 @@ bool Log_event::write_header(IO_CACHE* file, ulong event_data_length)
log_pos= my_b_safe_tell(file)+data_written; log_pos= my_b_safe_tell(file)+data_written;
} }
/* Set time of we this isn't a query */ now= get_time(); // Query start time
if (!(now= (ulong) when))
{
THD *thd= current_thd;
/* thd will only be 0 here at time of log creation */
now= thd ? thd->start_time : my_time(0);
}
/* /*
Header will be of size LOG_EVENT_HEADER_LEN for all events, except for Header will be of size LOG_EVENT_HEADER_LEN for all events, except for
...@@ -816,10 +810,12 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, ...@@ -816,10 +810,12 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Log_event* Log_event::read_log_event(IO_CACHE* file, Log_event* Log_event::read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock, pthread_mutex_t* log_lock,
const Format_description_log_event *description_event) const Format_description_log_event
*description_event)
#else #else
Log_event* Log_event::read_log_event(IO_CACHE* file, Log_event* Log_event::read_log_event(IO_CACHE* file,
const Format_description_log_event *description_event) const Format_description_log_event
*description_event)
#endif #endif
{ {
DBUG_ENTER("Log_event::read_log_event"); DBUG_ENTER("Log_event::read_log_event");
...@@ -1474,7 +1470,7 @@ Query_log_event::Query_log_event() ...@@ -1474,7 +1470,7 @@ Query_log_event::Query_log_event()
/* /*
SYNOPSIS SYNOPSIS
Query_log_event::Query_log_event() Query_log_event::Query_log_event()
thd - thread handle thd_arg - thread handle
query_arg - array of char representing the query query_arg - array of char representing the query
query_length - size of the `query_arg' array query_length - size of the `query_arg' array
using_trans - there is a modified transactional table using_trans - there is a modified transactional table
...@@ -1490,9 +1486,11 @@ Query_log_event::Query_log_event() ...@@ -1490,9 +1486,11 @@ Query_log_event::Query_log_event()
*/ */
Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
ulong query_length, bool using_trans, ulong query_length, bool using_trans,
bool suppress_use, THD::killed_state killed_status_arg) bool suppress_use,
THD::killed_state killed_status_arg)
:Log_event(thd_arg, :Log_event(thd_arg,
(thd_arg->thread_specific_used ? LOG_EVENT_THREAD_SPECIFIC_F : 0) | (thd_arg->thread_specific_used ? LOG_EVENT_THREAD_SPECIFIC_F :
0) |
(suppress_use ? LOG_EVENT_SUPPRESS_USE_F : 0), (suppress_use ? LOG_EVENT_SUPPRESS_USE_F : 0),
using_trans), using_trans),
data_buf(0), query(query_arg), catalog(thd_arg->catalog), data_buf(0), query(query_arg), catalog(thd_arg->catalog),
...@@ -1514,10 +1512,10 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -1514,10 +1512,10 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
error_code= error_code=
(killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno : (killed_status_arg == THD::NOT_KILLED) ? thd_arg->net.last_errno :
((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 :
thd->killed_errno()); thd_arg->killed_errno());
time(&end_time); time(&end_time);
exec_time = (ulong) (end_time - thd->start_time); exec_time = (ulong) (end_time - thd_arg->start_time);
catalog_len = (catalog) ? (uint32) strlen(catalog) : 0; catalog_len = (catalog) ? (uint32) strlen(catalog) : 0;
/* status_vars_len is set just before writing the event */ /* status_vars_len is set just before writing the event */
db_len = (db) ? (uint32) strlen(db) : 0; db_len = (db) ? (uint32) strlen(db) : 0;
...@@ -1526,15 +1524,15 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -1526,15 +1524,15 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
/* /*
If we don't use flags2 for anything else than options contained in If we don't use flags2 for anything else than options contained in
thd->options, it would be more efficient to flags2=thd_arg->options thd_arg->options, it would be more efficient to flags2=thd_arg->options
(OPTIONS_WRITTEN_TO_BINLOG would be used only at reading time). (OPTIONS_WRITTEN_TO_BINLOG would be used only at reading time).
But it's likely that we don't want to use 32 bits for 3 bits; in the future But it's likely that we don't want to use 32 bits for 3 bits; in the future
we will probably want to reclaim the 29 bits. So we need the &. we will probably want to reclaim the 29 bits. So we need the &.
*/ */
flags2= (uint32) (thd_arg->options & OPTIONS_WRITTEN_TO_BIN_LOG); flags2= (uint32) (thd_arg->options & OPTIONS_WRITTEN_TO_BIN_LOG);
DBUG_ASSERT(thd->variables.character_set_client->number < 256*256); DBUG_ASSERT(thd_arg->variables.character_set_client->number < 256*256);
DBUG_ASSERT(thd->variables.collation_connection->number < 256*256); DBUG_ASSERT(thd_arg->variables.collation_connection->number < 256*256);
DBUG_ASSERT(thd->variables.collation_server->number < 256*256); DBUG_ASSERT(thd_arg->variables.collation_server->number < 256*256);
int2store(charset, thd_arg->variables.character_set_client->number); int2store(charset, thd_arg->variables.character_set_client->number);
int2store(charset+2, thd_arg->variables.collation_connection->number); int2store(charset+2, thd_arg->variables.collation_connection->number);
int2store(charset+4, thd_arg->variables.collation_server->number); int2store(charset+4, thd_arg->variables.collation_server->number);
...@@ -2260,9 +2258,10 @@ Muted_query_log_event::Muted_query_log_event() ...@@ -2260,9 +2258,10 @@ Muted_query_log_event::Muted_query_log_event()
**************************************************************************/ **************************************************************************/
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Start_log_event_v3::Start_log_event_v3() :Log_event(), binlog_version(BINLOG_VERSION), artificial_event(0) Start_log_event_v3::Start_log_event_v3()
:Log_event(), created(0), binlog_version(BINLOG_VERSION),
artificial_event(0), dont_set_created(0)
{ {
created= when;
memcpy(server_version, ::server_version, ST_SERVER_VER_LEN); memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
} }
#endif #endif
...@@ -2332,7 +2331,8 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info) ...@@ -2332,7 +2331,8 @@ void Start_log_event_v3::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
*/ */
Start_log_event_v3::Start_log_event_v3(const char* buf, Start_log_event_v3::Start_log_event_v3(const char* buf,
const Format_description_log_event* description_event) const Format_description_log_event
*description_event)
:Log_event(buf, description_event) :Log_event(buf, description_event)
{ {
buf+= description_event->common_header_len; buf+= description_event->common_header_len;
...@@ -2344,6 +2344,7 @@ Start_log_event_v3::Start_log_event_v3(const char* buf, ...@@ -2344,6 +2344,7 @@ Start_log_event_v3::Start_log_event_v3(const char* buf,
created= uint4korr(buf+ST_CREATED_OFFSET); created= uint4korr(buf+ST_CREATED_OFFSET);
/* We use log_pos to mark if this was an artificial event or not */ /* We use log_pos to mark if this was an artificial event or not */
artificial_event= (log_pos == 0); artificial_event= (log_pos == 0);
dont_set_created= 1;
} }
...@@ -2357,6 +2358,8 @@ bool Start_log_event_v3::write(IO_CACHE* file) ...@@ -2357,6 +2358,8 @@ bool Start_log_event_v3::write(IO_CACHE* file)
char buff[START_V3_HEADER_LEN]; char buff[START_V3_HEADER_LEN];
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version); int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN); memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
if (!dont_set_created)
created= when= get_time();
int4store(buff + ST_CREATED_OFFSET,created); int4store(buff + ST_CREATED_OFFSET,created);
return (write_header(file, sizeof(buff)) || return (write_header(file, sizeof(buff)) ||
my_b_safe_write(file, (uchar*) buff, sizeof(buff))); my_b_safe_write(file, (uchar*) buff, sizeof(buff)));
...@@ -2387,8 +2390,7 @@ bool Start_log_event_v3::write(IO_CACHE* file) ...@@ -2387,8 +2390,7 @@ bool Start_log_event_v3::write(IO_CACHE* file)
int Start_log_event_v3::do_apply_event(RELAY_LOG_INFO const *rli) int Start_log_event_v3::do_apply_event(RELAY_LOG_INFO const *rli)
{ {
DBUG_ENTER("Start_log_event_v3::do_apply_event"); DBUG_ENTER("Start_log_event_v3::do_apply_event");
switch (binlog_version) switch (binlog_version) {
{
case 3: case 3:
case 4: case 4:
/* /*
...@@ -2459,7 +2461,6 @@ Format_description_log_event:: ...@@ -2459,7 +2461,6 @@ Format_description_log_event::
Format_description_log_event(uint8 binlog_ver, const char* server_ver) Format_description_log_event(uint8 binlog_ver, const char* server_ver)
:Start_log_event_v3() :Start_log_event_v3()
{ {
created= when;
binlog_version= binlog_ver; binlog_version= binlog_ver;
switch (binlog_ver) { switch (binlog_ver) {
case 4: /* MySQL 5.0 */ case 4: /* MySQL 5.0 */
...@@ -2611,6 +2612,8 @@ bool Format_description_log_event::write(IO_CACHE* file) ...@@ -2611,6 +2612,8 @@ bool Format_description_log_event::write(IO_CACHE* file)
uchar buff[FORMAT_DESCRIPTION_HEADER_LEN]; uchar buff[FORMAT_DESCRIPTION_HEADER_LEN];
int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version); int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version);
memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN); memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN);
if (!dont_set_created)
created= when= get_time();
int4store(buff + ST_CREATED_OFFSET,created); int4store(buff + ST_CREATED_OFFSET,created);
buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN; buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN;
memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len, memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len,
...@@ -4917,8 +4920,9 @@ int Create_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli) ...@@ -4917,8 +4920,9 @@ int Create_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
*/ */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Append_block_log_event::Append_block_log_event(THD* thd_arg, const char* db_arg, Append_block_log_event::Append_block_log_event(THD *thd_arg,
char* block_arg, const char *db_arg,
char *block_arg,
uint block_len_arg, uint block_len_arg,
bool using_trans) bool using_trans)
:Log_event(thd_arg,0, using_trans), block(block_arg), :Log_event(thd_arg,0, using_trans), block(block_arg),
...@@ -5167,7 +5171,8 @@ int Delete_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli) ...@@ -5167,7 +5171,8 @@ int Delete_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli)
*/ */
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Execute_load_log_event::Execute_load_log_event(THD *thd_arg, const char* db_arg, Execute_load_log_event::Execute_load_log_event(THD *thd_arg,
const char* db_arg,
bool using_trans) bool using_trans)
:Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg) :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg)
{ {
...@@ -5368,7 +5373,7 @@ int Begin_load_query_log_event::get_create_or_append() const ...@@ -5368,7 +5373,7 @@ int Begin_load_query_log_event::get_create_or_append() const
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Execute_load_query_log_event:: Execute_load_query_log_event::
Execute_load_query_log_event(THD* thd_arg, const char* query_arg, Execute_load_query_log_event(THD *thd_arg, const char* query_arg,
ulong query_length_arg, uint fn_pos_start_arg, ulong query_length_arg, uint fn_pos_start_arg,
uint fn_pos_end_arg, uint fn_pos_end_arg,
enum_load_dup_handling dup_handling_arg, enum_load_dup_handling dup_handling_arg,
...@@ -7108,7 +7113,9 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error) ...@@ -7108,7 +7113,9 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error)
return error? error : local_error; return error? error : local_error;
} }
int Write_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli,
int Write_rows_log_event::do_prepare_row(THD *thd_arg,
RELAY_LOG_INFO const *rli,
TABLE *table, TABLE *table,
uchar const *const row_start, uchar const *const row_start,
uchar const **const row_end) uchar const **const row_end)
...@@ -7382,7 +7389,8 @@ replace_record(THD *thd, TABLE *table, ...@@ -7382,7 +7389,8 @@ replace_record(THD *thd, TABLE *table,
DBUG_RETURN(ENOMEM); DBUG_RETURN(ENOMEM);
} }
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum, 0); key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
0);
error= table->file->index_read_idx_map(table->record[1], keynum, error= table->file->index_read_idx_map(table->record[1], keynum,
(const uchar*)key.get(), (const uchar*)key.get(),
HA_WHOLE_KEY, HA_WHOLE_KEY,
...@@ -7838,7 +7846,8 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error) ...@@ -7838,7 +7846,8 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error)
return error; return error;
} }
int Delete_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, int Delete_rows_log_event::do_prepare_row(THD *thd_arg,
RELAY_LOG_INFO const *rli,
TABLE *table, TABLE *table,
uchar const *const row_start, uchar const *const row_start,
uchar const **const row_end) uchar const **const row_end)
...@@ -8004,7 +8013,10 @@ int Update_rows_log_event::do_before_row_operations(TABLE *table) ...@@ -8004,7 +8013,10 @@ int Update_rows_log_event::do_before_row_operations(TABLE *table)
int Update_rows_log_event::do_after_row_operations(TABLE *table, int error) int Update_rows_log_event::do_after_row_operations(TABLE *table, int error)
{ {
/*error= ToDo:find out what this should really be, this triggers close_scan in nbd, returning error?*/ /*
error= ToDo:find out what this should really be, this triggers
close_scan in nbd, returning error?
*/
table->file->ha_index_or_rnd_end(); table->file->ha_index_or_rnd_end();
my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR)); my_free(m_memory, MYF(MY_ALLOW_ZERO_PTR));
m_memory= NULL; m_memory= NULL;
...@@ -8014,7 +8026,8 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error) ...@@ -8014,7 +8026,8 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error)
return error; return error;
} }
int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rli, int Update_rows_log_event::do_prepare_row(THD *thd_arg,
RELAY_LOG_INFO const *rli,
TABLE *table, TABLE *table,
uchar const *const row_start, uchar const *const row_start,
uchar const **const row_end) uchar const **const row_end)
...@@ -8029,7 +8042,8 @@ int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rl ...@@ -8029,7 +8042,8 @@ int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rl
/* record[0] is the before image for the update */ /* record[0] is the before image for the update */
if ((error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, if ((error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end,
&m_master_reclength, table->read_set, UPDATE_ROWS_EVENT))) &m_master_reclength, table->read_set,
UPDATE_ROWS_EVENT)))
{ {
thd_arg->net.last_errno= error; thd_arg->net.last_errno= error;
return error; return error;
...@@ -8039,7 +8053,8 @@ int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rl ...@@ -8039,7 +8053,8 @@ int Update_rows_log_event::do_prepare_row(THD *thd_arg, RELAY_LOG_INFO const *rl
uchar const *next_start = *row_end; uchar const *next_start = *row_end;
/* m_after_image is the after image for the update */ /* m_after_image is the after image for the update */
if ((error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end, if ((error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end,
&m_master_reclength, table->write_set, UPDATE_ROWS_EVENT))) &m_master_reclength, table->write_set,
UPDATE_ROWS_EVENT)))
{ {
thd_arg->net.last_errno= error; thd_arg->net.last_errno= error;
return error; return error;
...@@ -8225,5 +8240,3 @@ Incident_log_event::write_data_body(IO_CACHE *file) ...@@ -8225,5 +8240,3 @@ Incident_log_event::write_data_body(IO_CACHE *file)
DBUG_ENTER("Incident_log_event::write_data_body"); DBUG_ENTER("Incident_log_event::write_data_body");
DBUG_RETURN(write_str(file, m_message.str, m_message.length)); DBUG_RETURN(write_str(file, m_message.str, m_message.length));
} }
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
which increments every time we write an event to the binlog) (3 bytes). which increments every time we write an event to the binlog) (3 bytes).
Q: how do we handle when the counter is overflowed and restarts from 0 ? Q: how do we handle when the counter is overflowed and restarts from 0 ?
- Query and Load (Create or Execute) events may have a more precise timestamp - Query and Load (Create or Execute) events may have a more precise
(with microseconds), number of matched/affected/warnings rows timestamp (with microseconds), number of matched/affected/warnings rows
and fields of session variables: SQL_MODE, and fields of session variables: SQL_MODE,
FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, SQL_AUTO_IS_NULL, the collations and FOREIGN_KEY_CHECKS, UNIQUE_CHECKS, SQL_AUTO_IS_NULL, the collations and
charsets, the PASSWORD() version (old/new/...). charsets, the PASSWORD() version (old/new/...).
...@@ -708,7 +708,8 @@ class Log_event ...@@ -708,7 +708,8 @@ class Log_event
*/ */
static Log_event* read_log_event(IO_CACHE* file, static Log_event* read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock, pthread_mutex_t* log_lock,
const Format_description_log_event *description_event); const Format_description_log_event
*description_event);
static int read_log_event(IO_CACHE* file, String* packet, static int read_log_event(IO_CACHE* file, String* packet,
pthread_mutex_t* log_lock); pthread_mutex_t* log_lock);
/* /*
...@@ -736,7 +737,8 @@ class Log_event ...@@ -736,7 +737,8 @@ class Log_event
Log_event() : temp_buf(0) {} Log_event() : temp_buf(0) {}
/* avoid having to link mysqlbinlog against libpthread */ /* avoid having to link mysqlbinlog against libpthread */
static Log_event* read_log_event(IO_CACHE* file, static Log_event* read_log_event(IO_CACHE* file,
const Format_description_log_event *description_event); const Format_description_log_event
*description_event);
/* print*() functions are used by mysqlbinlog */ /* print*() functions are used by mysqlbinlog */
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0; virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
void print_timestamp(IO_CACHE* file, time_t *ts = 0); void print_timestamp(IO_CACHE* file, time_t *ts = 0);
...@@ -777,7 +779,8 @@ class Log_event ...@@ -777,7 +779,8 @@ class Log_event
virtual bool is_valid() const = 0; virtual bool is_valid() const = 0;
virtual bool is_artificial_event() { return 0; } virtual bool is_artificial_event() { return 0; }
inline bool get_cache_stmt() const { return cache_stmt; } inline bool get_cache_stmt() const { return cache_stmt; }
Log_event(const char* buf, const Format_description_log_event* description_event); Log_event(const char* buf, const Format_description_log_event
*description_event);
virtual ~Log_event() { free_temp_buf();} virtual ~Log_event() { free_temp_buf();}
void register_temp_buf(char* buf) { temp_buf = buf; } void register_temp_buf(char* buf) { temp_buf = buf; }
void free_temp_buf() void free_temp_buf()
...@@ -800,6 +803,8 @@ class Log_event ...@@ -800,6 +803,8 @@ class Log_event
/* returns the human readable name of the event's type */ /* returns the human readable name of the event's type */
const char* get_type_str(); const char* get_type_str();
/* Return start of query time or current time */
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
public: public:
...@@ -811,7 +816,8 @@ class Log_event ...@@ -811,7 +816,8 @@ class Log_event
@see do_apply_event @see do_apply_event
*/ */
int apply_event(RELAY_LOG_INFO const *rli) { int apply_event(RELAY_LOG_INFO const *rli)
{
return do_apply_event(rli); return do_apply_event(rli);
} }
...@@ -920,6 +926,18 @@ class Log_event ...@@ -920,6 +926,18 @@ class Log_event
*/ */
virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli); virtual enum_skip_reason do_shall_skip(RELAY_LOG_INFO *rli);
inline ulong get_time()
{
THD *tmp_thd;
if (when)
return (ulong) when;
if (thd)
return thd->start_time;
if ((tmp_thd= current_thd))
return tmp_thd->start_time;
return my_time(0);
}
#endif #endif
}; };
...@@ -1151,7 +1169,8 @@ class Load_log_event: public Log_event ...@@ -1151,7 +1169,8 @@ class Load_log_event: public Log_event
char **fn_start, char **fn_end); char **fn_start, char **fn_end);
protected: protected:
int copy_log_event(const char *buf, ulong event_len, int copy_log_event(const char *buf, ulong event_len,
int body_offset, const Format_description_log_event* description_event); int body_offset,
const Format_description_log_event* description_event);
public: public:
ulong thread_id; ulong thread_id;
...@@ -1296,6 +1315,11 @@ class Start_log_event_v3: public Log_event ...@@ -1296,6 +1315,11 @@ class Start_log_event_v3: public Log_event
setting log_event == 0 (for now). setting log_event == 0 (for now).
*/ */
bool artificial_event; bool artificial_event;
/*
We set this to 1 if we don't want to have the created time in the log,
which is the case when we rollover to a new log.
*/
bool dont_set_created;
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Start_log_event_v3(); Start_log_event_v3();
...@@ -1362,7 +1386,8 @@ class Format_description_log_event: public Start_log_event_v3 ...@@ -1362,7 +1386,8 @@ class Format_description_log_event: public Start_log_event_v3
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0); Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
Format_description_log_event(const char* buf, uint event_len, Format_description_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event
*description_event);
~Format_description_log_event() { my_free((uchar*)post_header_len, MYF(0)); } ~Format_description_log_event() { my_free((uchar*)post_header_len, MYF(0)); }
Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;} Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;}
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
...@@ -1420,7 +1445,8 @@ class Intvar_log_event: public Log_event ...@@ -1420,7 +1445,8 @@ class Intvar_log_event: public Log_event
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif #endif
Intvar_log_event(const char* buf, const Format_description_log_event* description_event); Intvar_log_event(const char* buf,
const Format_description_log_event *description_event);
~Intvar_log_event() {} ~Intvar_log_event() {}
Log_event_type get_type_code() { return INTVAR_EVENT;} Log_event_type get_type_code() { return INTVAR_EVENT;}
const char* get_var_type_name(); const char* get_var_type_name();
...@@ -1467,7 +1493,8 @@ class Rand_log_event: public Log_event ...@@ -1467,7 +1493,8 @@ class Rand_log_event: public Log_event
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif #endif
Rand_log_event(const char* buf, const Format_description_log_event* description_event); Rand_log_event(const char* buf,
const Format_description_log_event *description_event);
~Rand_log_event() {} ~Rand_log_event() {}
Log_event_type get_type_code() { return RAND_EVENT;} Log_event_type get_type_code() { return RAND_EVENT;}
int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ } int get_data_size() { return 16; /* sizeof(ulonglong) * 2*/ }
...@@ -1510,7 +1537,8 @@ class Xid_log_event: public Log_event ...@@ -1510,7 +1537,8 @@ class Xid_log_event: public Log_event
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif #endif
Xid_log_event(const char* buf, const Format_description_log_event* description_event); Xid_log_event(const char* buf,
const Format_description_log_event *description_event);
~Xid_log_event() {} ~Xid_log_event() {}
Log_event_type get_type_code() { return XID_EVENT;} Log_event_type get_type_code() { return XID_EVENT;}
int get_data_size() { return sizeof(xid); } int get_data_size() { return sizeof(xid); }
...@@ -1556,7 +1584,8 @@ class User_var_log_event: public Log_event ...@@ -1556,7 +1584,8 @@ class User_var_log_event: public Log_event
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif #endif
User_var_log_event(const char* buf, const Format_description_log_event* description_event); User_var_log_event(const char* buf,
const Format_description_log_event *description_event);
~User_var_log_event() {} ~User_var_log_event() {}
Log_event_type get_type_code() { return USER_VAR_EVENT;} Log_event_type get_type_code() { return USER_VAR_EVENT;}
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
...@@ -1588,7 +1617,8 @@ class Stop_log_event: public Log_event ...@@ -1588,7 +1617,8 @@ class Stop_log_event: public Log_event
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
#endif #endif
Stop_log_event(const char* buf, const Format_description_log_event* description_event): Stop_log_event(const char* buf,
const Format_description_log_event *description_event):
Log_event(buf, description_event) Log_event(buf, description_event)
{} {}
~Stop_log_event() {} ~Stop_log_event() {}
...@@ -1697,7 +1727,8 @@ class Create_file_log_event: public Load_log_event ...@@ -1697,7 +1727,8 @@ class Create_file_log_event: public Load_log_event
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#else #else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool enable_local); void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
bool enable_local);
#endif #endif
Create_file_log_event(const char* buf, uint event_len, Create_file_log_event(const char* buf, uint event_len,
...@@ -1772,7 +1803,8 @@ class Append_block_log_event: public Log_event ...@@ -1772,7 +1803,8 @@ class Append_block_log_event: public Log_event
#endif #endif
Append_block_log_event(const char* buf, uint event_len, Append_block_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event
*description_event);
~Append_block_log_event() {} ~Append_block_log_event() {}
Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;} Log_event_type get_type_code() { return APPEND_BLOCK_EVENT;}
int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;} int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;}
...@@ -1808,7 +1840,8 @@ class Delete_file_log_event: public Log_event ...@@ -1808,7 +1840,8 @@ class Delete_file_log_event: public Log_event
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#else #else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info); void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
void print(FILE* file, PRINT_EVENT_INFO* print_event_info, bool enable_local); void print(FILE* file, PRINT_EVENT_INFO* print_event_info,
bool enable_local);
#endif #endif
Delete_file_log_event(const char* buf, uint event_len, Delete_file_log_event(const char* buf, uint event_len,
...@@ -1851,7 +1884,8 @@ class Execute_load_log_event: public Log_event ...@@ -1851,7 +1884,8 @@ class Execute_load_log_event: public Log_event
#endif #endif
Execute_load_log_event(const char* buf, uint event_len, Execute_load_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event
*description_event);
~Execute_load_log_event() {} ~Execute_load_log_event() {}
Log_event_type get_type_code() { return EXEC_LOAD_EVENT;} Log_event_type get_type_code() { return EXEC_LOAD_EVENT;}
int get_data_size() { return EXEC_LOAD_HEADER_LEN ;} int get_data_size() { return EXEC_LOAD_HEADER_LEN ;}
...@@ -1890,7 +1924,8 @@ class Begin_load_query_log_event: public Append_block_log_event ...@@ -1890,7 +1924,8 @@ class Begin_load_query_log_event: public Append_block_log_event
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
#endif #endif
Begin_load_query_log_event(const char* buf, uint event_len, Begin_load_query_log_event(const char* buf, uint event_len,
const Format_description_log_event* description_event); const Format_description_log_event
*description_event);
~Begin_load_query_log_event() {} ~Begin_load_query_log_event() {}
Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; } Log_event_type get_type_code() { return BEGIN_LOAD_QUERY_EVENT; }
}; };
...@@ -1942,7 +1977,8 @@ class Execute_load_query_log_event: public Query_log_event ...@@ -1942,7 +1977,8 @@ class Execute_load_query_log_event: public Query_log_event
const char *local_fname); const char *local_fname);
#endif #endif
Execute_load_query_log_event(const char* buf, uint event_len, Execute_load_query_log_event(const char* buf, uint event_len,
const Format_description_log_event *description_event); const Format_description_log_event
*description_event);
~Execute_load_query_log_event() {} ~Execute_load_query_log_event() {}
Log_event_type get_type_code() { return EXECUTE_LOAD_QUERY_EVENT; } Log_event_type get_type_code() { return EXECUTE_LOAD_QUERY_EVENT; }
...@@ -1969,7 +2005,8 @@ class Unknown_log_event: public Log_event ...@@ -1969,7 +2005,8 @@ class Unknown_log_event: public Log_event
Log_event's ctor, this way we can extract maximum information from the Log_event's ctor, this way we can extract maximum information from the
event's header (the unique ID for example). event's header (the unique ID for example).
*/ */
Unknown_log_event(const char* buf, const Format_description_log_event* description_event): Unknown_log_event(const char* buf,
const Format_description_log_event *description_event):
Log_event(buf, description_event) Log_event(buf, description_event)
{} {}
~Unknown_log_event() {} ~Unknown_log_event() {}
......
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