Skip to content

Commit

Permalink
Fixed some wrong printf() usage after changing m_table_id to ulonglong
Browse files Browse the repository at this point in the history
This caused some crashes on 32 bit platforms.
  • Loading branch information
montywi committed Jan 27, 2024
1 parent daca0c0 commit e20693c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 3 additions & 2 deletions sql/log_event_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1502,8 +1502,9 @@ bool Rows_log_event::print_verbose(IO_CACHE *file,
if (!(map= print_event_info->m_table_map.get_table(m_table_id)) ||
!(td= map->create_table_def()))
{
return (my_b_printf(file, "### Row event for unknown table #%llu",
(ulonglong) m_table_id));
char llbuff[22];
return (my_b_printf(file, "### Row event for unknown table #%s",
ullstr(m_table_id, llbuff)));
}

/* If the write rows event contained no values for the AI */
Expand Down
11 changes: 6 additions & 5 deletions sql/log_event_old.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,7 @@ Old_rows_log_event::Old_rows_log_event(const uchar *buf, uint event_len,

const uchar* const ptr_rows_data= (const uchar*) ptr_after_width;
size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf);
DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %zu",
DBUG_PRINT("info",("m_table_id: %llu m_flags: %d m_width: %lu data_size: %zu",
m_table_id, m_flags, m_width, data_size));
DBUG_DUMP("rows_data", (uchar*) ptr_rows_data, data_size);

Expand Down Expand Up @@ -1790,7 +1790,7 @@ bool Old_rows_log_event::write_data_header()
DBUG_ASSERT(m_table_id != UINT32_MAX);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
{
int4store(buf + 0, m_table_id);
int4store(buf + 0, (ulong) m_table_id);
int2store(buf + 4, m_flags);
return write_data(buf, 6);
});
Expand Down Expand Up @@ -1837,7 +1837,7 @@ void Old_rows_log_event::pack_info(Protocol *protocol)
char const *const flagstr=
get_flags(STMT_END_F) ? " flags: STMT_END_F" : "";
size_t bytes= my_snprintf(buf, sizeof(buf),
"table_id: %lu%s", m_table_id, flagstr);
"table_id: %llu%s", m_table_id, flagstr);
protocol->store(buf, bytes, &my_charset_bin);
}
#endif
Expand All @@ -1859,9 +1859,10 @@ bool Old_rows_log_event::print_helper(FILE *file,

if (!print_event_info->short_form)
{
char llbuff[22];
if (print_header(head, print_event_info, !do_print_encoded) ||
my_b_printf(head, "\t%s: table id %lu%s\n",
name, m_table_id,
my_b_printf(head, "\t%s: table id %s%s\n",
name, ullstr(m_table_id, llbuff),
do_print_encoded ? " flags: STMT_END_F" : "") ||
print_base64(body, print_event_info, do_print_encoded))
goto err;
Expand Down
8 changes: 4 additions & 4 deletions sql/log_event_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6074,7 +6074,7 @@ bool Rows_log_event::write_data_header()
DBUG_ASSERT(m_table_id != UINT32_MAX);
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
{
int4store(buf + 0, m_table_id);
int4store(buf + 0, (ulong) m_table_id);
int2store(buf + 4, m_flags);
return (write_data(buf, 6));
});
Expand Down Expand Up @@ -6588,7 +6588,7 @@ int Table_map_log_event::do_apply_event(rpl_group_info *rgi)
char buf[256];

my_snprintf(buf, sizeof(buf),
"Found table map event mapping table id %u which "
"Found table map event mapping table id %llu which "
"was already mapped but with different settings.",
table_list->table_id);

Expand Down Expand Up @@ -6633,7 +6633,7 @@ bool Table_map_log_event::write_data_header()
uchar buf[TABLE_MAP_HEADER_LEN];
DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master",
{
int4store(buf + 0, m_table_id);
int4store(buf + 0, (ulong) m_table_id);
int2store(buf + 4, m_flags);
return (write_data(buf, 6));
});
Expand Down Expand Up @@ -7069,7 +7069,7 @@ void Table_map_log_event::pack_info(Protocol *protocol)
{
char buf[256];
size_t bytes= my_snprintf(buf, sizeof(buf),
"table_id: %llu (%s.%s)",
"table_id: %llu (%s.%s)",
m_table_id, m_dbnam, m_tblnam);
protocol->store(buf, bytes, &my_charset_bin);
}
Expand Down

0 comments on commit e20693c

Please sign in to comment.