1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-36810 Deduplicate LOG_EVENT_OFFSET

`LOG_EVENT_OFFSET` is a duplicate of `EVENT_TYPE_OFFSET`
and `BIN_LOG_HEADER_SIZE` depending on the context.

While there, centralize `BIN_LOG_HEADER_SIZE` to `sql/rpl_constants.h`
(previously from `sql/unireg.h` and `client/mysqlbinlog.cc`)

Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
This commit is contained in:
ParadoxV5
2025-07-23 09:45:19 -06:00
parent 46d7450f75
commit 20bb4ed882
6 changed files with 21 additions and 18 deletions

View File

@@ -70,7 +70,6 @@ extern "C" unsigned char *mysql_net_store_length(unsigned char *packet, size_t l
Rpl_filter *binlog_filter= 0;
#define BIN_LOG_HEADER_SIZE 4
#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4)
/* Needed for Rpl_filter */

View File

@@ -5956,8 +5956,11 @@ int MYSQL_BIN_LOG::new_file_impl(bool commit_by_rotate)
We log the whole file name for log file as the user may decide
to change base names at some point.
*/
Rotate_log_event r(new_name + dirname_length(new_name), 0, LOG_EVENT_OFFSET,
is_relay_log ? Rotate_log_event::RELAY_LOG : 0);
Rotate_log_event r(
&new_name[dirname_length(new_name)], /* strlen() */ 0,
BIN_LOG_HEADER_SIZE,
is_relay_log ? Rotate_log_event::RELAY_LOG : 0
);
enum_binlog_checksum_alg checksum_alg = BINLOG_CHECKSUM_ALG_UNDEF;
/*
The current relay-log's closing Rotate event must have checksum

View File

@@ -92,8 +92,6 @@ class String;
#define LOG_READ_CHECKSUM_FAILURE -8
#define LOG_READ_DECRYPT -9
#define LOG_EVENT_OFFSET 4
/*
3 is MySQL 4.x; 4 is MySQL 5.0.0.
Compared to version 3, version 4 has:

View File

@@ -20,6 +20,9 @@
#include <my_sys.h>
#include <my_crypt.h>
/** Size of the `"\xfe""bin"` magic mumber */
#define BIN_LOG_HEADER_SIZE 4
/**
Enumeration of the incidents that can occur for the server.
*/

View File

@@ -2261,7 +2261,9 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type,
return "Failed on my_net_write()";
}
DBUG_PRINT("info", ("log event code %d", (*packet)[LOG_EVENT_OFFSET+1] ));
DBUG_PRINT("info", ("log event code %d",
(*packet)[/* Replication protocol status byte */ 1 + EVENT_TYPE_OFFSET]
));
if (event_type == LOAD_EVENT)
{
if (send_file(info->thd))
@@ -2528,7 +2530,9 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
DBUG_RETURN(1);
}
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
event_type= static_cast<Log_event_type>(
static_cast<unsigned char>((*packet)[ev_offset + EVENT_TYPE_OFFSET])
);
/*
The packet has offsets equal to the normal offsets in a
@@ -2663,7 +2667,9 @@ static int send_format_descriptor_event(binlog_send_info *info, IO_CACHE *log,
DBUG_RETURN(1);
}
event_type= (Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET + ev_offset]);
event_type= static_cast<Log_event_type>(
static_cast<unsigned char>((*packet)[ev_offset + EVENT_TYPE_OFFSET])
);
if (event_type == START_ENCRYPTION_EVENT)
{
Start_encryption_log_event *sele= (Start_encryption_log_event *)
@@ -2931,8 +2937,10 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo,
return 1;
}
Log_event_type event_type=
(Log_event_type)((uchar)(*packet)[LOG_EVENT_OFFSET+ev_offset]);
Log_event_type event_type= static_cast<Log_event_type>(
static_cast<unsigned char>((*packet)[ev_offset + EVENT_TYPE_OFFSET])
);
#ifndef DBUG_OFF
if (info->dbug_reconnect_counter > 0)

View File

@@ -144,14 +144,6 @@
*/
#define MIN_TURBOBM_PATTERN_LEN 3
/*
Defines for binary logging.
Do not decrease the value of BIN_LOG_HEADER_SIZE.
Do not even increase it before checking code.
*/
#define BIN_LOG_HEADER_SIZE 4
#define DEFAULT_KEY_CACHE_NAME "default"