diff --git a/mysql-test/include/rpl_events.inc b/mysql-test/include/rpl_events.inc index 5f4cc3c6985..b8fac61c383 100644 --- a/mysql-test/include/rpl_events.inc +++ b/mysql-test/include/rpl_events.inc @@ -6,7 +6,7 @@ ################################################################## --disable_warnings -DROP EVENT IF EXISTS justonce; +DROP EVENT IF EXISTS test.justonce; drop table if exists t1,t2; --enable_warnings @@ -23,9 +23,11 @@ CURRENT_TIMESTAMP, 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 +CREATE EVENT test.justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTO t1 (c) VALUES ('from justonce'); +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; + # wait 3 seconds, so the event can trigger --real_sleep 3 @@ -37,7 +39,6 @@ SELECT * FROM t1; --disable_info sync_slave_with_master; -connection slave; --echo "in the slave" --enable_info @@ -45,6 +46,8 @@ connection slave; SELECT * FROM t1; --disable_info +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; + # Create an event on the slave and check to see what the originator is. --disable_warnings DROP EVENT IF EXISTS test.slave_once; @@ -52,7 +55,7 @@ DROP EVENT IF EXISTS test.slave_once; 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; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; --disable_warnings DROP EVENT IF EXISTS test.slave_once; @@ -61,39 +64,40 @@ DROP EVENT IF EXISTS test.slave_once; connection master; # BUG#20384 - disable events on slave +--disable_warnings DROP EVENT IF EXISTS test.justonce; +--enable_warnings + 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'; +SELECT db, name, status, originator, body 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'; +SELECT db, name, status, originator, body 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'; +SELECT db, name, status, originator, body 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'; +SELECT db, name, status, originator, body 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'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; --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'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; --echo "in the master" connection master; diff --git a/mysql-test/r/rpl_events.result b/mysql-test/r/rpl_events.result index 59bd16adbf6..332d8cf1c0c 100644 --- a/mysql-test/r/rpl_events.result +++ b/mysql-test/r/rpl_events.result @@ -6,7 +6,7 @@ reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; set binlog_format=row; -DROP EVENT IF EXISTS justonce; +DROP EVENT IF EXISTS test.justonce; drop table if exists t1,t2; CREATE TABLE `t1` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, @@ -16,8 +16,11 @@ CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO t1 (c) VALUES ('manually'); -CREATE EVENT justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTo t1 +CREATE EVENT test.justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTO t1 (c) VALUES ('from justonce'); +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; +db name status originator +test justonce ENABLED 1 "in the master" SELECT * FROM t1; id c ts @@ -30,46 +33,46 @@ id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; +db name status originator +test justonce SLAVESIDE_DISABLED 1 DROP EVENT IF EXISTS test.slave_once; 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; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; db name status originator -test justonce SLAVESIDE_DISABLED 1 test slave_once ENABLED 2 DROP EVENT IF EXISTS test.slave_once; DROP EVENT IF EXISTS test.justonce; -Warnings: -Note 1305 Event justonce does not exist 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'; -db name status originator -test er ENABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er ENABLED 1 INSERT INTO t1(c) VALUES ('from er') "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; -db name status originator -test er SLAVESIDE_DISABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er SLAVESIDE_DISABLED 1 INSERT INTO t1(c) VALUES ('from er') "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'; -db name status originator -test er ENABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er ENABLED 1 INSERT into t1(c) VALUES ('from alter er') "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; -db name status originator -test er SLAVESIDE_DISABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er SLAVESIDE_DISABLED 1 INSERT into t1(c) VALUES ('from alter er') "in the master" DROP EVENT test.er; -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "in the master" DROP TABLE t1; set binlog_format=statement; -DROP EVENT IF EXISTS justonce; +DROP EVENT IF EXISTS test.justonce; drop table if exists t1,t2; CREATE TABLE `t1` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, @@ -79,8 +82,11 @@ CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO t1 (c) VALUES ('manually'); -CREATE EVENT justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTo t1 +CREATE EVENT test.justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTO t1 (c) VALUES ('from justonce'); +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; +db name status originator +test justonce ENABLED 1 "in the master" SELECT * FROM t1; id c ts @@ -93,41 +99,41 @@ id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce'; +db name status originator +test justonce SLAVESIDE_DISABLED 1 DROP EVENT IF EXISTS test.slave_once; 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; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once'; db name status originator -test justonce SLAVESIDE_DISABLED 1 test slave_once ENABLED 2 DROP EVENT IF EXISTS test.slave_once; DROP EVENT IF EXISTS test.justonce; -Warnings: -Note 1305 Event justonce does not exist 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'; -db name status originator -test er ENABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er ENABLED 1 INSERT INTO t1(c) VALUES ('from er') "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; -db name status originator -test er SLAVESIDE_DISABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er SLAVESIDE_DISABLED 1 INSERT INTO t1(c) VALUES ('from er') "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'; -db name status originator -test er ENABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er ENABLED 1 INSERT into t1(c) VALUES ('from alter er') "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; -db name status originator -test er SLAVESIDE_DISABLED 1 +SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er'; +db name status originator body +test er SLAVESIDE_DISABLED 1 INSERT into t1(c) VALUES ('from alter er') "in the master" DROP EVENT test.er; -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "in the slave" -SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; +SELECT db, name, status, originator FROM mysql.event WHERE db = 'test'; db name status originator "in the master" DROP TABLE t1; diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql index 7be5c94ad80..0c386fdc9c2 100644 --- a/scripts/mysql_system_tables.sql +++ b/scripts/mysql_system_tables.sql @@ -70,7 +70,7 @@ CALL create_slow_log_table(); DROP PROCEDURE create_slow_log_table; -CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; +CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator int(10) NOT NULL, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index a639ff89fbe..7f54ac0dfe7 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -658,7 +658,8 @@ void Event_parse_data::check_originator_id(THD *thd) (thd->system_thread == SYSTEM_THREAD_SLAVE_IO)) { DBUG_PRINT("info", ("Invoked object status set to SLAVESIDE_DISABLED.")); - if (status == Event_basic::ENABLED) + if ((status == Event_basic::ENABLED) || + (status == Event_basic::DISABLED)) status = Event_basic::SLAVESIDE_DISABLED; originator = thd->server_id; } @@ -1590,6 +1591,13 @@ Event_queue_element::update_timing_fields(THD *thd) status_changed= FALSE; } + /* + Turn off row binlogging of event timing updates. These are not used + for RBR of events replicated to the slave. + */ + if (thd->current_stmt_binlog_row_based) + thd->clear_current_stmt_binlog_row_based(); + if ((table->file->ha_update_row(table->record[1], table->record[0]))) ret= TRUE; diff --git a/sql/event_queue.cc b/sql/event_queue.cc index c0f3166777c..4858becdf0d 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -197,8 +197,8 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element) DBUG_PRINT("enter", ("thd: 0x%lx et=%s.%s", (long) thd, new_element->dbname.str, new_element->name.str)); - if (res || new_element->status == Event_queue_element::DISABLED - || new_element->status == Event_queue_element::SLAVESIDE_DISABLED) + if ((new_element->status == Event_queue_element::DISABLED) + || (new_element->status == Event_queue_element::SLAVESIDE_DISABLED)) delete new_element; else { @@ -234,7 +234,8 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name, DBUG_ENTER("Event_queue::update_event"); DBUG_PRINT("enter", ("thd: 0x%lx et=[%s.%s]", (long) thd, dbname.str, name.str)); - if (new_element->status == Event_queue_element::DISABLED) + if ((new_element->status == Event_queue_element::DISABLED) || + (new_element->status == Event_queue_element::SLAVESIDE_DISABLED)) { DBUG_PRINT("info", ("The event is disabled.")); /* diff --git a/sql/sql_show.cc b/sql/sql_show.cc index bb3f4a82e1b..2e2b661f932 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5447,8 +5447,8 @@ ST_FIELD_INFO events_fields_info[]= {"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0}, {"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0}, {"LAST_EXECUTED", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, 0}, - {"ORIGINATOR", 10, MYSQL_TYPE_LONG, 0, 0, "Originator"}, {"EVENT_COMMENT", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0}, + {"ORIGINATOR", 10, MYSQL_TYPE_LONG, 0, 0, "Originator"}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} };