1333.1.2
by Jay Pipes
Add savepoint test case |
1 |
# Tests of various SAVEPOINT functionality
|
2 |
||
3 |
# Test for Bug #534806 - SAVEPOINT without active transaction
|
|
4 |
# triggers assert in InnoDB handler
|
|
5 |
||
1491.2.2
by Jay Pipes
Reduce large test case for savepoints on Bug 542299 down to the smallest reproduceable test case. |
6 |
--echo Start Test of Bug 534806 |
7 |
||
1333.1.2
by Jay Pipes
Add savepoint test case |
8 |
SET AUTOCOMMIT = 0; |
9 |
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY); |
|
10 |
COMMIT; |
|
11 |
UPDATE t1 SET id = 2 WHERE id != 2 LIMIT 0; |
|
12 |
SAVEPOINT A; |
|
13 |
||
1491.2.2
by Jay Pipes
Reduce large test case for savepoints on Bug 542299 down to the smallest reproduceable test case. |
14 |
--echo End Test of Bug 534806 |
1890.2.17
by Stewart Smith
use explicit COMMITs in savepoints test instead of implicit COMMITs in DROP TABLE statement |
15 |
COMMIT; |
1333.1.2
by Jay Pipes
Add savepoint test case |
16 |
DROP TABLE t1; |
17 |
||
18 |
# Let's test the non-edge case for SAVEPOINTS:
|
|
19 |
#
|
|
20 |
# Typical usage pattern of starting a transaction, doing
|
|
21 |
# some work, savepointing, do more work, savepointing, etc
|
|
22 |
# and committing without any rollbacks or savepoint releases.
|
|
23 |
||
24 |
CREATE TABLE t1 (id INT NOT NULL PRIMARY KEY); |
|
25 |
START TRANSACTION; |
|
26 |
INSERT INTO t1 VALUES (1); |
|
27 |
SAVEPOINT A; |
|
28 |
INSERT INTO t1 VALUES (2); |
|
29 |
SAVEPOINT B; |
|
30 |
INSERT INTO t1 VALUES (3); |
|
31 |
COMMIT; |
|
32 |
||
33 |
# t1 should now have 1,2,3 in it.
|
|
34 |
SELECT * FROM t1; |
|
35 |
||
36 |
# We now test another typical usage pattern, similar to above,
|
|
37 |
# but we issue a ROLLBACK at the end instead of a COMMIT. All
|
|
38 |
# work done in all savepoints should be rolled back.
|
|
39 |
||
40 |
START TRANSACTION; |
|
41 |
INSERT INTO t1 VALUES (4); |
|
42 |
SAVEPOINT A; |
|
43 |
INSERT INTO t1 VALUES (5); |
|
44 |
SAVEPOINT B; |
|
45 |
INSERT INTO t1 VALUES (6); |
|
46 |
ROLLBACK; |
|
47 |
||
48 |
# t1 should still have 1,2,3 in it.
|
|
49 |
SELECT * FROM t1; |
|
50 |
||
51 |
# We now test the final typical usage pattern, where we
|
|
52 |
# ROLLBACK work to a specific SAVEPOINT and then COMMIT.
|
|
53 |
||
54 |
START TRANSACTION; |
|
55 |
INSERT INTO t1 VALUES (4); |
|
56 |
SAVEPOINT A; |
|
57 |
INSERT INTO t1 VALUES (5); |
|
58 |
SAVEPOINT B; |
|
59 |
INSERT INTO t1 VALUES (6); |
|
60 |
ROLLBACK TO SAVEPOINT A; |
|
61 |
COMMIT; |
|
62 |
||
63 |
# t1 should have 1,2,3,4 in it.
|
|
64 |
SELECT * FROM t1; |
|
1890.2.17
by Stewart Smith
use explicit COMMITs in savepoints test instead of implicit COMMITs in DROP TABLE statement |
65 |
COMMIT; |
1333.1.2
by Jay Pipes
Add savepoint test case |
66 |
DROP TABLE t1; |
1491.2.1
by Jay Pipes
Add exact SQL that produces bug #542299 to the savepoints.test case. |
67 |
|
68 |
#
|
|
69 |
# Test for Bug #542299
|
|
70 |
#
|
|
71 |
# segfault on ROLLBACK TO SAVEPOINT A - during randgen
|
|
72 |
#
|
|
73 |
--echo Start Test of Bug 542299 |
|
1491.2.2
by Jay Pipes
Reduce large test case for savepoints on Bug 542299 down to the smallest reproduceable test case. |
74 |
|
1491.2.1
by Jay Pipes
Add exact SQL that produces bug #542299 to the savepoints.test case. |
75 |
CREATE TABLE t1 (a int,id integer auto_increment,b int,/*Indices*/key (a ),primary key (id)) ENGINE=innodb; |
76 |
INSERT INTO t1 VALUES (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100) , (100, NULL, 100); |
|
1491.2.2
by Jay Pipes
Reduce large test case for savepoints on Bug 542299 down to the smallest reproduceable test case. |
77 |
SET AUTOCOMMIT=OFF; |
78 |
DELETE FROM t1 WHERE 1 = 1 LIMIT 1; |
|
79 |
COMMIT; /* OR ROLLBACK... */ |
|
80 |
SAVEPOINT A; |
|
81 |
INSERT INTO t1 ( a, b ) VALUES ( 1 , 9 ); |
|
82 |
ROLLBACK TO SAVEPOINT A; |
|
83 |
||
1491.2.1
by Jay Pipes
Add exact SQL that produces bug #542299 to the savepoints.test case. |
84 |
--echo End Test of Bug 542299 |
1890.2.17
by Stewart Smith
use explicit COMMITs in savepoints test instead of implicit COMMITs in DROP TABLE statement |
85 |
COMMIT; |
2016.1.4
by Brian Aker
Fix tests where not cleaning them up after running. |
86 |
DROP TABLE t1; |