summaryrefslogtreecommitdiff
path: root/sql/rpl_utility.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-10-19 21:45:18 +0200
committerSergei Golubchik <sergii@pisem.net>2011-10-19 21:45:18 +0200
commit76f0b94bb0b2994d639353530c5b251d0f1a204b (patch)
tree9ed50628aac34f89a37637bab2fc4915b86b5eb4 /sql/rpl_utility.cc
parent4e46d8e5bff140f2549841167dc4b65a3c0a645d (diff)
parent5dc1a2231f55bacc9aaf0e24816f3d9c2ee1f21d (diff)
downloadmariadb-git-76f0b94bb0b2994d639353530c5b251d0f1a204b.tar.gz
merge with 5.3
sql/sql_insert.cc: CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. ****** CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. sql/sql_table.cc: small cleanup ****** small cleanup
Diffstat (limited to 'sql/rpl_utility.cc')
-rw-r--r--sql/rpl_utility.cc57
1 files changed, 56 insertions, 1 deletions
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 6f66905eb5d..23a62b9a532 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -303,7 +303,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
@@ -1056,3 +1056,58 @@ table_def::~table_def()
#endif
}
+/**
+ @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]= (uchar) flags;
+ }
+ res= !(computed == incoming);
+ }
+ return DBUG_EVALUATE_IF("simulate_checksum_test_failure", TRUE, res);
+}