1
#############################################################################
2
# Original Author: JBM #
3
# Original Date: Aug/15/2005 #
4
# Update: 08/29/2005 Comment out sleep. Only needed for debugging #
5
#############################################################################
6
# Note: Many lines are commented out in this test case. These were used for #
7
# creating the test case and debugging and are being left for #
8
# debugging, but they can not be used for the regular testing as the #
9
# Time changes and is not deteministic, so instead we dump both the #
10
# master and slave and diff the dumps. If the dumps differ then the #
11
# test case will fail. To run during diff failuers, comment out the #
13
# Test: Tests MySQL stored function using RAND() and a flow control. The #
14
# test inserts rows into a givin table with the function used in #
15
# the insert statement. Depending on the RAND() value returned #
16
# inside the function one set of text is returned. In addition, #
17
# it uses a transaction to see the effect a rollback has on master #
19
#############################################################################
22
-- source include/have_binlog_format_row.inc
23
-- source include/master-slave.inc
26
# Begin clean up test section
29
DROP FUNCTION IF EXISTS test.f1;
30
DROP TABLE IF EXISTS test.t1;
35
eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
38
create function test.f1() RETURNS CHAR(16)
41
DECLARE var_name FLOAT;
42
SET var_name = RAND();
44
THEN SET tmp = 'Texas';
45
ELSE SET tmp = 'MySQL';
51
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
53
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
56
#Select in this test are used for debugging
57
#select * from test.t1;
59
#select * from test.t1;
64
INSERT INTO test.t1 VALUES (null,test.f1());
67
#select * from test.t1;
71
#select * from test.t1;
78
# time to dump the databases and so we can see if they match
80
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
81
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
84
DROP FUNCTION test.f1;
88
# the test will show that the diff statement failed and no reject file
89
# will be created. You will need to go to the mysql-test dir and diff
90
# the files yourself to see what is not matching :-) File are located
91
# in $MYSQLTEST_VARDIR/tmp
93
exec diff $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
96
# End of 5.0 test case