summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-09-02 17:03:19 +0200
committerSergei Golubchik <serg@mariadb.org>2015-09-04 10:33:50 +0200
commit08687f7ef3ccb59ca78a3d037e9db5a514145d64 (patch)
tree7111820588edd5f46a0588d8733a2ff6bef6ce2d
parent66b9a9409c73e298d6ceb668783a7cdd5ee85a69 (diff)
downloadmariadb-git-08687f7ef3ccb59ca78a3d037e9db5a514145d64.tar.gz
cleanup: my_checksum
remove my_crc_dbug_check (gdb can do it itself). use 0 instead of my_checkum(0, 0, 0) - just as 10.0 does now.
-rw-r--r--include/my_sys.h1
-rw-r--r--mysql-test/suite/sys_vars/r/debug_crc_break_basic.result39
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_debug.result14
-rw-r--r--mysql-test/suite/sys_vars/t/debug_crc_break_basic.test46
-rw-r--r--mysys/checksum.c4
-rw-r--r--sql/log.cc18
-rw-r--r--sql/log_event.cc5
-rw-r--r--sql/rpl_utility.cc6
-rw-r--r--sql/sql_repl.cc7
-rw-r--r--sql/sys_vars.cc8
10 files changed, 17 insertions, 131 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index 453d1322cb5..31d4ffd7667 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -615,7 +615,6 @@ my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
int my_b_pread(IO_CACHE *info, uchar *Buffer, size_t Count, my_off_t pos);
typedef uint32 ha_checksum;
-extern ulong my_crc_dbug_check;
#include <my_alloc.h>
diff --git a/mysql-test/suite/sys_vars/r/debug_crc_break_basic.result b/mysql-test/suite/sys_vars/r/debug_crc_break_basic.result
deleted file mode 100644
index 70f338ad305..00000000000
--- a/mysql-test/suite/sys_vars/r/debug_crc_break_basic.result
+++ /dev/null
@@ -1,39 +0,0 @@
-SET @start_global_value = @@global.debug_crc_break;
-select @@global.debug_crc_break;
-@@global.debug_crc_break
-0
-select @@session.debug_crc_break;
-ERROR HY000: Variable 'debug_crc_break' is a GLOBAL variable
-show global variables like 'debug_crc_break';
-Variable_name Value
-debug_crc_break 0
-show session variables like 'debug_crc_break';
-Variable_name Value
-debug_crc_break 0
-select * from information_schema.global_variables where variable_name='debug_crc_break';
-VARIABLE_NAME VARIABLE_VALUE
-DEBUG_CRC_BREAK 0
-select * from information_schema.session_variables where variable_name='debug_crc_break';
-VARIABLE_NAME VARIABLE_VALUE
-DEBUG_CRC_BREAK 0
-set global debug_crc_break=1;
-select @@global.debug_crc_break;
-@@global.debug_crc_break
-1
-set session debug_crc_break=1;
-ERROR HY000: Variable 'debug_crc_break' is a GLOBAL variable and should be set with SET GLOBAL
-set global debug_crc_break=1.1;
-ERROR 42000: Incorrect argument type to variable 'debug_crc_break'
-set global debug_crc_break=1e1;
-ERROR 42000: Incorrect argument type to variable 'debug_crc_break'
-set global debug_crc_break="foo";
-ERROR 42000: Incorrect argument type to variable 'debug_crc_break'
-set global debug_crc_break=0;
-select @@global.debug_crc_break;
-@@global.debug_crc_break
-0
-set global debug_crc_break=cast(-1 as unsigned int);
-select @@global.debug_crc_break;
-@@global.debug_crc_break
-18446744073709551615
-SET @@global.debug_crc_break = @start_global_value;
diff --git a/mysql-test/suite/sys_vars/r/sysvars_debug.result b/mysql-test/suite/sys_vars/r/sysvars_debug.result
index a46e135af0a..f50e796bff4 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_debug.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_debug.result
@@ -29,20 +29,6 @@ NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
-VARIABLE_NAME DEBUG_CRC_BREAK
-SESSION_VALUE NULL
-GLOBAL_VALUE 0
-GLOBAL_VALUE_ORIGIN COMPILE-TIME
-DEFAULT_VALUE 0
-VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
-VARIABLE_COMMENT Call my_debug_put_break_here() if crc matches this number (for debug)
-NUMERIC_MIN_VALUE 0
-NUMERIC_MAX_VALUE 18446744073709551615
-NUMERIC_BLOCK_SIZE 1
-ENUM_VALUE_LIST NULL
-READ_ONLY NO
-COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME DEBUG_DBUG
SESSION_VALUE
GLOBAL_VALUE
diff --git a/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test b/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test
deleted file mode 100644
index 435a6c33341..00000000000
--- a/mysql-test/suite/sys_vars/t/debug_crc_break_basic.test
+++ /dev/null
@@ -1,46 +0,0 @@
---source include/have_debug.inc
-# ulong global
-
-SET @start_global_value = @@global.debug_crc_break;
-
-#
-# exists as global only
-#
-select @@global.debug_crc_break;
---error ER_INCORRECT_GLOBAL_LOCAL_VAR
-select @@session.debug_crc_break;
-show global variables like 'debug_crc_break';
-show session variables like 'debug_crc_break';
-select * from information_schema.global_variables where variable_name='debug_crc_break';
-select * from information_schema.session_variables where variable_name='debug_crc_break';
-
-#
-# show that it's writable
-#
-set global debug_crc_break=1;
-select @@global.debug_crc_break;
---error ER_GLOBAL_VARIABLE
-set session debug_crc_break=1;
-
-#
-# incorrect types
-#
---error ER_WRONG_TYPE_FOR_VAR
-set global debug_crc_break=1.1;
---error ER_WRONG_TYPE_FOR_VAR
-set global debug_crc_break=1e1;
---error ER_WRONG_TYPE_FOR_VAR
-set global debug_crc_break="foo";
-
-#
-# min/max values
-#
-set global debug_crc_break=0;
-select @@global.debug_crc_break;
---disable_warnings
-set global debug_crc_break=cast(-1 as unsigned int);
---enable_warnings
---replace_result 4294967295 18446744073709551615
-select @@global.debug_crc_break;
-
-SET @@global.debug_crc_break = @start_global_value;
diff --git a/mysys/checksum.c b/mysys/checksum.c
index 7bc52c6a178..a948785d935 100644
--- a/mysys/checksum.c
+++ b/mysys/checksum.c
@@ -18,8 +18,6 @@
#include <my_sys.h>
#include <zlib.h>
-ulong my_crc_dbug_check= ~0; /* Cannot happen */
-
/*
Calculate a long checksum for a memoryblock.
@@ -34,7 +32,5 @@ ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length)
{
crc= (ha_checksum) crc32((uint)crc, pos, (uint) length);
DBUG_PRINT("info", ("crc: %lu", (ulong) crc));
- if ((ulong)crc == my_crc_dbug_check)
- my_debug_put_break_here();
return crc;
}
diff --git a/sql/log.cc b/sql/log.cc
index e3d9c3e98f8..6df9cea94b0 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -6585,7 +6585,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
long val;
ulong end_log_pos_inc= 0; // each event processed adds BINLOG_CHECKSUM_LEN 2 t
uchar header[LOG_EVENT_HEADER_LEN];
- ha_checksum crc= 0, crc_0= 0;
+ ha_checksum crc= 0;
my_bool do_checksum= (binlog_checksum_options != BINLOG_CHECKSUM_ALG_OFF);
uchar buf[BINLOG_CHECKSUM_LEN];
DBUG_ENTER("MYSQL_BIN_LOG::write_cache");
@@ -6610,7 +6610,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
group= (uint)my_b_tell(&log_file);
hdr_offs= carry= 0;
-
+
do
{
/*
@@ -6655,7 +6655,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
if (do_checksum)
{
- DBUG_ASSERT(crc == crc_0 && remains == 0);
+ DBUG_ASSERT(crc == 0 && remains == 0);
crc= my_checksum(crc, header, carry);
remains= uint4korr(header + EVENT_LEN_OFFSET) - carry -
BINLOG_CHECKSUM_LEN;
@@ -6678,7 +6678,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
if (do_checksum && hdr_offs >= length)
{
- DBUG_ASSERT(remains != 0 && crc != crc_0);
+ DBUG_ASSERT(remains != 0 && crc != 0);
crc= my_checksum(crc, cache->read_pos, length);
remains -= length;
@@ -6689,7 +6689,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
int4store(buf, crc);
if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
DBUG_RETURN(ER_ERROR_ON_WRITE);
- crc= crc_0;
+ crc= 0;
}
}
@@ -6708,7 +6708,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
finish off with remains of the last event that crawls
from previous into the current buffer
*/
- DBUG_ASSERT(crc != crc_0);
+ DBUG_ASSERT(crc != 0);
crc= my_checksum(crc, cache->read_pos, hdr_offs);
int4store(buf, crc);
remains -= hdr_offs;
@@ -6716,7 +6716,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
if (my_b_write(&log_file, cache->read_pos, hdr_offs) ||
my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
DBUG_RETURN(ER_ERROR_ON_WRITE);
- crc= crc_0;
+ crc= 0;
}
}
@@ -6753,7 +6753,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
int4store(buf, crc);
if (my_b_write(&log_file, buf, BINLOG_CHECKSUM_LEN))
DBUG_RETURN(ER_ERROR_ON_WRITE);
- crc= crc_0; // crc is complete
+ crc= 0; // crc is complete
}
}
@@ -6787,7 +6787,7 @@ int MYSQL_BIN_LOG::write_cache(THD *thd, IO_CACHE *cache)
DBUG_ASSERT(carry == 0);
DBUG_ASSERT(!do_checksum || remains == 0);
- DBUG_ASSERT(!do_checksum || crc == crc_0);
+ DBUG_ASSERT(!do_checksum || crc == 0);
DBUG_RETURN(0); // All OK
}
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 81c0d0c1304..97399ea935d 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -49,6 +49,7 @@
#include <base64.h>
#include <my_bitmap.h>
#include "rpl_utility.h"
+#include "rpl_constants.h"
#include "sql_digest.h"
#define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1))
@@ -3750,7 +3751,7 @@ Query_log_event::dummy_event(String *packet, ulong ev_offset,
if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
{
- ha_checksum crc= my_checksum(0L, p, data_len);
+ ha_checksum crc= my_checksum(0, p, data_len);
int4store(p + data_len, crc);
}
return 0;
@@ -3815,7 +3816,7 @@ Query_log_event::begin_event(String *packet, ulong ev_offset,
if (checksum_alg == BINLOG_CHECKSUM_ALG_CRC32)
{
- ha_checksum crc= my_checksum(0L, p, data_len);
+ ha_checksum crc= my_checksum(0, p, data_len);
int4store(p + data_len, crc);
}
return 0;
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 5147dc4f0cb..ac49a1bf08f 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -1192,10 +1192,8 @@ bool event_checksum_test(uchar *event_buf, ulong event_len, uint8 alg)
compile_time_assert(BINLOG_CHECKSUM_ALG_ENUM_END <= 0x80);
}
incoming= uint4korr(event_buf + event_len - BINLOG_CHECKSUM_LEN);
- computed= 0;
- /* checksum the event content but the checksum part itself */
- computed= my_checksum(computed, (const uchar*) event_buf,
- event_len - BINLOG_CHECKSUM_LEN);
+ /* checksum the event content without the checksum part itself */
+ computed= my_checksum(0, event_buf, event_len - BINLOG_CHECKSUM_LEN);
if (flags != 0)
{
/* restoring the orig value of flags of FD */
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 71e53dd86a2..50177b94d9e 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -404,11 +404,11 @@ inline void fix_checksum(String *packet, ulong ev_offset)
{
/* recalculate the crc for this event */
uint data_len = uint4korr(packet->ptr() + ev_offset + EVENT_LEN_OFFSET);
- ha_checksum crc= my_checksum(0L, NULL, 0);
+ ha_checksum crc;
DBUG_ASSERT(data_len ==
LOG_EVENT_MINIMAL_HEADER_LEN + FORMAT_DESCRIPTION_HEADER_LEN +
BINLOG_CHECKSUM_ALG_DESC_LEN + BINLOG_CHECKSUM_LEN);
- crc= my_checksum(crc, (uchar *)packet->ptr() + ev_offset, data_len -
+ crc= my_checksum(0, (uchar *)packet->ptr() + ev_offset, data_len -
BINLOG_CHECKSUM_LEN);
int4store(packet->ptr() + ev_offset + data_len - BINLOG_CHECKSUM_LEN, crc);
}
@@ -810,8 +810,7 @@ static int send_heartbeat_event(binlog_send_info *info,
if (do_checksum)
{
char b[BINLOG_CHECKSUM_LEN];
- ha_checksum crc;
- crc= my_checksum(0, (uchar*) header, sizeof(header));
+ ha_checksum crc= my_checksum(0, (uchar*) header, sizeof(header));
crc= my_checksum(crc, (uchar*) p, ident_len);
int4store(b, crc);
packet->append(b, sizeof(b));
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 396b4c0ae83..99611c557f6 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4986,14 +4986,6 @@ static Sys_var_ulong Sys_deadlock_timeout_depth_long(
SESSION_VAR(wt_timeout_long), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(50000000), BLOCK_SIZE(1));
-#ifndef DBUG_OFF
-static Sys_var_ulong Sys_debug_crc_break(
- "debug_crc_break",
- "Call my_debug_put_break_here() if crc matches this number (for debug)",
- GLOBAL_VAR(my_crc_dbug_check), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1));
-#endif
-
static Sys_var_uint Sys_extra_port(
"extra_port",
"Extra port number to use for tcp connections in a "