Debian Codegraph @

mysql-test/suite/binlog/t/binlog_transaction_write_set_savepoint_basic.test

raw
1 ###############################################################################
2 #
3 # Basic test to confirm the correct behavior when executing SAVEPOINT,
4 # ROLLBACK TO and RELEASE SAVEPOINT commands
5 #
6 # The execution of SELECT guarantee the correct values on TABLE after process
7 # SAVEPOINT commands
8 #
9 # Test:
10 # 0. Create a table to insert data
11 # 1. Create a transaction and insert values and savepoints (S1, S2, S3, S4)
12 # 2. Release savepoint S4
13 # 4. Rollback to a savepoint S2 and verify that savepoint S3 disappeared
14 # 5. Insert more values and rollback to S2 to verify that rollback don't
15 # remove savepoint
16 # 6. Check the multitable update on 'rollback to savepoint' is proper.
17 # 7. Clean-up
18 #
19 ###############################################################################
20
21 --source include/have_log_bin.inc
22
23 CREATE TABLE t1(a int primary key);
24 CREATE TABLE t2(a int primary key);
25
26 BEGIN;
27
28 --echo #
29 --echo # Insert values on table and savepoints
30 --echo #
31
32 SAVEPOINT S1;
33 INSERT INTO t1 values(3);
34 INSERT INTO t1 values(4);
35 SAVEPOINT S2;
36 INSERT INTO t1 values(5);
37 INSERT INTO t1 values(6);
38 SAVEPOINT S3;
39 SAVEPOINT S4;
40
41 --echo #
42 --echo # RELEASE S4
43 --echo #
44
45 RELEASE SAVEPOINT S4;
46
47 INSERT INTO t1 values(7);
48 SELECT * FROM t1;
49
50 --echo #
51 --echo # ROLLBACK TO S2
52 --echo #
53
54 ROLLBACK TO S2;
55
56 --echo #
57 --echo # Confirm S3 was removed when rollbacking to S2
58 --echo #
59
60 --error ER_SP_DOES_NOT_EXIST
61 ROLLBACK TO S3;
62
63 SELECT * FROM t1;
64
65 INSERT INTO t1 values(7);
66
67 SELECT * FROM t1;
68
69 --echo #
70 --echo # Confirm S2 exists after ROLLBACK TO S2
71 --echo #
72
73 ROLLBACK TO S2;
74 SELECT * FROM t1;
75
76 COMMIT;
77
78 --echo #
79 --echo # Check the multitable update on 'rollback to savepoint'
80 --echo #
81
82 BEGIN;
83 INSERT INTO t1 values (5);
84
85 SAVEPOINT S1;
86 DELETE FROM t1;
87 INSERT INTO t1 values (1);
88 INSERT INTO t2 SELECT * FROM t1;
89 UPDATE t1,t2 SET t1.a=3, t2.a=3;
90
91 SELECT * FROM t1;
92 SELECT * FROM t2;
93
94 ROLLBACK TO SAVEPOINT S1;
95 INSERT INTO t2 SELECT * FROM t1;
96 COMMIT;
97
98 SELECT * FROM t1;
99 SELECT * FROM t2;
100
101 # Clean-up
102 DROP TABLE t1;
103 DROP TABLE t2;