~vkolesnikov/pbxt/pbxt-07-diskfull

« back to all changes in this revision

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

  • Committer: paul-mccullagh
  • Date: 2006-10-23 09:14:04 UTC
  • Revision ID: paul-mccullagh-918861e03d351978a9541168a96e58cc826734ee
Initial import

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
# Includes
 
22
-- source include/have_binlog_format_row.inc
 
23
-- source include/master-slave.inc
 
24
 
 
25
 
 
26
# Begin clean up test section
 
27
connection master;
 
28
--disable_warnings
 
29
DROP FUNCTION IF EXISTS test.f1;
 
30
DROP TABLE IF EXISTS test.t1;
 
31
 
 
32
--enable_warnings
 
33
 
 
34
 
 
35
eval CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT, c CHAR(16),PRIMARY KEY(a))ENGINE=$engine_type;
 
36
 
 
37
delimiter |;
 
38
create function test.f1() RETURNS CHAR(16) 
 
39
BEGIN
 
40
   DECLARE tmp CHAR(16);
 
41
   DECLARE var_name FLOAT;
 
42
   SET var_name = RAND();
 
43
   IF var_name > .6 
 
44
      THEN SET tmp = 'Texas';
 
45
      ELSE SET tmp = 'MySQL';
 
46
   END IF;
 
47
RETURN tmp;
 
48
END|
 
49
delimiter ;|
 
50
 
 
51
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
 
52
sleep 6;
 
53
INSERT INTO test.t1 VALUES (null,test.f1()),(null,test.f1()),(null,test.f1());
 
54
sleep 6;
 
55
 
 
56
#Select in this test are used for debugging
 
57
#select * from test.t1;
 
58
#connection slave;
 
59
#select * from test.t1;
 
60
 
 
61
connection master;
 
62
SET AUTOCOMMIT=0;
 
63
START TRANSACTION;
 
64
INSERT INTO test.t1 VALUES (null,test.f1());
 
65
ROLLBACK;
 
66
SET AUTOCOMMIT=1;
 
67
#select * from test.t1;
 
68
#sleep 6;
 
69
 
 
70
#connection slave;
 
71
#select * from test.t1;
 
72
 
 
73
#connection master;
 
74
 
 
75
#used for debugging
 
76
#show binlog events;
 
77
 
 
78
# time to dump the databases and so we can see if they match
 
79
 
 
80
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_master.sql
 
81
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLTEST_VARDIR/tmp/func003_slave.sql
 
82
 
 
83
# First lets cleanupi
 
84
DROP FUNCTION test.f1;
 
85
DROP TABLE test.t1;
 
86
 
 
87
 
 
88
# the test will show that the diff statement failed and no reject file
 
89
# will be created. You will need to go to the mysql-test dir and diff
 
90
# the files yourself to see what is not matching :-) File are located
 
91
# in $MYSQLTEST_VARDIR/tmp
 
92
 
 
93
exec diff $MYSQLTEST_VARDIR/tmp/func003_master.sql $MYSQLTEST_VARDIR/tmp/func003_slave.sql;
 
94
 
 
95
 
 
96
# End of 5.0 test case