Debian Codegraph @

mysql-test/suite/rpl/include/rpl_row_func003.test

raw
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: Time changes and is not deteministic, so instead we dump both the #
7 # master and slave and diff the dumps. If the dumps differ then the #
8 # test case will fail. To run during diff failuers, comment out the #
9 # diff. #
10 # Test: Tests MySQL stored function using RAND() and a flow control. The #
11 # test inserts rows into a givin table with the function used in #
12 # the insert statement. Depending on the RAND() value returned #
13 # inside the function one set of text is returned. In addition, #
14 # it uses a transaction to see the effect a rollback has on master #
15 # Vs slave. #
16 #############################################################################
17
18 CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
19
20 # Begin clean up test section
21 connection master;
22 --disable_warnings
23 DROP FUNCTION IF EXISTS test.f1;
24 DROP TABLE IF EXISTS test.t1;
25
26 --enable_warnings
27
28 eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
29
30 delimiter |;
31 create function test.f1() RETURNS CHAR(16)
32 BEGIN
33 DECLARE tmp CHAR(16);
34 DECLARE var_name FLOAT;
35 SET var_name = RAND();
36 IF var_name > .6
37 THEN SET tmp = 'Texas';
38 ELSE SET tmp = 'MySQL';
39 END IF;
40 RETURN tmp;
41 END|
42 delimiter ;|
43
44 --disable_warnings
45 INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
46 INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
47 --enable_warnings
48
49 SET AUTOCOMMIT=0;
50 START TRANSACTION;
51 --disable_warnings
52 INSERT INTO test.t1 VALUES (null,test.f1());
53 --enable_warnings
54 ROLLBACK;
55 SET AUTOCOMMIT=1;
56
57 sync_slave_with_master;
58 connection master;
59
60 # Time to dump the databases and so we can see if they match
61
62 --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
63 --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
64
65 # First lets cleanup
66 DROP FUNCTION test.f1;
67 DROP TABLE test.t1;
68
69
70 # the test will show that the diff statement failed and no reject file
71 # will be created. You will need to go to the mysql-test dir and diff
72 # the files yourself to see what is not matching :-) File are located
73 # in $MYSQLTEST_VARDIR/tmp
74
75 diff_files $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
76
77 # Clean up
78 remove_file $MYSQLTEST_VARDIR/tmp/func003_master.sql;
79 remove_file $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
80
81 # End of 5.0 test case