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