Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_misc_functions.test

raw
1 #
2 # Test of replicating some difficult functions
3 #
4 --source include/not_group_replication_plugin.inc
5 source include/set_privilege_checks_user_as_system_user.inc;
6 source include/master-slave.inc;
7
8 CALL mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
9
10 create table t1(id int, i int, r1 int, r2 int, p varchar(100));
11 insert into t1 values(1, connection_id(), 0, 0, "");
12 # Pure rand test
13 --disable_warnings
14 insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
15 --enable_warnings
16 # change the rand suite on the master
17 set sql_log_bin=0;
18 insert into t1 values(6, 0, rand(), rand(), "");
19 delete from t1 where id=6;
20 set sql_log_bin=1;
21 select * into outfile 'rpl_misc_functions.outfile' from t1;
22 let $MYSQLD_DATADIR= `select @@datadir`;
23 --source include/sync_slave_sql_with_master.inc
24 create temporary table t2 like t1;
25 # read the values from the master table
26 --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR
27 eval load data local infile '$MYSQLD_DATADIR/test/rpl_misc_functions.outfile' into table t2;
28 # compare them with the replica; the SELECT below should return no row
29 select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
30
31 connection master;
32 drop table t1;
33
34 # End of 4.1 tests
35
36 #
37 # BUG#25543 test calling rand() multiple times on the master in
38 # a stored procedure.
39 #
40
41 --disable_warnings
42 DROP TABLE IF EXISTS t1;
43 --enable_warnings
44
45 CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
46 col_a DOUBLE DEFAULT NULL);
47
48 DELIMITER |;
49
50 # Use a SP that calls rand() multiple times
51 CREATE PROCEDURE test_replication_sp1()
52 BEGIN
53 INSERT INTO t1 (col_a) VALUES (rand()), (rand());
54 INSERT INTO t1 (col_a) VALUES (rand());
55 END|
56
57 # Use a SP that calls another SP to call rand() multiple times
58 CREATE PROCEDURE test_replication_sp2()
59 BEGIN
60 CALL test_replication_sp1();
61 CALL test_replication_sp1();
62 END|
63
64 # Use a SF that calls rand() multiple times
65 CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC
66 BEGIN
67 RETURN (rand() + rand());
68 END|
69
70 DELIMITER ;|
71
72 # Exercise the functions and procedures then compare the results on
73 # the master to those on the slave.
74 --disable_warnings
75 CALL test_replication_sp1();
76 CALL test_replication_sp2();
77 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
78 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
79 INSERT INTO t1 (col_a) VALUES (test_replication_sf());
80 --enable_warnings
81
82 --source include/sync_slave_sql_with_master.inc
83
84 # Dump table on slave
85 select * from t1 into outfile "../../tmp/t1_slave.txt";
86
87 # Load data from slave into temp table on master
88 connection master;
89 --disable_warnings
90 create temporary table t1_slave select * from t1 where 1=0;
91 --enable_warnings
92 load data infile '../../tmp/t1_slave.txt' into table t1_slave;
93 --remove_file $MYSQLTEST_VARDIR/tmp/t1_slave.txt
94
95 # Compare master and slave temp table, use subtraction
96 # for floating point comparison of "double"
97 select count(*) into @aux from t1 join t1_slave using (id)
98 where ABS(t1.col_a - t1_slave.col_a) < 0.0000001 ;
99 SELECT @aux;
100 if (`SELECT @aux <> 12 OR @aux IS NULL`)
101 {
102 --echo # ERROR: We expected to get count(*) = 12.
103 SELECT id, col_a FROM t1;
104 SELECT id, col_a FROM t1_slave;
105 --echo # abort
106 exit;
107 }
108
109 # Cleanup
110 connection master;
111 DROP TABLE t1, t1_slave;
112 DROP PROCEDURE test_replication_sp1;
113 DROP PROCEDURE test_replication_sp2;
114 DROP FUNCTION test_replication_sf;
115
116 connection master;
117 CREATE TABLE t1 AS SELECT ST_POINTFROMGEOHASH("0123", 4326);
118 SHOW CREATE TABLE t1;
119 ### show binlog events;
120
121 --source include/sync_slave_sql_with_master.inc
122 connection slave;
123
124 SHOW CREATE TABLE t1;
125
126 connection master;
127 DROP TABLE t1;
128
129 --remove_file $MYSQLD_DATADIR/test/rpl_misc_functions.outfile
130 --source include/sync_slave_sql_with_master.inc
131
132
133 --source include/rpl_end.inc