Annotation of embedaddon/sqlite3/test/savepoint3.test, revision 1.1.1.1
1.1 misho 1: # 2008 December 15
2: #
3: # The author disclaims copyright to this source code. In place of
4: # a legal notice, here is a blessing:
5: #
6: # May you do good and not evil.
7: # May you find forgiveness for yourself and forgive others.
8: # May you share freely, never taking more than you give.
9: #
10: #***********************************************************************
11: #
12: # $Id: savepoint3.test,v 1.5 2009/06/05 17:09:12 drh Exp $
13:
14: set testdir [file dirname $argv0]
15: source $testdir/tester.tcl
16:
17: source $testdir/malloc_common.tcl
18:
19: do_malloc_test savepoint3-1 -sqlprep {
20: CREATE TABLE t1(a, b, c);
21: INSERT INTO t1 VALUES(1, 2, 3);
22: } -sqlbody {
23: SAVEPOINT one;
24: INSERT INTO t1 VALUES(4, 5, 6);
25: SAVEPOINT two;
26: DELETE FROM t1;
27: ROLLBACK TO two;
28: RELEASE one;
29: }
30:
31: do_malloc_test savepoint3-2 -sqlprep {
32: PRAGMA cache_size = 10;
33: CREATE TABLE t1(a, b, c);
34: INSERT INTO t1 VALUES(randstr(400,400), randstr(400,400), randstr(400,400));
35: INSERT INTO t1 SELECT
36: randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
37: INSERT INTO t1
38: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
39: INSERT INTO t1
40: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
41: INSERT INTO t1
42: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
43: INSERT INTO t1
44: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
45: INSERT INTO t1
46: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
47: INSERT INTO t1
48: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
49: INSERT INTO t1
50: SELECT randstr(400,400), randstr(400,400), randstr(400,400) FROM t1;
51: } -sqlbody {
52: PRAGMA cache_size = 10;
53: SAVEPOINT one;
54: DELETE FROM t1 WHERE rowid < 5;
55: SAVEPOINT two;
56: DELETE FROM t1 WHERE rowid > 10;
57: ROLLBACK TO two;
58: ROLLBACK TO one;
59: RELEASE one;
60: }
61:
62: do_ioerr_test savepoint3.3 -sqlprep {
63: CREATE TABLE t1(a, b, c);
64: INSERT INTO t1 VALUES(1, randstr(1000,1000), randstr(1000,1000));
65: INSERT INTO t1 VALUES(2, randstr(1000,1000), randstr(1000,1000));
66: } -sqlbody {
67: BEGIN;
68: UPDATE t1 SET a = 3 WHERE a = 1;
69: SAVEPOINT one;
70: UPDATE t1 SET a = 4 WHERE a = 2;
71: COMMIT;
72: } -cleanup {
73: db eval {
74: SAVEPOINT one;
75: RELEASE one;
76: }
77: }
78:
79: # The following test does a really big savepoint rollback. One involving
80: # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet()
81: # operation in pagerPlaybackSavepoint() to fail.
82: #do_malloc_test savepoint3-4 -sqlprep {
83: # BEGIN;
84: # CREATE TABLE t1(a, b);
85: # CREATE INDEX i1 ON t1(a);
86: # CREATE INDEX i2 ON t1(b);
87: # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1
88: # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2
89: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4
90: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8
91: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16
92: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32
93: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64
94: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128
95: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256
96: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512
97: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024
98: # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048
99: # COMMIT;
100: # BEGIN;
101: # SAVEPOINT abc;
102: # UPDATE t1 SET a = randstr(500,500);
103: #} -sqlbody {
104: # ROLLBACK TO abc;
105: #}
106:
107:
108: # Cause a specific malloc in savepoint rollback code to fail.
109: #
110: do_malloc_test savepoint3-4 -start 7 -sqlprep {
111: PRAGMA auto_vacuum = incremental;
112: PRAGMA cache_size = 1000;
113:
114: CREATE TABLE t1(a, b);
115: CREATE TABLE t2(a, b);
116: CREATE TABLE t3(a, b);
117: INSERT INTO t1 VALUES(1, randstr(500,500));
118: INSERT INTO t1 VALUES(2, randstr(500,500));
119: INSERT INTO t1 VALUES(3, randstr(500,500));
120: DELETE FROM t1;
121:
122: BEGIN;
123: INSERT INTO t1 VALUES(1, randstr(500,500));
124: INSERT INTO t1 VALUES(2, randstr(500,500));
125: INSERT INTO t1 VALUES(3, randstr(500,500));
126: DROP TABLE t3; -- Page 5 of the database file is now free.
127: DROP TABLE t2; -- Page 4 of the database file is now free.
128:
129: SAVEPOINT abc;
130: PRAGMA incremental_vacuum;
131: } -sqlbody {
132: ROLLBACK TO abc;
133: }
134:
135:
136: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>