1: # 2001 October 12
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: # This file implements regression tests for SQLite library. The
12: # focus of this file is testing for correct handling of I/O errors
13: # such as writes failing because the disk is full.
14: #
15: # The tests in this file use special facilities that are only
16: # available in the SQLite test fixture.
17: #
18: # $Id: autovacuum_ioerr2.test,v 1.1.1.1 2012/02/21 17:04:16 misho Exp $
19:
20: set testdir [file dirname $argv0]
21: source $testdir/tester.tcl
22:
23: # If this build of the library does not support auto-vacuum, omit this
24: # whole file.
25: ifcapable {!autovacuum} {
26: finish_test
27: return
28: }
29:
30: do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
31: PRAGMA auto_vacuum = 1;
32: CREATE TABLE abc(a);
33: INSERT INTO abc VALUES(randstr(1500,1500));
34: } -sqlbody {
35: CREATE TABLE abc2(a);
36: BEGIN;
37: DELETE FROM abc;
38: INSERT INTO abc VALUES(randstr(1500,1500));
39: CREATE TABLE abc3(a);
40: COMMIT;
41: }
42:
43: do_ioerr_test autovacuum-ioerr2-2 -tclprep {
44: execsql {
45: PRAGMA auto_vacuum = 1;
46: PRAGMA cache_size = 10;
47: BEGIN;
48: CREATE TABLE abc(a);
49: INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
50: INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
51: }
52: for {set i 0} {$i<150} {incr i} {
53: execsql {
54: INSERT INTO abc VALUES(randstr(100,100));
55: }
56: }
57: execsql COMMIT
58: } -sqlbody {
59: BEGIN;
60: DELETE FROM abc WHERE length(a)>100;
61: UPDATE abc SET a = randstr(90,90);
62: CREATE TABLE abc3(a);
63: COMMIT;
64: }
65:
66: do_ioerr_test autovacuum-ioerr2-3 -sqlprep {
67: PRAGMA auto_vacuum = 1;
68: CREATE TABLE abc(a);
69: CREATE TABLE abc2(b);
70: } -sqlbody {
71: BEGIN;
72: INSERT INTO abc2 VALUES(10);
73: DROP TABLE abc;
74: COMMIT;
75: DROP TABLE abc2;
76: }
77:
78: forcedelete backup.db
79: ifcapable subquery {
80: do_ioerr_test autovacuum-ioerr2-4 -tclprep {
81: if {![file exists backup.db]} {
82: sqlite3 dbb backup.db
83: execsql {
84: PRAGMA auto_vacuum = 1;
85: BEGIN;
86: CREATE TABLE abc(a);
87: INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
88: INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
89: } dbb
90: for {set i 0} {$i<2500} {incr i} {
91: execsql {
92: INSERT INTO abc VALUES(randstr(100,100));
93: } dbb
94: }
95: execsql {
96: COMMIT;
97: PRAGMA cache_size = 10;
98: } dbb
99: dbb close
100: }
101: db close
102: forcedelete test.db
103: forcedelete test.db-journal
104: forcecopy backup.db test.db
105: set ::DB [sqlite3 db test.db]
106: execsql {
107: PRAGMA cache_size = 10;
108: }
109: } -sqlbody {
110: BEGIN;
111: DELETE FROM abc WHERE oid < 3;
112: UPDATE abc SET a = randstr(100,100) WHERE oid > 2300;
113: UPDATE abc SET a = randstr(1100,1100) WHERE oid =
114: (select max(oid) from abc);
115: COMMIT;
116: }
117: }
118:
119: do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
120: PRAGMA auto_vacuum = 1;
121: CREATE TABLE abc(a);
122: INSERT INTO abc VALUES(randstr(1500,1500));
123: } -sqlbody {
124: CREATE TABLE abc2(a);
125: BEGIN;
126: DELETE FROM abc;
127: INSERT INTO abc VALUES(randstr(1500,1500));
128: CREATE TABLE abc3(a);
129: COMMIT;
130: }
131:
132: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>