~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/extra/rpl_tests/rpl_row_func003.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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   #
 
12
#       diff.                                                               #
 
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    #
 
18
#       Vs slave.                                                           #
 
19
#############################################################################
 
20
 
 
21
CALL mtr.add_suppression('Statement may not be safe to log in statement format.');
 
22
 
 
23
# Begin clean up test section
 
24
connection master;
 
25
--disable_warnings
 
26
DROP FUNCTION IF EXISTS test.f1;
 
27
DROP TABLE IF EXISTS test.t1;
 
28
 
 
29
--enable_warnings
 
30
 
 
31
 
 
32
eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
 
33
 
 
34
delimiter |;
 
35
create function test.f1() RETURNS CHAR(16) 
 
36
BEGIN
 
37
   DECLARE tmp CHAR(16);
 
38
   DECLARE var_name FLOAT;
 
39
   SET var_name = RAND();
 
40
   IF var_name > .6 
 
41
      THEN SET tmp = 'Texas';
 
42
      ELSE SET tmp = 'MySQL';
 
43
   END IF;
 
44
RETURN tmp;
 
45
END|
 
46
delimiter ;|
 
47
 
 
48
--disable_warnings
 
49
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
 
50
sleep 6;
 
51
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
 
52
sleep 6;
 
53
--enable_warnings
 
54
 
 
55
#Select in this test are used for debugging
 
56
#select * from test.t1;
 
57
#connection slave;
 
58
#select * from test.t1;
 
59
 
 
60
connection master;
 
61
SET AUTOCOMMIT=0;
 
62
START TRANSACTION;
 
63
--disable_warnings
 
64
INSERT INTO test.t1 VALUES (null,test.f1());
 
65
--enable_warnings
 
66
ROLLBACK;
 
67
SET AUTOCOMMIT=1;
 
68
#select * from test.t1;
 
69
#sleep 6;
 
70
 
 
71
#connection slave;
 
72
#select * from test.t1;
 
73
 
 
74
#connection master;
 
75
 
 
76
#used for debugging
 
77
#show binlog events;
 
78
 
 
79
# time to dump the databases and so we can see if they match
 
80
 
 
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
 
83
 
 
84
# First lets cleanup
 
85
DROP FUNCTION test.f1;
 
86
DROP TABLE test.t1;
 
87
 
 
88
 
 
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
 
93
 
 
94
diff_files $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
 
95
 
 
96
 
 
97
# End of 5.0 test case