3
# The author disclaims copyright to this source code. In place of
4
# a legal notice, here is a blessing:
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.
10
#***********************************************************************
11
# This file implements regression tests for SQLite library. The
12
# focus of this file is testing for correct handling of disk full
15
# $Id: diskfull.test,v 1.8 2008/07/12 14:52:20 drh Exp $
17
set testdir [file dirname $argv0]
18
source $testdir/tester.tcl
20
set sqlite_io_error_persist 0
21
set sqlite_io_error_hit 0
22
set sqlite_io_error_pending 0
23
do_test diskfull-1.1 {
26
INSERT INTO t1 VALUES(randstr(1000,1000));
27
INSERT INTO t1 SELECT * FROM t1;
28
INSERT INTO t1 SELECT * FROM t1;
29
INSERT INTO t1 SELECT * FROM t1;
30
INSERT INTO t1 SELECT * FROM t1;
31
CREATE INDEX t1i1 ON t1(x);
32
CREATE TABLE t2 AS SELECT x AS a, x AS b FROM t1;
33
CREATE INDEX t2i1 ON t2(b);
36
set sqlite_diskfull_pending 0
37
integrity_check diskfull-1.2
38
do_test diskfull-1.3 {
39
set sqlite_diskfull_pending 1
41
INSERT INTO t1 SELECT * FROM t1;
43
} {1 {database or disk is full}}
44
set sqlite_diskfull_pending 0
45
integrity_check diskfull-1.4
46
do_test diskfull-1.5 {
47
set sqlite_diskfull_pending 1
51
} {1 {database or disk is full}}
52
set sqlite_diskfull_pending 0
53
set sqlite_io_error_hit 0
54
integrity_check diskfull-1.6
56
proc do_diskfull_test {prefix sql} {
62
do_test ${prefix}.$::i.1 {
63
set ::sqlite_diskfull_pending $::i
64
set ::sqlite_diskfull 0
65
set r [catchsql $::sql]
66
if {!$::sqlite_diskfull} {
67
set r {1 {database or disk is full}}
70
if {$r=="1 {disk I/O error}"} {
71
set r {1 {database or disk is full}}
74
} {1 {database or disk is full}}
75
set ::sqlite_diskfull_pending 0
78
integrity_check ${prefix}.$::i.2
82
do_diskfull_test diskfull-2 VACUUM
85
# file delete -force test.db
86
# file delete -force test.db-journal
89
# do_test diskfull-3.1 {
91
# PRAGMA default_cache_size = 10;
92
# CREATE TABLE t3(a, b, UNIQUE(a, b));
93
# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
94
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
95
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
96
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
97
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
98
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
99
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
100
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
102
# SET b = (SELECT a FROM t3 WHERE rowid = (SELECT max(rowid)-1 FROM t3))
103
# WHERE rowid = (SELECT max(rowid) FROM t3);
108
# do_diskfull_test diskfull-3.2 {
110
# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
111
# UPDATE t3 SET a = b;