diff options
author | Andrei Elkin <andrei.elkin@mariadb.com> | 2020-08-11 21:45:09 +0300 |
---|---|---|
committer | Andrei Elkin <andrei.elkin@mariadb.com> | 2020-08-31 18:37:44 +0300 |
commit | 6112a0f93d137b9754bc04449873311784e0edd9 (patch) | |
tree | dc038437c44d0397460a3acf624163c370d86b81 /client | |
parent | 9bb17ecf4352e0ba009d6afb9260d291ed70fa4c (diff) | |
download | mariadb-git-6112a0f93d137b9754bc04449873311784e0edd9.tar.gz |
MDEV-16372 ER_BASE64_DECODE_ERROR upon replaying binary log via mysqlbinlog --verbose
(This commit is exclusively for 10.2 branch. Do not merge it to 10.3)
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 'client')
-rw-r--r-- | client/mysqlbinlog.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 13a92c0b581..4e28876cdf6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -891,7 +891,8 @@ static bool print_base64(PRINT_EVENT_INFO *print_event_info, Log_event *ev) ev->print(result_file, print_event_info); return print_event_info->head_cache.error == -1 || - print_event_info->body_cache.error == -1; + print_event_info->body_cache.error == -1 || + print_event_info->tail_cache.error == -1; } @@ -962,8 +963,12 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, my_b_printf(body_cache, "'%s\n", print_event_info->delimiter); // flush cache - if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, result_file) || - copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, result_file))) + if ((copy_event_cache_to_file_and_reinit(&print_event_info->head_cache, + result_file) || + copy_event_cache_to_file_and_reinit(&print_event_info->body_cache, + result_file) || + copy_event_cache_to_file_and_reinit(&print_event_info->tail_cache, + result_file))) return 1; } } |