Debian Codegraph @

mysql-test/suite/group_replication/t/gr_compound_statements.test

raw
1 ########################################################################
2 # Purpose: This test does the basic check of compound statements in a
3 # group replication environment
4 #
5 # 0. This test requires two servers
6 # 1. Start Group Replication on two servers
7 # 2. Execute following compound statements on the members of the group:
8 # a) BEGIN..END
9 # b) WHILE \<condition> DO..END WHILE
10 # c) DECLARE local variable
11 # d) RETURN
12 # e) SET statement
13 # 3. Verify the consistency of data across the group
14 # 4. Clean-up
15 #########################################################################
16
17 # Start GR with two servers
18 --source include/set_privilege_checks_user_as_system_user.inc
19 --source include/have_group_replication_plugin.inc
20 --source include/group_replication.inc
21
22 # Connect to server1, create a table
23 --echo
24 CREATE TABLE t1 (a INT PRIMARY KEY);
25
26 # Define compound statements
27 # Define a stored procedure to insert data on t1
28 --echo
29 delimiter $$;
30 CREATE PROCEDURE insert_into_t1(IN a INT, IN b INT)
31 BEGIN
32 DECLARE x INT;
33 SET x=a;
34 WHILE x<b DO
35 INSERT INTO t1 VALUES (x);
36 SET x=x+1;
37 END WHILE;
38 END$$
39 delimiter ;$$
40 --echo
41 # Define a function to get the count of records
42 CREATE FUNCTION f1() RETURNS INT RETURN (SELECT COUNT(*) FROM t1);
43 --echo
44
45 # Call the procedure to insert data on t1
46 --echo Calling procedure
47 CALL insert_into_t1(0,10);
48 --echo
49 # Call function f1
50 SELECT f1();
51
52 # Wait for the records to get synced to server2
53 --source include/rpl_sync.inc
54 --echo
55 --echo Check if server1 and server2 has same data in test.t1
56 --let $diff_tables= server1:test.t1, server2:test.t1
57 --source include/diff_tables.inc
58 --echo
59
60 # Clean-up
61 # Drop table
62 DROP TABLE t1;
63 --echo
64
65 # Drop procedure
66 DROP PROCEDURE insert_into_t1;
67 --echo
68
69 # Drop function
70 DROP FUNCTION f1;
71 --echo
72
73 --source include/group_replication_end.inc