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
#############################################################################
21
CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
23
# Begin clean up test section
26
DROP FUNCTION IF EXISTS test.f1;
27
DROP TABLE IF EXISTS test.t1;
32
eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
35
create function test.f1() RETURNS CHAR(16)
38
DECLARE var_name FLOAT;
39
SET var_name = RAND();
41
THEN SET tmp = 'Texas';
42
ELSE SET tmp = 'MySQL';
49
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
51
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
55
#Select in this test are used for debugging
56
#select * from test.t1;
58
#select * from test.t1;
64
INSERT INTO test.t1 VALUES (null,test.f1());
68
#select * from test.t1;
72
#select * from test.t1;
79
# time to dump the databases and so we can see if they match
81
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
82
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
85
DROP FUNCTION test.f1;
89
# the test will show that the diff statement failed and no reject file
90
# will be created. You will need to go to the mysql-test dir and diff
91
# the files yourself to see what is not matching :-) File are located
92
# in $MYSQLTEST_VARDIR/tmp
94
diff_files $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
97
# End of 5.0 test case