~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/savepoints.test

  • Committer: Lee
  • Date: 2008-10-30 22:02:01 UTC
  • mto: (572.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: lbieber@lbieber-desktop-20081030220201-elb6qprbzpn7c5a4
add my name to the AUTHORS file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Tests of various SAVEPOINT functionality
2
 
 
3
 
# Test for Bug #534806 - SAVEPOINT without active transaction
4
 
# triggers assert in InnoDB handler
5
 
 
6
 
--echo Start Test of Bug 534806
7
 
 
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
 
 
14
 
--echo End Test of Bug 534806
15
 
COMMIT;
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;
65
 
COMMIT;
66
 
DROP TABLE t1;
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
74
 
 
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);
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
 
 
84
 
--echo End Test of Bug 542299
85
 
COMMIT;
86
 
DROP TABLE t1;