mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
MDEV-35519 Populate thread_id of Backward Compatibility Query event
This commit bubbles `info->fdev` to `Query_log_event::begin_event` so it can reconstruct the GTID event from binlog for *real* conversion. `Gtid_log_event`s and `Query_log_event`s had no common fields previously, but that changed when MDEV-7850 added Thread ID records to GTID events.
This commit is contained in:
parent
a090a3c571
commit
8ffabc8059
4 changed files with 21 additions and 10 deletions
|
@ -1906,16 +1906,18 @@ Query_log_event::dummy_event(String *packet, ulong ev_offset,
|
|||
}
|
||||
|
||||
/*
|
||||
Replace an event (GTID event) with a BEGIN query event, to be compatible
|
||||
Replace a Gtid_log_event with a BEGIN query event, to be compatible
|
||||
with an old slave.
|
||||
*/
|
||||
int
|
||||
Query_log_event::begin_event(String *packet, ulong ev_offset,
|
||||
Format_description_log_event* fdev,
|
||||
enum_binlog_checksum_alg checksum_alg)
|
||||
{
|
||||
uchar *p= (uchar *)packet->ptr() + ev_offset;
|
||||
uchar *q= p + LOG_EVENT_HEADER_LEN;
|
||||
size_t data_len= packet->length() - ev_offset;
|
||||
Gtid_log_event original_event= Gtid_log_event(p, data_len, fdev);
|
||||
size_t dummy_bytes;
|
||||
uint16 flags;
|
||||
|
||||
|
@ -1927,15 +1929,20 @@ Query_log_event::begin_event(String *packet, ulong ev_offset,
|
|||
|
||||
|
||||
flags= uint2korr(p + FLAGS_OFFSET);
|
||||
flags&= ~LOG_EVENT_THREAD_SPECIFIC_F;
|
||||
flags|= LOG_EVENT_SUPPRESS_USE_F;
|
||||
int2store(p + FLAGS_OFFSET, flags);
|
||||
|
||||
p[EVENT_TYPE_OFFSET]= QUERY_EVENT;
|
||||
int4store(q + Q_THREAD_ID_OFFSET, 0);
|
||||
if (original_event.flags_extra & Gtid_log_event::FL_EXTRA_THREAD_ID)
|
||||
int4store(q + Q_THREAD_ID_OFFSET, original_event.thread_id);
|
||||
else
|
||||
{
|
||||
flags&= ~LOG_EVENT_THREAD_SPECIFIC_F;
|
||||
int4store(q + Q_THREAD_ID_OFFSET, 0);
|
||||
}
|
||||
int4store(q + Q_EXEC_TIME_OFFSET, 0);
|
||||
q[Q_DB_LEN_OFFSET]= 0;
|
||||
int2store(q + Q_ERR_CODE_OFFSET, 0);
|
||||
int2store(p + FLAGS_OFFSET, flags);
|
||||
|
||||
/*
|
||||
If the allocated GTID event packet header is longer than the size of the
|
||||
|
@ -2407,7 +2414,7 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event(
|
|||
Global transaction ID stuff
|
||||
**************************************************************************/
|
||||
|
||||
Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len,
|
||||
Gtid_log_event::Gtid_log_event(const uchar *buf, size_t event_len,
|
||||
const Format_description_log_event
|
||||
*description_event)
|
||||
: Log_event(buf, description_event), seq_no(0), commit_id(0),
|
||||
|
@ -2450,7 +2457,7 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len,
|
|||
xid.bqual_length= (long) buf[1];
|
||||
buf+= 2;
|
||||
|
||||
long data_length= xid.bqual_length + xid.gtrid_length;
|
||||
ulong data_length= xid.bqual_length + xid.gtrid_length;
|
||||
if (event_len < static_cast<uint>(buf - buf_0) + data_length)
|
||||
{
|
||||
seq_no= 0;
|
||||
|
|
|
@ -2253,6 +2253,7 @@ public:
|
|||
static int dummy_event(String *packet, ulong ev_offset,
|
||||
enum_binlog_checksum_alg checksum_alg);
|
||||
static int begin_event(String *packet, ulong ev_offset,
|
||||
Format_description_log_event* fdev,
|
||||
enum_binlog_checksum_alg checksum_alg);
|
||||
#ifdef MYSQL_SERVER
|
||||
bool write(Log_event_writer *writer) override;
|
||||
|
@ -3425,7 +3426,7 @@ public:
|
|||
#else
|
||||
bool print(FILE *file, PRINT_EVENT_INFO *print_event_info) override;
|
||||
#endif
|
||||
Gtid_log_event(const uchar *buf, uint event_len,
|
||||
Gtid_log_event(const uchar *buf, size_t event_len,
|
||||
const Format_description_log_event *description_event);
|
||||
~Gtid_log_event() = default;
|
||||
Log_event_type get_type_code() override { return GTID_EVENT; }
|
||||
|
@ -3447,7 +3448,9 @@ public:
|
|||
#ifdef MYSQL_SERVER
|
||||
bool write(Log_event_writer *writer) override;
|
||||
static int make_compatible_event(String *packet, bool *need_dummy_event,
|
||||
ulong ev_offset, enum_binlog_checksum_alg checksum_alg);
|
||||
ulong ev_offset,
|
||||
Format_description_log_event* fdev,
|
||||
enum_binlog_checksum_alg checksum_alg);
|
||||
static bool peek(const uchar *event_start, size_t event_len,
|
||||
enum_binlog_checksum_alg checksum_alg,
|
||||
uint32 *domain_id, uint32 *server_id, uint64 *seq_no,
|
||||
|
|
|
@ -3083,6 +3083,7 @@ Gtid_log_event::write(Log_event_writer *writer)
|
|||
int
|
||||
Gtid_log_event::make_compatible_event(String *packet, bool *need_dummy_event,
|
||||
ulong ev_offset,
|
||||
Format_description_log_event* fdev,
|
||||
enum_binlog_checksum_alg checksum_alg)
|
||||
{
|
||||
uchar flags2;
|
||||
|
@ -3097,7 +3098,7 @@ Gtid_log_event::make_compatible_event(String *packet, bool *need_dummy_event,
|
|||
}
|
||||
|
||||
*need_dummy_event= true;
|
||||
return Query_log_event::begin_event(packet, ev_offset, checksum_alg);
|
||||
return Query_log_event::begin_event(packet, ev_offset, fdev, checksum_alg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2197,7 +2197,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
|
|||
bool need_dummy=
|
||||
mariadb_slave_capability < MARIA_SLAVE_CAPABILITY_TOLERATE_HOLES;
|
||||
bool err= Gtid_log_event::make_compatible_event(packet, &need_dummy,
|
||||
ev_offset,
|
||||
ev_offset, info->fdev,
|
||||
current_checksum_alg);
|
||||
if (err)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue