-C Add\sthe\sexperimental\ssqlite3_expired()\sAPI.\s(CVS\s2263)
-D 2005-01-22T03:03:54
+C Test\sscript\schanges:\sBug\sfix\sand\scleanup\son\sioerr\stests.\sAlso,\sdon't\suse\sTCL\s"file\scopy"\scommand\son\swindows.\s(CVS\s2264)
+D 2005-01-22T03:39:39
F Makefile.in ffd81f5e926d40b457071b4de8d7c1fa18f39b5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
F src/os_unix.h f3097815e041e82e24d92505e1ff61ba24172d13
F src/os_win.c 3c0b0a3bc33318cf555a1cd130232ad1b9a5a711
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 49ee879e0a0b06e6dcdb30f601c1bf4ac68bf028
+F src/pager.c 886a1ae43365ae3b2599d8c6eb6091d5dc91ca7c
F src/pager.h 9eba8c53dd91eae7f3f90743b2ee242da02a9862
F src/parse.y 5f2c197fcb63c6aed1787da436ec5a35247ab7a4
F src/pragma.c 141a3f4985b76035d102dc7ca37be6b04cfb8376
F test/autovacuum.test a87871f29761093dc171e97c9d0dd5ae7d43b0d1
F test/autovacuum_crash.test 05a63b8805b20cfba7ace82856ce4ccdda075a31
F test/autovacuum_ioerr.test 9cf27275ca47b72e188a47c53b61b6d583a01d24
-F test/autovacuum_ioerr2.test c4c8943eebf5051f773ec9739461318f057e5c15
+F test/autovacuum_ioerr2.test 8feb1cfb4d8177c639cd1e0b8c41d3c88a2a1518
F test/bigfile.test d3744a8821ce9abb8697f2826a3e3d22b719e89f
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bind.test d83cf2cdc5e2aae3066bbb9c6d12db51e6512fc9
F test/capi3b.test 5b6a66f9f295f79f443b5d3f33187fa5ef6cf336
F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03
F test/collate2.test 224a632ba04907c049804b08162efd234aa7871f
-F test/collate3.test a5ff693872a915fc6267956673d20915485c1829
+F test/collate3.test 7e30d58e2ae550ad259f2272d203dbb803fd08b9
F test/collate4.test b8668612691c4dcf90f67a8df1eeb1544e7fdaf8
F test/collate5.test 581775b94604b7435dc6a5c6e72fbbf7d69e3830
F test/collate6.test 6c9470d1606ee3e564675b229653e320c49ec638
F test/conflict.test c5b849b01cfbe0a4f63a90cba6f68e2fe3a75f87
F test/corrupt.test 916977f0255c81217a44abe0ac01b8508f65dcbf
-F test/corrupt2.test cb1f813df7559de3021e01170af0bba31507a9a5
+F test/corrupt2.test 88342570828f2b8cbbd8369eff3891f5c0bdd5ba
F test/crash.test f38b980a0508655d08c957a6dd27d66bca776504
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/cursor.test d7c65ea0fc4e321e12fbcf5c7f3e2211ef45379b
F test/insert3.test fa7cb5b01709a1bca3e28c82c80c1d44386b3676
F test/interrupt.test 5b4d8389e6cf2d01b94f87cfd02d9df1073bfb2d
F test/intpkey.test b57cf5236fde1bd8cbc1388fa0c91908f6fd9194
-F test/ioerr.test fb507c2596bb07aeaff257cb48fcc93340159f0c
+F test/ioerr.test 3155522a4fd73c714a78fc3403cced7252a130f3
F test/join.test e08471279574487cac0d17fa1ea66aca15c4de7f
F test/join2.test f2171c265e57ee298a27e57e7051d22962f9f324
F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
F test/lock2.test 59c3dd7d9b24d1bf7ec91b2d1541c37e97939d5f
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/main.test a60a1d234b5f5784097973bd395514ca56003ef1
-F test/malloc.test 180f7f7e19aca748ec923ab4ada6a2976b781722
+F test/malloc.test b7bc72bb1627e09d6003f58de9bcd6e4be839753
F test/memdb.test 1860e060be810bf0775bc57408a5b7c4954bcaea
F test/memleak.test c0af09191af44a7501ec2494fdd079ac538a256c
F test/minmax.test 9429a06f1f93acf76fcacafd17160a4392e88526
F test/misuse.test 600738a8e611989bc5f544303f5e311c5f228084
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test 69c62daf1630bf54c87bbc7ef2e22012e58d6da8
-F test/pager.test f78a03ab8f9f64db47101e4957ac16a3a5563317
+F test/pager.test 1579e8f07291ae8e24db62ffade5c101c3e76597
F test/pager2.test 49c0f57c7da0b060f0486b85fdd074025caa694e
F test/pager3.test 647f696a9cf7409df00a1e0047c2eb55585a1b85
F test/pagesize.test 1b826d1608fd86d2303aa895b5586052ad07eba1
F test/sort.test 87882e6c72a75d45e98a1c802c1ded0eac557d85
F test/subquery.test a3ed9f11a4e576ff31b539ab5d65953dc3d27a81
F test/subselect.test 3f3f7a940dc3195c3139f4d530385cb54665d614
-F test/table.test a6b6b897731b4971f06db165d65bd608a9f2d461
+F test/table.test fe2fa0d684eee90b3bd823f23c1403818630780b
F test/tableapi.test 6a66d58b37d46dc0f2b3c7d4bd2617d209399bd1
F test/tclsqlite.test f467d9062e17c1ace54467e6fba5ce3ca176c0fe
F test/temptable.test 63a16e3ad19adf073cfbcdf7624c92ac5236522c
-F test/tester.tcl 0e9e3697983873ebd58aeefa61a87de2bc2c56ae
+F test/tester.tcl d734cbbce1662179a4dd9910c891af3709f2b058
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd
-P fede252d19cce6a88f6baff3362b057ab3b8af4b
-R f63a0d547a129b500c164681f97b8ec5
-U drh
-Z 57c27b4a6f46b9df6f843f9dba7ad549
+P df648d50c0696cf7ada2fe5973d285b494891964
+R b0c675a4cb045c75fc37543174b70695
+U danielk1977
+Z 7904849f77948860180c69bbf40c06c8
-df648d50c0696cf7ada2fe5973d285b494891964
\ No newline at end of file
+764b55adb5dff944db36d0d19ce5e7cc758b3a9e
\ No newline at end of file
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.185 2005/01/21 08:13:15 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.186 2005/01/22 03:39:39 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
}
if( zMaster ){
/* If there was a master journal and this routine will return true,
- ** see if it is possible to delete the master journal. If errors
- ** occur during this process, ignore them.
+ ** see if it is possible to delete the master journal.
*/
if( rc==SQLITE_OK ){
- pager_delmaster(zMaster);
+ rc = pager_delmaster(zMaster);
}
sqliteFree(zMaster);
}
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
-# $Id: autovacuum_ioerr2.test,v 1.3 2005/01/16 09:06:34 danielk1977 Exp $
+# $Id: autovacuum_ioerr2.test,v 1.4 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
return
}
-proc opendb {} {
- catch {file delete -force test.db}
- catch {file delete -force test.db-journal}
- sqlite3 db test.db
- execsql {pragma auto_vacuum = 1}
- execsql {SELECT * FROM sqlite_master}
+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;
}
-set ::go 1
-for {set n 1} {$go} {incr n} {
- do_test autovacuum-ioerr2-1.$n.1 {
- set ::sqlite_io_error_pending 0
- db close
- opendb
+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} {
execsql {
- CREATE TABLE abc(a);
- INSERT INTO abc VALUES(randstr(1500,1500));
+ INSERT INTO abc VALUES(randstr(100,100));
}
- expr [file size test.db]/1024
- } {4}
- do_test autovacuum-ioerr2-1.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
- do_test autovacuum-ioerr2-1.$n.3 {
- set r [catch {db eval {
- CREATE TABLE abc2(a);
- BEGIN;
- DELETE FROM abc;
- INSERT INTO abc VALUES(randstr(1500,1500));
- CREATE TABLE abc3(a);
- COMMIT;
- }} msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- } {1}
+ }
+ 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;
}
-set ::sqlite_io_error_pending 0
-set ::go 1
-for {set n 1} {$go} {incr n} {
- do_test autovacuum-ioerr2-2.$n.1 {
- set ::sqlite_io_error_pending 0
- db close
- opendb
+file delete -force backup.db
+do_ioerr_test autovacuum-ioerr2-4 -tclprep {
+ if {![file exists backup.db]} {
+ sqlite3 dbb backup.db
execsql {
- PRAGMA cache_size = 10;
+ 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
- }
- for {set i 0} {$i<150} {incr i} {
+ } dbb
+ for {set i 0} {$i<2500} {incr i} {
execsql {
INSERT INTO abc VALUES(randstr(100,100));
- }
+ } dbb
}
- execsql COMMIT
- } {}
- do_test autovacuum-ioerr2-2.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
- do_test autovacuum-ioerr2-2.$n.3 {
- set r [catch {db eval {
- BEGIN;
- DELETE FROM abc WHERE length(a)>100;
- UPDATE abc SET a = randstr(90,90);
- CREATE TABLE abc3(a);
- COMMIT;
- }} msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- } {1}
-}
-set ::sqlite_io_error_pending 0
-
-set ::go 1
-for {set n 1} {$go} {incr n} {
- do_test autovacuum-ioerr2-3.$n.1 {
- set ::sqlite_io_error_pending 0
- db close
- opendb
execsql {
- CREATE TABLE abc(a);
- CREATE TABLE abc2(b);
- }
- } {}
- do_test autovacuum-ioerr2-3.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
- do_test autovacuum-ioerr2-3.$n.3 {
- set r [catch {db eval {
- BEGIN;
- INSERT INTO abc2 VALUES(10);
- DROP TABLE abc;
COMMIT;
- DROP TABLE abc2;
- }} msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- } {1}
-}
-set ::sqlite_io_error_pending 0
-
-do_test autovacuum-ioerr2.4.0 {
+ PRAGMA cache_size = 10;
+ } dbb
+ dbb close
+ }
db close
- opendb
+ file delete -force test.db
+ file delete -force test.db-journal
+ copy_file backup.db test.db
+ set ::DB [sqlite3 db test.db]
execsql {
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<2500} {incr i} {
- execsql {
- INSERT INTO abc VALUES(randstr(100,100));
- }
}
- execsql COMMIT
- file copy -force test.db backup.db
-} {}
-
-proc opendb2 {} {
- catch {file delete -force test.db}
- catch {file delete -force test.db-journal}
- file copy backup.db test.db
- sqlite3 db test.db
- execsql {select * from sqlite_master}
- execsql {PRAGMA cache_size = 10}
- return ""
+} -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;
}
-set ::go 1
-for {set n 1} {$go} {incr n} {
- do_test autovacuum-ioerr2-4.$n.1 {
- set ::sqlite_io_error_pending 0
- db close
- opendb2
- } {}
- do_test autovacuum-ioerr2-4.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
- do_test autovacuum-ioerr2-4.$n.3 {
- set r [catch {db eval {
- 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;
- }} msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- } {1}
-}
-set ::sqlite_io_error_pending 0
-
-
-rename opendb ""
-db close
-catch {file delete -force test.db}
-catch {file delete -force test.db-journal}
-
finish_test
-
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
-# $Id: collate3.test,v 1.7 2005/01/03 02:26:55 drh Exp $
+# $Id: collate3.test,v 1.8 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
expr 0
} 0
db eval {select * from collate3t1}
-breakpoint
do_test collate3-3.1 {
catchsql {
INSERT INTO collate3t1 VALUES('xxx', 0);
# This file implements tests to make sure SQLite does not crash or
# segfault if it sees a corrupt database file.
#
-# $Id: corrupt2.test,v 1.1 2005/01/11 10:25:07 danielk1977 Exp $
+# $Id: corrupt2.test,v 1.2 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Corrupt the 16 byte magic string at the start of the file
file delete -force corrupt.db
file delete -force corrupt.db-journal
- file copy test.db corrupt.db
+ copy_file test.db corrupt.db
set f [open corrupt.db a]
seek $f 8 start
puts $f blah
# Corrupt the page-size (bytes 16 and 17 of page 1).
file delete -force corrupt.db
file delete -force corrupt.db-journal
- file copy test.db corrupt.db
+ copy_file test.db corrupt.db
set f [open corrupt.db a]
fconfigure $f -encoding binary
seek $f 16 start
# Corrupt the free-block list on page 1.
file delete -force corrupt.db
file delete -force corrupt.db-journal
- file copy test.db corrupt.db
+ copy_file test.db corrupt.db
set f [open corrupt.db a]
fconfigure $f -encoding binary
seek $f 101 start
# Corrupt the free-block list on page 1.
file delete -force corrupt.db
file delete -force corrupt.db-journal
- file copy test.db corrupt.db
+ copy_file test.db corrupt.db
set f [open corrupt.db a]
fconfigure $f -encoding binary
seek $f 101 start
# The tests in this file use special facilities that are only
# available in the SQLite test fixture.
#
-# $Id: ioerr.test,v 1.16 2005/01/19 03:47:16 danielk1977 Exp $
+# $Id: ioerr.test,v 1.17 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
-# Usage: do_ioerr_test <test number> <options...>
-#
-# The first argument, <test number>, is an integer used to name the
-# tests executed by this proc. Options are as follows:
-#
-# -tclprep TCL script to run to prepare test.
-# -sqlprep SQL script to run to prepare test.
-# -tclbody TCL script to run with IO error simulation.
-# -sqlbody TCL script to run with IO error simulation.
-# -exclude List of 'N' values not to test.
-# -start Value of 'N' to begin with (default 1)
-#
-proc do_ioerr_test {tn args} {
- array set ::ioerropts $args
-
- set ::go 1
- if {![info exists ::ioerropts(-start)]} {
- set ::ioerropts(-start) 1
- }
- for {set n $::ioerropts(-start)} {$::go} {incr n} {
-
- if {[info exists ::ioerropts(-exclude)]} {
- if {[lsearch $::ioerropts(-exclude) $n]!=-1} continue
- }
-
- do_test ioerr-$tn.$n.1 {
- set ::sqlite_io_error_pending 0
- catch {db close}
- catch {file delete -force test.db}
- catch {file delete -force test.db-journal}
- catch {file delete -force test2.db}
- catch {file delete -force test2.db-journal}
-
- set ::DB [sqlite3 db test.db]
-
- if {[info exists ::ioerropts(-tclprep)]} {
- eval $::ioerropts(-tclprep)
- }
- if {[info exists ::ioerropts(-sqlprep)]} {
- execsql $::ioerropts(-sqlprep)
- }
- expr 0
- } {0}
-
- do_test ioerr-$tn.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
-
- set ::ioerrorbody {}
- if {[info exists ::ioerropts(-tclbody)]} {
- append ::ioerrorbody "$::ioerropts(-tclbody)\n"
- }
- if {[info exists ::ioerropts(-sqlbody)]} {
- append ::ioerrorbody "db eval {$::ioerropts(-sqlbody)}"
- }
- do_test ioerr-$tn.$n.3 {
- set r [catch $::ioerrorbody msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- } {1}
- }
- set ::sqlite_io_error_pending 0
- unset ::ioerropts
-}
-
# If SQLITE_DEFAULT_AUTOVACUUM is set to true, then a simulated IO error
# on the 8th IO operation in the SQL script below doesn't report an error.
#
# file when the file on disk is only 1 page. The pager layer detects that
# this has happened and suppresses the error returned by the OS layer.
#
-do_ioerr_test 1 -sqlprep {
+do_ioerr_test ioerr-1 -sqlprep {
SELECT * FROM sqlite_master;
} -sqlbody {
CREATE TABLE t1(a,b,c);
DELETE FROM t1 WHERE a<100;
} -exclude [expr [string match [execsql {pragma auto_vacuum}] 1] ? 8 : 0]
+# Test for IO errors during a VACUUM.
+#
+# The first IO call is excluded from the test. This call attempts to read
+# the file-header of the temporary database used by VACUUM. Since the
+# database doesn't exist at that point, the IO error is not detected.
+#
+# Additionally, if auto-vacuum is enabled, the 12th IO error is not
+# detected. Same reason as the 8th in the test case above.
+#
+# IO error 134 is omitted because this occurs while closing the
+# temporary database used by vacuum and is not reported.
+#
+do_ioerr_test ioerr-2 -cksum true -sqlprep {
+ BEGIN;
+ CREATE TABLE t1(a, b, c);
+ INSERT INTO t1 VALUES(1, randstr(5,50), randstr(5,50));
+ INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;
+ INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));
+ CREATE TABLE t2 AS SELECT * FROM t1;
+ CREATE TABLE t3 AS SELECT * FROM t1;
+ COMMIT;
+ DROP TABLE t2;
+} -sqlbody {
+ VACUUM;
+} -exclude [list \
+ 1 134 [expr [string match [execsql {pragma auto_vacuum}] 1]?12:-1]]
-proc cksum {{db db}} {
- set txt [$db eval {
- SELECT name, type, sql FROM sqlite_master order by name
- }]\n
- foreach tbl [$db eval {
- SELECT name FROM sqlite_master WHERE type='table' order by name
- }] {
- append txt [$db eval "SELECT * FROM $tbl"]\n
- }
- foreach prag {default_synchronous default_cache_size} {
- append txt $prag-[$db eval "PRAGMA $prag"]\n
- }
- set cksum [string length $txt]-[md5 $txt]
- # puts $cksum-[file size test.db]
- return $cksum
-}
-
-set ::go 1
-for {set n 1} {$go} {incr n} {
- if {$n==24} breakpoint
- do_test ioerr-2.$n.1 {
- set ::sqlite_io_error_pending 0
- db close
- catch {file delete -force test.db}
- catch {file delete -force test.db-journal}
- catch {file delete -force test2.db}
- catch {file delete -force test2.db-journal}
- sqlite3 db test.db
- execsql {
- BEGIN;
- CREATE TABLE t1(a, b, c);
- INSERT INTO t1 VALUES(1, randstr(5,50), randstr(5,50));
- INSERT INTO t1 SELECT a+2, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+4, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+8, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+16, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+32, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+64, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 SELECT a+128, b||'-'||rowid, c||'-'||rowid FROM t1;
- INSERT INTO t1 VALUES(1, randstr(600,600), randstr(600,600));
- CREATE TABLE t2 AS SELECT * FROM t1;
- CREATE TABLE t3 AS SELECT * FROM t1;
- COMMIT;
- DROP TABLE t2;
- }
- set ::cksum [cksum]
- execsql {
- SELECT name FROM sqlite_master WHERE type='table'
- }
- } {t1 t3}
- do_test ioerr-2.$n.2 [subst {
- set ::sqlite_io_error_pending $n
- }] $n
- do_test ioerr-2.$n.3 {
- set r [catch {db eval {
- VACUUM;
- }} msg]
- set ::go [expr {$::sqlite_io_error_pending<=0}]
- expr {$::sqlite_io_error_pending>0 || $r!=0}
- set ::sqlite_io_error_pending 0
- db close
- sqlite3 db test.db
- cksum
- } $cksum
-}
-set ::sqlite_io_error_pending 0
-
-
-do_ioerr_test 3 -tclprep {
+do_ioerr_test ioerr-3 -tclprep {
execsql {
PRAGMA cache_size = 10;
BEGIN;
# Test IO errors that can occur retrieving a record header that flows over
# onto an overflow page.
-do_ioerr_test 4 -tclprep {
+do_ioerr_test ioerr-4 -tclprep {
set sql "CREATE TABLE abc(a1"
for {set i 2} {$i<1300} {incr i} {
append sql ", a$i"
if {[string match [execsql {pragma auto_vacuum}] 1]} {
set ex [list 8 17]
}
-do_ioerr_test 5 -sqlprep {
+do_ioerr_test ioerr-5 -sqlprep {
ATTACH 'test2.db' AS test2;
} -sqlbody {
BEGIN;
# Test IO errors when replaying two hot journals from a 2-file
# transaction. This test only runs on UNIX.
if {$tcl_platform(platform)=="unix" && [file exists ./crashtest]} {
- do_ioerr_test 6 -tclprep {
+ do_ioerr_test ioerr-6 -tclprep {
+ execsql {
+ ATTACH 'test2.db' as aux;
+ CREATE TABLE tx(a, b);
+ CREATE TABLE aux.ty(a, b);
+ }
set rc [crashsql 2 test2.db-journal {
ATTACH 'test2.db' as aux;
PRAGMA cache_size = 10;
error "Wrong error message: $rc"
}
} -sqlbody {
- ATTACH 'test2.db' as aux;
- SELECT * FROM t1;
- SELECT * FROM t2;
+ SELECT * FROM sqlite_master;
+ SELECT * FROM aux.sqlite_master;
}
-}
+}
# Test handling of IO errors that occur while rolling back hot journal
# files.
# SQLite holds a mandatory exclusive lock on journal files it has open.
#
if {$tcl_platform(platform)!="windows"} {
- do_ioerr_test 7 -tclprep {
+ do_ioerr_test ioerr-7 -tclprep {
db close
sqlite3 db2 test2.db
db2 eval {
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
- file copy -force test2.db test.db
- file copy -force test2.db-journal test.db-journal
+ copy_file test2.db test.db
+ copy_file test2.db-journal test.db-journal
db2 close
} -tclbody {
sqlite3 db test.db
} -exclude 1
}
-# do_ioerr_test 15 -sqlprep {
-# CREATE TABLE abc(a UNIQUE, b, c);
-# INSERT INTO abc VALUES(1, 2, 3);
-# } -sqlbody {
-# BEGIN;
-# INSERT INTO abc VALUES(1, 2, 3);
-# COMMIT;
-# }
-
finish_test
# special feature is used to see what happens in the library if a malloc
# were to really fail due to an out-of-memory situation.
#
-# $Id: malloc.test,v 1.21 2005/01/19 03:52:55 danielk1977 Exp $
+# $Id: malloc.test,v 1.22 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
BEGIN;
INSERT INTO t1 VALUES(3, 4);
}
- file copy -force test2.db test.db
- file copy -force test2.db-journal test.db-journal
+ copy_file test2.db test.db
+ copy_file test2.db-journal test.db-journal
db2 close
} -tclbody {
sqlite3 db test.db
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
-# $Id: pager.test,v 1.22 2005/01/20 02:17:02 danielk1977 Exp $
+# $Id: pager.test,v 1.23 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
BEGIN;
UPDATE abc SET c = randstr(200,200);
} db2
- file copy -force test2.db test.db
- file copy -force test2.db-journal test.db-journal
+ copy_file test2.db test.db
+ copy_file test2.db-journal test.db-journal
set f [open test.db-journal a]
fconfigure $f -encoding binary
} {{CREATE TABLE abc(a, b, c)}}
do_test pager-6.2 {
- file copy -force test2.db test.db
- file copy -force test2.db-journal test.db-journal
+ copy_file test2.db test.db
+ copy_file test2.db-journal test.db-journal
set f [open test.db-journal a]
fconfigure $f -encoding binary
} {{CREATE TABLE abc(a, b, c)}}
do_test pager-6.3 {
- file copy -force test2.db test.db
- file copy -force test2.db-journal test.db-journal
+ copy_file test2.db test.db
+ copy_file test2.db-journal test.db-journal
set f [open test.db-journal a]
fconfigure $f -encoding binary
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE TABLE statement.
#
-# $Id: table.test,v 1.36 2005/01/21 03:12:16 danielk1977 Exp $
+# $Id: table.test,v 1.37 2005/01/22 03:39:39 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Try out the CREATE TABLE AS syntax
#
do_test table-8.1 {
-breakpoint
execsql2 {
CREATE TABLE t2 AS SELECT * FROM weird;
SELECT * FROM t2;
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
-# $Id: tester.tcl,v 1.45 2005/01/21 03:12:16 danielk1977 Exp $
+# $Id: tester.tcl,v 1.46 2005/01/22 03:39:39 danielk1977 Exp $
# Make sure tclsqlite3 was compiled correctly. Abort now with an
# error message if not.
lappend r $msg
}
+# Usage: do_ioerr_test <test number> <options...>
+#
+# This proc is used to implement test cases that check that IO errors
+# are correctly handled. The first argument, <test number>, is an integer
+# used to name the tests executed by this proc. Options are as follows:
+#
+# -tclprep TCL script to run to prepare test.
+# -sqlprep SQL script to run to prepare test.
+# -tclbody TCL script to run with IO error simulation.
+# -sqlbody TCL script to run with IO error simulation.
+# -exclude List of 'N' values not to test.
+# -start Value of 'N' to begin with (default 1)
+#
+# -cksum Boolean. If true, test that the database does
+# not change during the execution of the test case.
+#
+proc do_ioerr_test {testname args} {
+
+ if {$testname=="ioerr-2"} {
+ breakpoint
+ }
+ set ::ioerropts(-start) 1
+ set ::ioerropts(-cksum) 0
+
+ array set ::ioerropts $args
+
+ set ::go 1
+ for {set n $::ioerropts(-start)} {$::go} {incr n} {
+
+ # Skip this IO error if it was specified with the "-exclude" option.
+ if {[info exists ::ioerropts(-exclude)]} {
+ if {[lsearch $::ioerropts(-exclude) $n]!=-1} continue
+ }
+
+ # Delete the files test.db and test2.db, then execute the TCL and
+ # SQL (in that order) to prepare for the test case.
+ do_test $testname.$n.1 {
+ set ::sqlite_io_error_pending 0
+ catch {db close}
+ catch {file delete -force test.db}
+ catch {file delete -force test.db-journal}
+ catch {file delete -force test2.db}
+ catch {file delete -force test2.db-journal}
+ set ::DB [sqlite3 db test.db]
+ if {[info exists ::ioerropts(-tclprep)]} {
+ eval $::ioerropts(-tclprep)
+ }
+ if {[info exists ::ioerropts(-sqlprep)]} {
+ execsql $::ioerropts(-sqlprep)
+ }
+ expr 0
+ } {0}
+
+ # Read the 'checksum' of the database.
+ if {$::ioerropts(-cksum)} {
+ set checksum [cksum]
+ }
+
+ # Set the Nth IO error to fail.
+ do_test $testname.$n.2 [subst {
+ set ::sqlite_io_error_pending $n
+ }] $n
+
+ # Create a single TCL script from the TCL and SQL specified
+ # as the body of the test.
+ set ::ioerrorbody {}
+ if {[info exists ::ioerropts(-tclbody)]} {
+ append ::ioerrorbody "$::ioerropts(-tclbody)\n"
+ }
+ if {[info exists ::ioerropts(-sqlbody)]} {
+ append ::ioerrorbody "db eval {$::ioerropts(-sqlbody)}"
+ }
+
+ # Execute the TCL Script created in the above block. If
+ # there are at least N IO operations performed by SQLite as
+ # a result of the script, the Nth will fail.
+ do_test $testname.$n.3 {
+ set r [catch $::ioerrorbody msg]
+ set ::go [expr {$::sqlite_io_error_pending<=0}]
+ set s [expr $::sqlite_io_error_pending>0]
+ # puts "$::sqlite_io_error_pending $r $msg"
+ expr { ($s && !$r) || (!$s && $r) }
+ # expr {$::sqlite_io_error_pending>0 || $r!=0}
+ } {1}
+
+ # If an IO error occured, then the checksum of the database should
+ # be the same as before the script that caused the IO error was run.
+ if {$::go && $::ioerropts(-cksum)} {
+ do_test $testname.$n.4 {
+ catch {db close}
+ set ::DB [sqlite3 db test.db]
+ cksum
+ } $checksum
+ }
+
+ }
+ set ::sqlite_io_error_pending 0
+ unset ::ioerropts
+}
+
+# Return a checksum based on the contents of database 'db'.
+#
+proc cksum {{db db}} {
+ set txt [$db eval {
+ SELECT name, type, sql FROM sqlite_master order by name
+ }]\n
+ foreach tbl [$db eval {
+ SELECT name FROM sqlite_master WHERE type='table' order by name
+ }] {
+ append txt [$db eval "SELECT * FROM $tbl"]\n
+ }
+ foreach prag {default_synchronous default_cache_size} {
+ append txt $prag-[$db eval "PRAGMA $prag"]\n
+ }
+ set cksum [string length $txt]-[md5 $txt]
+ # puts $cksum-[file size test.db]
+ return $cksum
+}
+
+# Copy file $from into $to. This is used because some versions of
+# TCL for windows (notably the 8.4.1 binary package shipped with the
+# current mingw release) have a broken "file copy" command.
+#
+proc copy_file {from to} {
+ if {$::tcl_platform(platform)=="unix"} {
+ file copy -force $from $to
+ } else {
+ set f [open $from]
+ fconfigure $f -translation binary
+ set t [open $to w]
+ fconfigure $t -translation binary
+ puts -nonewline $t [read $f [file size $from]]
+ close $t
+ close $f
+ }
+}
+
# If the library is compiled with the SQLITE_DEFAULT_AUTOVACUUM macro set
# to non-zero, then set the global variable $AUTOVACUUM to 1.
set AUTOVACUUM $sqlite_options(default_autovacuum)