summaryrefslogtreecommitdiff
path: root/sql/events.cc
diff options
context:
space:
mode:
authorcbell/Chuck@mysql_cab_desk. <>2007-03-16 09:56:57 -0400
committercbell/Chuck@mysql_cab_desk. <>2007-03-16 09:56:57 -0400
commit3e44599c11e90c2b6470e64dbe6d78bc6c5f9f10 (patch)
tree15f703b3b46120a527b00e8e328eb91286163cec /sql/events.cc
parent2763e9af9addbaea0d55c6653c36ee59803979d8 (diff)
downloadmariadb-git-3e44599c11e90c2b6470e64dbe6d78bc6c5f9f10.tar.gz
WL#3629 - Replication of Invocation and Invoked Features
This changeset adds replication of events and user-defined functions. There are several bug reports involved in this change: BUG#16421, BUG#17857, BUG#20384: This patch modifies the mysql.events table to permit the addition of another enum value for the status column. The column now has values of ('DISABLED','SLAVESIDE_DISABLED','ENABLED'). A status of SLAVESIDE_DISABLED is set on the slave during replication of events. This enables users to determine which events werereplicated from the master and to later enable them if they promote the slave to a master. The CREATE, ALTER, and DROP statements are binlogged. A new test was added for replication of events (rpl_events). BUG#17671: This patch modifies the code to permit logging of user-defined functions. Note: this is the CREATE FUNCTION ... SONAME variety. A more friendly error message to be displayed should a replicated user-defined function not be found in the loadable library or if the library is missing from the slave.The CREATE andDROP statements are binlogged. A new test was added for replication of user-defined functions (rpl_udf). The patch also adds a new column to the mysql.event table named 'originator' that is used to store the server_id of the server that the event originated on. This enables users to promote a slave to a master and later return the promoted slave to a slave and disable the replicated events.
Diffstat (limited to 'sql/events.cc')
-rw-r--r--sql/events.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/sql/events.cc b/sql/events.cc
index e6224915d6b..80ee613a6b9 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -347,7 +347,15 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists)
DBUG_RETURN(TRUE);
}
+ /*
+ Turn off row binlogging of this statement and use statement-based
+ so that all supporting tables are updated for CREATE EVENT command.
+ */
+ if (thd->current_stmt_binlog_row_based)
+ thd->clear_current_stmt_binlog_row_based();
+
pthread_mutex_lock(&LOCK_event_metadata);
+
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
{
@@ -357,6 +365,15 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists)
DBUG_ASSERT(ret == OP_LOAD_ERROR);
my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0));
}
+ else /* Binlog the create event. */
+ {
+ if (mysql_bin_log.is_open())
+ {
+ thd->clear_error();
+ thd->binlog_query(THD::MYSQL_QUERY_TYPE,
+ thd->query, thd->query_length, FALSE, FALSE);
+ }
+ }
}
pthread_mutex_unlock(&LOCK_event_metadata);
@@ -396,7 +413,15 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to)
DBUG_RETURN(TRUE);
}
+ /*
+ Turn off row binlogging of this statement and use statement-based
+ so that all supporting tables are updated for UPDATE EVENT command.
+ */
+ if (thd->current_stmt_binlog_row_based)
+ thd->clear_current_stmt_binlog_row_based();
+
pthread_mutex_lock(&LOCK_event_metadata);
+
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->update_event(thd, parse_data, new_dbname, new_name)))
{
@@ -406,6 +431,15 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to)
DBUG_ASSERT(ret == OP_LOAD_ERROR);
my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0));
}
+ else /* Binlog the alter event. */
+ {
+ if (mysql_bin_log.is_open())
+ {
+ thd->clear_error();
+ thd->binlog_query(THD::MYSQL_QUERY_TYPE,
+ thd->query, thd->query_length, FALSE, FALSE);
+ }
+ }
}
pthread_mutex_unlock(&LOCK_event_metadata);
@@ -445,12 +479,27 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
DBUG_RETURN(TRUE);
}
+ /*
+ Turn off row binlogging of this statement and use statement-based so
+ that all supporting tables are updated for DROP EVENT command.
+ */
+ if (thd->current_stmt_binlog_row_based)
+ thd->clear_current_stmt_binlog_row_based();
+
pthread_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
{
if (!only_from_disk)
event_queue->drop_event(thd, dbname, name);
+
+ /* Binlog the drop event. */
+ if (mysql_bin_log.is_open())
+ {
+ thd->clear_error();
+ thd->binlog_query(THD::MYSQL_QUERY_TYPE,
+ thd->query, thd->query_length, FALSE, FALSE);
+ }
}
pthread_mutex_unlock(&LOCK_event_metadata);
DBUG_RETURN(ret);