1
by brian
clean slate |
1 |
#############################################################################
|
2 |
# This test is being created to test out the non deterministic items with #
|
|
3 |
# row based replication. #
|
|
4 |
# Original Author: JBM #
|
|
5 |
# Original Date: Aug/10/2005 #
|
|
6 |
# Update: 08/29/2005 Turn on diff #
|
|
7 |
#############################################################################
|
|
8 |
# Note: Many lines are commented out in this test case. These were used for #
|
|
9 |
# creating the test case and debugging and are being left for #
|
|
10 |
# debugging, but they can not be used for the regular testing as the #
|
|
11 |
# Time changes and is not deteministic, so instead we dump both the #
|
|
12 |
# master and slave and diff the dumps. If the dumps differ then the #
|
|
13 |
# test case will fail. To run during diff failuers, comment out the #
|
|
14 |
# diff. #
|
|
15 |
#############################################################################
|
|
16 |
||
17 |
# Includes |
|
18 |
-- source include/have_binlog_format_row.inc |
|
19 |
-- source include/master-slave.inc |
|
20 |
||
21 |
||
22 |
# Begin clean up test section |
|
23 |
connection master; |
|
24 |
--disable_warnings |
|
25 |
--error 0,1305 |
|
26 |
DROP FUNCTION test.f1; |
|
27 |
DROP TABLE IF EXISTS test.t1; |
|
28 |
DROP TABLE IF EXISTS test.t2; |
|
29 |
||
30 |
--enable_warnings |
|
31 |
||
32 |
# Section 1 test from Peter G. This test changes uses a stored function to update rows and return the timestamp. We change the value of the time stamp on the master to see what is replicated. |
|
33 |
||
34 |
CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, t TIMESTAMP, t2 TIMESTAMP, PRIMARY KEY(a)); |
|
35 |
CREATE TABLE test.t2 (a INT NOT NULL AUTO_INCREMENT, t TIMESTAMP, t2 TIMESTAMP, PRIMARY KEY(a)); |
|
36 |
||
37 |
delimiter //; |
|
38 |
create function test.f1() RETURNS TIMESTAMP |
|
39 |
BEGIN |
|
40 |
UPDATE test.t1 SET t = CURRENT_TIMESTAMP; |
|
41 |
RETURN CURRENT_TIMESTAMP; |
|
42 |
END// |
|
43 |
delimiter ;// |
|
44 |
||
45 |
INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP); |
|
46 |
#select * from test.t1; |
|
47 |
#save_master_pos; |
|
48 |
#sync_slave_with_master; |
|
49 |
#connection slave; |
|
50 |
#select * from test.t1; |
|
51 |
#connection master; |
|
52 |
||
53 |
||
54 |
SET TIMESTAMP=2; |
|
55 |
INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP); |
|
56 |
#select * from test.t1; |
|
57 |
#save_master_pos; |
|
58 |
#sync_slave_with_master; |
|
59 |
#connection slave; |
|
60 |
#select * from test.t1; |
|
61 |
#connection master; |
|
62 |
||
63 |
#sleep 3; |
|
64 |
SET TIMESTAMP=1; |
|
65 |
INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP); |
|
66 |
#select * from test.t1; |
|
67 |
#save_master_pos; |
|
68 |
#sync_slave_with_master; |
|
69 |
#connection slave; |
|
70 |
#select * from test.t1; |
|
71 |
#connection master; |
|
72 |
||
73 |
||
74 |
SET TIMESTAMP=333300000; |
|
75 |
INSERT INTO test.t2 VALUES (null,f1(),CURRENT_TIMESTAMP); |
|
76 |
||
77 |
# We need a sync to ensure that the slave has caught up before |
|
78 |
# dumping the database. |
|
79 |
sync_slave_with_master; |
|
80 |
||
81 |
connection master; |
|
82 |
#Used for debugging |
|
83 |
#show binlog events; |
|
84 |
||
85 |
# time to dump the databases and so we can see if they match |
|
86 |
||
87 |
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_master.sql |
|
88 |
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func002_slave.sql |
|
89 |
||
90 |
# Cleanup |
|
91 |
DROP FUNCTION test.f1; |
|
92 |
DROP TABLE test.t1; |
|
93 |
DROP TABLE test.t2; |
|
94 |
sync_slave_with_master; |
|
95 |
||
96 |
# the test will show that the diff statement failed and no reject file |
|
97 |
# will be created. You will need to go to the mysql-test dir and diff |
|
98 |
# the files your self to see what is not matching :-). The files are located |
|
99 |
# in mysql-test/var/tmp |
|
100 |
||
101 |
diff_files $MYSQLTEST_VARDIR/tmp/func002_master.sql $MYSQLTEST_VARDIR/tmp/func002_slave.sql; |
|
102 |
||
103 |
# End of 5.0 test case |
|
104 |