~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_misc_functions.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Test of replicating some difficult functions
 
3
#
 
4
source include/master-slave.inc;
 
5
 
 
6
create table t1(id int, i int, r1 int, r2 int, p varchar(100));
 
7
insert into t1 values(1, connection_id(), 0, 0, "");
 
8
# don't put rand and password in the same query, to see if they replicate
 
9
# independently
 
10
# Pure rand test
 
11
insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
 
12
# change the rand suite on the master (we do this because otherwise password()
 
13
# benefits from the fact that the above rand() is well replicated : 
 
14
# it picks the same sequence element, which hides a possible bug in password() replication.
 
15
set sql_log_bin=0;
 
16
insert into t1 values(6, 0, rand(), rand(), "");
 
17
delete from t1 where id=6;
 
18
set sql_log_bin=1;
 
19
# Pure password test
 
20
insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
 
21
# "altogether now"
 
22
insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
 
23
select * into outfile 'rpl_misc_functions.outfile' from t1;
 
24
sync_slave_with_master;
 
25
create table t2 like t1; 
 
26
# read the values from the master table
 
27
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
28
eval load data local infile '$MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile' into table t2;
 
29
# compare them with the replica; the SELECT below should return no row
 
30
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);
 
31
 
 
32
connection master;
 
33
drop table t1;
 
34
 
 
35
# End of 4.1 tests
 
36
 
 
37
#
 
38
# BUG#25543 test calling rand() multiple times on the master in
 
39
# a stored procedure.
 
40
#
 
41
 
 
42
--disable_warnings
 
43
DROP TABLE IF EXISTS t1;
 
44
--enable_warnings
 
45
 
 
46
CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
 
47
  col_a DOUBLE DEFAULT NULL);
 
48
 
 
49
DELIMITER |;
 
50
 
 
51
# Use a SP that calls rand() multiple times
 
52
CREATE PROCEDURE test_replication_sp1()
 
53
BEGIN
 
54
 INSERT INTO t1 (col_a) VALUES (rand()), (rand());
 
55
 INSERT INTO t1 (col_a) VALUES (rand());
 
56
END|
 
57
 
 
58
# Use a SP that calls another SP to call rand() multiple times
 
59
CREATE PROCEDURE test_replication_sp2()
 
60
BEGIN
 
61
  CALL test_replication_sp1();
 
62
  CALL test_replication_sp1();
 
63
END|
 
64
 
 
65
# Use a SF that calls rand() multiple times
 
66
CREATE FUNCTION test_replication_sf() RETURNS DOUBLE DETERMINISTIC
 
67
BEGIN
 
68
 RETURN (rand() + rand());
 
69
END|
 
70
 
 
71
DELIMITER ;|
 
72
 
 
73
# Exercise the functions and procedures then compare the results on
 
74
# the master to those on the slave.
 
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
 
 
81
--sync_slave_with_master
 
82
 
 
83
# Dump table on slave
 
84
select * from t1 into outfile "../tmp/t1_slave.txt";
 
85
 
 
86
# Load data from slave into temp table on master
 
87
connection master;
 
88
create temporary table t1_slave select * from t1 where 1=0;
 
89
load data infile '../tmp/t1_slave.txt' into table t1_slave;
 
90
--remove_file $MYSQLTEST_VARDIR/tmp/t1_slave.txt
 
91
 
 
92
# Compare master and slave temp table, use subtraction
 
93
# for floating point comparison of "double"
 
94
select count(*) into @aux from t1 join t1_slave using (id)
 
95
where ABS(t1.col_a - t1_slave.col_a) < 0.0000001 ;
 
96
SELECT @aux;
 
97
if (`SELECT @aux <> 12 OR @aux IS NULL`)
 
98
{
 
99
   --echo # ERROR: We expected to get count(*) = 12.
 
100
   SELECT id, col_a FROM t1;
 
101
   SELECT id, col_a FROM t1_slave;
 
102
   --echo # abort
 
103
   exit;
 
104
}
 
105
 
 
106
# Cleanup
 
107
connection master;
 
108
DROP TABLE t1, t1_slave;
 
109
DROP PROCEDURE test_replication_sp1;
 
110
DROP PROCEDURE test_replication_sp2;
 
111
DROP FUNCTION test_replication_sf;
 
112
--remove_file $MYSQLTEST_VARDIR/master-data/test/rpl_misc_functions.outfile
 
113
--sync_slave_with_master
 
114
 
 
115