mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +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:
101
mysql-test/include/rpl_events.inc
Normal file
101
mysql-test/include/rpl_events.inc
Normal file
@ -0,0 +1,101 @@
|
||||
##################################################################
|
||||
# Author: Giuseppe, Chuck Bell #
|
||||
# Date: 17-January-2007 #
|
||||
# Purpose: To test that event effects are replicated #
|
||||
# in both row based and statement based format #
|
||||
##################################################################
|
||||
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS justonce;
|
||||
drop table if exists t1,t2;
|
||||
--enable_warnings
|
||||
|
||||
# first, we need a table to record something from an event
|
||||
|
||||
eval CREATE TABLE `t1` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`c` VARCHAR(50) NOT NULL,
|
||||
`ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
|
||||
CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=$engine_type DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO t1 (c) VALUES ('manually');
|
||||
|
||||
# then, we create the event
|
||||
CREATE EVENT justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTo t1
|
||||
(c) VALUES ('from justonce');
|
||||
|
||||
# wait 3 seconds, so the event can trigger
|
||||
--real_sleep 3
|
||||
|
||||
# check that table t1 contains something
|
||||
--echo "in the master"
|
||||
--enable_info
|
||||
--replace_column 3 TIMESTAMP
|
||||
SELECT * FROM t1;
|
||||
--disable_info
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
|
||||
--echo "in the slave"
|
||||
--enable_info
|
||||
--replace_column 3 TIMESTAMP
|
||||
SELECT * FROM t1;
|
||||
--disable_info
|
||||
|
||||
# Create an event on the slave and check to see what the originator is.
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS test.slave_once;
|
||||
--enable_warnings
|
||||
|
||||
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
|
||||
INSERT INTO t1(c) VALUES ('from slave_once');
|
||||
SELECT db, name, status, originator FROM mysql.event;
|
||||
|
||||
--disable_warnings
|
||||
DROP EVENT IF EXISTS test.slave_once;
|
||||
--enable_warnings
|
||||
|
||||
connection master;
|
||||
|
||||
# BUG#20384 - disable events on slave
|
||||
DROP EVENT IF EXISTS test.justonce;
|
||||
CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
|
||||
INSERT INTO t1(c) VALUES ('from er');
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
--echo "in the slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
connection master;
|
||||
--echo "in the master"
|
||||
ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO INSERT into t1(c) VALUES ('from alter er');
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
--echo "in the slave"
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
connection master;
|
||||
--echo "in the master"
|
||||
DROP EVENT test.er;
|
||||
--replace column 8 DATETIME
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
--disable_info
|
||||
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
--echo "in the slave"
|
||||
--replace column 8 DATETIME
|
||||
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er';
|
||||
|
||||
--echo "in the master"
|
||||
connection master;
|
||||
DROP TABLE t1;
|
||||
|
Reference in New Issue
Block a user