Fix for BUG#26194 "mysqlbinlog --base64-output produces invalid SQL";

when it was printing a Query event, it produced invalid SQL (missing
the BINLOG keyword, so the SQL started with the base64 string, which
is incorrect).
Note: no testcase; I have a .test which shows that the bugfix works,
but it triggers BUG#26361 and so gives Valgrind warnings. I'm sending
this test to the fixer of BUG#26361 for her/him to push when she/he
fixes BUG#26361.
parent 6a4dbc33
...@@ -483,19 +483,17 @@ static int ...@@ -483,19 +483,17 @@ static int
write_event_header_and_base64(Log_event *ev, FILE *result_file, write_event_header_and_base64(Log_event *ev, FILE *result_file,
PRINT_EVENT_INFO *print_event_info) PRINT_EVENT_INFO *print_event_info)
{ {
IO_CACHE *head= &print_event_info->head_cache;
IO_CACHE *body= &print_event_info->body_cache;
DBUG_ENTER("write_event_header_and_base64"); DBUG_ENTER("write_event_header_and_base64");
/* Write header and base64 output to cache */
IO_CACHE result_cache;
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); /* Write header and base64 output to cache */
ev->print_base64(&result_cache, print_event_info, FALSE); ev->print_header(head, print_event_info, FALSE);
ev->print_base64(body, print_event_info, FALSE);
/* Read data from cache and write to result file */ /* Read data from cache and write to result file */
my_b_copy_to_file(&result_cache, result_file); DBUG_RETURN(copy_event_cache_to_file_and_reinit(head, result_file) ||
close_cached_file(&result_cache); copy_event_cache_to_file_and_reinit(body, result_file));
DBUG_RETURN(0);
} }
......
...@@ -75,8 +75,7 @@ public: ...@@ -75,8 +75,7 @@ public:
~Write_on_release_cache() ~Write_on_release_cache()
{ {
if (!my_b_copy_to_file(m_cache, m_file)) copy_event_cache_to_file_and_reinit(m_cache, m_file);
reinit_io_cache(m_cache, WRITE_CACHE, 0L, FALSE, TRUE);
if (m_flags | FLUSH_F) if (m_flags | FLUSH_F)
fflush(m_file); fflush(m_file);
} }
...@@ -6160,10 +6159,8 @@ void Rows_log_event::print_helper(FILE *file, ...@@ -6160,10 +6159,8 @@ void Rows_log_event::print_helper(FILE *file,
if (get_flags(STMT_END_F)) if (get_flags(STMT_END_F))
{ {
my_b_copy_to_file(head, file); copy_event_cache_to_file_and_reinit(head, file);
my_b_copy_to_file(body, file); copy_event_cache_to_file_and_reinit(body, file);
reinit_io_cache(head, WRITE_CACHE, 0, FALSE, TRUE);
reinit_io_cache(body, WRITE_CACHE, 0, FALSE, TRUE);
} }
} }
#endif #endif
......
...@@ -2230,4 +2230,12 @@ private: ...@@ -2230,4 +2230,12 @@ private:
#endif #endif
}; };
static inline bool copy_event_cache_to_file_and_reinit(IO_CACHE *cache,
FILE *file)
{
return
my_b_copy_to_file(cache, file) ||
reinit_io_cache(cache, WRITE_CACHE, 0, FALSE, TRUE);
}
#endif /* _log_event_h */ #endif /* _log_event_h */
...@@ -150,7 +150,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table, ...@@ -150,7 +150,8 @@ void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
info->file= table->file; info->file= table->file;
info->forms= &info->table; /* Only one table */ info->forms= &info->table; /* Only one table */
if (table->s->tmp_table == TMP_TABLE && !table->sort.addon_field) if (table->s->tmp_table == NON_TRANSACTIONAL_TMP_TABLE &&
!table->sort.addon_field)
VOID(table->file->extra(HA_EXTRA_MMAP)); VOID(table->file->extra(HA_EXTRA_MMAP));
if (table->sort.addon_field) if (table->sort.addon_field)
......
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