Commit 7afaea74 authored by unknown's avatar unknown
Browse files

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl

into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-rpl

parents 1d94a1ac 092c0522
Loading
Loading
Loading
Loading
+105 −0
Original line number Diff line number Diff line
##################################################################
# 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 test.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 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

# 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;

--echo "in the slave"
--enable_info
--replace_column 3 TIMESTAMP
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;
--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 WHERE db = 'test' AND name = 'slave_once';

--disable_warnings
DROP EVENT IF EXISTS test.slave_once;
--enable_warnings

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, body FROM mysql.event WHERE db = 'test' AND name = 'er';

sync_slave_with_master;

--echo "in the slave"
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, body FROM mysql.event WHERE db = 'test' AND name = 'er';

sync_slave_with_master;

--echo "in the slave"
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;
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';

--disable_info

sync_slave_with_master;

--echo "in the slave"
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';

--echo "in the master"
connection master;
DROP TABLE t1;
+187 −0
Original line number Diff line number Diff line
#####################################################################
# 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

save_master_pos;
connection slave;
sync_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
+15 −14
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ create event
SHOW CREATE EVENT ðóóò21;
Event	sql_mode	time_zone	Create Event
ðóóò21		SYSTEM	CREATE EVENT `ðóóò21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND STARTS '#' 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 @@ drop event
set names latin1;
CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing";
SHOW EVENTS;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED	1
ALTER TABLE mysql.event ADD dummy INT FIRST;
SHOW EVENTS;
ERROR HY000: Column count of mysql.event is wrong. Expected 17, found 18. Table probably corrupted
ERROR HY000: Column count of mysql.event is wrong. Expected 18, found 19. 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 17, found 18. Table probably corrupted
ERROR HY000: Column count of mysql.event is wrong. Expected 18, found 19. Table probably corrupted
ALTER TABLE mysql.event DROP dummy2;
SHOW EVENTS;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	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,10 +258,11 @@ event CREATE TABLE `event` (
  `last_executed` datetime DEFAULT NULL,
  `starts` datetime DEFAULT NULL,
  `ends` datetime DEFAULT NULL,
  `status` enum('ENABLED','DISABLED') NOT NULL DEFAULT 'ENABLED',
  `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') NOT NULL DEFAULT '',
  `comment` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
  `originator` int(10) NOT NULL,
  `time_zone` char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM',
  PRIMARY KEY (`db`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
@@ -270,8 +271,8 @@ ERROR HY000: Cannot load from mysql.event. Table probably corrupted. See error l
ALTER TABLE mysql.event MODIFY db char(64) character set utf8 collate utf8_bin default '';
"This should work"
SHOW EVENTS;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	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.
@@ -280,14 +281,14 @@ SELECT event_name FROM INFORMATION_SCHEMA.EVENTS;
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 17, found 15. Table probably corrupted
ERROR HY000: Column count of mysql.event is wrong. Expected 18, found 16. 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	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	intact_check	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	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;
@@ -400,5 +401,5 @@ ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
SHOW EVENTS FROM ``;
ERROR 42000: Incorrect database name ''
SHOW EVENTS FROM `events\\test`;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
drop database events_test;
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ create event e_55 on schedule at 20000101000000 do drop table t;
Warnings:
Note	1584	Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. Event has not been created
show events;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'starts 10000101000000 do drop table t' at line 1
create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t;
+12 −12
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@ CREATE DATABASE IF NOT EXISTS events_test;
use events_test;
CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123;
SHOW EVENTS;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	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 @@ ERROR 42000: Access denied for user 'ev_test'@'localhost' to database 'events_te
USE events_test;
"We should see one event";
SHOW EVENTS;
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	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 two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE CO
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	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED
events_test	three_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED
events_test	two_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	one_event	root@localhost	SYSTEM	RECURRING	NULL	10	#	#	NULL	ENABLED	1
events_test	three_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED	1
events_test	two_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED	1
"This should show us only 2 events:";
SHOW EVENTS LIKE 't%event';
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
events_test	three_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED
events_test	two_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status	Originator
events_test	three_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED	1
events_test	two_event	ev_test@localhost	SYSTEM	RECURRING	NULL	20	#	#	NULL	ENABLED	1
"This should show us no events:";
SHOW EVENTS FROM test LIKE '%';
Db	Name	Definer	Time zone	Type	Execute at	Interval value	Interval field	Starts	Ends	Status
Db	Name	Definer	Time zone	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;
Loading