mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Simplify logging code a bit (to make code smaller and faster)
Moved duplicated code to inline function store_timestamp() Save thd->time_zone_used when logging to table as CSV internally cases it to be changed Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables. Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping Set TABLE->no_replicate on open client/mysqlbinlog.cc: Fixed several memory leaks (most in case of error situations) mysql-test/r/events_logs_tests.result: Made long_query_timeout smaller to ensure next query comes into log mysql-test/r/variables.result: Make it safe to run test with --log mysql-test/t/events_logs_tests.test: Made long_query_timeout smaller to ensure next query comes into log mysql-test/t/variables.test: Make it safe to run test with --log sql/field.cc: Moved duplicated code to inline function store_timestamp() sql/field.h: Moved duplicated code to inline function store_timestamp() sql/handler.cc: Reorder checks in likely order Simplify checks if we should do binary logging (no_replicate is set once and for all when table is opened) sql/log.cc: Save thd->time_zone_used as CVS internally cases it to be changed Use Field_timestamp->store_timestamp instead of automatic timestamps. This gives us correct timestamp even if thd->set_time() is not called (in case of connect) and we don't have to store thd->query_start_used anymore. sql/sql_base.cc: Removed not needed comment Moved LINT_INIT() to after declaration Renamed temporary variable to avoid compiler warning Added MYSQL_LOCK_IGNORE_FLUSH to log tables to avoid deadlock in case of flush tables. Mark log tables with TIMESTAMP_NO_AUTO_SET to avoid automatic timestamping sql/table.cc: Set TABLE->no_replicate on open
This commit is contained in:
@ -1087,6 +1087,7 @@ static int check_master_version(MYSQL *mysql_arg,
|
||||
break;
|
||||
case '4':
|
||||
*description_event= new Format_description_log_event(3);
|
||||
break;
|
||||
case '5':
|
||||
/*
|
||||
The server is soon going to send us its Format_description log
|
||||
@ -1310,9 +1311,15 @@ static void check_header(IO_CACHE* file,
|
||||
pos= my_b_tell(file);
|
||||
my_b_seek(file, (my_off_t)0);
|
||||
if (my_b_read(file, header, sizeof(header)))
|
||||
{
|
||||
delete *description_event;
|
||||
die("Failed reading header; Probably an empty file");
|
||||
}
|
||||
if (memcmp(header, BINLOG_MAGIC, sizeof(header)))
|
||||
{
|
||||
delete *description_event;
|
||||
die("File is not a binary log file");
|
||||
}
|
||||
|
||||
/*
|
||||
Imagine we are running with --start-position=1000. We still need
|
||||
@ -1333,9 +1340,12 @@ static void check_header(IO_CACHE* file,
|
||||
if (my_b_read(file, buf, sizeof(buf)))
|
||||
{
|
||||
if (file->error)
|
||||
{
|
||||
delete *description_event;
|
||||
die("\
|
||||
Could not read entry at offset %lu : Error in log format or read error",
|
||||
tmp_pos);
|
||||
}
|
||||
/*
|
||||
Otherwise this is just EOF : this log currently contains 0-2
|
||||
events. Maybe it's going to be filled in the next
|
||||
@ -1371,13 +1381,19 @@ Could not read entry at offset %lu : Error in log format or read error",
|
||||
break;
|
||||
else if (buf[4] == FORMAT_DESCRIPTION_EVENT) /* This is 5.0 */
|
||||
{
|
||||
Format_description_log_event *new_description_event;
|
||||
my_b_seek(file, tmp_pos); /* seek back to event's start */
|
||||
if (!(*description_event= (Format_description_log_event*)
|
||||
if (!(new_description_event= (Format_description_log_event*)
|
||||
Log_event::read_log_event(file, *description_event)))
|
||||
/* EOF can't be hit here normally, so it's a real error */
|
||||
{
|
||||
delete *description_event;
|
||||
die("Could not read a Format_description_log_event event \
|
||||
at offset %lu ; this could be a log format error or read error",
|
||||
tmp_pos);
|
||||
}
|
||||
delete *description_event;
|
||||
*description_event= new_description_event;
|
||||
DBUG_PRINT("info",("Setting description_event"));
|
||||
}
|
||||
else if (buf[4] == ROTATE_EVENT)
|
||||
@ -1386,8 +1402,11 @@ at offset %lu ; this could be a log format error or read error",
|
||||
my_b_seek(file, tmp_pos); /* seek back to event's start */
|
||||
if (!(ev= Log_event::read_log_event(file, *description_event)))
|
||||
/* EOF can't be hit here normally, so it's a real error */
|
||||
{
|
||||
delete *description_event;
|
||||
die("Could not read a Rotate_log_event event at offset %lu ;"
|
||||
" this could be a log format error or read error", tmp_pos);
|
||||
}
|
||||
delete ev;
|
||||
}
|
||||
else
|
||||
@ -1457,7 +1476,10 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
|
||||
}
|
||||
|
||||
if (!glob_description_event || !glob_description_event->is_valid())
|
||||
{
|
||||
delete glob_description_event;
|
||||
die("Invalid Format_description log event; could be out of memory");
|
||||
}
|
||||
|
||||
if (!start_position && my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE))
|
||||
{
|
||||
|
Reference in New Issue
Block a user