Skip to content

Commit

Permalink
MDEV-31646 untie from max_allowed_packet and opt_binlog_rows_event_ma…
Browse files Browse the repository at this point in the history
…x_size
  • Loading branch information
FooBarrior authored and vuvova committed Aug 15, 2023
1 parent d5e59c9 commit a539fac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
16 changes: 7 additions & 9 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,17 +761,13 @@ Log_event::Log_event(const uchar *buf,

int Log_event::read_log_event(IO_CACHE* file, String* packet,
const Format_description_log_event *fdle,
enum enum_binlog_checksum_alg checksum_alg_arg)
enum enum_binlog_checksum_alg checksum_alg_arg,
size_t max_allowed_packet)
{
ulong data_len;
char buf[LOG_EVENT_MINIMAL_HEADER_LEN];
uchar ev_offset= packet->length();
#if !defined(MYSQL_CLIENT)
THD *thd=current_thd;
ulong max_allowed_packet= thd ? thd->slave_thread ? slave_max_allowed_packet
: thd->variables.max_allowed_packet
: ~(uint)0;
#endif

DBUG_ENTER("Log_event::read_log_event(IO_CACHE*,String*...)");

if (my_b_read(file, (uchar*) buf, sizeof(buf)))
Expand Down Expand Up @@ -882,15 +878,17 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet,

Log_event* Log_event::read_log_event(IO_CACHE* file,
const Format_description_log_event *fdle,
my_bool crc_check)
my_bool crc_check,
size_t max_allowed_packet)
{
DBUG_ENTER("Log_event::read_log_event(IO_CACHE*,Format_description_log_event*...)");
DBUG_ASSERT(fdle != 0);
String event;
const char *error= 0;
Log_event *res= 0;

switch (read_log_event(file, &event, fdle, BINLOG_CHECKSUM_ALG_OFF))
switch (read_log_event(file, &event, fdle, BINLOG_CHECKSUM_ALG_OFF,
max_allowed_packet))
{
case 0:
break;
Expand Down
35 changes: 33 additions & 2 deletions sql/log_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,20 @@ class Log_event
#endif
#endif

private:
static size_t get_max_packet()
{
size_t max_packet= ~0UL;
#if !defined(MYSQL_CLIENT)
THD *thd=current_thd;
if (thd)
max_packet= thd->slave_thread ? slave_max_allowed_packet
: thd->variables.max_allowed_packet;
#endif
return max_packet;
}
public:

/*
read_log_event() functions read an event from a binlog or relay
log; used by SHOW BINLOG EVENTS, the binlog_dump thread on the
Expand All @@ -1377,7 +1391,15 @@ class Log_event
static Log_event* read_log_event(IO_CACHE* file,
const Format_description_log_event
*description_event,
my_bool crc_check);
my_bool crc_check,
size_t max_allowed_packet);
static Log_event* read_log_event(IO_CACHE* file,
const Format_description_log_event
*description_event,
my_bool crc_check)
{
return read_log_event(file, description_event, crc_check, get_max_packet());
}

/**
Reads an event from a binlog or relay log. Used by the dump thread
Expand All @@ -1404,7 +1426,16 @@ class Log_event
*/
static int read_log_event(IO_CACHE* file, String* packet,
const Format_description_log_event *fdle,
enum enum_binlog_checksum_alg checksum_alg_arg);
enum enum_binlog_checksum_alg checksum_alg_arg,
size_t max_allowed_packet);

static int read_log_event(IO_CACHE* file, String* packet,
const Format_description_log_event *fdle,
enum enum_binlog_checksum_alg checksum_alg)
{
return read_log_event(file, packet, fdle, checksum_alg, get_max_packet());
}

/*
The value is set by caller of FD constructor and
Log_event::write_header() for the rest.
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11665,7 +11665,7 @@ static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
do
{
const auto *descr_event= rgi->rli->relay_log.description_event_for_exec;
auto *ev= Log_event::read_log_event(log_file, descr_event, false);
auto *ev= Log_event::read_log_event(log_file, descr_event, false, ~0UL);
error= log_file->error;
if (unlikely(!ev))
{
Expand Down

0 comments on commit a539fac

Please sign in to comment.