1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for BUG#25628: "mysqlbinlog crashes while processing binary logs".

mysqlbinlog prints all row-based events of a single statement as a
single "BINLOG" statement containing the concatenation of those events.
Big (i.e. >64k) concatenations of row-based events
(e.g. Write_rows_log_event) caused mysqlbinlog's IO_CACHE to overflow
to a temporary file but the IO_CACHE had not been inited with
open_cached_file(), so it tried to create a temporary file in
an uninitialized directory (thus failing to create, then to write;
some OS errors were printed, and it finally segfaulted).
After fixing this, it appeared that mysqlbinlog was printing only
a piece of big concatenations of row-based events (it printed
at most the size of the IO_CACHE's buffer i.e. 64k); that caused data
loss at restore. We fix and test that.
Last, mysqlbinlog's printouts looked a bit strange with the informative
header (#-prefixed) of groupped Rows_log_event all on one line,
so we insert \n. After that, a small bug in the --hexdump code appeared
(only if the string to hex-print had its length a multiple of 16),
we fix it.
This commit is contained in:
gbichot@dl145h.mysql.com
2007-02-23 22:23:54 +01:00
parent 84f875cf6e
commit ba2452f092
6 changed files with 76 additions and 23 deletions

View File

@ -487,18 +487,15 @@ write_event_header_and_base64(Log_event *ev, FILE *result_file,
DBUG_ENTER("write_event_header_and_base64");
/* Write header and base64 output to cache */
IO_CACHE result_cache;
if (init_io_cache(&result_cache, -1, 0, WRITE_CACHE, 0L, FALSE,
MYF(MY_WME | MY_NABP)))
{
if (open_cached_file(&result_cache, NULL, NULL, 0, MYF(MY_WME | MY_NABP)))
return 1;
}
ev->print_header(&result_cache, print_event_info, FALSE);
ev->print_base64(&result_cache, print_event_info, FALSE);
/* Read data from cache and write to result file */
my_b_copy_to_file(&result_cache, result_file);
end_io_cache(&result_cache);
close_cached_file(&result_cache);
DBUG_RETURN(0);
}
@ -1016,6 +1013,9 @@ static int dump_log_entries(const char* logname)
{
int rc;
PRINT_EVENT_INFO print_event_info;
if (!print_event_info.init_ok())
return 1;
/*
Set safe delimiter, to dump things
like CREATE PROCEDURE safely