summaryrefslogtreecommitdiff
path: root/sql/log_event_old.cc
diff options
context:
space:
mode:
authorAndrei Elkin <andrei.elkin@mariadb.com>2020-08-11 21:45:09 +0300
committerAndrei Elkin <andrei.elkin@mariadb.com>2020-08-31 18:38:57 +0300
commitcaa35f8e25ce22d6b4f4c377970354cf582c7f41 (patch)
tree180390b6a5e5e8c9c16eb44337730913a710113f /sql/log_event_old.cc
parent6a042281bdbfe91cc39e1f6e02295bfe7eaa9d43 (diff)
downloadmariadb-git-caa35f8e25ce22d6b4f4c377970354cf582c7f41.tar.gz
MDEV-16372 ER_BASE64_DECODE_ERROR upon replaying binary log via mysqlbinlog --verbose
(This commit is for 10.3 and upper branches) In case of a pattern of non-STMT_END-marked Rows-log-event (A) followed by a STMT_END marked one (B) mysqlbinlog mixes up the base64 encoded rows events with their pseudo sql representation produced by the verbose option: BINLOG ' base64 encoded data for A ### verbose section for A base64 encoded data for B ### verbose section for B '/*!*/; In effect the produced BINLOG '...' query is not valid and is rejected with the error. Examples of this way malformed BINLOG could have been found in binlog_row_annotate.result that gets corrected with the patch. The issue is fixed with introduction an auxiliary IO_CACHE to hold on the verbose comments until the terminal STMT_END event is found. The new cache is emptied out after two pre-existing ones are done at that time. The correctly produced output now for the above case is as the following: BINLOG ' base64 encoded data for A base64 encoded data for B '/*!*/; ### verbose section for A ### verbose section for B Thanks to Alexey Midenkov for the problem recognition and attempt to tackle, and to Venkatesh Duggirala who produced a patch for the upstream whose idea is exploited here, as well as to MDEV-23077 reporter LukeXwang who also contributed a piece of a patch aiming at this issue.
Diffstat (limited to 'sql/log_event_old.cc')
-rw-r--r--sql/log_event_old.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 8ec823d3d64..c71a1f39e28 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1848,6 +1848,7 @@ bool Old_rows_log_event::print_helper(FILE *file,
{
IO_CACHE *const head= &print_event_info->head_cache;
IO_CACHE *const body= &print_event_info->body_cache;
+ IO_CACHE *const tail= &print_event_info->tail_cache;
bool do_print_encoded=
print_event_info->base64_output_mode != BASE64_OUTPUT_DECODE_ROWS &&
print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER &&
@@ -1867,8 +1868,9 @@ bool Old_rows_log_event::print_helper(FILE *file,
{
if (copy_event_cache_to_file_and_reinit(head, file) ||
copy_cache_to_file_wrapped(body, file, do_print_encoded,
- print_event_info->delimiter,
- print_event_info->verbose))
+ print_event_info->delimiter,
+ print_event_info->verbose) ||
+ copy_event_cache_to_file_and_reinit(tail, file))
goto err;
}
return 0;