1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
cbell/Chuck@mysql_cab_desk.
2007-03-16 09:56:57 -04:00
parent 2763e9af9a
commit 3e44599c11
27 changed files with 1041 additions and 90 deletions

View File

@ -58,7 +58,8 @@ Event_parse_data::new_instance(THD *thd)
*/
Event_parse_data::Event_parse_data()
:on_completion(ON_COMPLETION_DROP), status(ENABLED),
:on_completion(Event_basic::ON_COMPLETION_DROP),
status(Event_basic::ENABLED),
item_starts(NULL), item_ends(NULL), item_execute_at(NULL),
starts_null(TRUE), ends_null(TRUE), execute_at_null(TRUE),
item_expression(NULL), expression(0)
@ -550,9 +551,9 @@ Event_parse_data::check_parse_data(THD *thd)
init_name(thd, identifier);
init_definer(thd);
ret= init_execute_at(thd) || init_interval(thd) || init_starts(thd) ||
init_ends(thd);
check_originator_id(thd);
DBUG_RETURN(ret);
}
@ -598,6 +599,30 @@ Event_parse_data::init_definer(THD *thd)
}
/*
Set the originator id of the event to the server_id if executing on
the master or set to the server_id of the master if executing on
the slave. If executing on slave, also set status to SLAVESIDE_DISABLED.
SYNOPSIS
Event_parse_data::check_originator_id()
*/
void Event_parse_data::check_originator_id(THD *thd)
{
/* Disable replicated events on slave. */
if ((thd->system_thread == SYSTEM_THREAD_SLAVE_SQL) ||
(thd->system_thread == SYSTEM_THREAD_SLAVE_IO))
{
DBUG_PRINT("info", ("Invoked object status set to SLAVESIDE_DISABLED."));
if (status == Event_basic::ENABLED)
status = Event_basic::SLAVESIDE_DISABLED;
originator = thd->server_id;
}
else
originator = server_id;
}
/*
Constructor
@ -927,8 +952,23 @@ Event_queue_element::load_from_row(TABLE *table)
goto error;
DBUG_PRINT("load_from_row", ("Event [%s] is [%s]", name.str, ptr));
status= (ptr[0]=='E'? Event_queue_element::ENABLED:
Event_queue_element::DISABLED);
/* Set event status (ENABLED | SLAVESIDE_DISABLED | DISABLED) */
switch (ptr[0])
{
case 'E' :
status = Event_queue_element::ENABLED;
break;
case 'S' :
status = Event_queue_element::SLAVESIDE_DISABLED;
break;
case 'D' :
status = Event_queue_element::DISABLED;
break;
}
if ((ptr= get_field(&mem_root, table->field[ET_FIELD_ORIGINATOR])) == NullS)
goto error;
originator = table->field[ET_FIELD_ORIGINATOR]->val_int();
/* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
if ((ptr= get_field(&mem_root,
@ -1199,7 +1239,7 @@ Event_queue_element::compute_next_execution_time()
(long) TIME_to_ulonglong_datetime(&last_executed),
(long) this));
if (status == Event_queue_element::DISABLED)
if (status != Event_queue_element::ENABLED)
{
DBUG_PRINT("compute_next_execution_time",
("Event %s is DISABLED", name.str));
@ -1601,6 +1641,8 @@ Event_timed::get_create_event(THD *thd, String *buf)
if (status == Event_timed::ENABLED)
buf->append(STRING_WITH_LEN("ENABLE"));
else if (status == Event_timed::SLAVESIDE_DISABLED)
buf->append(STRING_WITH_LEN("SLAVESIDE_DISABLE"));
else
buf->append(STRING_WITH_LEN("DISABLE"));