~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/savepoints.test

  • Committer: Monty Taylor
  • Date: 2010-12-24 02:13:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101224021305-e3slv1cyjczqorij
Changed the bzrignore 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
 
 
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
DROP TABLE t1;
 
66
 
 
67
 
68
# Test for Bug #542299
 
69
#
 
70
# segfault on ROLLBACK TO SAVEPOINT A - during randgen
 
71
#
 
72
--echo Start Test of Bug 542299
 
73
 
 
74
CREATE TABLE t1 (a int,id integer auto_increment,b int,/*Indices*/key (a ),primary key (id)) ENGINE=innodb;
 
75
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);
 
76
SET AUTOCOMMIT=OFF;
 
77
DELETE FROM t1 WHERE 1 = 1 LIMIT 1;
 
78
COMMIT; /* OR ROLLBACK... */
 
79
SAVEPOINT A;
 
80
INSERT INTO t1 ( a, b ) VALUES ( 1 , 9 );
 
81
ROLLBACK TO SAVEPOINT A;
 
82
 
 
83
--echo End Test of Bug 542299
 
84
DROP TABLE t1;