diff options
29 files changed, 78 insertions, 17 deletions
diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 0898b3d576f..9d3197c0bd4 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -253,4 +253,5 @@ #define ER_CANT_USE_OPTION_HERE 1234 #define ER_NOT_SUPPORTED_YET 1235 #define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 -#define ER_ERROR_MESSAGES 237 +#define ER_SLAVE_IGNORED_TABLE 1237 /* only the slave SQL thread can be sent this */ +#define ER_ERROR_MESSAGES 238 diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result new file mode 100644 index 00000000000..826e97a8004 --- /dev/null +++ b/mysql-test/r/rpl_error_ignored_table.result @@ -0,0 +1,15 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +create table t1 (a int primary key); +insert into t1 values (1),(1); +Duplicate entry '1' for key 1 +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254 +show tables like 't1'; +Tables_in_test (t1) +drop table t1; diff --git a/mysql-test/t/rpl_error_ignored_table-slave.opt b/mysql-test/t/rpl_error_ignored_table-slave.opt new file mode 100644 index 00000000000..544ecb2959b --- /dev/null +++ b/mysql-test/t/rpl_error_ignored_table-slave.opt @@ -0,0 +1 @@ +--replicate-ignore-table=test.t1
\ No newline at end of file diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_error_ignored_table.test new file mode 100644 index 00000000000..caa289a184d --- /dev/null +++ b/mysql-test/t/rpl_error_ignored_table.test @@ -0,0 +1,22 @@ +# Test for +# Bug #797: If a query is ignored on slave (replicate-ignore-table) the slave +# still checks that it has the same error as on the master. + +source include/master-slave.inc; +connection master; +create table t1 (a int primary key); +# generate an error that goes to the binlog +--error 1062; +insert into t1 values (1),(1); +save_master_pos; +connection slave; +# as the t1 table is ignored on the slave, the slave should be able to sync +sync_with_master; +show slave status; +# check that the table has been ignored, because otherwise the test is nonsense +show tables like 't1'; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/log.cc b/sql/log.cc index ef7cdd0dbd5..7bcdc12ddf1 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -875,14 +875,9 @@ void MYSQL_LOG::new_file(bool need_lock) save_log_type=log_type; name=0; // Don't free name close(); -/* - if (save_log_type == LOG_BIN) - { - printf("after close, before open; I wait for 20 seconds\n"); - sleep(20); - printf("sleep finished, opening\n"); - } -*/ + + // TODO: at this place is_open() will see the log closed, which is BUG#791. + open(old_name, save_log_type, new_name_ptr, index_file_name, io_cache_type, no_auto_events, max_size); my_free(old_name,MYF(0)); diff --git a/sql/log_event.cc b/sql/log_event.cc index 5f3d4263642..a6d2abbf894 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -69,7 +69,8 @@ static void pretty_print_str(FILE* file, char* str, int len) inline int ignored_error_code(int err_code) { - return use_slave_mask && bitmap_is_set(&slave_error_mask, err_code); + return ((err_code == ER_SLAVE_IGNORED_TABLE) || + (use_slave_mask && bitmap_is_set(&slave_error_mask, err_code))); } diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index f5e879679cc..72a593cf5f7 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -247,3 +247,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 13c061d50a1..f59abfeb6da 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -241,3 +241,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 45dbd663fec..974b4601ac8 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -249,3 +249,4 @@ "Foutieve toepassing/plaatsing van '%s'", "Deze versie van MySQL ondersteunt nog geen '%s'", "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index b7910bd07b3..3d7ca3b28df 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -238,3 +238,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index c1b98d12b3a..38b45c1443b 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -243,3 +243,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 242343769e6..df2be2803b4 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -238,3 +238,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 10ec359abe8..cdeab579eca 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -241,3 +241,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 11534d9e11b..e3778aaac10 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -238,3 +238,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index f8c5dbcc836..85ea5c2e742 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -240,3 +240,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index a82b0cdf18f..3be8058661a 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -238,3 +238,4 @@ "Uso/posizione di '%s' sbagliato", "Questa versione di MySQL non supporta ancora '%s'", "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 1b04ee5c2e4..f99d262a689 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -240,3 +240,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index c57723f81e6..2a7e03b026d 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -238,3 +238,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index e331854ff68..e6ec84e98a0 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -240,3 +240,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 817eec3058d..fe379261151 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -240,3 +240,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index e5bede3b48c..a300dc1e2ab 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -242,3 +242,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index ea4f85f6b03..f9f37bfd924 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -238,3 +238,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 7fc0c182f6a..bf1306cd332 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -242,3 +242,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index fc090205041..03964efb26b 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -240,3 +240,4 @@ "Неверное использование или в неверном месте указан '%s'", "Эта версия MySQL пока еще не поддерживает '%s'", "Получена неисправимая ошибка %d: '%-.128s' от головного сервера в процессе выборки данных из двоичного журнала", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 89a000db554..b9970465871 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -246,3 +246,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index c8e33325786..78b7e5ac907 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -239,3 +239,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 7ef663839c9..32eec834ed1 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -238,3 +238,4 @@ "Fel anvДnding/placering av '%s'", "Denna version av MySQL kan Дnnu inte utfЖra '%s'", "Fick fatalt fel %d: '%-.128s' frЕn master vid lДsning av binДrloggen" +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index a0a4a274d4b..c0931ab9f02 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -243,3 +243,4 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", +"Slave SQL thread ignored the query because of replicate-*-table rules" diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4db802ffbcc..7e2aefc493d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1324,7 +1324,11 @@ mysql_execute_command(void) given and the table list says the query should not be replicated */ if (table_rules_on && tables && !tables_ok(thd,tables)) + { + /* we warn the slave SQL thread */ + my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); DBUG_VOID_RETURN; + } #ifndef TO_BE_DELETED /* This is a workaround to deal with the shortcoming in 3.23.44-3.23.46 @@ -1339,13 +1343,7 @@ mysql_execute_command(void) #endif } - /* - Skip if we are in the slave thread, some table rules have been given - and the table list says the query should not be replicated - */ - if ((lex->select_lex.next && create_total_list(thd,lex,&tables)) || - (table_rules_on && tables && thd->slave_thread && - !tables_ok(thd,tables))) + if (lex->select_lex.next && create_total_list(thd,lex,&tables)) DBUG_VOID_RETURN; /* @@ -2330,7 +2328,10 @@ mysql_execute_command(void) if (thd->slave_thread && (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) + { + my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); break; + } if (check_access(thd,CREATE_ACL,lex->name,0,1)) break; @@ -2354,7 +2355,10 @@ mysql_execute_command(void) if (thd->slave_thread && (!db_ok(lex->name, replicate_do_db, replicate_ignore_db) || !db_ok_with_wild_table(lex->name))) + { + my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); break; + } if (check_access(thd,DROP_ACL,lex->name,0,1)) break; if (thd->locked_tables || thd->active_transaction()) |