diff options
author | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-08-11 11:29:37 -0600 |
---|---|---|
committer | Brandon Nesterenko <brandon.nesterenko@mariadb.com> | 2021-08-23 13:57:38 -0600 |
commit | c622af26fca37fc7864e9526a60dbe059644d120 (patch) | |
tree | d9ed6be82f0da06e8b2ac68abea5988180289cd0 /sql/sql_parse.cc | |
parent | 64f7dffcc7e0e69c31d9a36c2090a26300e57c4c (diff) | |
download | mariadb-git-10.7-MDEV-4989.tar.gz |
MDEV-4989: Support for GTID in mysqlbinlog10.7-MDEV-4989
New Feature:
============
This commit extends the mariadb-binlog capabilities to allow events
to be filtered by GTID ranges. More specifically, the following
capabilities are addressed:
1) GTIDs can be used to filter results on local binlog files
2) GTIDs can be used to filter results from remote servers
3) For a given GTID range, its start-position is exclusive and its
stop-position is inclusive
4) After the events have been written, the session server id and
domain id are reset to their former values
5) Output filtered by GTID ranges can be piped to the MariaDB client
To facilitate these features, the --start-position and --stop-position
arguments have been extended to additionally accept values formatted
as a list of GTID positions, e.g. `--start-position=0-1-0,1-2-55`
Reviewed By:
============
<TODO>
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e46e46f803c..9f23f537cb1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2123,8 +2123,11 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * case COM_BINLOG_DUMP: { ulong pos; + uint32 n_start_gtids; + rpl_gtid *start_gtids= NULL; ushort flags; uint32 slave_server_id; + uint32 unpack_idx= 0; status_var_increment(thd->status_var.com_other); @@ -2133,19 +2136,42 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * break; /* TODO: The following has to be changed to an 8 byte integer */ - pos = uint4korr(packet); - flags = uint2korr(packet + 4); + if (packet[4] == '-' && packet[9] == '-') + { + unpack_idx= 18; + while (packet[unpack_idx] == ',') + unpack_idx += 19; // 18 chars for gtid + 1 for comma + start_gtids= gtid_unpack_string_to_list(packet, unpack_idx, &n_start_gtids); + + /* + Set pos to the start of the binlog file for scanning + + TODO: When GTID indexing is complete (MDEV-4991), update pos by + looking it up in the index + */ + pos= 4; + } /* if (packet[4] == '-' && packet[9] == '-') */ + else + { + /* Single numeric log position case */ + pos = uint4korr(packet); + unpack_idx += 4; + } + flags = uint2korr(packet + unpack_idx); + unpack_idx += 2; thd->variables.server_id=0; /* avoid suicide */ - if ((slave_server_id= uint4korr(packet+6))) // mysqlbinlog.server_id==0 + if ((slave_server_id= uint4korr(packet+unpack_idx))) // mysqlbinlog.server_id==0 kill_zombie_dump_threads(slave_server_id); thd->variables.server_id = slave_server_id; + unpack_idx += 4; - const char *name= packet + 10; + const char *name= packet + unpack_idx; size_t nlen= strlen(name); general_log_print(thd, command, "Log: '%s' Pos: %lu", name, pos); if (nlen < FN_REFLEN) - mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags); + mysql_binlog_send(thd, thd->strmake(name, nlen), (my_off_t)pos, flags, + start_gtids, n_start_gtids); thd->unregister_slave(); // todo: can be extraneous /* fake COM_QUIT -- if we get here, the thread needs to terminate */ error = TRUE; |