From 014b8e7f435e495151fe0ef2cfd5e93d1a398ce5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 May 2011 14:01:11 +0200 Subject: Backport MySQL WL#2540 into MariaDB. Patch backported: bzr diff '-rrevid:alfranio.correia@oracle.com-20101121143257-se3vpqus73l4mum0 ..revid:luis.soares@oracle.com-20101124111752-9b8260bd1qak87hr' --old=lp:mysql-server --new=lp:mysql-server --- sql/rpl_utility.cc | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'sql/rpl_utility.cc') diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 6058c473e9f..d4616723117 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -14,6 +14,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "rpl_utility.h" + +#ifndef MYSQL_CLIENT #include "rpl_rli.h" /********************************************************************* @@ -224,3 +226,62 @@ table_def::compatible_with(Relay_log_info const *rli_arg, TABLE *table) return error; } + +#endif /* MYSQL_CLIENT */ + + +/** + @param even_buf point to the buffer containing serialized event + @param event_len length of the event accounting possible checksum alg + + @return TRUE if test fails + FALSE as success +*/ +bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg) +{ + bool res= FALSE; + uint16 flags= 0; // to store in FD's buffer flags orig value + + if (alg != BINLOG_CHECKSUM_ALG_OFF && alg != BINLOG_CHECKSUM_ALG_UNDEF) + { + ha_checksum incoming; + ha_checksum computed; + + if (event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT) + { +#ifndef DBUG_OFF + int8 fd_alg= event_buf[event_len - BINLOG_CHECKSUM_LEN - + BINLOG_CHECKSUM_ALG_DESC_LEN]; +#endif + /* + FD event is checksummed and therefore verified w/o the binlog-in-use flag + */ + flags= uint2korr(event_buf + FLAGS_OFFSET); + if (flags & LOG_EVENT_BINLOG_IN_USE_F) + event_buf[FLAGS_OFFSET] &= ~LOG_EVENT_BINLOG_IN_USE_F; + /* + The only algorithm currently is CRC32. Zero indicates + the binlog file is checksum-free *except* the FD-event. + */ + DBUG_ASSERT(fd_alg == BINLOG_CHECKSUM_ALG_CRC32 || fd_alg == 0); + DBUG_ASSERT(alg == BINLOG_CHECKSUM_ALG_CRC32); + /* + Complile time guard to watch over the max number of alg + */ + compile_time_assert(BINLOG_CHECKSUM_ALG_ENUM_END <= 0x80); + } + incoming= uint4korr(event_buf + event_len - BINLOG_CHECKSUM_LEN); + computed= my_checksum(0L, NULL, 0); + /* checksum the event content but the checksum part itself */ + computed= my_checksum(computed, (const uchar*) event_buf, + event_len - BINLOG_CHECKSUM_LEN); + if (flags != 0) + { + /* restoring the orig value of flags of FD */ + DBUG_ASSERT(event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT); + event_buf[FLAGS_OFFSET]= flags; + } + res= !(computed == incoming); + } + return DBUG_EVALUATE_IF("simulate_checksum_test_failure", TRUE, res); +} -- cgit v1.2.1 From e843297d128b165125d17aab8958f7ca91808923 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sun, 8 May 2011 13:26:07 +0300 Subject: Fixed compiler warnings --- sql/rpl_utility.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/rpl_utility.cc') diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index d4616723117..c301dabcdb7 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -279,7 +279,7 @@ bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg) { /* restoring the orig value of flags of FD */ DBUG_ASSERT(event_buf[EVENT_TYPE_OFFSET] == FORMAT_DESCRIPTION_EVENT); - event_buf[FLAGS_OFFSET]= flags; + event_buf[FLAGS_OFFSET]= (uchar) flags; } res= !(computed == incoming); } -- cgit v1.2.1 From 7c459960ece917dcdc4dedc9f3dd0c9f5d07c3b8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 20 May 2011 23:56:13 +0200 Subject: db_low_byte_first is gone --- sql/rpl_utility.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/rpl_utility.cc') diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 6058c473e9f..56b0b293d88 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -133,7 +133,7 @@ uint32 table_def::calc_field_size(uint col, uchar *master_data) const always read the length in little-endian order. */ Field_blob fb(m_field_metadata[col]); - length= fb.get_packed_size(master_data, TRUE); + length= fb.get_packed_size(master_data); #else /* Compute the length of the data. We cannot use get_length() here -- cgit v1.2.1