2005-01-11 13:25:06 +03:00
|
|
|
# 2001 October 12
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library. The
|
|
|
|
# focus of this file is testing for correct handling of I/O errors
|
|
|
|
# such as writes failing because the disk is full.
|
|
|
|
#
|
|
|
|
# The tests in this file use special facilities that are only
|
|
|
|
# available in the SQLite test fixture.
|
|
|
|
#
|
2005-01-29 12:14:05 +03:00
|
|
|
# $Id: autovacuum_ioerr2.test,v 1.5 2005/01/29 09:14:05 danielk1977 Exp $
|
2005-01-11 13:25:06 +03:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2005-01-16 12:06:33 +03:00
|
|
|
# If this build of the library does not support auto-vacuum, omit this
|
|
|
|
# whole file.
|
|
|
|
ifcapable {!autovacuum} {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2005-01-22 06:39:39 +03:00
|
|
|
do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
|
|
|
|
PRAGMA auto_vacuum = 1;
|
|
|
|
CREATE TABLE abc(a);
|
|
|
|
INSERT INTO abc VALUES(randstr(1500,1500));
|
|
|
|
} -sqlbody {
|
|
|
|
CREATE TABLE abc2(a);
|
|
|
|
BEGIN;
|
|
|
|
DELETE FROM abc;
|
|
|
|
INSERT INTO abc VALUES(randstr(1500,1500));
|
|
|
|
CREATE TABLE abc3(a);
|
|
|
|
COMMIT;
|
2005-01-11 13:25:06 +03:00
|
|
|
}
|
|
|
|
|
2005-01-22 06:39:39 +03:00
|
|
|
do_ioerr_test autovacuum-ioerr2-2 -tclprep {
|
|
|
|
execsql {
|
|
|
|
PRAGMA auto_vacuum = 1;
|
|
|
|
PRAGMA cache_size = 10;
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE abc(a);
|
|
|
|
INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
|
|
|
|
INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
|
|
|
|
}
|
|
|
|
for {set i 0} {$i<150} {incr i} {
|
2005-01-11 13:25:06 +03:00
|
|
|
execsql {
|
2005-01-22 06:39:39 +03:00
|
|
|
INSERT INTO abc VALUES(randstr(100,100));
|
2005-01-11 13:25:06 +03:00
|
|
|
}
|
2005-01-22 06:39:39 +03:00
|
|
|
}
|
|
|
|
execsql COMMIT
|
|
|
|
} -sqlbody {
|
|
|
|
BEGIN;
|
|
|
|
DELETE FROM abc WHERE length(a)>100;
|
|
|
|
UPDATE abc SET a = randstr(90,90);
|
|
|
|
CREATE TABLE abc3(a);
|
|
|
|
COMMIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_ioerr_test autovacuum-ioerr2-3 -sqlprep {
|
|
|
|
PRAGMA auto_vacuum = 1;
|
|
|
|
CREATE TABLE abc(a);
|
|
|
|
CREATE TABLE abc2(b);
|
|
|
|
} -sqlbody {
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO abc2 VALUES(10);
|
|
|
|
DROP TABLE abc;
|
|
|
|
COMMIT;
|
|
|
|
DROP TABLE abc2;
|
2005-01-11 13:25:06 +03:00
|
|
|
}
|
|
|
|
|
2005-01-22 06:39:39 +03:00
|
|
|
file delete -force backup.db
|
2005-01-29 12:14:05 +03:00
|
|
|
ifcapable subquery {
|
|
|
|
do_ioerr_test autovacuum-ioerr2-4 -tclprep {
|
|
|
|
if {![file exists backup.db]} {
|
|
|
|
sqlite3 dbb backup.db
|
|
|
|
execsql {
|
|
|
|
PRAGMA auto_vacuum = 1;
|
|
|
|
BEGIN;
|
|
|
|
CREATE TABLE abc(a);
|
|
|
|
INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
|
|
|
|
INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
|
|
|
|
} dbb
|
|
|
|
for {set i 0} {$i<2500} {incr i} {
|
|
|
|
execsql {
|
|
|
|
INSERT INTO abc VALUES(randstr(100,100));
|
|
|
|
} dbb
|
|
|
|
}
|
2005-01-11 13:25:06 +03:00
|
|
|
execsql {
|
2005-01-29 12:14:05 +03:00
|
|
|
COMMIT;
|
|
|
|
PRAGMA cache_size = 10;
|
2005-01-22 06:39:39 +03:00
|
|
|
} dbb
|
2005-01-29 12:14:05 +03:00
|
|
|
dbb close
|
2005-01-11 13:25:06 +03:00
|
|
|
}
|
2005-01-29 12:14:05 +03:00
|
|
|
db close
|
|
|
|
file delete -force test.db
|
|
|
|
file delete -force test.db-journal
|
|
|
|
copy_file backup.db test.db
|
|
|
|
set ::DB [sqlite3 db test.db]
|
2005-01-11 13:25:06 +03:00
|
|
|
execsql {
|
2005-01-22 06:39:39 +03:00
|
|
|
PRAGMA cache_size = 10;
|
2005-01-29 12:14:05 +03:00
|
|
|
}
|
|
|
|
} -sqlbody {
|
|
|
|
BEGIN;
|
|
|
|
DELETE FROM abc WHERE oid < 3;
|
|
|
|
UPDATE abc SET a = randstr(100,100) WHERE oid > 2300;
|
|
|
|
UPDATE abc SET a = randstr(1100,1100) WHERE oid =
|
|
|
|
(select max(oid) from abc);
|
|
|
|
COMMIT;
|
2005-01-11 13:25:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
finish_test
|
|
|
|
|