1
#############################################################################
2
# Original Author: JBM #
3
# Original Date: Aug/15/2005 #
4
# Updated: 08/29/2005 to remove sleeps #
5
#############################################################################
6
# Test: This test uses two SPs, one to populate a table, and another to use #
7
# Cursors, CURRENT_DATE(), loop control, date math and logic control #
8
# to populate a table with data from the first table. #
9
#############################################################################
11
# Begin clean up test section
14
create database if not exists mysqltest1;
15
DROP PROCEDURE IF EXISTS mysqltest1.p1;
16
DROP PROCEDURE IF EXISTS mysqltest1.p2;
17
DROP TABLE IF EXISTS mysqltest1.t2;
18
DROP TABLE IF EXISTS mysqltest1.t1;
22
# Begin test section 1
23
eval CREATE TABLE IF NOT EXISTS mysqltest1.t1(name CHAR(16), birth DATE,PRIMARY KEY(name))ENGINE=$engine_type;
24
eval CREATE TABLE IF NOT EXISTS mysqltest1.t2(name CHAR(16), age INT ,PRIMARY KEY(name))ENGINE=$engine_type;
27
CREATE PROCEDURE mysqltest1.p1()
29
DECLARE done INT DEFAULT 0;
32
DECLARE cur1 CURSOR FOR SELECT name,
33
(YEAR(CURDATE())-YEAR(birth))-(RIGHT(CURDATE(),5)<RIGHT(birth,5))
35
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
41
FETCH cur1 INTO spa, spb;
44
INSERT INTO mysqltest1.t2 VALUES (spa,spb);
47
UNTIL done END REPEAT;
52
CREATE PROCEDURE mysqltest1.p2()
54
INSERT INTO mysqltest1.t1 VALUES ('MySQL','1993-02-04'),('ROCKS', '1990-08-27'),('Texas', '1999-03-30'),('kyle','2005-1-1');
59
sync_slave_with_master;
63
sync_slave_with_master;
67
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/sp006_master.sql
68
--exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info mysqltest1 > $MYSQLTEST_VARDIR/tmp/sp006_slave.sql
71
DROP PROCEDURE IF EXISTS mysqltest1.p1;
72
DROP PROCEDURE IF EXISTS mysqltest1.p2;
73
DROP TABLE IF EXISTS mysqltest1.t1;
74
DROP TABLE IF EXISTS mysqltest1.t2;
75
DROP DATABASE mysqltest1;
77
# Lets compare. Note: If they match test will pass, if they do not match
78
# the test will show that the diff statement failed and not reject file
79
# will be created. You will need to go to the mysql-test dir and diff
80
# the files your self to see what is not matching :-) Failed test
81
# Dump files will be located in $MYSQLTEST_VARDIR/tmp.
83
diff_files $MYSQLTEST_VARDIR/tmp/sp006_master.sql $MYSQLTEST_VARDIR/tmp/sp006_slave.sql;
85
sync_slave_with_master;
87
# End of 5.1 test case