summaryrefslogtreecommitdiff
path: root/sql/log_event.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log_event.h')
-rw-r--r--sql/log_event.h117
1 files changed, 95 insertions, 22 deletions
diff --git a/sql/log_event.h b/sql/log_event.h
index 91a2ad9693c..53fc8f986b4 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -72,6 +72,7 @@
#define LOG_READ_MEM -5
#define LOG_READ_TRUNC -6
#define LOG_READ_TOO_LARGE -7
+#define LOG_READ_CHECKSUM_FAILURE -8
#define LOG_EVENT_OFFSET 4
@@ -525,6 +526,22 @@ struct sql_ex_info
#endif
#undef EXPECTED_OPTIONS /* You shouldn't use this one */
+enum enum_binlog_checksum_alg {
+ BINLOG_CHECKSUM_ALG_OFF= 0, // Events are without checksum though its generator
+ // is checksum-capable New Master (NM).
+ BINLOG_CHECKSUM_ALG_CRC32= 1, // CRC32 of zlib algorithm.
+ BINLOG_CHECKSUM_ALG_ENUM_END, // the cut line: valid alg range is [1, 0x7f].
+ BINLOG_CHECKSUM_ALG_UNDEF= 255 // special value to tag undetermined yet checksum
+ // or events from checksum-unaware servers
+};
+
+#define CHECKSUM_CRC32_SIGNATURE_LEN 4
+/**
+ defined statically while there is just one alg implemented
+*/
+#define BINLOG_CHECKSUM_LEN CHECKSUM_CRC32_SIGNATURE_LEN
+#define BINLOG_CHECKSUM_ALG_DESC_LEN 1 /* 1 byte checksum alg descriptor */
+
/**
@enum Log_event_type
@@ -923,6 +940,27 @@ public:
uint16 flags;
bool cache_stmt;
+ /*
+ The revid:alfranio.correia@sun.com-20091103190256-637o8qxlveikrt3i commit
+ ("WL#2687 WL#5072 BUG#40278 BUG#47175") in MySQL 5.5 changes the bool
+ cache_stmt into an enum cache_type. For the backport of WL#2540 binlog
+ event checksum, we need this event_type member to know if we are writing
+ directly to the log, or into a transaction cache.
+
+ Until the cache_type stuff is merged, we temporarily partially backport
+ the cache_type member, only enough to be able to check if we are writing
+ directly to log or not. Once MySQL 5.5 is merged, this can be removed, and
+ replaced with the MySQL 5.5 code.
+
+ Similarly, in MySQL 5.5 the decision on whether to write directly to log
+ or indirectly through cache is decided differently, and the
+ pre_55_writing_direct() (and all calls to it) are not needed and can be
+ removed once 5.5 is merged.
+ */
+ enum enum_event_cache_type { EVENT_INVALID_CACHE, EVENT_STMT_CACHE,
+ EVENT_TRANSACTIONAL_CACHE, EVENT_NO_CACHE };
+ uint16 cache_type;
+ void pre_55_writing_direct() { cache_type= EVENT_NO_CACHE; }
/**
A storage to cache the global system variable's value.
@@ -930,6 +968,10 @@ public:
*/
ulong slave_exec_mode;
+ /**
+ Placeholder for event checksum while writing to binlog.
+ */
+ ha_checksum crc;
#ifndef MYSQL_CLIENT
THD* thd;
@@ -949,9 +991,10 @@ public:
static Log_event* read_log_event(IO_CACHE* file,
pthread_mutex_t* log_lock,
const Format_description_log_event
- *description_event);
+ *description_event,
+ my_bool crc_check);
static int read_log_event(IO_CACHE* file, String* packet,
- pthread_mutex_t* log_lock);
+ pthread_mutex_t* log_lock, uint8 checksum_alg_arg);
/*
init_show_field_list() prepares the column names and types for the
output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG
@@ -978,7 +1021,7 @@ public:
/* avoid having to link mysqlbinlog against libpthread */
static Log_event* read_log_event(IO_CACHE* file,
const Format_description_log_event
- *description_event);
+ *description_event, my_bool crc_check);
/* print*() functions are used by mysqlbinlog */
virtual void print(FILE* file, PRINT_EVENT_INFO* print_event_info) = 0;
void print_timestamp(IO_CACHE* file, time_t *ts = 0);
@@ -987,6 +1030,15 @@ public:
void print_base64(IO_CACHE* file, PRINT_EVENT_INFO* print_event_info,
bool is_more);
#endif
+ /*
+ The value is set by caller of FD constructor and
+ Log_event::write_header() for the rest.
+ In the FD case it's propagated into the last byte
+ of post_header_len[] at FD::write().
+ On the slave side the value is assigned from post_header_len[last]
+ of the last seen FD event.
+ */
+ uint8 checksum_alg;
static void *operator new(size_t size)
{
@@ -1001,14 +1053,19 @@ public:
/* Placement version of the above operators */
static void *operator new(size_t, void* ptr) { return ptr; }
static void operator delete(void*, void*) { }
+ bool wrapper_my_b_safe_write(IO_CACHE* file, const uchar* buf, ulong data_length);
#ifndef MYSQL_CLIENT
bool write_header(IO_CACHE* file, ulong data_length);
+ bool write_footer(IO_CACHE* file);
+ my_bool need_checksum();
+
virtual bool write(IO_CACHE* file)
{
- return (write_header(file, get_data_size()) ||
- write_data_header(file) ||
- write_data_body(file));
+ return(write_header(file, get_data_size()) ||
+ write_data_header(file) ||
+ write_data_body(file) ||
+ write_footer(file));
}
virtual bool write_data_header(IO_CACHE* file)
{ return 0; }
@@ -1058,7 +1115,7 @@ public:
static Log_event* read_log_event(const char* buf, uint event_len,
const char **error,
const Format_description_log_event
- *description_event);
+ *description_event, my_bool crc_check);
/**
Returns the human readable name of the given event type.
*/
@@ -2237,9 +2294,17 @@ public:
*/
uint8 common_header_len;
uint8 number_of_event_types;
- /* The list of post-headers' lengthes */
+ /*
+ The list of post-headers' lengths followed
+ by the checksum alg decription byte
+ */
uint8 *post_header_len;
- uchar server_version_split[3];
+ struct master_version_split {
+ enum {KIND_MYSQL, KIND_MARIADB};
+ int kind;
+ uchar ver[3];
+ };
+ master_version_split server_version_split;
const uint8 *event_type_permutation;
Format_description_log_event(uint8 binlog_ver, const char* server_ver=0);
@@ -2271,7 +2336,7 @@ public:
}
void calc_server_version_split();
-
+ static bool is_version_before_checksum(master_version_split *version_split);
protected:
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
virtual int do_apply_event(Relay_log_info const *rli);
@@ -2326,9 +2391,10 @@ public:
uchar type;
#ifndef MYSQL_CLIENT
- Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
- :Log_event(thd_arg,0,0),val(val_arg),type(type_arg)
- {}
+ Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg,0,0), val(val_arg), type(type_arg)
+ { cache_type= cache_type_arg; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2402,9 +2468,10 @@ class Rand_log_event: public Log_event
ulonglong seed2;
#ifndef MYSQL_CLIENT
- Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg)
- :Log_event(thd_arg,0,0),seed1(seed1_arg),seed2(seed2_arg)
- {}
+ Rand_log_event(THD* thd_arg, ulonglong seed1_arg, ulonglong seed2_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg, 0, 0), seed1(seed1_arg), seed2(seed2_arg)
+ { cache_type= cache_type_arg; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2448,7 +2515,8 @@ class Xid_log_event: public Log_event
my_xid xid;
#ifndef MYSQL_CLIENT
- Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg,0,0), xid(x) {}
+ Xid_log_event(THD* thd_arg, my_xid x): Log_event(thd_arg, 0, 0), xid(x)
+ { cache_type= EVENT_NO_CACHE; }
#ifdef HAVE_REPLICATION
void pack_info(Protocol* protocol);
#endif /* HAVE_REPLICATION */
@@ -2495,10 +2563,11 @@ public:
#ifndef MYSQL_CLIENT
User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg,
char *val_arg, ulong val_len_arg, Item_result type_arg,
- uint charset_number_arg)
- :Log_event(), name(name_arg), name_len(name_len_arg), val(val_arg),
- val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
- { is_null= !val; }
+ uint charset_number_arg,
+ uint16 cache_type_arg)
+ :Log_event(thd_arg, 0, 0), name(name_arg), name_len(name_len_arg), val(val_arg),
+ val_len(val_len_arg), type(type_arg), charset_number(charset_number_arg)
+ { is_null= !val; cache_type= cache_type_arg; }
void pack_info(Protocol* protocol);
#else
void print(FILE* file, PRINT_EVENT_INFO* print_event_info);
@@ -3010,7 +3079,7 @@ class Annotate_rows_log_event: public Log_event
{
public:
#ifndef MYSQL_CLIENT
- Annotate_rows_log_event(THD*);
+ Annotate_rows_log_event(THD*, uint16 cache_type_arg);
#endif
Annotate_rows_log_event(const char *buf, uint event_len,
const Format_description_log_event*);
@@ -4040,6 +4109,10 @@ bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
const char **group_relay_log_name,
ulonglong *relay_log_pos);
+bool event_checksum_test(uchar *buf, ulong event_len, uint8 alg);
+uint8 get_checksum_alg(const char* buf, ulong len);
+extern TYPELIB binlog_checksum_typelib;
+
/**
@} (end of group Replication)
*/