summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/rpl_loaddata_charset.result (renamed from mysql-test/r/rpl_loaddata2.result)0
-rw-r--r--mysql-test/r/rpl_replicate_do.result34
-rw-r--r--mysql-test/t/rpl_loaddata_charset.test (renamed from mysql-test/t/rpl_loaddata2.test)0
-rw-r--r--mysql-test/t/rpl_replicate_do.test32
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/slave.cc4
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_parse.cc25
-rw-r--r--sql/sql_trigger.cc6
-rw-r--r--sql/sql_trigger.h4
11 files changed, 104 insertions, 7 deletions
diff --git a/mysql-test/r/rpl_loaddata2.result b/mysql-test/r/rpl_loaddata_charset.result
index 929d06e74cf..929d06e74cf 100644
--- a/mysql-test/r/rpl_loaddata2.result
+++ b/mysql-test/r/rpl_loaddata_charset.result
diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result
index 43e7c6779bf..51a281fdb12 100644
--- a/mysql-test/r/rpl_replicate_do.result
+++ b/mysql-test/r/rpl_replicate_do.result
@@ -41,3 +41,37 @@ select * from t1;
ts
2005-08-12 00:00:00
drop table t1;
+*** master ***
+create table t1 (a int, b int);
+create trigger trg1 before insert on t1 for each row set new.b=2;
+create table t2 (a int, b int);
+create trigger trg2 before insert on t2 for each row set new.b=2;
+show tables;
+Tables_in_test
+t1
+t2
+show triggers;
+Trigger Event Table Statement Timing Created sql_mode Definer
+trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
+trg2 INSERT t2 set new.b=2 BEFORE NULL root@localhost
+*** slave ***
+show tables;
+Tables_in_test
+t1
+show triggers;
+Trigger Event Table Statement Timing Created sql_mode Definer
+trg1 INSERT t1 set new.b=2 BEFORE NULL root@localhost
+*** master ***
+drop trigger trg1;
+drop trigger trg2;
+show triggers;
+Trigger Event Table Statement Timing Created sql_mode Definer
+*** slave ***
+show tables;
+Tables_in_test
+t1
+show triggers;
+Trigger Event Table Statement Timing Created sql_mode Definer
+*** master ***
+drop table t1;
+drop table t2;
diff --git a/mysql-test/t/rpl_loaddata2.test b/mysql-test/t/rpl_loaddata_charset.test
index 7f2389cb9f6..7f2389cb9f6 100644
--- a/mysql-test/t/rpl_loaddata2.test
+++ b/mysql-test/t/rpl_loaddata_charset.test
diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test
index e7141c3f905..600840a2828 100644
--- a/mysql-test/t/rpl_replicate_do.test
+++ b/mysql-test/t/rpl_replicate_do.test
@@ -58,3 +58,35 @@ drop table t1;
sync_slave_with_master;
# End of 4.1 tests
+
+#
+# Bug#24478 DROP TRIGGER is not caught by replicate-*-table filters
+#
+--echo *** master ***
+connection master;
+create table t1 (a int, b int);
+create trigger trg1 before insert on t1 for each row set new.b=2;
+create table t2 (a int, b int);
+create trigger trg2 before insert on t2 for each row set new.b=2;
+show tables;
+show triggers;
+sync_slave_with_master;
+--echo *** slave ***
+connection slave;
+show tables;
+show triggers;
+--echo *** master ***
+connection master;
+drop trigger trg1;
+drop trigger trg2;
+show triggers;
+sync_slave_with_master;
+--echo *** slave ***
+connection slave;
+show tables;
+show triggers;
+--echo *** master ***
+connection master;
+drop table t1;
+drop table t2;
+sync_slave_with_master;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 88ebe83dd1f..fad99a083df 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -99,7 +99,7 @@ void net_set_read_timeout(NET *net, uint timeout);
#define WARN_DEPRECATED(Thd,Ver,Old,New) \
do { \
DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \
- if (Thd != NULL) \
+ if (((gptr)Thd) != NULL) \
push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \
(Old), (Ver), (New)); \
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 38dd0ae5de7..57d91bfdad0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7632,7 +7632,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (!slave_warning_issued) //only show the warning once
{
slave_warning_issued = true;
- WARN_DEPRECATED(0, "5.2", "for replication startup options",
+ WARN_DEPRECATED(NULL, "5.2", "for replication startup options",
"'CHANGE MASTER'");
}
break;
diff --git a/sql/slave.cc b/sql/slave.cc
index bb2aa11626e..dc37ad34e70 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -53,6 +53,10 @@ ulonglong relay_log_space_limit = 0;
*/
int disconnect_slave_event_count = 0, abort_slave_event_count = 0;
+int events_till_abort = -1;
+#ifndef DBUG_OFF
+static int events_till_disconnect = -1;
+#endif
typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index a1f028796ae..5a3f0a7b261 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -362,6 +362,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
List_item *values;
Name_resolution_context *context;
Name_resolution_context_state ctx_state;
+#ifndef EMBEDDED_LIBRARY
char *query= thd->query;
/*
log_on is about delayed inserts only.
@@ -370,6 +371,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
*/
bool log_on= ((thd->options & OPTION_BIN_LOG) ||
(!(thd->security_ctx->master_access & SUPER_ACL)));
+#endif
thr_lock_type lock_type = table_list->lock_type;
Item *unused_conds= 0;
DBUG_ENTER("mysql_insert");
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 11eb510d6c8..e0ff22200e2 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -27,6 +27,7 @@
#include "sp_cache.h"
#include "events.h"
#include "event_data_objects.h"
+#include "sql_trigger.h"
/* Used in error handling only */
#define SP_TYPE_STRING(LP) \
@@ -1596,6 +1597,30 @@ mysql_execute_command(THD *thd)
#ifdef HAVE_REPLICATION
if (unlikely(thd->slave_thread))
{
+ if (lex->sql_command == SQLCOM_DROP_TRIGGER)
+ {
+ /*
+ When dropping a trigger, we need to load its table name
+ before checking slave filter rules.
+ */
+ add_table_for_trigger(thd, thd->lex->spname, 1, &all_tables);
+
+ if (!all_tables)
+ {
+ /*
+ If table name cannot be loaded,
+ it means the trigger does not exists possibly because
+ CREATE TRIGGER was previously skipped for this trigger
+ according to slave filtering rules.
+ Returning success without producing any errors in this case.
+ */
+ DBUG_RETURN(0);
+ }
+
+ // force searching in slave.cc:tables_ok()
+ all_tables->updating= 1;
+ }
+
/*
Check if statment should be skipped because of slave filtering
rules
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index df363c3c21c..5c61f172ecd 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -106,10 +106,6 @@ const LEX_STRING trg_event_type_names[]=
};
-static int
-add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
- TABLE_LIST ** table);
-
class Handle_old_incorrect_sql_modes_hook: public Unknown_key_hook
{
private:
@@ -1180,7 +1176,7 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event,
1 Error
*/
-static int
+int
add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
TABLE_LIST **table)
{
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index 75dda6be1cf..707fcc4e380 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -137,3 +137,7 @@ private:
extern const LEX_STRING trg_action_time_type_names[];
extern const LEX_STRING trg_event_type_names[];
+
+int
+add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists,
+ TABLE_LIST **table);