From 11f44544fcb9c8508c95b75dd4d3ef7ee254588a Mon Sep 17 00:00:00 2001 From: "Tatiana A. Nurnberg" Date: Mon, 6 Apr 2009 13:42:33 +0200 Subject: [PATCH] Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors We didn't expect "error: no error", although this is in fact a legitimate state (if something is erroneous on the master, but not on the slave, e.g. INSERT fails on master due to UNIQUE constraint which does not exist on slave). We now list the ignore for "0: no error" the same way as any other ignore; moreover, if no or an empty --slave-skip-errors is passed at start-up, we show "OFF" instead of empty list, as intended. (The code for that was there, but was only run for the empty- argument case, even if it subsequently tested for both conditions.) --- mysql-test/r/not_embedded_server.result | 3 +++ mysql-test/r/variables-notembedded.result | 6 +++--- mysql-test/t/not_embedded_server.test | 6 ++++++ mysql-test/t/variables-notembedded-master.opt | 2 +- sql/slave.cc | 12 +++++++++++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/not_embedded_server.result b/mysql-test/r/not_embedded_server.result index 8f7c125196a..60c92bd0196 100644 --- a/mysql-test/r/not_embedded_server.result +++ b/mysql-test/r/not_embedded_server.result @@ -1,3 +1,6 @@ select 1; 1 1 +SHOW VARIABLES like 'slave_skip_errors'; +Variable_name Value +slave_skip_errors OFF diff --git a/mysql-test/r/variables-notembedded.result b/mysql-test/r/variables-notembedded.result index c9125bcee90..8c6d54757ed 100644 --- a/mysql-test/r/variables-notembedded.result +++ b/mysql-test/r/variables-notembedded.result @@ -11,7 +11,7 @@ Variable_name Value slave_load_tmpdir SLAVE_LOAD_TMPDIR show variables like 'slave_skip_errors'; Variable_name Value -slave_skip_errors 3,100,137,643,1752 +slave_skip_errors 0,3,100,137,643,1752 ---- Clean Up ---- set global slave_net_timeout=default; set global sql_slave_skip_counter= 0; @@ -98,12 +98,12 @@ ERROR HY000: Variable 'slave_load_tmpdir' is a read only variable # SHOW VARIABLES like 'slave_skip_errors'; Variable_name Value -slave_skip_errors 3,100,137,643,1752 +slave_skip_errors 0,3,100,137,643,1752 SELECT @@session.slave_skip_errors; ERROR HY000: Variable 'slave_skip_errors' is a GLOBAL variable SELECT @@global.slave_skip_errors; @@global.slave_skip_errors -3,100,137,643,1752 +0,3,100,137,643,1752 SET @@session.slave_skip_errors= 7; ERROR HY000: Variable 'slave_skip_errors' is a read only variable SET @@global.slave_skip_errors= 7; diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test index 233ac3edfbb..fa2b659ec57 100644 --- a/mysql-test/t/not_embedded_server.test +++ b/mysql-test/t/not_embedded_server.test @@ -36,4 +36,10 @@ select 1; #execute stmt1; #deallocate prepare stmt1; +# +# Bug#43835: SHOW VARIABLES does not include 0 for slave_skip_errors +# + +SHOW VARIABLES like 'slave_skip_errors'; + # End of 5.1 tests diff --git a/mysql-test/t/variables-notembedded-master.opt b/mysql-test/t/variables-notembedded-master.opt index a684e591d10..8a173a043ac 100644 --- a/mysql-test/t/variables-notembedded-master.opt +++ b/mysql-test/t/variables-notembedded-master.opt @@ -1 +1 @@ ---loose-slave-skip-errors=3,100,137,643,1752 +--loose-slave-skip-errors=3,100,137,0,643,1752 diff --git a/sql/slave.cc b/sql/slave.cc index 8c29cb8a72f..b862c5eff20 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -128,6 +128,7 @@ static bool wait_for_relay_log_space(Relay_log_info* rli); static inline bool io_slave_killed(THD* thd,Master_info* mi); static inline bool sql_slave_killed(THD* thd,Relay_log_info* rli); static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type); +static void print_slave_skip_errors(void); static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi); static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi, bool suppress_warnings); @@ -231,6 +232,15 @@ int init_slave() */ active_mi= new Master_info; + /* + If --slave-skip-errors=... was not used, the string value for the + system variable has not been set up yet. Do it now. + */ + if (!use_slave_mask) + { + print_slave_skip_errors(); + } + /* If master_host is not specified, try to read it from the master_info file. If master_host is specified, create the master_info file if it doesn't @@ -311,7 +321,7 @@ static void print_slave_skip_errors(void) char *bend= buff + sizeof(slave_skip_error_names); int errnum; - for (errnum= 1; errnum < MAX_SLAVE_ERROR; errnum++) + for (errnum= 0; errnum < MAX_SLAVE_ERROR; errnum++) { if (bitmap_is_set(&slave_error_mask, errnum)) {