From: Date: February 8 2007 8:00pm Subject: bk commit into 5.1 tree (cbell:1.2409) BUG#16421 List-Archive: http://lists.mysql.com/commits/19581 Message-Id: <200702081900.l18J0m3T013470@mail.mysql.com> Below is the list of changes that have just been committed into a local 5.1 repository of cbell. When cbell does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-02-08 13:32:10-05:00, cbell@mysql_cab_desk. +27 -0 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. mysql-test/include/rpl_events.inc@stripped, 2007-02-08 13:32:06-05:00, cbell@mysql_cab_desk. +92 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new include file for testing replication of events. This file contains the core test procedures. mysql-test/include/rpl_events.inc@stripped, 2007-02-08 13:32:06-05:00, cbell@mysql_cab_desk. +0 -0 mysql-test/include/rpl_udf.inc@stripped, 2007-02-08 13:32:06-05:00, cbell@mysql_cab_desk. +185 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new include file for testing replication of UDFs. This file contains the core test procedures. mysql-test/include/rpl_udf.inc@stripped, 2007-02-08 13:32:06-05:00, cbell@mysql_cab_desk. +0 -0 mysql-test/lib/init_db.sql@stripped, 2007-02-08 13:31:57-05:00, cbell@mysql_cab_desk. +2 -1 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. mysql-test/r/events.result@stripped, 2007-02-08 13:31:57-05:00, cbell@mysql_cab_desk. +15 -14 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/events_grant.result@stripped, 2007-02-08 13:31:58-05:00, cbell@mysql_cab_desk. +12 -12 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_grant test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/events_restart_phase1.result@stripped, 2007-02-08 13:31:58-05:00, cbell@mysql_cab_desk. +2 -2 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_restart_phase1 test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/rpl_events.result@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +115 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new result file for testing replication of events. mysql-test/r/rpl_events.result@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +0 -0 mysql-test/r/rpl_udf.result@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +310 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new result file for testing replication of UDFs. mysql-test/r/rpl_udf.result@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +0 -0 mysql-test/r/system_mysql_db.result@stripped, 2007-02-08 13:31:58-05:00, cbell@mysql_cab_desk. +2 -1 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. These changes to the result file were necessary to ensure correct test results. mysql-test/t/events.test@stripped, 2007-02-08 13:31:59-05:00, cbell@mysql_cab_desk. +1 -1 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events test. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/t/events_restart_phase1.test@stripped, 2007-02-08 13:31:59-05:00, cbell@mysql_cab_desk. +2 -2 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_restart_phase1 test. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/t/rpl_events.test@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +24 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new test for testing replication of events. The test uses include files so that the test can test under both RBR and SBR. mysql-test/t/rpl_events.test@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +0 -0 mysql-test/t/rpl_udf.test@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +22 -0 WL#3629 - Replication of Invocation and Invoked Features This patch adds a new test for testing replication of UDFs. The test uses include files so that the test can test under both RBR and SBR. mysql-test/t/rpl_udf.test@stripped, 2007-02-08 13:32:05-05:00, cbell@mysql_cab_desk. +0 -0 scripts/mysql_create_system_tables.sh@stripped, 2007-02-08 13:31:59-05:00, cbell@mysql_cab_desk. +2 -1 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. scripts/mysql_fix_privilege_tables.sql@stripped, 2007-02-08 13:32:00-05:00, cbell@mysql_cab_desk. +2 -1 WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. sql/event_data_objects.cc@stripped, 2007-02-08 13:32:00-05:00, cbell@mysql_cab_desk. +24 -4 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. This patch uses the new Event_basic:: enumerated values. sql/event_data_objects.h@stripped, 2007-02-08 13:32:00-05:00, cbell@mysql_cab_desk. +24 -28 WL#3629 - Replication of Invocation and Invoked Features This patch moves the duplicated enumeration values for ENABLED, SLAVESIDE_DISABLED, and DISABLED to the Event_basic class removing them from the other Event_* classes. sql/event_db_repository.cc@stripped, 2007-02-08 13:32:01-05:00, cbell@mysql_cab_desk. +12 -2 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. 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. sql/event_db_repository.h@stripped, 2007-02-08 13:32:01-05:00, cbell@mysql_cab_desk. +1 -0 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add a new field named 'originator' to the enum_event_table_field and associated structure. sql/event_queue.cc@stripped, 2007-02-08 13:32:01-05:00, cbell@mysql_cab_desk. +5 -3 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. sql/events.cc@stripped, 2007-02-08 13:32:02-05:00, cbell@mysql_cab_desk. +39 -0 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. sql/lex.h@stripped, 2007-02-08 13:32:02-05:00, cbell@mysql_cab_desk. +1 -0 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add the new SLAVESIDE_DISABLE symbol to the lexical parser. sql/slave.cc@stripped, 2007-02-08 13:32:02-05:00, cbell@mysql_cab_desk. +17 -2 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit the capture of the error on the slave when a UDF from a loadable library is not loaded on the server when replicated from the master. sql/sql_parse.cc@stripped, 2007-02-08 13:32:03-05:00, cbell@mysql_cab_desk. +0 -1 WL#3629 - Replication of Invocation and Invoked Features This patch removes the comment because drop functions commands are replicated. sql/sql_show.cc@stripped, 2007-02-08 13:32:03-05:00, cbell@mysql_cab_desk. +9 -2 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. The code also adds changes the display width of the status column for the schema table for the show events command and also adds the new column 'originator' to the events_field_info structure. sql/sql_udf.cc@stripped, 2007-02-08 13:32:04-05:00, cbell@mysql_cab_desk. +18 -0 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add the binlogging of the create and drop function events. sql/sql_yacc.yy@stripped, 2007-02-08 13:32:04-05:00, cbell@mysql_cab_desk. +12 -4 WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to change the enumeration of the status column for the events in the parser. The code uses the Event_basic:: enumerations allowing the enums to be defined in one place. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: cbell # Host: mysql_cab_desk. # Root: C:/source/c++/mysql-5.1_WL_3629 --- 1.169/sql/lex.h 2007-02-08 13:32:31 -05:00 +++ 1.170/sql/lex.h 2007-02-08 13:32:31 -05:00 @@ -467,6 +467,7 @@ { "SIGNED", SYM(SIGNED_SYM)}, { "SIMPLE", SYM(SIMPLE_SYM)}, { "SLAVE", SYM(SLAVE)}, + { "SLAVESIDE_DISABLE", SYM(SLAVESIDE_DISABLE_SYM)}, /* WL#3629 */ { "SNAPSHOT", SYM(SNAPSHOT_SYM)}, { "SMALLINT", SYM(SMALLINT)}, { "SOCKET", SYM(SOCKET_SYM)}, --- 1.302/sql/slave.cc 2007-02-08 13:32:31 -05:00 +++ 1.303/sql/slave.cc 2007-02-08 13:32:31 -05:00 @@ -2393,10 +2393,25 @@ /* Print any warnings issued */ List_iterator_fast it(thd->warn_list); MYSQL_ERROR *err; + /* + WL#3629: added controlled slave thread cancel for replication + of user-defined variables. + */ + bool udf_error = false; while ((err= it++)) + { + if (err->code == ER_CANT_OPEN_LIBRARY) + udf_error = true; sql_print_warning("Slave: %s Error_code: %d",err->msg, err->code); - - sql_print_error("\ + } + if (udf_error) + sql_print_error("Error loading user-defined library, slave SQL " + "thread aborted. Install the missing library, and restart the " + "slave SQL thread with \"SLAVE START\". We stopped at log '%s' " + "position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, + llbuff)); + else + sql_print_error("\ Error running query, slave SQL thread aborted. Fix the problem, and restart \ the slave SQL thread with \"SLAVE START\". We stopped at log \ '%s' position %s", RPL_LOG_NAME, llstr(rli->group_master_log_pos, llbuff)); --- 1.616/sql/sql_parse.cc 2007-02-08 13:32:31 -05:00 +++ 1.617/sql/sql_parse.cc 2007-02-08 13:32:31 -05:00 @@ -4839,7 +4839,6 @@ if (check_access(thd, DELETE_ACL, "mysql", 0, 1, 0, 0)) goto error; - /* Does NOT write to binlog */ if (!(res = mysql_drop_function(thd, &lex->spname->m_name))) { send_ok(thd); --- 1.385/sql/sql_show.cc 2007-02-08 13:32:31 -05:00 +++ 1.386/sql/sql_show.cc 2007-02-08 13:32:31 -05:00 @@ -49,6 +49,7 @@ ISE_STARTS, ISE_ENDS, ISE_STATUS, + ISE_ORIGINATOR, ISE_ON_COMPLETION, ISE_CREATED, ISE_LAST_ALTERED, @@ -4345,8 +4346,13 @@ /* status */ if (et.status == Event_timed::ENABLED) sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN("ENABLED"), scs); + /* WL#3629 */ + else if (et.status == Event_timed::SLAVESIDE_DISABLED) + sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN("SLAVESIDE_DISABLED"), + scs); else sch_table->field[ISE_STATUS]->store(STRING_WITH_LEN("DISABLED"), scs); + sch_table->field[ISE_ORIGINATOR]->store(et.originator, TRUE); /* on_completion */ if (et.on_completion == Event_timed::ON_COMPLETION_DROP) @@ -4835,7 +4841,7 @@ { TABLE *table; DBUG_ENTER("mysql_schema_table"); - if (!(table= table_list->schema_table->create_table(thd, table_list))) + if (!(table= table_list->schema_table->create_table(thd, table_list))) { DBUG_RETURN(1); } @@ -5318,7 +5324,8 @@ {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, 0}, {"STARTS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Starts"}, {"ENDS", 0, MYSQL_TYPE_TIMESTAMP, 0, 1, "Ends"}, - {"STATUS", 8, MYSQL_TYPE_STRING, 0, 0, "Status"}, + {"STATUS", 18, MYSQL_TYPE_STRING, 0, 0, "Status"}, /* WL#3629 */ + {"ORIGINATOR", 10, MYSQL_TYPE_LONG, 0, 0, "Originator"}, /* WL#3629 */ {"ON_COMPLETION", 12, MYSQL_TYPE_STRING, 0, 0, 0}, {"CREATED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0}, {"LAST_ALTERED", 0, MYSQL_TYPE_TIMESTAMP, 0, 0, 0}, --- 1.70/sql/sql_udf.cc 2007-02-08 13:32:31 -05:00 +++ 1.71/sql/sql_udf.cc 2007-02-08 13:32:31 -05:00 @@ -466,6 +466,15 @@ goto err; } rw_unlock(&THR_LOCK_udf); + + /* WL#3629 : Binlog the create function. */ + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, + thd->query, thd->query_length, FALSE, FALSE); + } + DBUG_RETURN(0); err: @@ -525,6 +534,15 @@ close_thread_tables(thd); rw_unlock(&THR_LOCK_udf); + + /* WL#3629 : Binlog the drop function. */ + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, + thd->query, thd->query_length, FALSE, FALSE); + } + DBUG_RETURN(0); err: rw_unlock(&THR_LOCK_udf); --- 1.533/sql/sql_yacc.yy 2007-02-08 13:32:31 -05:00 +++ 1.534/sql/sql_yacc.yy 2007-02-08 13:32:31 -05:00 @@ -791,6 +791,7 @@ %token SIGNED_SYM %token SIMPLE_SYM /* SQL-2003-N */ %token SLAVE +%token SLAVESIDE_DISABLE_SYM /* WL#3629 */ %token SMALLINT /* SQL-2003-R */ %token SNAPSHOT_SYM %token SOCKET_SYM @@ -1610,12 +1611,18 @@ opt_ev_status: /* empty */ { $$= 0; } | ENABLE_SYM { - Lex->event_parse_data->status= Event_parse_data::ENABLED; + Lex->event_parse_data->status= Event_basic::ENABLED; + $$= 1; + } + /* WL#3629 */ + | SLAVESIDE_DISABLE_SYM + { + Lex->event_parse_data->status= Event_basic::SLAVESIDE_DISABLED; $$= 1; } | DISABLE_SYM { - Lex->event_parse_data->status= Event_parse_data::DISABLED; + Lex->event_parse_data->status= Event_basic::DISABLED; $$= 1; } ; @@ -1645,13 +1652,13 @@ ON COMPLETION_SYM PRESERVE_SYM { Lex->event_parse_data->on_completion= - Event_parse_data::ON_COMPLETION_PRESERVE; + Event_basic::ON_COMPLETION_PRESERVE; $$= 1; } | ON COMPLETION_SYM NOT_SYM PRESERVE_SYM { Lex->event_parse_data->on_completion= - Event_parse_data::ON_COMPLETION_DROP; + Event_basic::ON_COMPLETION_DROP; $$= 1; } ; @@ -9789,6 +9796,7 @@ | SIMPLE_SYM {} | SHARE_SYM {} | SHUTDOWN {} + | SLAVESIDE_DISABLE_SYM {} /* WL#3629 */ | SNAPSHOT_SYM {} | SOUNDS_SYM {} | SQL_CACHE_SYM {} --- 1.46/mysql-test/r/events.result 2007-02-08 13:32:31 -05:00 +++ 1.47/mysql-test/r/events.result 2007-02-08 13:32:31 -05:00 @@ -193,7 +193,7 @@ SHOW CREATE EVENT ????21; Event sql_mode Create Event ????21 CREATE EVENT `????21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND ON COMPLETION NOT PRESERVE ENABLE COMMENT '???? ? 1251 ????????' DO select 1 -insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND"); +insert into mysql.event (db, name, body, definer, interval_value, interval_field, originator) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND", 1); show create event root22; ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND' SHOW EVENTS; @@ -225,18 +225,18 @@ set names latin1; CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED 1 ALTER TABLE mysql.event ADD dummy INT FIRST; SHOW EVENTS; -ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 17. Table probably corrupted +ERROR HY000: Column count of mysql.event is wrong. Expected 17, found 18. Table probably corrupted ALTER TABLE mysql.event DROP dummy, ADD dummy2 VARCHAR(64) FIRST; SHOW EVENTS; -ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 17. Table probably corrupted +ERROR HY000: Column count of mysql.event is wrong. Expected 17, found 18. Table probably corrupted ALTER TABLE mysql.event DROP dummy2; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED 1 CREATE TABLE event_like LIKE mysql.event; INSERT INTO event_like SELECT * FROM mysql.event; ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default ''; @@ -258,7 +258,8 @@ `last_executed` datetime DEFAULT NULL, `starts` datetime DEFAULT NULL, `ends` datetime DEFAULT NULL, - `status` enum('ENABLED','DISABLED') NOT NULL DEFAULT 'ENABLED', + `status` enum('ENABLED','SLAVESIDE_DISABLED','DISABLED') NOT NULL DEFAULT 'ENABLED', + `originator` int(10) NOT NULL, `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') NOT NULL DEFAULT '', `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', @@ -269,8 +270,8 @@ ALTER TABLE mysql.event MODIFY db char(64) character set utf8 collate utf8_bin default ''; "This should work" SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED 1 ALTER TABLE mysql.event MODIFY db char(64) character set cp1251 default ''; SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log. @@ -279,14 +280,14 @@ ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error log. ALTER TABLE mysql.event DROP comment, DROP starts; SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; -ERROR HY000: Column count of mysql.event is wrong. Expected 16, found 14. Table probably corrupted +ERROR HY000: Column count of mysql.event is wrong. Expected 17, found 15. Table probably corrupted DROP TABLE mysql.event; CREATE TABLE mysql.event like event_like; INSERT INTO mysql.event SELECT * FROM event_like; DROP TABLE event_like; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test intact_check root@localhost RECURRING NULL 10 HOUR # # ENABLED 1 DROP EVENT intact_check; create event e_26 on schedule at '2017-01-01 00:00:00' disable do set @a = 5; select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; @@ -399,5 +400,5 @@ SHOW EVENTS FROM ``; ERROR 42000: Incorrect database name '' SHOW EVENTS FROM `events\\test`; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator drop database events_test; --- 1.3/mysql-test/r/events_grant.result 2007-02-08 13:32:31 -05:00 +++ 1.4/mysql-test/r/events_grant.result 2007-02-08 13:32:31 -05:00 @@ -2,8 +2,8 @@ use events_test; CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED 1 SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT NULL events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE @@ -29,8 +29,8 @@ USE events_test; "We should see one event"; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED 1 SELECT CONCAT("Let's create some new events from the name of ", USER()); CONCAT("Let's create some new events from the name of ", USER()) Let's create some new events from the name of ev_test@localhost @@ -40,18 +40,18 @@ CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123; "Now we should see 3 events:"; SHOW EVENTS; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED -events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED -events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test one_event root@localhost RECURRING NULL 10 SECOND # # ENABLED 1 +events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED 1 +events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED 1 "This should show us only 2 events:"; SHOW EVENTS LIKE 't%event'; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status -events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED -events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator +events_test three_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED 1 +events_test two_event ev_test@localhost RECURRING NULL 20 SECOND # # ENABLED 1 "This should show us no events:"; SHOW EVENTS FROM test LIKE '%'; -Db Name Definer Type Execute at Interval value Interval field Starts Ends Status +Db Name Definer Type Execute at Interval value Interval field Starts Ends Status Originator GRANT EVENT ON events_test2.* TO ev_test@localhost; USE events_test2; CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; --- 1.2/mysql-test/r/events_restart_phase1.result 2007-02-08 13:32:31 -05:00 +++ 1.3/mysql-test/r/events_restart_phase1.result 2007-02-08 13:32:31 -05:00 @@ -7,6 +7,6 @@ create event abc3 on schedule every 1 second do insert into execution_log value('abc3'); select name from execution_log; name -insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1'); -insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2'); +insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED',1,'DROP','','comment1'); +insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED',1,'DROP','','comment2'); "Now we restart the server" --- 1.43/mysql-test/t/events.test 2007-02-08 13:32:31 -05:00 +++ 1.44/mysql-test/t/events.test 2007-02-08 13:32:31 -05:00 @@ -160,7 +160,7 @@ set names cp1251; create event ????21 on schedule every '50:23:59:95' day_second COMMENT '???? ? 1251 ????????' do select 1; SHOW CREATE EVENT ????21; -insert into mysql.event (db, name, body, definer, interval_value, interval_field) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND"); +insert into mysql.event (db, name, body, definer, interval_value, interval_field, originator) values (database(), "root22", "select 1", user(), 100, "SECOND_MICROSECOND", 1); --error ER_NOT_SUPPORTED_YET show create event root22; --error ER_NOT_SUPPORTED_YET --- 1.2/mysql-test/t/events_restart_phase1.test 2007-02-08 13:32:31 -05:00 +++ 1.3/mysql-test/t/events_restart_phase1.test 2007-02-08 13:32:31 -05:00 @@ -14,6 +14,6 @@ --sleep 1.5 select name from execution_log; -insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment1'); -insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED','DROP','','comment2'); +insert into mysql.event values ('db1','bad','select 42','root@localhost',NULL,1000,'MICROSECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED',1,'DROP','','comment1'); +insert into mysql.event values ('db1','bad2','sect','root@localhost',NULL,1000,'SECOND','2006-05-05 17:39:11','2006-05-05 17:39:20','2016-05-05 15:39:24','2016-05-05 15:39:11',NULL,'ENABLED',1,'DROP','','comment2'); --echo "Now we restart the server" --- 1.67/sql/events.cc 2007-02-08 13:32:31 -05:00 +++ 1.68/sql/events.cc 2007-02-08 13:32:31 -05:00 @@ -348,6 +348,19 @@ } pthread_mutex_lock(&LOCK_event_metadata); + + /* WL#3629 - 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 (parse_data->status == Event_basic::ENABLED) + parse_data->status = Event_basic::SLAVESIDE_DISABLED; + parse_data->originator = thd->server_id; + } + else + parse_data->originator = server_id; + /* 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 +370,15 @@ DBUG_ASSERT(ret == OP_LOAD_ERROR); my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0)); } + else /* WL#3629 : 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); @@ -406,6 +428,15 @@ DBUG_ASSERT(ret == OP_LOAD_ERROR); my_error(ER_EVENT_MODIFY_QUEUE_ERROR, MYF(0)); } + else /* WL#3629 : 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); @@ -451,6 +482,14 @@ { if (!only_from_disk) event_queue->drop_event(thd, dbname, name); + + /* WL#3629 : 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); --- 1.20/sql/event_db_repository.cc 2007-02-08 13:32:31 -05:00 +++ 1.21/sql/event_db_repository.cc 2007-02-08 13:32:31 -05:00 @@ -94,7 +94,14 @@ }, { { C_STRING_WITH_LEN("status") }, - { C_STRING_WITH_LEN("enum('ENABLED','DISABLED')") }, + /* WL#3629 */ + { C_STRING_WITH_LEN("enum('ENABLED','SLAVESIDE_DISABLED','DISABLED')") }, + {NULL, 0} + }, + /* WL#3629 */ + { + { C_STRING_WITH_LEN("originator") }, + { C_STRING_WITH_LEN("int(10)") }, {NULL, 0} }, { @@ -170,6 +177,10 @@ fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE); + /* WL#3629 */ + fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE); + + /* Change the SQL_MODE only if body was present in an ALTER EVENT and of course always during CREATE EVENT. @@ -535,7 +546,6 @@ my_error(ER_EVENT_OPEN_TABLE_FAILED, MYF(0)); goto err; } - DBUG_PRINT("info", ("name: %.*s", parse_data->name.length, parse_data->name.str)); --- 1.12/sql/event_db_repository.h 2007-02-08 13:32:31 -05:00 +++ 1.13/sql/event_db_repository.h 2007-02-08 13:32:31 -05:00 @@ -32,6 +32,7 @@ ET_FIELD_STARTS, ET_FIELD_ENDS, ET_FIELD_STATUS, + ET_FIELD_ORIGINATOR, ET_FIELD_ON_COMPLETION, ET_FIELD_SQL_MODE, ET_FIELD_COMMENT, --- 1.21/sql/event_queue.cc 2007-02-08 13:32:31 -05:00 +++ 1.22/sql/event_queue.cc 2007-02-08 13:32:31 -05:00 @@ -220,7 +220,9 @@ new_element= new Event_queue_element(); res= db_repository->load_named_event(thd, dbname, name, new_element); - if (res || new_element->status == Event_queue_element::DISABLED) + /* WL#3629 */ + if (res || new_element->status == Event_queue_element::DISABLED + || new_element->status == Event_queue_element::SLAVESIDE_DISABLED) delete new_element; else { @@ -233,7 +235,6 @@ pthread_cond_broadcast(&COND_queue_state); UNLOCK_QUEUE_DATA(); } - DBUG_RETURN(res); } @@ -273,7 +274,8 @@ delete new_element; goto end; } - else if (new_element->status == Event_queue_element::DISABLED) + /* WL#3629 */ + else if (new_element->status != Event_queue_element::ENABLED) { DBUG_PRINT("info", ("The event is disabled.")); /* --- 1.83/sql/event_data_objects.cc 2007-02-08 13:32:32 -05:00 +++ 1.84/sql/event_data_objects.cc 2007-02-08 13:32:32 -05:00 @@ -58,7 +58,8 @@ */ 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) @@ -927,8 +928,23 @@ 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); + + /* WL#3629 : 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 +1215,8 @@ (long) TIME_to_ulonglong_datetime(&last_executed), (long) this)); - if (status == Event_queue_element::DISABLED) + /* WL#3629 */ + if (status != Event_queue_element::ENABLED) { DBUG_PRINT("compute_next_execution_time", ("Event %s is DISABLED", name.str)); @@ -1602,6 +1619,9 @@ if (status == Event_timed::ENABLED) buf->append(STRING_WITH_LEN("ENABLE")); + /* WL#3629 */ + else if (status == Event_timed::SLAVESIDE_DISABLED) + buf->append(STRING_WITH_LEN("SLAVESIDE_DISABLE")); else buf->append(STRING_WITH_LEN("DISABLE")); --- 1.15/sql/event_data_objects.h 2007-02-08 13:32:32 -05:00 +++ 1.16/sql/event_data_objects.h 2007-02-08 13:32:32 -05:00 @@ -22,17 +22,33 @@ #define EVEX_BAD_PARAMS -5 #define EVEX_MICROSECOND_UNSUP -6 - class sp_head; class Sql_alloc; - class Event_basic { protected: MEM_ROOT mem_root; public: + /* + ENABLED = feature can function normally (is turned on) + SLAVESIDE_DISABLED = feature is turned off on slave + DISABLED = feature is turned off + */ + typedef enum enum_status + { + ENABLED = 1, + SLAVESIDE_DISABLED = 2, /* WL#3629 */ + DISABLED + } ENUM_STATUS; + + typedef enum enum_on_completion + { + ON_COMPLETION_DROP = 1, + ON_COMPLETION_PRESERVE + } ENUM_ON_COMPLETION; + LEX_STRING dbname; LEX_STRING name; LEX_STRING definer;// combination of user and host @@ -57,20 +73,9 @@ bool last_executed_changed; public: - enum enum_status - { - ENABLED = 1, - DISABLED - }; - - enum enum_on_completion - { - ON_COMPLETION_DROP = 1, - ON_COMPLETION_PRESERVE - }; - - enum enum_on_completion on_completion; - enum enum_status status; + Event_basic::ENUM_ON_COMPLETION on_completion; + Event_basic::ENUM_STATUS status; + longlong originator; TIME last_executed; TIME execute_at; @@ -194,19 +199,10 @@ class Event_parse_data : public Sql_alloc { public: - enum enum_status - { - ENABLED = 1, - DISABLED - }; - enum enum_on_completion - { - ON_COMPLETION_DROP = 1, - ON_COMPLETION_PRESERVE - }; - enum enum_on_completion on_completion; - enum enum_status status; + Event_basic::ENUM_ON_COMPLETION on_completion; + Event_basic::ENUM_STATUS status; + longlong originator; const uchar *body_begin; --- New file --- +++ mysql-test/include/rpl_events.inc 07/02/08 13:32:06 ################################################################## # 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" --replace column 8 DATETIME 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; --- New file --- +++ mysql-test/include/rpl_udf.inc 07/02/08 13:32:06 ##################################################################### # Author: Chuck Bell # # Date: 2006-12-21 # # Purpose: To test that UDFs are replicated in both row based and # # statement based format. This tests work completed in WL#3629. # # # # This test is designed to exercise two of the three types of UDFs: # # 1) UDFs via loadable libraries, and 2) UDFs with a SQL body. # ##################################################################### --source include/have_udf.inc # # To run this tests the "sql/udf_example.c" need to be compiled into # udf_example.so and LD_LIBRARY_PATH should be setup to point out where # the library are. # connection master; --disable_warnings drop table if exists t1; --enable_warnings # # Test 1) Test UDFs via loadable libraries # --echo "*** Test 1) Test UDFs via loadable libraries *** --echo "Running on the master" --enable_info --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB --error ER_CANT_FIND_DL_ENTRY eval CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; SELECT * FROM mysql.func; --disable_info sync_slave_with_master; # Check to see that UDF CREATE statements were replicated --echo "Running on the slave" --enable_info SELECT * FROM mysql.func; --disable_info connection master; # Use the UDFs to do something --echo "Running on the master" --enable_info eval CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=$engine_type; INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); SELECT * FROM t1 ORDER BY sum; --disable_info sync_slave_with_master; # Check to see if data was replicated --echo "Running on the slave" --enable_info SELECT * FROM t1 ORDER BY sum; # Check to see that the functions are available for execution on the slave SELECT myfunc_int(25); SELECT myfunc_double(75.00); --disable_info connection master; # Drop the functions --echo "Running on the master" --enable_info DROP FUNCTION myfunc_double; DROP FUNCTION myfunc_int; SELECT * FROM mysql.func; --disable_info sync_slave_with_master; # Check to see if the UDFs were dropped on the slave --echo "Running on the slave" --enable_info SELECT * FROM mysql.func; --disable_info connection master; # Cleanup --echo "Running on the master" --enable_info DROP TABLE t1; --disable_info # # Test 2) Test UDFs with SQL body # --echo "*** Test 2) Test UDFs with SQL body *** --echo "Running on the master" --enable_info CREATE FUNCTION myfuncsql_int(i INT) RETURNS INTEGER DETERMINISTIC RETURN i; CREATE FUNCTION myfuncsql_double(d DOUBLE) RETURNS INTEGER DETERMINISTIC RETURN d * 0.95; SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; --disable_info sync_slave_with_master; # Check to see that UDF CREATE statements were replicated --echo "Running on the slave" --enable_info SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; --disable_info connection master; # Use the UDFs to do something --echo "Running on the master" --enable_info eval CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=$engine_type; INSERT INTO t1 VALUES(myfuncsql_int(100), myfuncsql_double(50.00)); INSERT INTO t1 VALUES(myfuncsql_int(10), myfuncsql_double(5.00)); INSERT INTO t1 VALUES(myfuncsql_int(200), myfuncsql_double(25.00)); INSERT INTO t1 VALUES(myfuncsql_int(1), myfuncsql_double(500.00)); SELECT * FROM t1 ORDER BY sum; --disable_info sync_slave_with_master; # Check to see if data was replicated --echo "Running on the slave" --enable_info SELECT * FROM t1 ORDER BY sum; --disable_info connection master; # Modify the UDFs to add a comment --echo "Running on the master" --enable_info ALTER FUNCTION myfuncsql_int COMMENT "This was altered."; ALTER FUNCTION myfuncsql_double COMMENT "This was altered."; SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; --disable_info sync_slave_with_master; # Check to see if data was replicated --echo "Running on the slave" --enable_info SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; # Check to see that the functions are available for execution on the slave SELECT myfuncsql_int(25); SELECT myfuncsql_double(75.00); --disable_info connection master; # Drop the functions --echo "Running on the master" --enable_info DROP FUNCTION myfuncsql_double; DROP FUNCTION myfuncsql_int; SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; --disable_info sync_slave_with_master; # Check to see if the UDFs were dropped on the slave --echo "Running on the slave" --enable_info SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; --disable_info connection master; # Cleanup --echo "Running on the master" --enable_info DROP TABLE t1; --disable_info --- New file --- +++ mysql-test/r/rpl_events.result 07/02/08 13:32:05 set global event_scheduler=1; stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; 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 table if exists t1,t2; 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=MyISAM DEFAULT CHARSET=utf8; INSERT INTO t1 (c) VALUES ('manually'); CREATE EVENT justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTo t1 (c) VALUES ('from justonce'); "in the master" SELECT * FROM t1; id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 "in the slave" SELECT * FROM t1; id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 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; 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 "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 "in the master" DROP EVENT test.er; SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; db name status originator "in the slave" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; db name status originator "in the master" DROP TABLE t1; set binlog_format=statement; DROP EVENT IF EXISTS justonce; drop table if exists t1,t2; 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=MyISAM DEFAULT CHARSET=utf8; INSERT INTO t1 (c) VALUES ('manually'); CREATE EVENT justonce ON SCHEDULE AT NOW() + INTERVAL 2 SECOND DO INSERT INTo t1 (c) VALUES ('from justonce'); "in the master" SELECT * FROM t1; id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 "in the slave" SELECT * FROM t1; id c ts 1 manually TIMESTAMP 2 from justonce TIMESTAMP affected rows: 2 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; 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 "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 "in the master" DROP EVENT test.er; SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; db name status originator "in the slave" SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'er'; db name status originator "in the master" DROP TABLE t1; --- New file --- +++ mysql-test/r/rpl_udf.result 07/02/08 13:32:05 stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; set binlog_format=row; drop table if exists t1; "*** Test 1) Test UDFs via loadable libraries *** "Running on the master" CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB"; affected rows: 0 CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; affected rows: 0 CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; ERROR HY000: Can't find symbol 'myfunc_nonexist' in library SELECT * FROM mysql.func; name ret dl type myfunc_double 1 udf_example.dll function myfunc_int 2 udf_example.dll function affected rows: 2 "Running on the slave" SELECT * FROM mysql.func; name ret dl type myfunc_double 1 udf_example.dll function myfunc_int 2 udf_example.dll function affected rows: 2 "Running on the master" CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price 1 48.5 10 48.75 100 48.6 200 49 affected rows: 4 "Running on the slave" SELECT * FROM t1 ORDER BY sum; sum price 1 48.5 10 48.75 100 48.6 200 49 affected rows: 4 SELECT myfunc_int(25); myfunc_int(25) 25 affected rows: 1 SELECT myfunc_double(75.00); myfunc_double(75.00) 50.00 affected rows: 1 "Running on the master" DROP FUNCTION myfunc_double; affected rows: 0 DROP FUNCTION myfunc_int; affected rows: 0 SELECT * FROM mysql.func; name ret dl type affected rows: 0 "Running on the slave" SELECT * FROM mysql.func; name ret dl type affected rows: 0 "Running on the master" DROP TABLE t1; affected rows: 0 "*** Test 2) Test UDFs with SQL body *** "Running on the master" CREATE FUNCTION myfuncsql_int(i INT) RETURNS INTEGER DETERMINISTIC RETURN i; affected rows: 0 CREATE FUNCTION myfuncsql_double(d DOUBLE) RETURNS INTEGER DETERMINISTIC RETURN d * 0.95; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 test myfuncsql_int FUNCTION i INT RETURN i affected rows: 2 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 test myfuncsql_int FUNCTION i INT RETURN i affected rows: 2 "Running on the master" CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfuncsql_int(100), myfuncsql_double(50.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(10), myfuncsql_double(5.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(200), myfuncsql_double(25.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(1), myfuncsql_double(500.00)); affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price 1 475 10 5 100 47 200 24 affected rows: 4 "Running on the slave" SELECT * FROM t1 ORDER BY sum; sum price 1 475 10 5 100 47 200 24 affected rows: 4 "Running on the master" ALTER FUNCTION myfuncsql_int COMMENT "This was altered."; affected rows: 0 ALTER FUNCTION myfuncsql_double COMMENT "This was altered."; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 This was altered. test myfuncsql_int FUNCTION i INT RETURN i This was altered. affected rows: 2 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 This was altered. test myfuncsql_int FUNCTION i INT RETURN i This was altered. affected rows: 2 SELECT myfuncsql_int(25); myfuncsql_int(25) 25 affected rows: 1 SELECT myfuncsql_double(75.00); myfuncsql_double(75.00) 71 affected rows: 1 "Running on the master" DROP FUNCTION myfuncsql_double; affected rows: 0 DROP FUNCTION myfuncsql_int; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment affected rows: 0 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment affected rows: 0 "Running on the master" DROP TABLE t1; affected rows: 0 set binlog_format=statement; drop table if exists t1; "*** Test 1) Test UDFs via loadable libraries *** "Running on the master" CREATE FUNCTION myfunc_double RETURNS REAL SONAME "UDF_EXAMPLE_LIB"; affected rows: 0 CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; affected rows: 0 CREATE FUNCTION myfunc_nonexist RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; ERROR HY000: Can't find symbol 'myfunc_nonexist' in library SELECT * FROM mysql.func; name ret dl type myfunc_int 2 udf_example.dll function myfunc_double 1 udf_example.dll function affected rows: 2 "Running on the slave" SELECT * FROM mysql.func; name ret dl type myfunc_int 2 udf_example.dll function myfunc_double 1 udf_example.dll function affected rows: 2 "Running on the master" CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); affected rows: 1 INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price 1 48.5 10 48.75 100 48.6 200 49 affected rows: 4 "Running on the slave" SELECT * FROM t1 ORDER BY sum; sum price 1 48.5 10 48.75 100 48.6 200 49 affected rows: 4 SELECT myfunc_int(25); myfunc_int(25) 25 affected rows: 1 SELECT myfunc_double(75.00); myfunc_double(75.00) 50.00 affected rows: 1 "Running on the master" DROP FUNCTION myfunc_double; affected rows: 0 DROP FUNCTION myfunc_int; affected rows: 0 SELECT * FROM mysql.func; name ret dl type affected rows: 0 "Running on the slave" SELECT * FROM mysql.func; name ret dl type affected rows: 0 "Running on the master" DROP TABLE t1; affected rows: 0 "*** Test 2) Test UDFs with SQL body *** "Running on the master" CREATE FUNCTION myfuncsql_int(i INT) RETURNS INTEGER DETERMINISTIC RETURN i; affected rows: 0 CREATE FUNCTION myfuncsql_double(d DOUBLE) RETURNS INTEGER DETERMINISTIC RETURN d * 0.95; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 test myfuncsql_int FUNCTION i INT RETURN i affected rows: 2 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 test myfuncsql_int FUNCTION i INT RETURN i affected rows: 2 "Running on the master" CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=MyISAM; affected rows: 0 INSERT INTO t1 VALUES(myfuncsql_int(100), myfuncsql_double(50.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(10), myfuncsql_double(5.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(200), myfuncsql_double(25.00)); affected rows: 1 INSERT INTO t1 VALUES(myfuncsql_int(1), myfuncsql_double(500.00)); affected rows: 1 SELECT * FROM t1 ORDER BY sum; sum price 1 475 10 5 100 47 200 24 affected rows: 4 "Running on the slave" SELECT * FROM t1 ORDER BY sum; sum price 1 475 10 5 100 47 200 24 affected rows: 4 "Running on the master" ALTER FUNCTION myfuncsql_int COMMENT "This was altered."; affected rows: 0 ALTER FUNCTION myfuncsql_double COMMENT "This was altered."; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 This was altered. test myfuncsql_int FUNCTION i INT RETURN i This was altered. affected rows: 2 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment test myfuncsql_double FUNCTION d DOUBLE RETURN d * 0.95 This was altered. test myfuncsql_int FUNCTION i INT RETURN i This was altered. affected rows: 2 SELECT myfuncsql_int(25); myfuncsql_int(25) 25 affected rows: 1 SELECT myfuncsql_double(75.00); myfuncsql_double(75.00) 71 affected rows: 1 "Running on the master" DROP FUNCTION myfuncsql_double; affected rows: 0 DROP FUNCTION myfuncsql_int; affected rows: 0 SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment affected rows: 0 "Running on the slave" SELECT db, name, type, param_list, body, comment FROM mysql.proc WHERE db = 'test' AND name LIKE 'myfuncsql%'; db name type param_list body comment affected rows: 0 "Running on the master" DROP TABLE t1; affected rows: 0 --- New file --- +++ mysql-test/t/rpl_events.test 07/02/08 13:32:05 ################################################################## # Author: Giuseppe # # Date: 2006-12-20 # # Purpose: To test that event effects are replicated # # in both row based and statement based format # ################################################################## set global event_scheduler=1; --source include/not_embedded.inc --source include/master-slave.inc let $engine_type= MyISAM; set binlog_format=row; # Embedded server doesn't support binlogging --source include/rpl_events.inc set binlog_format=statement; # Embedded server doesn't support binlogging --source include/rpl_events.inc --- New file --- +++ mysql-test/t/rpl_udf.test 07/02/08 13:32:05 ################################################################### # Author: Chuck Bell # # Date: 2006-12-21 # # Purpose: To test that UDFs are replicated in both row based and # # statement based format. This tests work completed in WL#3629. # ################################################################### --source include/not_embedded.inc --source include/master-slave.inc let $engine_type= MyISAM; set binlog_format=row; # Embedded server doesn't support binlogging --source include/rpl_udf.inc set binlog_format=statement; # Embedded server doesn't support binlogging --source include/rpl_udf.inc --- 1.31/mysql-test/lib/init_db.sql 2007-02-08 13:32:32 -05:00 +++ 1.32/mysql-test/lib/init_db.sql 2007-02-08 13:32:32 -05:00 @@ -610,7 +610,8 @@ last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, - status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', + status ENUM('ENABLED','SLAVESIDE_DISABLED','DISABLED') NOT NULL default 'ENABLED', + originator int(10) NOT NULL, on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set( 'REAL_AS_FLOAT', --- 1.53/scripts/mysql_fix_privilege_tables.sql 2007-02-08 13:32:32 -05:00 +++ 1.54/scripts/mysql_fix_privilege_tables.sql 2007-02-08 13:32:32 -05:00 @@ -647,7 +647,8 @@ last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, - status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED', + status ENUM('ENABLED','SLAVESIDE_DISABLED','DISABLED') NOT NULL default 'ENABLED', + originator int(10) NOT NULL, on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set( 'REAL_AS_FLOAT', --- 1.46/mysql-test/r/system_mysql_db.result 2007-02-08 13:32:32 -05:00 +++ 1.47/mysql-test/r/system_mysql_db.result 2007-02-08 13:32:32 -05:00 @@ -220,7 +220,8 @@ `last_executed` datetime DEFAULT NULL, `starts` datetime DEFAULT NULL, `ends` datetime DEFAULT NULL, - `status` enum('ENABLED','DISABLED') NOT NULL DEFAULT 'ENABLED', + `status` enum('ENABLED','SLAVESIDE_DISABLED','DISABLED') NOT NULL DEFAULT 'ENABLED', + `originator` int(10) NOT NULL, `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') NOT NULL DEFAULT '', `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', --- 1.45/scripts/mysql_create_system_tables.sh 2007-02-08 13:32:32 -05:00 +++ 1.46/scripts/mysql_create_system_tables.sh 2007-02-08 13:32:32 -05:00 @@ -832,7 +832,8 @@ c_ev="$c_ev last_executed DATETIME default NULL," c_ev="$c_ev starts DATETIME default NULL," c_ev="$c_ev ends DATETIME default NULL," - c_ev="$c_ev status ENUM('ENABLED','DISABLED') NOT NULL default 'ENABLED'," + c_ev="$c_ev status ENUM('ENABLED','SLAVESIDE_DISABLED','DISABLED') NOT NULL default 'ENABLED'," + c_ev="$c_ev originator int(10) NOT NULL, c_ev="$c_ev on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP'," c_ev="$c_ev sql_mode set(" c_ev="$c_ev 'REAL_AS_FLOAT',"