Index: Makefile.msc ================================================================== --- Makefile.msc +++ Makefile.msc @@ -41,10 +41,15 @@ # Omitting the define will cause extra debugging code to be inserted and # includes extra comments when "EXPLAIN stmt" is used. # TCC = $(TCC) -DNDEBUG +# +# Prevent warnings about "insecure" runtime library functions being used. +# +TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS + # The locations of the Tcl header and library files. Also, the library that # non-stubs enabled programs using Tcl must link against. These variables # (TCLINCDIR, TCLLIBDIR, and LIBTCL) may be overridden via the environment # prior to running nmake in order to match the actual installed location and # version on this machine. Index: src/os_win.c ================================================================== --- src/os_win.c +++ src/os_win.c @@ -2189,10 +2189,11 @@ int isTemp = 0; #endif winFile *pFile = (winFile*)id; void *zConverted; /* Filename in OS encoding */ const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */ + int cnt = 0; /* If argument zPath is a NULL pointer, this function is required to open ** a temporary file. Use this buffer to store the file name in. */ char zTmpname[MAX_PATH+1]; /* Buffer used to create temp filename */ @@ -2308,34 +2309,34 @@ #if SQLITE_OS_WINCE dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; #endif if( isNT() ){ - h = CreateFileW((WCHAR*)zConverted, - dwDesiredAccess, - dwShareMode, - NULL, - dwCreationDisposition, - dwFlagsAndAttributes, - NULL - ); + while( (h = CreateFileW((WCHAR*)zConverted, + dwDesiredAccess, + dwShareMode, NULL, + dwCreationDisposition, + dwFlagsAndAttributes, + NULL))==INVALID_HANDLE_VALUE && + retryIoerr(&cnt) ){} /* isNT() is 1 if SQLITE_OS_WINCE==1, so this else is never executed. ** Since the ASCII version of these Windows API do not exist for WINCE, ** it's important to not reference them for WINCE builds. */ #if SQLITE_OS_WINCE==0 }else{ - h = CreateFileA((char*)zConverted, - dwDesiredAccess, - dwShareMode, - NULL, - dwCreationDisposition, - dwFlagsAndAttributes, - NULL - ); + while( (h = CreateFileA((char*)zConverted, + dwDesiredAccess, + dwShareMode, NULL, + dwCreationDisposition, + dwFlagsAndAttributes, + NULL))==INVALID_HANDLE_VALUE && + retryIoerr(&cnt) ){} #endif } + + logIoerr(cnt); OSTRACE(("OPEN %d %s 0x%lx %s\n", h, zName, dwDesiredAccess, h==INVALID_HANDLE_VALUE ? "failed" : "ok")); Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -5643,10 +5643,11 @@ /* ** Information passed from the main thread into the windows file locker ** background thread. */ struct win32FileLocker { + char *evName; /* Name of event to signal thread startup */ HANDLE h; /* Handle of the file to be locked */ int delay1; /* Delay before locking */ int delay2; /* Delay before unlocking */ int ok; /* Finished ok */ int err; /* True if an error occurs */ @@ -5658,10 +5659,17 @@ /* ** The background thread that does file locking. */ static void win32_file_locker(void *pAppData){ struct win32FileLocker *p = (struct win32FileLocker*)pAppData; + if( p->evName ){ + HANDLE ev = OpenEvent(EVENT_MODIFY_STATE, FALSE, p->evName); + if ( ev ){ + SetEvent(ev); + CloseHandle(ev); + } + } if( p->delay1 ) Sleep(p->delay1); if( LockFile(p->h, 0, 0, 100000000, 0) ){ Sleep(p->delay2); UnlockFile(p->h, 0, 0, 100000000, 0); p->ok = 1; @@ -5686,20 +5694,22 @@ void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ - static struct win32FileLocker x = { 0, 0, 0 }; + static struct win32FileLocker x = { "win32_file_lock", 0, 0, 0, 0, 0 }; const char *zFilename; + char zBuf[200]; int retry = 0; + HANDLE ev; + DWORD wResult; if( objc!=4 && objc!=1 ){ Tcl_WrongNumArgs(interp, 1, objv, "FILENAME DELAY1 DELAY2"); return TCL_ERROR; } if( objc==1 ){ - char zBuf[200]; sqlite3_snprintf(sizeof(zBuf), zBuf, "%d %d %d %d %d", x.ok, x.err, x.delay1, x.delay2, x.h); Tcl_AppendResult(interp, zBuf, (char*)0); return TCL_OK; } @@ -5718,13 +5728,25 @@ FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if( !x.h ){ Tcl_AppendResult(interp, "cannot open file: ", zFilename, (char*)0); return TCL_ERROR; + } + ev = CreateEvent(NULL, TRUE, FALSE, x.evName); + if ( !ev ){ + Tcl_AppendResult(interp, "cannot create event: ", x.evName, (char*)0); + return TCL_ERROR; } _beginthread(win32_file_locker, 0, (void*)&x); Sleep(0); + if ( (wResult = WaitForSingleObject(ev, 10000))!=WAIT_OBJECT_0 ){ + sqlite3_snprintf(sizeof(zBuf), zBuf, "0x%x", wResult); + Tcl_AppendResult(interp, "wait failed: ", zBuf, (char*)0); + CloseHandle(ev); + return TCL_ERROR; + } + CloseHandle(ev); return TCL_OK; } #endif Index: test/8_3_names.test ================================================================== --- test/8_3_names.test +++ test/8_3_names.test @@ -65,12 +65,12 @@ } 0 do_test 8_3_names-2.1 { file exists test.nal } 1 forcedelete test2.db test2.nal test2.db-journal -file copy test.db test2.db -file copy test.nal test2.nal +copy_file test.db test2.db +copy_file test.nal test2.nal do_test 8_3_names-2.2 { db eval { COMMIT; SELECT length(x) FROM t1 } @@ -99,12 +99,12 @@ } 1 do_test 8_3_names-3.1 { file exists test.nal } 0 forcedelete test2.db test2.nal test2.db-journal -file copy test.db test2.db -file copy test.db-journal test2.db-journal +copy_file test.db test2.db +copy_file test.db-journal test2.db-journal do_test 8_3_names-3.2 { db eval { COMMIT; SELECT length(x) FROM t1 } Index: test/alter.test ================================================================== --- test/alter.test +++ test/alter.test @@ -219,12 +219,12 @@ # Check that ALTER TABLE works on attached databases. # ifcapable attach { do_test alter-1.8.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' AS aux; } } {} do_test alter-1.8.2 { @@ -410,12 +410,12 @@ set ::TRIGGER } {trig3 4 5 6} # Make sure "ON" cannot be used as a database, table or column name without # quoting. Otherwise the sqlite_alter_trigger() function might not work. -file delete -force test3.db -file delete -force test3.db-journal +forcedelete test3.db +forcedelete test3.db-journal ifcapable attach { do_test alter-3.2.1 { catchsql { ATTACH 'test3.db' AS ON; } Index: test/alter2.test ================================================================== --- test/alter2.test +++ test/alter2.test @@ -313,12 +313,12 @@ sqlite3 db test.db get_file_format } {2} ifcapable attach { do_test alter2-6.2 { - file delete -force test2.db-journal - file delete -force test2.db + forcedelete test2.db-journal + forcedelete test2.db execsql { ATTACH 'test2.db' AS aux; CREATE TABLE aux.t1(a, b); } get_file_format test2.db Index: test/alter3.test ================================================================== --- test/alter3.test +++ test/alter3.test @@ -194,11 +194,11 @@ } {11} } do_test alter3-4.1 { db close - file delete -force test.db + forcedelete test.db set ::DB [sqlite3 db test.db] execsql { PRAGMA legacy_file_format=ON; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 100); @@ -235,12 +235,12 @@ } } {} ifcapable attach { do_test alter3-5.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 'one'); INSERT INTO t1 VALUES(2, 'two'); ATTACH 'test2.db' AS aux; Index: test/alter4.test ================================================================== --- test/alter4.test +++ test/alter4.test @@ -176,11 +176,11 @@ } {10} } do_test alter4-4.1 { db close - file delete -force test.db + forcedelete test.db set ::DB [sqlite3 db test.db] execsql { CREATE TEMP TABLE t1(a, b); INSERT INTO t1 VALUES(1, 100); INSERT INTO t1 VALUES(2, 300); @@ -211,12 +211,12 @@ } } {} ifcapable attach { do_test alter4-5.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { CREATE TEMP TABLE t1(a, b); INSERT INTO t1 VALUES(1, 'one'); INSERT INTO t1 VALUES(2, 'two'); ATTACH 'test2.db' AS aux; Index: test/async.test ================================================================== --- test/async.test +++ test/async.test @@ -66,11 +66,11 @@ if {[lsearch -exact $ASYNC_INCLUDE $tail]<0} continue source $testfile # Make sure everything is flushed through. This is because [source]ing # the next test file will delete the database file on disk (using - # [file delete]). If the asynchronous backend still has the file + # [delete_file]). If the asynchronous backend still has the file # open, it will become confused. # flush_async_queue } Index: test/async2.test ================================================================== --- test/async2.test +++ test/async2.test @@ -49,11 +49,11 @@ foreach err [list ioerr malloc-transient malloc-persistent] { set ::go 10 for {set n 1} {$::go} {incr n} { set ::sqlite_io_error_pending 0 sqlite3_memdebug_fail -1 - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql $::setup_script db close sqlite3async_initialize "" 1 Index: test/async3.test ================================================================== --- test/async3.test +++ test/async3.test @@ -39,12 +39,12 @@ chocolate/banana/./vanilla/extra_bit/../file.db } do_test async3-1.0 { file mkdir [file join chocolate banana vanilla] - file delete -force chocolate/banana/vanilla/file.db - file delete -force chocolate/banana/vanilla/file.db-journal + forcedelete chocolate/banana/vanilla/file.db + forcedelete chocolate/banana/vanilla/file.db-journal } {} do_test async3-1.1 { sqlite3 db chocolate/banana/vanilla/file.db execsql { Index: test/async5.test ================================================================== --- test/async5.test +++ test/async5.test @@ -18,11 +18,11 @@ finish_test return } db close -file delete -force test2.db +forcedelete test2.db sqlite3async_initialize "" 1 sqlite3async_control halt never sqlite3 db test.db do_test async5-1.1 { Index: test/attach.test ================================================================== --- test/attach.test +++ test/attach.test @@ -22,12 +22,12 @@ finish_test return } for {set i 2} {$i<=15} {incr i} { - file delete -force test$i.db - file delete -force test$i.db-journal + forcedelete test$i.db + forcedelete test$i.db-journal } do_test attach-1.1 { execsql { CREATE TABLE t1(a,b); @@ -626,11 +626,11 @@ ifcapable {trigger} { do_test attach-5.1 { db close sqlite3 db test.db db2 close - file delete -force test2.db + forcedelete test2.db sqlite3 db2 test2.db catchsql { ATTACH DATABASE 'test.db' AS orig; CREATE TRIGGER r1 AFTER INSERT ON orig.t1 BEGIN SELECT 'no-op'; @@ -723,21 +723,21 @@ dbx eval {CREATE TABLE t1(a,b,c)} dbx close file attributes cannot-read -permission 0000 if {[file writable cannot-read]} { puts "\n**** Tests do not work when run as root ****" - file delete -force cannot-read + forcedelete cannot-read exit 1 } catchsql { ATTACH DATABASE 'cannot-read' AS noread; } } {1 {unable to open database: cannot-read}} do_test attach-6.2.2 { db errorcode } {14} - file delete -force cannot-read + forcedelete cannot-read } # Check the error message if we try to access a database that has # not been attached. do_test attach-6.3 { @@ -747,16 +747,16 @@ } {1 {unknown database no_such_db}} for {set i 2} {$i<=15} {incr i} { catch {db$i close} } db close -file delete -force test2.db -file delete -force no-such-file +forcedelete test2.db +forcedelete no-such-file ifcapable subquery { do_test attach-7.1 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db catchsql { DETACH RAISE ( IGNORE ) IN ( SELECT "AAAAAA" . * ORDER BY REGISTER LIMIT "AAAAAA" . "AAAAAA" OFFSET RAISE ( IGNORE ) NOT NULL ) } @@ -775,11 +775,11 @@ } } {1 {file is encrypted or is not a database}} do_test attach-8.2 { db errorcode } {26} -file delete -force test2.db +forcedelete test2.db do_test attach-8.3 { sqlite3 db2 test2.db db2 eval {CREATE TABLE t1(x); BEGIN EXCLUSIVE} catchsql { ATTACH 'test2.db' AS t2; @@ -787,17 +787,17 @@ } {1 {database is locked}} do_test attach-8.4 { db errorcode } {5} db2 close -file delete -force test2.db +forcedelete test2.db # Test that it is possible to attach the same database more than # once when not in shared-cache mode. That this is not possible in # shared-cache mode is tested in shared7.test. do_test attach-9.1 { - file delete -force test4.db + forcedelete test4.db execsql { ATTACH 'test4.db' AS aux1; CREATE TABLE aux1.t1(a, b); INSERT INTO aux1.t1 VALUES(1, 2); ATTACH 'test4.db' AS aux2; Index: test/attach2.test ================================================================== --- test/attach2.test +++ test/attach2.test @@ -31,12 +31,12 @@ do_test attach2-1.1 { db eval { CREATE TABLE t1(a,b); CREATE INDEX x1 ON t1(a); } - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal sqlite3 db2 test2.db db2 eval { CREATE TABLE t1(a,b); CREATE INDEX x1 ON t1(a); } @@ -325,19 +325,19 @@ execsql {SELECT * FROM t1} db2 } {1 2 1 2} db close db2 close -file delete -force test2.db +forcedelete test2.db sqlite3_soft_heap_limit $soft_limit # These tests - attach2-5.* - check that the master journal file is deleted # correctly when a multi-file transaction is committed or rolled back. # # Update: It's not actually created if a rollback occurs, so that test # doesn't really prove too much. -foreach f [glob test.db*] {file delete -force $f} +foreach f [glob test.db*] {forcedelete $f} do_test attach2-5.1 { sqlite3 db test.db execsql { ATTACH 'test.db2' AS aux; } Index: test/attach3.test ================================================================== --- test/attach3.test +++ test/attach3.test @@ -33,12 +33,12 @@ CREATE TABLE t1(a, b); CREATE TABLE t2(c, d); } # Create tables t1 and t2 in database file test2.db -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db2 test2.db execsql { CREATE TABLE t1(a, b); CREATE TABLE t2(c, d); } db2 Index: test/attachmalloc.test ================================================================== --- test/attachmalloc.test +++ test/attachmalloc.test @@ -27,12 +27,12 @@ do_malloc_test attachmalloc-1 -tclprep { catch { db close } for {set i 2} {$i<=4} {incr i} { catch { db$i close } - file delete -force test$i.db - file delete -force test$i.db-journal + forcedelete test$i.db + forcedelete test$i.db-journal } } -tclbody { if {[catch {sqlite3 db test.db}]} { error "out of memory" } @@ -46,12 +46,12 @@ ATTACH 'test4.db' AS four; CREATE TABLE four.t1(x); } do_malloc_test attachmalloc-2 -tclprep { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal sqlite3 db2 test2.db db2 eval { CREATE TABLE t1(a, b, c); CREATE INDEX i1 ON t1(a, b); } Index: test/autoinc.test ================================================================== --- test/autoinc.test +++ test/autoinc.test @@ -425,12 +425,12 @@ # Make sure AUTOINCREMENT works on ATTACH-ed tables. # ifcapable tempdb&&attach { do_test autoinc-5.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal sqlite3 db2 test2.db execsql { CREATE TABLE t4(m INTEGER PRIMARY KEY AUTOINCREMENT, n); CREATE TABLE t5(o, p INTEGER PRIMARY KEY AUTOINCREMENT); } db2; @@ -518,11 +518,11 @@ # that creates the sqlite_sequence table does not mess up the database. # do_test autoinc-8.1 { catch {db2 close} catch {db close} - file delete -force test.db + forcedelete test.db sqlite3 db test.db set DB [sqlite3_connection_pointer db] set STMT [sqlite3_prepare $DB { CREATE TABLE t1( x INTEGER PRIMARY KEY AUTOINCREMENT Index: test/autovacuum.test ================================================================== --- test/autovacuum.test +++ test/autovacuum.test @@ -465,11 +465,11 @@ } } {1} do_test autovacuum-3.4 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { PRAGMA auto_vacuum; } } $AUTOVACUUM @@ -500,11 +500,11 @@ do_test autovacuum-4.0 { # The last round of tests may have left the db in non-autovacuum mode. # Reset everything just in case. # db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA auto_vacuum = 1; PRAGMA auto_vacuum; } @@ -597,12 +597,12 @@ # and the destination location collides with at least one other # entry in the page hash-table (internal to the pager.c module. # do_test autovacuum-7.1 { db close - file delete -force test.db - file delete -force test.db-journal + forcedelete test.db + forcedelete test.db-journal sqlite3 db test.db execsql { PRAGMA auto_vacuum=1; CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); Index: test/autovacuum_ioerr2.test ================================================================== --- test/autovacuum_ioerr2.test +++ test/autovacuum_ioerr2.test @@ -73,11 +73,11 @@ DROP TABLE abc; COMMIT; DROP TABLE abc2; } -file delete -force backup.db +forcedelete backup.db ifcapable subquery { do_ioerr_test autovacuum-ioerr2-4 -tclprep { if {![file exists backup.db]} { sqlite3 dbb backup.db execsql { @@ -97,13 +97,13 @@ PRAGMA cache_size = 10; } dbb dbb close } db close - file delete -force test.db - file delete -force test.db-journal - copy_file backup.db test.db + forcedelete test.db + forcedelete test.db-journal + forcecopy backup.db test.db set ::DB [sqlite3 db test.db] execsql { PRAGMA cache_size = 10; } } -sqlbody { Index: test/backcompat.test ================================================================== --- test/backcompat.test +++ test/backcompat.test @@ -59,11 +59,11 @@ puts "version [get_version $bin]" } proc do_backcompat_test {rv bin1 bin2 script} { - file delete -force test.db + forcedelete test.db if {$bin1 != ""} { set ::bc_chan1 [launch_testfixture $bin1] } set ::bc_chan2 [launch_testfixture $bin2] if { $rv } { @@ -150,11 +150,11 @@ set ret } proc write_file_system {data} { foreach f {test.db test.db-journal test.db-wal} d $data { if {[string length $d] == 0} { - file delete -force $f + forcedelete $f } else { write_file $f $d } } } Index: test/backup.test ================================================================== --- test/backup.test +++ test/backup.test @@ -71,11 +71,11 @@ test_contents backup-1.2 db main db main # Check that it is possible to create and finish backup operations. # do_test backup-1.3.1 { - file delete test2.db + delete_file test2.db sqlite3 db2 test2.db sqlite3_backup B db2 main db main } {B} do_test backup-1.3.2 { B finish @@ -166,12 +166,12 @@ foreach rows_dest {0 3 10} { foreach pgsz_dest {512 1024 2048} { foreach nPagePerStep {1 200} { # Open the databases. - catch { file delete test.db } - catch { file delete test2.db } + catch { delete_file test.db } + catch { delete_file test2.db } eval $zOpenScript # Set to true if copying to an in-memory destination. Copying to an # in-memory destination is only possible if the initial destination # page size is the same as the source page size (in this case 1024 bytes). @@ -277,12 +277,12 @@ set iTest 1 foreach nSrcPg {10 64 65 66 100} { foreach nDestRow {10 100} { foreach nDestPgsz {512 1024 2048 4096} { - catch { file delete test.db } - catch { file delete test2.db } + catch { delete_file test.db } + catch { delete_file test2.db } sqlite3 db test.db sqlite3 db2 test2.db # Set up the content of the two databases. # @@ -325,12 +325,12 @@ } } #-------------------------------------------------------------------- do_test backup-3.$iTest.1 { - catch { file delete -force test.db } - catch { file delete -force test2.db } + catch { forcedelete test.db } + catch { forcedelete test2.db } sqlite3 db test.db set iTab 1 db eval { PRAGMA page_size = 512 } while {[file size test.db] <= $::sqlite_pending_byte} { @@ -390,12 +390,12 @@ do_test backup-4.1.4 { sqlite3_errmsg db } {unknown database aux} do_test backup-4.2.1 { - catch { file delete -force test3.db } - catch { file delete -force test4.db } + catch { forcedelete test3.db } + catch { forcedelete test4.db } execsql { ATTACH 'test3.db' AS aux1; CREATE TABLE aux1.t1(a, b); } execsql { @@ -437,11 +437,11 @@ } {1 SQLITE_ERROR {source and destination must be distinct}} db close db2 close do_test backup-4.5.1 { - catch { file delete -force test.db } + catch { forcedelete test.db } sqlite3 db test.db sqlite3 db2 :memory: execsql { CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); @@ -489,16 +489,16 @@ # 2) Backing up file-to-file. The writer writes via the same pager as # is used by the backup operation. # 3) Backing up memory-to-file. # set iTest 0 -file delete -force bak.db-wal +forcedelete bak.db-wal foreach {writer file} {db test.db db3 test.db db :memory:} { incr iTest - catch { file delete bak.db } + catch { delete_file bak.db } sqlite3 db2 bak.db - catch { file delete $file } + catch { delete_file $file } sqlite3 db $file sqlite3 db3 $file do_test backup-5.$iTest.1.1 { execsql { @@ -595,13 +595,13 @@ test_contents backup-5.$iTest.4.6 db main db2 main catch {db close} catch {db2 close} catch {db3 close} - catch { file delete bak.db } + catch { delete_file bak.db } sqlite3 db2 bak.db - catch { file delete $file } + catch { delete_file $file } sqlite3 db $file sqlite3 db3 $file do_test backup-5.$iTest.5.1 { execsql { PRAGMA auto_vacuum = incremental; @@ -642,12 +642,12 @@ #--------------------------------------------------------------------- # Test the sqlite3_backup_remaining() and backup_pagecount() APIs. # do_test backup-6.1 { - catch { file delete -force test.db } - catch { file delete -force test2.db } + catch { forcedelete test.db } + catch { forcedelete test2.db } sqlite3 db test.db sqlite3 db2 test2.db execsql { BEGIN; CREATE TABLE t1(a, b); @@ -699,12 +699,12 @@ # SQLITE_LOCKED). # # backup-7.3.*: Destination database is externally locked (return SQLITE_BUSY). # do_test backup-7.0 { - catch { file delete -force test.db } - catch { file delete -force test2.db } + catch { forcedelete test.db } + catch { forcedelete test2.db } sqlite3 db2 test2.db sqlite3 db test.db execsql { CREATE TABLE t1(a, b); CREATE INDEX i1 ON t1(a, b); @@ -752,11 +752,11 @@ integrity_check backup-7.3.6 db2 do_test backup-7.3.1 { db2 close db3 close - file delete -force test2.db + forcedelete test2.db sqlite3 db2 test2.db sqlite3 db3 test2.db sqlite3_backup B db2 main db main execsql { BEGIN ; CREATE TABLE t2(a, b); } db3 @@ -781,12 +781,12 @@ # database while a read transaction is active. # # These tests reuse the database "test.db" left over from backup-7.*. # do_test backup-8.1 { - catch { file delete -force test2.db } - catch { file delete -force test3.db } + catch { forcedelete test2.db } + catch { forcedelete test3.db } sqlite3 db2 test2.db sqlite3 db3 test3.db sqlite3_backup B2 db2 main db main sqlite3_backup B3 db3 main db main @@ -863,12 +863,12 @@ } {SQLITE_OK} catch {db2 close} ifcapable memorymanage { db close - file delete -force test.db - file delete -force bak.db + forcedelete test.db + forcedelete bak.db sqlite3 db test.db sqlite3 db2 test.db sqlite3 db3 bak.db @@ -916,11 +916,11 @@ # # 10.1.*: If the db is in-memory, the backup is restarted. # 10.2.*: If the db is a file, the backup is not restarted. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal foreach {tn file rc} { 1 test.db SQLITE_DONE 2 :memory: SQLITE_OK } { do_test backup-10.$tn.1 { @@ -946,11 +946,11 @@ set pgs [execsql {pragma page_count}] expr {$pgs > 50 && $pgs < 75} } {1} do_test backup-10.$tn.3 { - file delete -force bak.db bak.db-journal + forcedelete bak.db bak.db-journal sqlite3 db2 bak.db sqlite3_backup B db2 main db main B step 50 } {SQLITE_OK} Index: test/backup2.test ================================================================== --- test/backup2.test +++ test/backup2.test @@ -59,11 +59,11 @@ # Make a backup of the test data. Verify that the backup copy # is identical to the original. # do_test backup2-2 { - file delete -force bu1.db + forcedelete bu1.db db backup bu1.db sqlite3 db2 bu1.db dbcksum db2 main } $cksum @@ -70,21 +70,21 @@ # Delete the original. Restore from backup. Verify the content is # unchanged. # do_test backup2-3.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db2 eval {BEGIN EXCLUSIVE} set rc [catch {db restore bu1.db} res] lappend rc $res db2 eval {ROLLBACK} set rc } {1 {restore failed: source database busy}} do_test backup2-3.2 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db restore bu1.db dbcksum db main } $cksum @@ -94,11 +94,11 @@ db restore temp bu1.db dbcksum db temp } $cksum do_test backup2-5 { db2 close - file delete -force bu1.db bu2.db + forcedelete bu1.db bu2.db db backup temp bu2.db sqlite3 db2 bu2.db dbcksum db2 main } $cksum @@ -125,11 +125,11 @@ } {1 {backup failed: file is encrypted or is not a database}} # Try to backup database that does not exist # do_test backup2-8 { - file delete -force bu1.db + forcedelete bu1.db set rc [catch {db backup aux1 bu1.db} res] lappend rc $res } {1 {backup failed: unknown database aux1}} # Invalid syntax on the backup method @@ -141,19 +141,19 @@ # Try to restore from an unreadable file. # if {$tcl_platform(platform)=="windows"} { do_test backup2-10 { - file delete -force bu3.db + forcedelete bu3.db file mkdir bu3.db set rc [catch {db restore temp bu3.db} res] lappend rc $res } {1 {cannot open source database: unable to open database file}} } if {$tcl_platform(platform)!="windows"} { do_test backup2-10 { - file delete -force bu3.db + forcedelete bu3.db file mkdir bu3.db set rc [catch {db restore temp bu3.db} res] lappend rc $res } {1 {cannot open source database: disk I/O error}} } @@ -170,11 +170,11 @@ do_test backup2-12 { set rc [catch {db restore aux1 bu2.db} res] lappend rc $res } {1 {restore failed: unknown database aux1}} do_test backup2-13 { - file delete -force bu4.db + forcedelete bu4.db set rc [catch {db restore bu4.db} res] lappend rc $res } {1 {cannot open source database: unable to open database file}} # Invalid syntax on the restore method @@ -182,8 +182,8 @@ do_test backup2-14 { set rc [catch {db restore} res] lappend rc $res } {1 {wrong # args: should be "db restore ?DATABASE? FILENAME"}} -file delete -force bu1.db bu2.db bu3.db bu4.db +forcedelete bu1.db bu2.db bu3.db bu4.db finish_test Index: test/backup_ioerr.test ================================================================== --- test/backup_ioerr.test +++ test/backup_ioerr.test @@ -58,11 +58,11 @@ do_test backup_ioerr-1.2 { expr {[file size test.db] > $sqlite_pending_byte} } {1} do_test backup_ioerr-1.3 { db close - file delete -force test.db + forcedelete test.db } {} # Turn off IO error simulation. # proc clear_ioerr_simulation {} { @@ -153,12 +153,12 @@ # Disable IO error simulation. clear_ioerr_simulation catch { ddb close } catch { sdb close } - catch { file delete -force test.db } - catch { file delete -force bak.db } + catch { forcedelete test.db } + catch { forcedelete bak.db } # Open the source and destination databases. sqlite3 sdb test.db sqlite3 ddb bak.db Index: test/capi3.test ================================================================== --- test/capi3.test +++ test/capi3.test @@ -695,11 +695,11 @@ if {![sqlite3 -has-codec]} { # Now test that the library correctly handles bogus entries in the # sqlite_master table (schema corruption). do_test capi3-8.1 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { CREATE TABLE t1(a); } db close @@ -720,11 +720,11 @@ } {1 {malformed database schema (?)}} do_test capi3-8.4 { # Build a 5-field row record. The first field is a string 'table', and # subsequent fields are all NULL. db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { CREATE TABLE t1(a); PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); @@ -737,12 +737,12 @@ SELECT * FROM sqlite_master; } } {1 {malformed database schema (?)}} db close } -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ Index: test/capi3c.test ================================================================== --- test/capi3c.test +++ test/capi3c.test @@ -668,11 +668,11 @@ if {![sqlite3 -has-codec]} { # Now test that the library correctly handles bogus entries in the # sqlite_master table (schema corruption). do_test capi3c-8.1 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { CREATE TABLE t1(a); } db close @@ -693,11 +693,11 @@ } {1 {malformed database schema (?)}} do_test capi3c-8.4 { # Build a 5-field row record. The first field is a string 'table', and # subsequent fields are all NULL. db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { CREATE TABLE t1(a); PRAGMA writable_schema=ON; INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL); @@ -710,12 +710,12 @@ SELECT * FROM sqlite_master; } } {1 {malformed database schema (?)}} db close } -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal # Test the english language string equivalents for sqlite error codes set code2english [list \ SQLITE_OK {not an error} \ Index: test/collate7.test ================================================================== --- test/collate7.test +++ test/collate7.test @@ -42,11 +42,11 @@ db close set ::caseless_del } {2} do_test collate7-2.1 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del} execsql { PRAGMA encoding='utf-16'; CREATE TABLE abc16(a COLLATE CASELESS, b, c); Index: test/corrupt.test ================================================================== --- test/corrupt.test +++ test/corrupt.test @@ -13,11 +13,11 @@ # This file implements tests to make sure SQLite does not crash or # segfault if it sees a corrupt database file. # # $Id: corrupt.test,v 1.12 2009/07/13 09:41:45 danielk1977 Exp $ -catch {file delete -force test.db test.db-journal test.bu} +catch {forcedelete test.db test.db-journal test.bu} set testdir [file dirname $argv0] source $testdir/tester.tcl # Do not use a codec for tests in this file, as the database file is @@ -49,26 +49,14 @@ COMMIT; } } {} integrity_check corrupt-1.2 -# Copy file $from into $to -# -proc copy_file {from to} { - 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 -} - # Setup for the tests. Make a backup copy of the good database in test.bu. # Create a string of garbage data that is 256 bytes long. # -copy_file test.db test.bu +forcecopy test.db test.bu set fsize [file size test.db] set junk "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" while {[string length $junk]<256} {append junk $junk} set junk [string range $junk 0 255] @@ -77,11 +65,11 @@ # the database engine can recover gracefully from the corruption. # for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} { set tn [expr {$i/256}] db close - copy_file test.bu test.db + forcecopy test.bu test.db set fd [open test.db r+] fconfigure $fd -translation binary seek $fd $i puts -nonewline $fd $junk close $fd @@ -130,11 +118,11 @@ # index on t1) in sqlite_master. Then perform a few different queries # and make sure this is detected as corruption. # do_test corrupt-3.1 { db close - copy_file test.bu test.db + forcecopy test.bu test.db sqlite3 db test.db list } {} do_test corrupt-3.2 { set t1_r [execsql {SELECT rootpage FROM sqlite_master WHERE name = 't1i1'}] @@ -179,11 +167,11 @@ } } {1 {database disk image is malformed}} do_test corrupt-4.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA page_size = 1024; CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT); } @@ -211,11 +199,11 @@ catchsql { DELETE FROM t1 WHERE rowid = 3 } } {1 {database disk image is malformed}} do_test corrupt-5.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA page_size = 1024 } set ct "CREATE TABLE t1(c0 " set i 0 @@ -234,11 +222,11 @@ # At one point, the specific corruption caused by this test case was # causing a buffer overwrite. Although a crash was never demonstrated, # running this testcase under valgrind revealed the problem. do_test corrupt-6.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA page_size = 1024; CREATE TABLE t1(x); } @@ -262,11 +250,11 @@ catchsql { INSERT INTO t1 VALUES( randomblob(10) ) } } {1 {database disk image is malformed}} ifcapable oversize_cell_check { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA page_size = 1024; CREATE TABLE t1(x); } @@ -315,11 +303,11 @@ } } {1 {database disk image is malformed}} } db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal do_test corrupt-8.1 { sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA secure_delete = on; @@ -333,11 +321,11 @@ catchsql { INSERT OR REPLACE INTO t1 VALUES(5, randomblob(1900)) } } {1 {database disk image is malformed}} db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal do_test corrupt-8.2 { sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA secure_delete = on; Index: test/corrupt2.test ================================================================== --- test/corrupt2.test +++ test/corrupt2.test @@ -39,13 +39,13 @@ } {} do_test corrupt2-1.2 { # Corrupt the 16 byte magic string at the start of the file - file delete -force corrupt.db - file delete -force corrupt.db-journal - copy_file test.db corrupt.db + forcedelete corrupt.db + forcedelete corrupt.db-journal + forcecopy test.db corrupt.db set f [open corrupt.db RDWR] seek $f 8 start puts $f blah close $f @@ -58,13 +58,13 @@ do_test corrupt2-1.3 { db2 close # Corrupt the page-size (bytes 16 and 17 of page 1). - file delete -force corrupt.db - file delete -force corrupt.db-journal - copy_file test.db corrupt.db + forcedelete corrupt.db + forcedelete corrupt.db-journal + forcecopy test.db corrupt.db set f [open corrupt.db RDWR] fconfigure $f -encoding binary seek $f 16 start puts -nonewline $f "\x00\xFF" close $f @@ -78,13 +78,13 @@ do_test corrupt2-1.4 { db2 close # Corrupt the free-block list on page 1. - file delete -force corrupt.db - file delete -force corrupt.db-journal - copy_file test.db corrupt.db + forcedelete corrupt.db + forcedelete corrupt.db-journal + forcecopy test.db corrupt.db set f [open corrupt.db RDWR] fconfigure $f -encoding binary seek $f 101 start puts -nonewline $f "\xFF\xFF" close $f @@ -98,13 +98,13 @@ do_test corrupt2-1.5 { db2 close # Corrupt the free-block list on page 1. - file delete -force corrupt.db - file delete -force corrupt.db-journal - copy_file test.db corrupt.db + forcedelete corrupt.db + forcedelete corrupt.db-journal + forcecopy test.db corrupt.db set f [open corrupt.db RDWR] fconfigure $f -encoding binary seek $f 101 start puts -nonewline $f "\x00\xC8" seek $f 200 start @@ -121,13 +121,13 @@ db2 close # Corrupt a database by having 2 indices of the same name: do_test corrupt2-2.1 { - file delete -force corrupt.db - file delete -force corrupt.db-journal - copy_file test.db corrupt.db + forcedelete corrupt.db + forcedelete corrupt.db-journal + forcecopy test.db corrupt.db sqlite3 db2 corrupt.db execsql " $::presql CREATE INDEX a1 ON abc(a); @@ -148,12 +148,12 @@ } {1 {malformed database schema (a3) - index a3 already exists}} db2 close do_test corrupt2-3.1 { - file delete -force corrupt.db - file delete -force corrupt.db-journal + forcedelete corrupt.db + forcedelete corrupt.db-journal sqlite3 db2 corrupt.db execsql " $::presql PRAGMA auto_vacuum = 1; @@ -198,12 +198,12 @@ db2 close unset -nocomplain result do_test corrupt2-5.1 { - file delete -force corrupt.db - file delete -force corrupt.db-journal + forcedelete corrupt.db + forcedelete corrupt.db-journal sqlite3 db2 corrupt.db execsql " $::presql PRAGMA auto_vacuum = 0; @@ -255,12 +255,12 @@ set A(-sqlprep) {} set A(-tclprep) {} array set A $args catch {db close} - file delete -force corrupt.db - file delete -force corrupt.db-journal + forcedelete corrupt.db + forcedelete corrupt.db-journal sqlite3 db corrupt.db db eval $::presql eval $A(-tclprep) db eval $A(-sqlprep) Index: test/corrupt9.test ================================================================== --- test/corrupt9.test +++ test/corrupt9.test @@ -84,11 +84,11 @@ # Corrupt the freelist by adding duplicate entries to the freelist. # Make sure the corruption is detected. # db close -file copy -force test.db test.db-template +forcecopy test.db test.db-template corrupt_freelist test.db 1 sqlite3 db test.db do_test corrupt9-2.1 { set x [db eval {PRAGMA integrity_check}] @@ -101,11 +101,11 @@ } } {1 {database disk image is malformed}} db close -file copy -force test.db-template test.db +forcecopy test.db-template test.db corrupt_freelist test.db 2 sqlite3 db test.db do_test corrupt9-3.1 { set x [db eval {PRAGMA integrity_check}] expr {$x!="ok"} @@ -116,11 +116,11 @@ REINDEX; } } {1 {database disk image is malformed}} db close -file copy -force test.db-template test.db +forcecopy test.db-template test.db corrupt_freelist test.db 3 sqlite3 db test.db do_test corrupt9-4.1 { set x [db eval {PRAGMA integrity_check}] expr {$x!="ok"} Index: test/corruptA.test ================================================================== --- test/corruptA.test +++ test/corruptA.test @@ -38,40 +38,40 @@ # Corrupt the file header in various ways and make sure the corruption # is detected when opening the database file. # db close -file copy -force test.db test.db-template +forcecopy test.db test.db-template set unreadable_version 02 ifcapable wal { set unreadable_version 03 } do_test corruptA-2.1 { - file copy -force test.db-template test.db + forcecopy test.db-template test.db hexio_write test.db 19 $unreadable_version ;# the read format number sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is encrypted or is not a database}} do_test corruptA-2.2 { db close - file copy -force test.db-template test.db + forcecopy test.db-template test.db hexio_write test.db 21 41 ;# max embedded payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is encrypted or is not a database}} do_test corruptA-2.3 { db close - file copy -force test.db-template test.db + forcecopy test.db-template test.db hexio_write test.db 22 1f ;# min embedded payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is encrypted or is not a database}} do_test corruptA-2.4 { db close - file copy -force test.db-template test.db + forcecopy test.db-template test.db hexio_write test.db 23 21 ;# min leaf payload fraction sqlite3 db test.db catchsql {SELECT * FROM t1} } {1 {file is encrypted or is not a database}} Index: test/corruptB.test ================================================================== --- test/corruptB.test +++ test/corruptB.test @@ -44,11 +44,11 @@ } expr {[file size test.db] > (1024*9)} } {1} integrity_check corruptB-1.2 -file copy -force test.db bak.db +forcecopy test.db bak.db # Set the right-child of a B-Tree rootpage to refer to the root-page itself. # do_test corruptB-1.3.1 { set ::root [execsql {SELECT rootpage FROM sqlite_master}] @@ -63,11 +63,11 @@ # Set the left-child of a cell in a B-Tree rootpage to refer to the # root-page itself. # do_test corruptB-1.4.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db set cell_offset [hexio_get_int [hexio_read test.db [expr $offset+12] 2]] hexio_write test.db [expr $offset+$cell_offset] [hexio_render_int32 $::root] } {4} do_test corruptB-1.4.2 { sqlite3 db test.db @@ -76,11 +76,11 @@ # Now grow the table B-Tree so that it is more than 2 levels high. # do_test corruptB-1.5.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db sqlite3 db test.db execsql { INSERT INTO t1 SELECT randomblob(200) FROM t1; INSERT INTO t1 SELECT randomblob(200) FROM t1; INSERT INTO t1 SELECT randomblob(200) FROM t1; @@ -89,11 +89,11 @@ INSERT INTO t1 SELECT randomblob(200) FROM t1; INSERT INTO t1 SELECT randomblob(200) FROM t1; } } {} -file copy -force test.db bak.db +forcecopy test.db bak.db # Set the right-child pointer of the right-child of the root page to point # back to the root page. # do_test corruptB-1.6.1 { @@ -110,11 +110,11 @@ # Set the left-child pointer of a cell of the right-child of the root page to # point back to the root page. # do_test corruptB-1.7.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]] hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root] } {4} do_test corruptB-1.7.2 { sqlite3 db test.db @@ -138,11 +138,11 @@ # Set the left-child pointer of a cell of the right-child of the root page to # point back to the root page. # do_test corruptB-1.9.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db set cell_offset [hexio_get_int [hexio_read test.db [expr $c_offset+12] 2]] hexio_write test.db [expr $c_offset+$cell_offset] [hexio_render_int32 $::root] } {4} do_test corruptB-1.9.2 { sqlite3 db test.db @@ -151,11 +151,11 @@ #--------------------------------------------------------------------------- do_test corruptB-2.1.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db hexio_write test.db [expr $offset+8] [hexio_render_int32 0x6FFFFFFF] } {4} do_test corruptB-2.1.2 { sqlite3 db test.db catchsql { SELECT * FROM t1 } @@ -165,11 +165,11 @@ # Corrupt the header-size field of a database record. # do_test corruptB-3.1.1 { db close - file copy -force bak.db test.db + forcecopy bak.db test.db sqlite3 db test.db set v [string repeat abcdefghij 200] execsql { CREATE TABLE t2(a); INSERT INTO t2 VALUES($v); Index: test/corruptC.test ================================================================== --- test/corruptC.test +++ test/corruptC.test @@ -15,11 +15,11 @@ # data base file, then tests that single byte corruptions in # increasingly larger quantities are handled gracefully. # # $Id: corruptC.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $ -catch {file delete -force test.db test.db-journal test.bu} +catch {forcedelete test.db test.db-journal test.bu} set testdir [file dirname $argv0] source $testdir/tester.tcl # Do not use a codec for tests in this file, as the database file is @@ -56,20 +56,14 @@ # proc random {range} { return [expr {round(rand()*$range)}] } -# Copy file $from into $to -# -proc copy_file {from to} { - file copy -force $from $to -} - # Setup for the tests. Make a backup copy of the good database in test.bu. # db close -copy_file test.db test.bu +forcecopy test.db test.bu sqlite3 db test.db set fsize [file size test.db] # Set a quasi-random random seed. if {[info exists ::G(issoak)]} { @@ -90,11 +84,11 @@ # # test that a corrupt content offset size is handled (seed 5577) do_test corruptC-2.1 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 2053 [format %02x 0x04] sqlite3 db test.db @@ -102,11 +96,11 @@ } {1 {database disk image is malformed}} # test that a corrupt content offset size is handled (seed 5649) do_test corruptC-2.2 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 27 [format %02x 0x08] hexio_write test.db 233 [format %02x 0x6a] hexio_write test.db 328 [format %02x 0x67] @@ -123,11 +117,11 @@ } {1 {database disk image is malformed}} # test that a corrupt free cell size is handled (seed 13329) do_test corruptC-2.3 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 1094 [format %02x 0x76] sqlite3 db test.db @@ -135,11 +129,11 @@ } {1 {database disk image is malformed}} # test that a corrupt free cell size is handled (seed 169571) do_test corruptC-2.4 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 3119 [format %02x 0xdf] sqlite3 db test.db @@ -147,11 +141,11 @@ } {1 {database disk image is malformed}} # test that a corrupt free cell size is handled (seed 169571) do_test corruptC-2.5 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 3119 [format %02x 0xdf] hexio_write test.db 4073 [format %02x 0xbf] @@ -167,11 +161,11 @@ # Fragmented space is 249 byte reported as 21 on page 4}}} # test that a corrupt free cell size is handled (seed 169595) do_test corruptC-2.6 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 619 [format %02x 0xe2] hexio_write test.db 3150 [format %02x 0xa8] @@ -180,11 +174,11 @@ } {1 {database disk image is malformed}} # corruption (seed 178692) do_test corruptC-2.7 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 3074 [format %02x 0xa0] sqlite3 db test.db @@ -192,11 +186,11 @@ } {1 {database disk image is malformed}} # corruption (seed 179069) do_test corruptC-2.8 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 1393 [format %02x 0x7d] hexio_write test.db 84 [format %02x 0x19] hexio_write test.db 3287 [format %02x 0x3b] @@ -208,11 +202,11 @@ } {1 {database disk image is malformed}} # corruption (seed 170434) do_test corruptC-2.9 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 2095 [format %02x 0xd6] sqlite3 db test.db @@ -220,11 +214,11 @@ } {1 {database disk image is malformed}} # corruption (seed 186504) do_test corruptC-2.10 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 3130 [format %02x 0x02] sqlite3 db test.db @@ -232,11 +226,11 @@ } {1 {database disk image is malformed}} # corruption (seed 1589) do_test corruptC-2.11 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 55 [format %02x 0xa7] sqlite3 db test.db @@ -244,11 +238,11 @@ } {1 {database disk image is malformed}} # corruption (seed 14166) do_test corruptC-2.12 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 974 [format %02x 0x2e] sqlite3 db test.db @@ -256,11 +250,11 @@ } {1 {malformed database schema (t1i1) - corrupt database}} # corruption (seed 218803) do_test corruptC-2.13 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 102 [format %02x 0x12] sqlite3 db test.db @@ -267,11 +261,11 @@ catchsql {BEGIN; CREATE TABLE t3 AS SELECT x,3 as y FROM t2 WHERE rowid%5!=0; ROLLBACK;} } {1 {database disk image is malformed}} do_test corruptC-2.14 { db close - copy_file test.bu test.db + forcecopy test.bu test.db sqlite3 db test.db set blob [string repeat abcdefghij 10000] execsql { INSERT INTO t1 VALUES (1, $blob) } @@ -284,11 +278,11 @@ # At one point this particular corrupt database was causing a buffer # overread. Which caused a crash in a run of all.test once. # do_test corruptC-2.15 { db close - copy_file test.bu test.db + forcecopy test.bu test.db hexio_write test.db 986 b9 sqlite3 db test.db catchsql {SELECT count(*) FROM sqlite_master;} } {1 {malformed database schema (t1i1) - no such table: main.t1}} @@ -298,11 +292,11 @@ # each byte at least once. for {set tn 0} {$tn<$fsize} {incr tn 1} { # setup for test db close - copy_file test.bu test.db + forcecopy test.bu test.db sqlite3 db test.db # Seek to a random location in the file, and write a random single byte # value. Then do various operations on the file to make sure that # the database engine can handle the corruption gracefully. Index: test/corruptD.test ================================================================== --- test/corruptD.test +++ test/corruptD.test @@ -83,11 +83,11 @@ DELETE FROM t1 WHERE a = 10; DELETE FROM t1 WHERE a = 20; DELETE FROM t1 WHERE a = 30; DELETE FROM t1 WHERE a = 40; } - copy_file test.db test.bu + forcecopy test.db test.bu } {} proc incr_change_counter {} { hexio_write test.db 24 [ hexio_render_int32 [expr [hexio_get_int [hexio_read test.db 24 4]] + 1] @@ -94,11 +94,11 @@ ] } proc restore_file {} { db close - copy_file test.bu test.db + forcecopy test.bu test.db sqlite3 db test.db } #------------------------------------------------------------------------- # The following tests, corruptD-1.1.*, focus on the page header field Index: test/corruptE.test ================================================================== --- test/corruptE.test +++ test/corruptE.test @@ -14,11 +14,11 @@ # segfault if it sees a corrupt database file. It specifcally # focuses on rowid order corruption. # # $Id: corruptE.test,v 1.14 2009/07/11 06:55:34 danielk1977 Exp $ -catch {file delete -force test.db test.db-journal test.bu} +catch {forcedelete test.db test.db-journal test.bu} set testdir [file dirname $argv0] source $testdir/tester.tcl # Do not use a codec for tests in this file, as the database file is @@ -58,27 +58,21 @@ ifcapable {integrityck} { integrity_check corruptE-1.2 } -# Copy file $from into $to -# -proc copy_file {from to} { - file copy -force $from $to -} - # Setup for the tests. Make a backup copy of the good database in test.bu. # db close -copy_file test.db test.bu +forcecopy test.db test.bu sqlite3 db test.db set fsize [file size test.db] do_test corruptE-2.1 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 2041 [format %02x 0x2e] sqlite3 db test.db @@ -90,11 +84,11 @@ [regexp {out of order.*max larger than parent max} $ans] } {1 1} do_test corruptE-2.2 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 2047 [format %02x 0x84] sqlite3 db test.db @@ -106,11 +100,11 @@ [regexp {out of order.*min less than parent min} $ans] } {1 1} do_test corruptE-2.3 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 7420 [format %02x 0xa8] hexio_write test.db 10459 [format %02x 0x8d] @@ -122,11 +116,11 @@ list [regexp {out of order.*max larger than parent min} $ans] } {1} do_test corruptE-2.4 { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db 10233 [format %02x 0xd0] sqlite3 db test.db @@ -163,11 +157,11 @@ set tc 1 foreach test $tests { do_test corruptE-3.$tc { db close - copy_file test.bu test.db + forcecopy test.bu test.db # insert corrupt byte(s) hexio_write test.db [lindex $test 0] [format %02x [lindex $test 1]] sqlite3 db test.db Index: test/crash.test ================================================================== --- test/crash.test +++ test/crash.test @@ -213,12 +213,12 @@ # crash-4.3.*: Test recovery when crash occurs during sync() of the master # journal file. # ifcapable attach { do_test crash-4.0 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' AS aux; PRAGMA aux.default_cache_size = 10; CREATE TABLE aux.abc2 AS SELECT 2*a as a, 2*b as b, 2*c as c FROM abc; } @@ -316,11 +316,11 @@ # sqlite3pager_movepage() API used by auto-vacuum databases. # database when a crash occurs during a multi-file transaction. See comments # in test crash-5.3 for details. # db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test crash-5.1 { execsql { CREATE TABLE abc(a, b, c); -- Root page 3 INSERT INTO abc VALUES(randstr(1500,1500), 0, 0); -- Overflow page 4 Index: test/crash3.test ================================================================== --- test/crash3.test +++ test/crash3.test @@ -71,11 +71,11 @@ {CREATE TABLE def(d, e, f)} {n/a} \ ] { for {set ii 0} {$ii < 10} {incr ii} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db do_test crash3-1.$tn.1 { execsql { PRAGMA page_size = 1024; BEGIN; @@ -104,11 +104,11 @@ } # This block tests both the IOCAP_SEQUENTIAL and IOCAP_SAFE_APPEND flags. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test crash3-2.0 { execsql { BEGIN; CREATE TABLE abc(a PRIMARY KEY, b, c); @@ -175,11 +175,11 @@ # for some other reason (i.e. nTrunk) were not being written to # disk. # for {set ii 0} {$ii < 10} {incr ii} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal crashsql -file test.db -char {sequential atomic} { CREATE TABLE abc(a, b, c); } sqlite3 db test.db do_test crash3-3.$ii { Index: test/crash4.test ================================================================== --- test/crash4.test +++ test/crash4.test @@ -61,11 +61,11 @@ # over and over. Stop testing when the entire sequence of SQL # statements runs to completing without hitting the crash. # for {set cnt 1; set fin 0} {!$fin} {incr cnt} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal do_test crash4-1.$cnt.1 { set seed [expr {int(abs(rand()*10000))}] set delay [expr {int($cnt/50)+1}] set file [expr {($cnt&1)?"test.db":"test.db-journal"}] set c [crashsql -delay $delay -file $file -seed $seed -tclbody { Index: test/crash5.test ================================================================== --- test/crash5.test +++ test/crash5.test @@ -32,11 +32,11 @@ for {set jj 50} {$jj < 100} {incr jj} { # Set up the database so that it is an auto-vacuum database # containing a single table (root page 3) with a single row. # The row has an overflow page (page 4). - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db set c [string repeat 3 1500] db eval { pragma auto_vacuum = 1; CREATE TABLE t1(a, b, c); Index: test/crash6.test ================================================================== --- test/crash6.test +++ test/crash6.test @@ -21,11 +21,11 @@ return } for {set ii 0} {$ii < 10} {incr ii} { catch {db close} - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal crashsql -delay 2 -file test.db { PRAGMA auto_vacuum=OFF; PRAGMA page_size=4096; BEGIN; CREATE TABLE abc AS SELECT 1 AS a, 2 AS b, 3 AS c; @@ -38,11 +38,11 @@ integrity_check crash6-1.$ii } for {set ii 0} {$ii < 10} {incr ii} { catch {db close} - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA auto_vacuum=OFF; PRAGMA page_size=2048; BEGIN; @@ -64,11 +64,11 @@ # Test case for crashing during database sync with page-size values # from 1024 to 8192. # for {set ii 0} {$ii < 30} {incr ii} { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db set pagesize [expr 1024 << ($ii % 4)] if {$pagesize>$::SQLITE_MAX_PAGE_SIZE} { set pagesize $::SQLITE_MAX_PAGE_SIZE Index: test/crash7.test ================================================================== --- test/crash7.test +++ test/crash7.test @@ -24,11 +24,11 @@ } foreach f [list test.db test.db-journal] { for {set ii 1} {$ii < 64} {incr ii} { db close - file delete test.db + delete_file test.db sqlite3 db test.db set from_size [expr 1024 << ($ii&3)] set to_size [expr 1024 << (($ii>>2)&3)] Index: test/crash8.test ================================================================== --- test/crash8.test +++ test/crash8.test @@ -241,11 +241,11 @@ # journal files, and that the results behave correctly if a hot-journal # rollback occurs. # ifcapable pragma { reset_db - file delete -force test2.db + forcedelete test2.db do_test crash8-4.1 { execsql { PRAGMA journal_mode = persist; CREATE TABLE ab(a, b); @@ -334,18 +334,18 @@ do_test crash8-4.9 { execsql { SELECT b FROM aux.ab WHERE a = 0 } } {def} do_test crash8-4.10 { - file delete $zMasterJournal + delete_file $zMasterJournal execsql { SELECT b FROM main.ab WHERE a = 0 } } {jkl} } for {set i 1} {$i < 10} {incr i} { catch { db close } - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db do_test crash8-5.$i.1 { execsql { CREATE TABLE t1(x PRIMARY KEY); INSERT INTO t1 VALUES(randomblob(900)); @@ -365,11 +365,11 @@ } execsql { PRAGMA integrity_check } } {ok} catch { db close } - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db do_test crash8-5.$i.2 { execsql { PRAGMA cache_size = 10; CREATE TABLE t1(x PRIMARY KEY); @@ -381,13 +381,13 @@ INSERT INTO t1 SELECT randomblob(900) FROM t1; INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 64 rows */ BEGIN; UPDATE t1 SET x = randomblob(900); } - file delete -force testX.db testX.db-journal testX.db-wal - copy_file test.db testX.db - copy_file test.db-journal testX.db-journal + forcedelete testX.db testX.db-journal testX.db-wal + forcecopy test.db testX.db + forcecopy test.db-journal testX.db-journal db close crashsql -file test.db -delay [expr ($::i%2) + 1] { SELECT * FROM sqlite_master; INSERT INTO t1 VALUES(randomblob(900)); Index: test/createtab.test ================================================================== --- test/createtab.test +++ test/createtab.test @@ -25,11 +25,11 @@ # Run these tests for all possible values of autovacuum. # for {set av 0} {$av<=$upperBound} {incr av} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db # Create a table that spans multiple pages. It is important # that part of the database be in pages beyond the root page. # Index: test/dbstatus.test ================================================================== --- test/dbstatus.test +++ test/dbstatus.test @@ -153,11 +153,11 @@ } { set tn "$::lookaside_buffer_size-$tn" # Step 1. db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500 db cache size 0 catch { register_echo_module db } @@ -285,11 +285,11 @@ } { set tn "$::lookaside_buffer_size-$tn" # Step 1. db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db sqlite3_db_config_lookaside db 0 $::lookaside_buffer_size 500 db cache size 1000 catch { register_echo_module db } Index: test/delete.test ================================================================== --- test/delete.test +++ test/delete.test @@ -273,11 +273,11 @@ INSERT INTO t3 VALUES(123); SELECT * FROM t3; } } {123} db close -catch {file delete -force test.db-journal} +catch {forcedelete test.db-journal} catch {file attributes test.db -permissions 0444} catch {file attributes test.db -readonly 1} sqlite3 db test.db set ::DB [sqlite3_connection_pointer db] do_test delete-8.1 { @@ -310,16 +310,16 @@ execsql {SELECT * FROM t3} } {123} integrity_check delete-8.7 # Need to do the following for tcl 8.5 on mac. On that configuration, the -# -readonly flag is taken so seriously that a subsequent [file delete -force] +# -readonly flag is taken so seriously that a subsequent [forcedelete] # (required before the next test file can be executed) will fail. # catch {file attributes test.db -readonly 0} db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal # The following tests verify that SQLite correctly handles the case # where an index B-Tree is being scanned, the rowid column being read # from each index entry and another statement deletes some rows from # the index B-Tree. At one point this (obscure) scenario was causing Index: test/descidx1.test ================================================================== --- test/descidx1.test +++ test/descidx1.test @@ -295,18 +295,18 @@ # the get_file_format command. # ifcapable legacyformat { do_test descidx1-6.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql {PRAGMA legacy_file_format} } {1} } else { do_test descidx1-6.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql {PRAGMA legacy_file_format} } {0} } do_test descidx1-6.2 { @@ -326,11 +326,11 @@ get_file_format } {1} } do_test descidx1-6.4 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql {PRAGMA legacy_file_format=NO} execsql {PRAGMA legacy_file_format} } {0} do_test descidx1-6.5 { Index: test/diskfull.test ================================================================== --- test/diskfull.test +++ test/diskfull.test @@ -80,12 +80,12 @@ } do_diskfull_test diskfull-2 VACUUM # db close -# file delete -force test.db -# file delete -force test.db-journal +# forcedelete test.db +# forcedelete test.db-journal # sqlite3 db test.db # # do_test diskfull-3.1 { # execsql { # PRAGMA default_cache_size = 10; Index: test/e_expr.test ================================================================== --- test/e_expr.test +++ test/e_expr.test @@ -655,11 +655,11 @@ do_execsql_test e_expr-12.2.8 {SELECT CURRENT_TIMESTAMP} {{1970-01-01 00:00:01}} set sqlite_current_time 0 # EVIDENCE-OF: R-57598-59332 -- syntax diagram expr # -file delete -force test.db2 +forcedelete test.db2 execsql { ATTACH 'test.db2' AS dbname; CREATE TABLE dbname.tblname(cname); } @@ -1673,11 +1673,11 @@ #------------------------------------------------------------------------- # Test statements related to the EXISTS and NOT EXISTS operators. # catch { db close } -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_execsql_test e_expr-34.1 { CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); @@ -1754,11 +1754,11 @@ #------------------------------------------------------------------------- # Test statements related to scalar sub-queries. # catch { db close } -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test e_expr-35.0 { execsql { CREATE TABLE t2(a, b); INSERT INTO t2 VALUES('one', 'two'); Index: test/e_fts3.test ================================================================== --- test/e_fts3.test +++ test/e_fts3.test @@ -58,11 +58,11 @@ # Reset the database and database connection. If this iteration of the # [foreach] loop is testing with OOM errors, disable the lookaside buffer. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 } db eval "PRAGMA encoding = '$enc'" proc mit {blob} { @@ -635,11 +635,11 @@ # Test that FTS3 tables can be renamed using the ALTER RENAME command. # OOM errors are tested during ALTER RENAME commands also. # foreach DO_MALLOC_TEST {0 1 2} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db if {$DO_MALLOC_TEST} { sqlite3_db_config_lookaside db 0 0 0 } ddl_test 9.1.1 { CREATE VIRTUAL TABLE t10 USING fts3(x) } write_test 9.1.2 t10_content { INSERT INTO t10 VALUES('fts3 tables') } Index: test/enc2.test ================================================================== --- test/enc2.test +++ test/enc2.test @@ -140,11 +140,11 @@ set encodings [list UTF-8 UTF-16le UTF-16be] set sqlite_os_trace 0 set i 1 foreach enc $encodings { - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval "PRAGMA encoding = \"$enc\"" execsql $dbcontents do_test enc2-$i.0.1 { db eval {PRAGMA encoding} @@ -170,17 +170,17 @@ # Test that it is an error to try to attach a database with a different # encoding to the main database. ifcapable attach { do_test enc2-4.1 { - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval "PRAGMA encoding = 'UTF-8'" db eval "CREATE TABLE abc(a, b, c);" } {} do_test enc2-4.2 { - file delete -force test2.db + forcedelete test2.db sqlite3 db2 test2.db db2 eval "PRAGMA encoding = 'UTF-16'" db2 eval "CREATE TABLE abc(a, b, c);" } {} do_test enc2-4.3 { @@ -204,11 +204,11 @@ set res [expr $l - $r] # puts "enc=$enc lhs=$lhs/$l rhs=$rhs/$r res=$res" return $res } -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] do_test enc2-5.0 { execsql { CREATE TABLE t5(a); INSERT INTO t5 VALUES('one'); @@ -233,11 +233,11 @@ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-16BE} db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16LE'} do_test enc2-5.4 { execsql { CREATE TABLE t5(a); @@ -263,11 +263,11 @@ set res [execsql {SELECT * FROM t5 ORDER BY 1 COLLATE test_collate}] lappend res $::test_collate_enc } {one two three four five UTF-8} db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16BE'} do_test enc2-5.8 { execsql { CREATE TABLE t5(a); @@ -309,11 +309,11 @@ do_test enc2-5.14 { set ::sqlite_last_needed_collation } test_collate db close -file delete -force test.db +forcedelete test.db do_test enc2-5.15 { sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] add_test_collate_needed $::DB set ::sqlite_last_needed_collation @@ -331,11 +331,11 @@ proc test_function {enc arg} { return "$enc $arg" } db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-8'} do_test enc2-6.0 { execsql { CREATE TABLE t5(a); @@ -364,11 +364,11 @@ SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16LE'} do_test enc2-6.3 { execsql { CREATE TABLE t5(a); @@ -397,11 +397,11 @@ SELECT test_function('sqlite') } } {{UTF-16BE sqlite}} db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db; set DB [sqlite3_connection_pointer db] execsql {pragma encoding = 'UTF-16BE'} do_test enc2-6.7 { execsql { CREATE TABLE t5(a); @@ -431,11 +431,11 @@ } } {{UTF-16BE sqlite}} db close -file delete -force test.db +forcedelete test.db # The following tests - enc2-7.* - function as follows: # # 1: Open an empty database file assuming UTF-16 encoding. # 2: Open the same database with a different handle assuming UTF-8. Create @@ -491,11 +491,11 @@ } {0} } # Test that the encoding of an empty database may still be set after the # (empty) schema has been initialized. -file delete -force test.db +forcedelete test.db do_test enc2-9.1 { sqlite3 db test.db execsql { PRAGMA encoding = 'UTF-8'; PRAGMA encoding; @@ -535,11 +535,11 @@ # Ticket #1987. # Disallow encoding changes once the encoding has been set. # do_test enc2-10.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db eval { PRAGMA encoding=UTF16; CREATE TABLE t1(a); PRAGMA encoding=UTF8; Index: test/enc3.test ================================================================== --- test/enc3.test +++ test/enc3.test @@ -79,11 +79,11 @@ # Try to attach a database with a different encoding. # ifcapable {utf16 && shared_cache} { db close - file delete -force test8.db test8.db-journal + forcedelete test8.db test8.db-journal set ::enable_shared_cache [sqlite3_enable_shared_cache 1] sqlite3 dbaux test8.db sqlite3 db test.db db eval {SELECT 1 FROM sqlite_master LIMIT 1} do_test enc3-3.1 { @@ -98,10 +98,10 @@ ATTACH 'test.db' AS utf16; SELECT 1 FROM utf16.sqlite_master LIMIT 1; } dbaux } {1 {attached databases must use the same text encoding as main database}} dbaux close - file delete -force test8.db test8.db-journal + forcedelete test8.db test8.db-journal sqlite3_enable_shared_cache $::enable_shared_cache } finish_test Index: test/enc4.test ================================================================== --- test/enc4.test +++ test/enc4.test @@ -41,11 +41,11 @@ ] set i 1 foreach enc $encodings { - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval "PRAGMA encoding = \"$enc\"" do_test enc4-$i.1 { db eval {PRAGMA encoding} @@ -91,11 +91,11 @@ db close incr i } -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test enc4-4.1 { db eval "select 1+1." } {2.0} Index: test/exclusive.test ================================================================== --- test/exclusive.test +++ test/exclusive.test @@ -20,16 +20,16 @@ ifcapable {!pager_pragmas} { finish_test return } -file delete -force test2.db-journal -file delete -force test2.db -file delete -force test3.db-journal -file delete -force test3.db -file delete -force test4.db-journal -file delete -force test4.db +forcedelete test2.db-journal +forcedelete test2.db +forcedelete test3.db-journal +forcedelete test3.db +forcedelete test4.db-journal +forcedelete test4.db #---------------------------------------------------------------------- # Test cases exclusive-1.X test the PRAGMA logic. # do_test exclusive-1.0 { @@ -479,12 +479,12 @@ INSERT INTO t4 VALUES('Douglas-Home', 1963); INSERT INTO t4 VALUES('Wilson', 1964); } do_test exclusive-6.2 { forcedelete test2.db test2.db-journal - file copy test.db test2.db - file copy test.db-journal test2.db-journal + copy_file test.db test2.db + copy_file test.db-journal test2.db-journal sqlite3 db test2.db } {} do_execsql_test exclusive-6.3 { PRAGMA locking_mode = EXCLUSIVE; Index: test/exclusive2.test ================================================================== --- test/exclusive2.test +++ test/exclusive2.test @@ -257,12 +257,12 @@ # per write-transaction. # db close catch {close $::fd} -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal do_test exclusive2-3.0 { sqlite3 db test.db execsql { BEGIN; Index: test/fallocate.test ================================================================== --- test/fallocate.test +++ test/fallocate.test @@ -77,11 +77,11 @@ }] ifcapable !wal { set skipwaltests 1 } if {!$skipwaltests} { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db file_control_chunksize_test db main [expr 32*1024] do_test fallocate-2.1 { execsql { Index: test/filectrl.test ================================================================== --- test/filectrl.test +++ test/filectrl.test @@ -35,7 +35,7 @@ db close sqlite3 db test_control_lockproxy.db file_control_lockproxy_test db [pwd] } {} db close -file delete -force .test_control_lockproxy.db-conch test.proxy +forcedelete .test_control_lockproxy.db-conch test.proxy finish_test Index: test/filefmt.test ================================================================== --- test/filefmt.test +++ test/filefmt.test @@ -21,11 +21,11 @@ # manipulated directly using tcl scripts (using the [hexio_write] command). # do_not_use_codec db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal # Database begins with valid 16-byte header string. # do_test filefmt-1.1 { sqlite3 db test.db @@ -61,11 +61,11 @@ foreach pagesize {512 1024 2048 4096 8192 16384 32768} { if {[info exists SQLITE_MAX_PAGE_SIZE] && $pagesize>$SQLITE_MAX_PAGE_SIZE} continue do_test filefmt-1.5.$pagesize.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval "PRAGMA auto_vacuum=OFF" db eval "PRAGMA page_size=$pagesize" db eval {CREATE TABLE t1(x)} file size test.db @@ -103,11 +103,11 @@ # must be at least 480 bytes # ifcapable pager_pragmas { do_test filefmt-1.8 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval {PRAGMA page_size=512; CREATE TABLE t1(x)} db close hexio_write test.db 20 21 sqlite3 db test.db @@ -123,11 +123,11 @@ # by 3.6.23.1 and earlier. The difference difference is that 3.7.0 stores # the size of the database in the database file header, whereas 3.6.23.1 # always derives this from the size of the file. # db close -file delete -force test.db +forcedelete test.db set a_string_counter 1 proc a_string {n} { incr ::a_string_counter string range [string repeat "${::a_string_counter}." $n] 1 $n @@ -155,11 +155,11 @@ do_execsql_test filefmt-2.1.4 { INSERT INTO t2 VALUES(2) } {} integrity_check filefmt-2.1.5 do_test filefmt-2.1.6 { hexio_read test.db 28 4 } {00000010} db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db db func a_string a_string do_execsql_test filefmt-2.2.1 { PRAGMA page_size = 1024; Index: test/fts1j.test ================================================================== --- test/fts1j.test +++ test/fts1j.test @@ -17,12 +17,12 @@ finish_test return } # Clean up anything left over from a previous pass. -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db2 test2.db db eval { CREATE VIRTUAL TABLE t3 USING fts1(content); INSERT INTO t3 (rowid, content) VALUES(1, "hello world"); @@ -82,8 +82,8 @@ } db2 } {2} catch {db eval {DETACH DATABASE two}} catch {db2 close} -file delete -force test2.db +forcedelete test2.db finish_test Index: test/fts1o.test ================================================================== --- test/fts1o.test +++ test/fts1o.test @@ -93,11 +93,11 @@ #--------------------------------------------------------------------- # Test that it is possible to rename an fts1 table in an attached # database. # -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal do_test fts1o-4.1 { execsql { DROP TABLE t1_term; ALTER TABLE fts_t1 RENAME to t1; Index: test/fts2j.test ================================================================== --- test/fts2j.test +++ test/fts2j.test @@ -17,12 +17,12 @@ finish_test return } # Clean up anything left over from a previous pass. -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db2 test2.db db eval { CREATE VIRTUAL TABLE t3 USING fts2(content); INSERT INTO t3 (rowid, content) VALUES(1, "hello world"); @@ -82,8 +82,8 @@ } db2 } {2} catch {db eval {DETACH DATABASE two}} catch {db2 close} -file delete -force test2.db +forcedelete test2.db finish_test Index: test/fts2o.test ================================================================== --- test/fts2o.test +++ test/fts2o.test @@ -107,11 +107,11 @@ #------------------------------------------------------------------- # Close, delete and reopen the database. The following test should # be run on an initially empty db. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test fts2o-3.1 { execsql { CREATE VIRTUAL TABLE t1 USING fts2(a, b, c); @@ -132,11 +132,11 @@ #--------------------------------------------------------------------- # Test that it is possible to rename an fts2 table in an attached # database. # -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal do_test fts2o-3.1 { execsql { ATTACH 'test2.db' AS aux; CREATE VIRTUAL TABLE aux.t1 USING fts2(a, b, c); Index: test/fts3aj.test ================================================================== --- test/fts3aj.test +++ test/fts3aj.test @@ -17,12 +17,12 @@ finish_test return } # Clean up anything left over from a previous pass. -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db2 test2.db db eval { CREATE VIRTUAL TABLE t3 USING fts3(content); INSERT INTO t3 (rowid, content) VALUES(1, "hello world"); @@ -82,8 +82,8 @@ } db2 } {2} catch {db eval {DETACH DATABASE two}} catch {db2 close} -file delete -force test2.db +forcedelete test2.db finish_test Index: test/fts3ao.test ================================================================== --- test/fts3ao.test +++ test/fts3ao.test @@ -109,11 +109,11 @@ #------------------------------------------------------------------- # Close, delete and reopen the database. The following test should # be run on an initially empty db. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test fts3ao-3.1 { execsql { CREATE VIRTUAL TABLE t1 USING fts3(a, b, c); @@ -134,11 +134,11 @@ #--------------------------------------------------------------------- # Test that it is possible to rename an fts3 table in an attached # database. # -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal do_test fts3ao-3.1 { execsql { ATTACH 'test2.db' AS aux; CREATE VIRTUAL TABLE aux.t1 USING fts3(a, b, c); Index: test/fts3snippet.test ================================================================== --- test/fts3snippet.test +++ test/fts3snippet.test @@ -129,11 +129,11 @@ 1 utf8 1 utf16 } { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db sqlite3_db_config_lookaside db 0 0 0 db eval "PRAGMA encoding = \"$enc\"" # Set variable $T to the test name prefix for this iteration of the loop. Index: test/fts4aa.test ================================================================== --- test/fts4aa.test +++ test/fts4aa.test @@ -1684,11 +1684,11 @@ # Should get the same search results when the page size is very large # do_test fts4aa-3.0 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval { PRAGMA page_size=65536; CREATE VIRTUAL TABLE t1 USING fts4(words, tokenize porter); } Index: test/fuzz_malloc.test ================================================================== --- test/fuzz_malloc.test +++ test/fuzz_malloc.test @@ -45,11 +45,11 @@ set ::fuzzyopts(-sqlprep) {} array set ::fuzzyopts $args sqlite3_memdebug_fail -1 db close - file delete test.db test.db-journal + delete_file test.db test.db-journal sqlite3 db test.db set ::prep $::fuzzyopts(-sqlprep) execsql $::prep set jj 0 for {set ii 0} {$ii < $::fuzzyopts(-repeats)} {incr ii} { Index: test/hook.test ================================================================== --- test/hook.test +++ test/hook.test @@ -93,11 +93,11 @@ } {} # Ticket #3564. # do_test hook-3.10 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal sqlite3 db2 test2.db proc commit_hook {} { set y [db2 one {SELECT y FROM t3 WHERE y>10}] return [expr {$y>10}] } @@ -215,11 +215,11 @@ # Update-hook + ATTACH set ::update_hook {} ifcapable attach { do_test hook-4.2.3 { - file delete -force test2.db + forcedelete test2.db execsql { ATTACH 'test2.db' AS aux; CREATE TABLE aux.t3(a INTEGER PRIMARY KEY, b); INSERT INTO aux.t3 SELECT * FROM t1; UPDATE t3 SET b = 'two or so' WHERE a = 2; Index: test/incrblob.test ================================================================== --- test/incrblob.test +++ test/incrblob.test @@ -118,11 +118,11 @@ break } } db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql "PRAGMA auto_vacuum = $AutoVacuumMode" do_test incrblob-2.$AutoVacuumMode.1 { @@ -377,11 +377,11 @@ # # Test that opening a blob in an attached database works. # ifcapable attach { do_test incrblob-5.1 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal set ::size [expr [file size [info script]]] execsql { ATTACH 'test2.db' AS aux; CREATE TABLE aux.files(name, text); INSERT INTO aux.files VALUES('this one', zeroblob($::size)); @@ -582,11 +582,11 @@ fconfigure $fd -translation binary set ::data [read $fd 14000] close $fd db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test incrblob-7.2.1 { execsql { PRAGMA auto_vacuum = "incremental"; Index: test/incrvacuum.test ================================================================== --- test/incrvacuum.test +++ test/incrvacuum.test @@ -329,11 +329,11 @@ } set ::str1 [string repeat abcdefghij 130] set ::str2 [string repeat 1234567890 105] -file delete -force test1.db test1.db-journal test2.db test2.db-journal +forcedelete test1.db test1.db-journal test2.db test2.db-journal sqlite3 db1 test1.db sqlite3 db2 test2.db execsql { PRAGMA auto_vacuum = 'none' } db1 execsql { PRAGMA auto_vacuum = 'incremental' } db2 @@ -473,11 +473,11 @@ #--------------------------------------------------------------------- # At one point this test case was causing an assert() to fail. # do_test incrvacuum-9.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA auto_vacuum = 'incremental'; CREATE TABLE t1(a, b, c); @@ -591,11 +591,11 @@ # Test that if we set the auto_vacuum mode to 'incremental', then # create a database, thereafter that database defaults to incremental # vacuum mode. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db ifcapable default_autovacuum { do_test incrvacuum-11.1-av-dflt-on { execsql { @@ -649,11 +649,11 @@ #---------------------------------------------------------------------- # Special case: What happens if the database is locked when a "PRAGMA # auto_vacuum = XXX" statement is executed. # db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test incrvacuum-12.1 { execsql { PRAGMA auto_vacuum = 1; @@ -690,11 +690,11 @@ # statement when the database is empty, but doesn't execute it until # after some other process has created the database. # db2 close db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db ; set ::DB [sqlite3_connection_pointer db] sqlite3 db2 test.db do_test incrvacuum-13.1 { # File size is sometimes 1 instead of 0 due to the hack we put in @@ -741,11 +741,11 @@ } do_test incrvacuum-15.1 { db close db2 close - file delete -force test.db + forcedelete test.db sqlite3 db test.db set str [string repeat "abcdefghij" 500] execsql { Index: test/incrvacuum2.test ================================================================== --- test/incrvacuum2.test +++ test/incrvacuum2.test @@ -68,11 +68,11 @@ # Make sure incremental vacuum works on attached databases. # ifcapable attach { do_test incrvacuum2-2.1 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal execsql { ATTACH DATABASE 'test2.db' AS aux; PRAGMA aux.auto_vacuum=incremental; CREATE TABLE aux.t2(x); INSERT INTO t2 VALUES(zeroblob(30000)); Index: test/incrvacuum_ioerr.test ================================================================== --- test/incrvacuum_ioerr.test +++ test/incrvacuum_ioerr.test @@ -106,11 +106,11 @@ ifcapable shared_cache { catch { db close } - file delete -force test.db + forcedelete test.db set ::enable_shared_cache [sqlite3_enable_shared_cache 1] # Create two connections to a single shared-cache: # sqlite3 db1 test.db Index: test/insert5.test ================================================================== --- test/insert5.test +++ test/insert5.test @@ -32,11 +32,11 @@ } # Construct the sample database. # do_test insert5-1.0 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal execsql { CREATE TABLE MAIN(Id INTEGER, Id1 INTEGER); CREATE TABLE B(Id INTEGER, Id1 INTEGER); CREATE VIEW v1 AS SELECT * FROM B; CREATE VIEW v2 AS SELECT * FROM MAIN; Index: test/io.test ================================================================== --- test/io.test +++ test/io.test @@ -223,11 +223,11 @@ INSERT INTO abc VALUES(9, randstr(1000,1000)); COMMIT } } {1 {unable to open database file}} do_test io-2.6.3 { - file delete -force test.db-journal + forcedelete test.db-journal catchsql { COMMIT } } {0 {}} do_test io-2.6.4 { execsql { SELECT * FROM abc } } {1 2 3 4 5 6 7 8} @@ -235,11 +235,11 @@ # Test that if the database modification is part of multi-file commit, # the journal file is always created. In this case, the journal file # is created during execution of the COMMIT statement, so we have to # use the same technique to check that it is created as in the above # block. -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal ifcapable attach { do_test io-2.7.1 { execsql { ATTACH 'test2.db' AS aux; PRAGMA aux.page_size = 1024; @@ -259,11 +259,11 @@ do_test io-2.7.4 { file mkdir test2.db-journal catchsql { COMMIT } } {1 {unable to open database file}} do_test io-2.7.5 { - file delete -force test2.db-journal + forcedelete test2.db-journal catchsql { COMMIT } } {1 {cannot commit - no transaction is active}} do_test io-2.7.6 { execsql { SELECT * FROM abc UNION ALL SELECT * FROM abc2 } } {1 2 3 4 5 6 7 8} @@ -302,11 +302,11 @@ file exists test.db-journal } {1} do_test io-2.9.2 { execsql { ROLLBACK; } db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db -vfs devsym execsql { PRAGMA auto_vacuum = OFF; PRAGMA page_size = 2048; CREATE TABLE abc(a, b); @@ -373,11 +373,11 @@ # sqlite3_simulate_device -char sequential -sectorsize 0 ifcapable pager_pragmas { do_test io-3.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db -vfs devsym db eval { PRAGMA auto_vacuum=OFF; } # File size might be 1 due to the hack to work around ticket #3260. @@ -542,11 +542,11 @@ {atomic64K} 512 1024 } { incr tn if {$pgsize>$::SQLITE_MAX_PAGE_SIZE} continue db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3_simulate_device -char $char -sectorsize $sectorsize sqlite3 db test.db -vfs devsym db eval { PRAGMA auto_vacuum=OFF; } Index: test/ioerr.test ================================================================== --- test/ioerr.test +++ test/ioerr.test @@ -181,12 +181,12 @@ CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); BEGIN; INSERT INTO t1 VALUES(3, 4); } - copy_file test2.db test.db - copy_file test2.db-journal test.db-journal + forcecopy test2.db test.db + forcecopy test2.db-journal test.db-journal db2 close } -tclbody { sqlite3 db test.db db eval { SELECT * FROM t1; @@ -217,15 +217,15 @@ CREATE TABLE t1(a,b,c); INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2); BEGIN; INSERT INTO t1 VALUES(randstr(200,200), randstr(1000,1000), 2); } - copy_file test.db-journal test2.db-journal + forcecopy test.db-journal test2.db-journal execsql { COMMIT; } - copy_file test2.db-journal test.db-journal + forcecopy test2.db-journal test.db-journal set f [open test.db-journal a] fconfigure $f -encoding binary puts -nonewline $f "hello" puts -nonewline $f "\x00\x00\x00\x05\x01\x02\x03\x04" puts -nonewline $f "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" Index: test/ioerr4.test ================================================================== --- test/ioerr4.test +++ test/ioerr4.test @@ -29,11 +29,11 @@ do_test ioerr4-1.1 { db close set ::enable_shared_cache [sqlite3_enable_shared_cache 1] } {0} do_test ioerr4-1.2 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db sqlite3 db2 test.db db eval { PRAGMA auto_vacuum=INCREMENTAL; CREATE TABLE a(i INTEGER, b BLOB); @@ -77,24 +77,24 @@ # Set up for an I/O error on incremental vacuum # with two connections on shared cache. # db close db2 close -file copy -force test.db test.db-bu +forcecopy test.db test.db-bu do_ioerr_test ioerr4-2 -tclprep { catch {db2 close} db close - file delete -force test.db test.db-journal - file copy -force test.db-bu test.db + forcedelete test.db test.db-journal + forcecopy test.db-bu test.db sqlite3_enable_shared_cache 1 set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] db eval {PRAGMA auto_vacuum=INCREMENTAL} sqlite3 db2 test.db } -tclbody { db eval {PRAGMA incremental_vacuum(5)} } db2 close -file delete -force test.db-bu +forcedelete test.db-bu sqlite3_enable_shared_cache $::enable_shared_cache finish_test Index: test/journal1.test ================================================================== --- test/journal1.test +++ test/journal1.test @@ -18,11 +18,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl # These tests will not work on windows because windows uses -# manditory file locking which breaks the file copy command. +# manditory file locking which breaks the copy_file command. # if {$tcl_platform(platform)=="windows"} { finish_test return } @@ -49,19 +49,19 @@ do_test journal1-1.2 { execsql { BEGIN; DELETE FROM t1; } - file copy -force test.db-journal test.db-journal-bu + forcecopy test.db-journal test.db-journal-bu execsql { ROLLBACK; } db close - file delete test.db - file copy test.db-journal-bu test.db-journal + delete_file test.db + copy_file test.db-journal-bu test.db-journal sqlite3 db test.db catchsql { SELECT * FROM sqlite_master } } {0 {}} finish_test Index: test/journal2.test ================================================================== --- test/journal2.test +++ test/journal2.test @@ -165,11 +165,11 @@ set ::tvfs_error_on_write 1 catchsql { COMMIT } db2 } {1 {disk I/O error}} db2 close unset ::tvfs_error_on_write -file copy -force test.db testX.db +forcecopy test.db testX.db do_test journal2-1.14 { file exists test.db-journal } 1 do_test journal2-1.15 { execsql { SELECT count(*) FROM t2; Index: test/journal3.test ================================================================== --- test/journal3.test +++ test/journal3.test @@ -33,11 +33,11 @@ 4 00755 } { db close set effective [format %.5o [expr $permissions & ~$umask]] do_test journal3-1.2.$tn.1 { - catch { file delete -force test.db-journal } + catch { forcedelete test.db-journal } file attributes test.db -permissions $permissions file attributes test.db -permissions } $permissions do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0} do_test journal3-1.2.$tn.3 { Index: test/jrnlmode.test ================================================================== --- test/jrnlmode.test +++ test/jrnlmode.test @@ -198,11 +198,11 @@ } } {} } ifcapable attach { - file delete -force test2.db + forcedelete test2.db do_test jrnlmode-2.1 { execsql { ATTACH 'test2.db' AS aux; PRAGMA main.journal_mode = persist; PRAGMA aux.journal_mode = persist; @@ -240,12 +240,12 @@ #---------------------------------------------------------------------- # Test caes jrnlmode-3.X verify that ticket #3127 has been fixed. # db close - file delete -force test2.db - file delete -force test.db + forcedelete test2.db + forcedelete test.db sqlite3 db test.db do_test jrnlmode-3.1 { execsql { CREATE TABLE x(n INTEGER); @@ -268,11 +268,11 @@ } {} } ifcapable autovacuum&&pragma { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db do_test jrnlmode-4.1 { execsql { PRAGMA cache_size = 1; PRAGMA auto_vacuum = 1; @@ -301,11 +301,11 @@ #------------------------------------------------------------------------ # The following test caes, jrnlmode-5.*, test the journal_size_limit # pragma. ifcapable pragma { db close - file delete -force test.db test2.db test3.db + forcedelete test.db test2.db test3.db sqlite3 db test.db do_test jrnlmode-5.1 { execsql {pragma page_size=1024} execsql {pragma journal_mode=persist} @@ -509,11 +509,11 @@ } ifcapable pragma { catch { db close } do_test jrnlmode-7.1 { - foreach f [glob -nocomplain test.db*] { file delete -force $f } + foreach f [glob -nocomplain test.db*] { forcedelete $f } sqlite3 db test.db execsql { PRAGMA journal_mode = memory; PRAGMA auto_vacuum = 0; PRAGMA page_size = 1024; Index: test/jrnlmode2.test ================================================================== --- test/jrnlmode2.test +++ test/jrnlmode2.test @@ -110,11 +110,11 @@ catchsql { SELECT * FROM t1 } db2 } {0 {1 2 3 4 5 6}} do_test jrnlmode2-2.5 { db close - file delete test.db-journal + delete_file test.db-journal } {} do_test jrnlmode2-2.6 { sqlite3 db2 test.db -readonly 1 catchsql { SELECT * FROM t1 } db2 } {0 {1 2 3 4 5 6}} Index: test/jrnlmode3.test ================================================================== --- test/jrnlmode3.test +++ test/jrnlmode3.test @@ -46,11 +46,11 @@ SELECT * FROM t1; } } {1} db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db do_test jrnlmode3-2.1 { db eval { PRAGMA locking_mode=EXCLUSIVE; @@ -83,11 +83,11 @@ incr cnt # Start with a fresh database connection an empty database file. # db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db # Initialize the journal mode. # do_test jrnlmode3-3.$cnt.1-($fromjmode-to-$tojmode) { Index: test/loadext.test ================================================================== --- test/loadext.test +++ test/loadext.test @@ -132,11 +132,11 @@ sqlite3_enable_load_extension db 1 # Try to load an extension for which the file does not exist. # do_test loadext-2.1 { - file delete -force ${testextension}xx + forcedelete ${testextension}xx set rc [catch { sqlite3_load_extension db "${testextension}xx" } msg] list $rc $msg } [list 1 [format $dlerror_nosuchfile ${testextension}xx]] Index: test/lock4.test ================================================================== --- test/lock4.test +++ test/lock4.test @@ -24,11 +24,11 @@ do_test lock4-1.1 { db eval { PRAGMA auto_vacuum=OFF; CREATE TABLE t1(x); } - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal sqlite3 db2 test2.db db2 eval { PRAGMA auto_vacuum=OFF; CREATE TABLE t2(x) } Index: test/lock5.test ================================================================== --- test/lock5.test +++ test/lock5.test @@ -22,11 +22,11 @@ if {[catch {sqlite3 db test.db -vfs unix-none} msg]} { finish_test return } db close -file delete -force test.db.lock +forcedelete test.db.lock ifcapable lock_proxy_pragmas { set ::using_proxy 0 foreach {name value} [array get env SQLITE_FORCE_PROXY_LOCKING] { set ::using_proxy $value @@ -98,11 +98,11 @@ file exists test.db.lock } {0} ##################################################################### -file delete -force test.db +forcedelete test.db if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} { finish_test return } Index: test/main.test ================================================================== --- test/main.test +++ test/main.test @@ -299,11 +299,11 @@ # Try to open a database with a corrupt database file. # if {[permutation] == ""} { do_test main-2.0 { catch {db close} - file delete -force test.db + forcedelete test.db set fd [open test.db w] puts $fd hi! close $fd set v [catch {sqlite3 db test.db} msg] if {$v} {lappend v $msg} {lappend v {}} @@ -312,20 +312,20 @@ # Here are some tests for tokenize.c. # do_test main-3.1 { catch {db close} - foreach f [glob -nocomplain testdb/*] {file delete -force $f} - file delete -force testdb + foreach f [glob -nocomplain testdb/*] {forcedelete $f} + forcedelete testdb sqlite3 db testdb set v [catch {execsql {SELECT * from T1 where x!!5}} msg] lappend v $msg } {1 {unrecognized token: "!!"}} do_test main-3.2 { catch {db close} - foreach f [glob -nocomplain testdb/*] {file delete -force $f} - file delete -force testdb + foreach f [glob -nocomplain testdb/*] {forcedelete $f} + forcedelete testdb sqlite3 db testdb set v [catch {execsql {SELECT * from T1 where ^x}} msg] lappend v $msg } {1 {unrecognized token: "^"}} do_test main-3.2.2 { @@ -440,12 +440,12 @@ } {0 123} do_test main-3.3 { catch {db close} - foreach f [glob -nocomplain testdb/*] {file delete -force $f} - file delete -force testdb + foreach f [glob -nocomplain testdb/*] {forcedelete $f} + forcedelete testdb sqlite3 db testdb execsql { create table T1(X REAL); /* C-style comments allowed */ insert into T1 values(0.5); insert into T1 values(0.5e2); Index: test/malloc.test ================================================================== --- test/malloc.test +++ test/malloc.test @@ -268,11 +268,11 @@ # This block tests malloc() failures that occur while opening a # connection to a database. do_malloc_test 10 -tclprep { catch {db2 close} db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db sqlite3_extended_result_codes db 1 db eval {CREATE TABLE abc(a, b, c)} } -tclbody { db close @@ -339,12 +339,12 @@ CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); BEGIN; INSERT INTO t1 VALUES(3, 4); } - copy_file test2.db test.db - copy_file test2.db-journal test.db-journal + forcecopy test2.db test.db + forcecopy test2.db-journal test.db-journal db2 close } -tclbody { sqlite3 db test.db sqlite3_extended_result_codes db 1 @@ -497,11 +497,11 @@ # when the malloc failure occurs within the nested parse. # ifcapable attach { do_malloc_test 20 -tclprep { db close - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal sqlite3 db test2.db sqlite3_extended_result_codes db 1 db eval {CREATE TABLE t1(x);} db close } -tclbody { Index: test/malloc3.test ================================================================== --- test/malloc3.test +++ test/malloc3.test @@ -461,11 +461,11 @@ } {a b c a b c 1 2 3 1 2 3} } # Test a simple multi-file transaction # -file delete -force test2.db +forcedelete test2.db ifcapable attach { SQL {ATTACH 'test2.db' AS aux;} SQL {BEGIN} SQL {CREATE TABLE aux.tbl2(x, y, z)} SQL {INSERT INTO tbl2 VALUES(1, 2, 3)} @@ -648,11 +648,11 @@ db cache size 0 run_test $::run_test_script 1 # Close and reopen the db. db close -file delete -force test.db test.db-journal test2.db test2.db-journal +forcedelete test.db test.db-journal test2.db test2.db-journal sqlite3 db test.db sqlite3_extended_result_codes db 1 set ::DB [sqlite3_connection_pointer db] # Turn off the Tcl interface's prepared statement caching facility in Index: test/malloc5.test ================================================================== --- test/malloc5.test +++ test/malloc5.test @@ -273,11 +273,11 @@ set bt [btree_from_db $db] array set stats [btree_pager_stats $bt] set stats(page) } db close -file delete -force test.db test.db-journal test2.db test2.db-journal +forcedelete test.db test.db-journal test2.db test2.db-journal # This block of test-cases (malloc5-6.1.*) prepares two database files # for the subsequent tests. do_test malloc5-6.1.1 { sqlite3 db test.db @@ -302,11 +302,11 @@ SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; INSERT INTO abc SELECT randstr(50,50), randstr(75,75), randstr(100,100) FROM abc; COMMIT; } - copy_file test.db test2.db + forcecopy test.db test2.db sqlite3 db2 test2.db list \ [expr ([file size test.db]/1024)>20] [expr ([file size test2.db]/1024)>20] } {1 1} do_test malloc5-6.1.2 { Index: test/mallocA.test ================================================================== --- test/mallocA.test +++ test/mallocA.test @@ -25,11 +25,11 @@ } # Construct a test database # -file delete -force test.db.bu +forcedelete test.db.bu db eval { CREATE TABLE t1(a COLLATE NOCASE,b,c); INSERT INTO t1 VALUES(1,2,3); INSERT INTO t1 VALUES(1,2,4); INSERT INTO t1 VALUES(2,3,4); @@ -36,11 +36,11 @@ CREATE INDEX t1i1 ON t1(a); CREATE INDEX t1i2 ON t1(b,c); CREATE TABLE t2(x,y,z); } db close -file copy test.db test.db.bu +copy_file test.db test.db.bu do_malloc_test mallocA-1 -testdb test.db.bu -sqlbody { ANALYZE } @@ -72,7 +72,7 @@ do_test malloc-99.X { catch {db close} set sqlite_open_file_count } {0} -file delete -force test.db.bu +forcedelete test.db.bu finish_test Index: test/malloc_common.tcl ================================================================== --- test/malloc_common.tcl +++ test/malloc_common.tcl @@ -406,11 +406,11 @@ # failing. # set zRepeat "transient" if {$::iRepeat} {set zRepeat "persistent"} restore_prng_state - foreach file [glob -nocomplain test.db-mj*] {file delete -force $file} + foreach file [glob -nocomplain test.db-mj*] {forcedelete $file} do_test ${tn}.${zRepeat}.${::n} { # Remove all traces of database files test.db and test2.db # from the file-system. Then open (empty database) "test.db" @@ -423,11 +423,11 @@ forcedelete test.db-wal forcedelete test2.db forcedelete test2.db-journal forcedelete test2.db-wal if {[info exists ::mallocopts(-testdb)]} { - file copy $::mallocopts(-testdb) test.db + copy_file $::mallocopts(-testdb) test.db } catch { sqlite3 db test.db } if {[info commands db] ne ""} { sqlite3_extended_result_codes db 1 } Index: test/manydb.test ================================================================== --- test/manydb.test +++ test/manydb.test @@ -42,11 +42,11 @@ } foreach fd $filehandles { close $fd } catch { - file delete -force testfile.1 + forcedelete testfile.1 } set N [expr $i / $num_fd_per_openwrite_db] # Create a bunch of random database names # @@ -90,13 +90,13 @@ # Close the databases and erase the files. # for {set i 0} {$i<$N} {incr i} { do_test manydb-3.$i { db$i close - file delete -force $dbname($i) + forcedelete $dbname($i) } {} } finish_test Index: test/memsubsys1.test ================================================================== --- test/memsubsys1.test +++ test/memsubsys1.test @@ -30,11 +30,11 @@ # rebalance operations in the btree-layer and to require a large # page cache), verifies correct results, then returns. # proc build_test_db {testname pragmas} { catch {db close} - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db sqlite3_db_config_lookaside db 0 0 0 db eval $pragmas db eval { CREATE TABLE t1(x, y); Index: test/memsubsys2.test ================================================================== --- test/memsubsys2.test +++ test/memsubsys2.test @@ -22,11 +22,11 @@ # rebalance operations in the btree-layer and to require a large # page cache), verifies correct results, then returns. # proc build_test_db {testname pragmas} { catch {db close} - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db eval $pragmas db eval { CREATE TABLE t1(x, y); CREATE TABLE t2(a, b); Index: test/misc1.test ================================================================== --- test/misc1.test +++ test/misc1.test @@ -489,11 +489,11 @@ execsql {UPDATE t1 SET a=a||'y' WHERE 1} file exists ../test.db-journal } {1} do_test misc1-14.3 { cd .. - file delete -force tempdir + forcedelete tempdir execsql {COMMIT} file exists ./test.db-journal } {0} # A failed create table should not leave the table in the internal Index: test/misc2.test ================================================================== --- test/misc2.test +++ test/misc2.test @@ -163,11 +163,11 @@ # the table being SELECTed from within the callback of the query. # ifcapable tclvar { do_test misc2-7.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); @@ -263,11 +263,11 @@ # in reverse order so that we exercise the sqlite3BtreePrev() routine # instead of sqlite3BtreeNext() # do_test misc2-7.11 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { CREATE TABLE t1(x); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); @@ -359,11 +359,11 @@ execsql {SELECT * FROM t1} } {1 2 3 4 5 6 7 8 9 10} } db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db catchsql { pragma recursive_triggers = off } # Ticket #453. If the SQL ended with "-", the tokenizer was calling that # an incomplete token, which caused problem. The solution was to just call Index: test/misc5.test ================================================================== --- test/misc5.test +++ test/misc5.test @@ -512,11 +512,11 @@ # when trying to open them as a database. # if {[permutation] == ""} { do_test misc5-4.1 { db close - file delete -force test.db + forcedelete test.db set fd [open test.db w] puts $fd "This is not really a database" close $fd sqlite3 db test.db catchsql { @@ -542,11 +542,11 @@ # Ticket #1582. Ensure that an unknown table in a LIMIT clause applied to # a UNION ALL query causes an error, not a crash. # db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db ifcapable subquery&&compound { do_test misc5-6.1 { catchsql { SELECT * FROM sqlite_master Index: test/misc7.test ================================================================== --- test/misc7.test +++ test/misc7.test @@ -28,11 +28,11 @@ } {} # Try to open a directory: # do_test misc7-4 { - file delete mydir + delete_file mydir file mkdir mydir set rc [catch { sqlite3 db2 ./mydir } msg] list $rc $msg @@ -39,11 +39,11 @@ } {1 {unable to open database file}} # Try to open a file with a directory where its journal file should be. # do_test misc7-5 { - file delete mydir + delete_file mydir file mkdir mydir-journal sqlite3 db2 ./mydir catchsql { CREATE TABLE abc(a, b, c); } db2 @@ -150,12 +150,12 @@ #-------------------------------------------------------------------- # Test that nothing goes horribly wrong when attaching a database # after the omit_readlock pragma has been exercised. # do_test misc7-7.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { PRAGMA omit_readlock = 1; ATTACH 'test2.db' AS aux; CREATE TABLE aux.hello(world); SELECT name FROM aux.sqlite_master; @@ -252,12 +252,12 @@ } {1 2 3} unset ::echo_module_cost } db close -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal sqlite3 db test.db ifcapable explain { do_execsql_test misc7-14.1 { CREATE TABLE abc(a PRIMARY KEY, b, c); @@ -276,12 +276,12 @@ {SCAN TABLE abc AS t2 USING INDEX sqlite_autoindex_abc_1 (~1000000 rows)} } } db close -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal sqlite3 db test.db #-------------------------------------------------------------------- # This is all to force the pager_remove_from_stmt_list() function # (inside pager.c) to remove a pager from the middle of the @@ -321,12 +321,12 @@ randstr(100,100), randstr(100,100), randstr(100,100) FROM abc; } } {} db close -file delete -force test.db -file delete -force test.db-journal +forcedelete test.db +forcedelete test.db-journal sqlite3 db test.db do_ioerr_test misc7-16 -sqlprep { PRAGMA cache_size = 10; PRAGMA default_cache_size = 10; @@ -383,19 +383,19 @@ do_test misc7-17.1 { execsql { BEGIN; DELETE FROM t3 WHERE (oid%3)==0; } - copy_file test.db bak.db - copy_file test.db-journal bak.db-journal + forcecopy test.db bak.db + forcecopy test.db-journal bak.db-journal execsql { COMMIT; } db close - copy_file bak.db test.db - copy_file bak.db-journal test.db-journal + forcecopy bak.db test.db + forcecopy bak.db-journal test.db-journal sqlite3 db test.db catch {file attributes test.db-journal -permissions r--------} catch {file attributes test.db-journal -readonly 1} catchsql { @@ -482,8 +482,8 @@ list $rc $msg } {1 {unable to open database file}} db close -file delete -force test.db +forcedelete test.db finish_test Index: test/misuse.test ================================================================== --- test/misuse.test +++ test/misuse.test @@ -37,12 +37,12 @@ # Make sure the test logic works # do_test misuse-1.1 { db close - catch {file delete -force test2.db} - catch {file delete -force test2.db-journal} + catch {forcedelete test2.db} + catch {forcedelete test2.db-journal} sqlite3 db test2.db; set ::DB [sqlite3_connection_pointer db] execsql { CREATE TABLE t1(a,b); INSERT INTO t1 VALUES(1,2); } Index: test/multiplex.test ================================================================== --- test/multiplex.test +++ test/multiplex.test @@ -143,11 +143,11 @@ # sqlite3_multiplex_initialize "" 1 multiplex_set db main 32768 16 -file delete -force test.x +forcedelete test.x do_test multiplex-2.1.2 { sqlite3 db test.x execsql { PRAGMA page_size=1024; PRAGMA auto_vacuum=OFF; @@ -512,11 +512,11 @@ catch { db close } multiplex_delete test.db file mkdir test.db list [catch { sqlite3 db test.db } msg] $msg } {1 {unable to open database file}} -catch { file delete test.db } +catch { delete_file test.db } do_faultsim_test multiplex-5.5 -prep { catch { sqlite3_multiplex_shutdown } } -body { sqlite3_multiplex_initialize "" 1 Index: test/notify1.test ================================================================== --- test/notify1.test +++ test/notify1.test @@ -138,11 +138,11 @@ # connections: db, db2 and db3. # do_test notify1-2.3.1 { db close db2 close - file delete -force test.db test2.db test3.db + forcedelete test.db test2.db test3.db foreach con {db db2 db3} { sqlite3 $con test.db $con eval { ATTACH 'test2.db' AS aux2 } $con eval { ATTACH 'test3.db' AS aux3 } } @@ -292,11 +292,11 @@ # committing its transaction, the first does. The # unlock-notify callback is therefore invoked. # db close do_test notify1-6.1.1 { - file delete -force test.db test2.db + forcedelete test.db test2.db foreach conn {db db2 db3} { sqlite3 $conn test.db execsql { ATTACH 'test2.db' AS two } $conn } execsql { Index: test/notify2.test ================================================================== --- test/notify2.test +++ test/notify2.test @@ -165,11 +165,11 @@ foreach {iTest xStep xPrepare} { 1 sqlite3_blocking_step sqlite3_blocking_prepare_v2 2 sqlite3_step sqlite3_nonblocking_prepare_v2 } { - file delete -force test.db test2.db test3.db + forcedelete test.db test2.db test3.db set ThreadSetup "set xStep $xStep;set xPrepare $xPrepare;set nSecond $nSecond" # Set up the database schema used by this test. Each thread opens file # test.db as the main database, then attaches files test2.db and test3.db Index: test/notify3.test ================================================================== --- test/notify3.test +++ test/notify3.test @@ -23,11 +23,11 @@ } set esc [sqlite3_enable_shared_cache 1] sqlite3 db test.db -file delete -force test.db2 test.db2-journal test.db2-wal +forcedelete test.db2 test.db2-journal test.db2-wal sqlite3 db2 test.db2 do_test notify3-1.1 { execsql { CREATE TABLE t1(a, b); Index: test/openv2.test ================================================================== --- test/openv2.test +++ test/openv2.test @@ -15,11 +15,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal do_test openv2-1.1 { set rc [catch {sqlite3 db test.db -create 0} msg] lappend rc $msg } {1 {unable to open database file}} do_test openv2-1.2 { Index: test/pager1.test ================================================================== --- test/pager1.test +++ test/pager1.test @@ -450,11 +450,11 @@ PRAGMA integrity_check; } } {4 ok} do_test pager1.4.2.3 { faultsim_restore_and_reopen - foreach f [glob test.db-mj*] { file delete -force $f } + foreach f [glob test.db-mj*] { forcedelete $f } execsql { SELECT count(*) FROM t1; PRAGMA integrity_check; } } {64 ok} @@ -467,11 +467,11 @@ } } {4 ok} do_test pager1.4.2.5 { faultsim_restore_and_reopen hexio_write test.db-journal [expr [file size test.db-journal]-20] 123456 - foreach f [glob test.db-mj*] { file delete -force $f } + foreach f [glob test.db-mj*] { forcedelete $f } execsql { SELECT count(*) FROM t1; PRAGMA integrity_check; } } {4 ok} @@ -647,11 +647,11 @@ # delete the master-journal file from the file-system. It now appears that # the transaction was committed (no master-journal file == no rollback). # do_test pager1-4.4.$tn.7 { faultsim_restore_and_reopen $prefix - foreach f [glob ${prefix}-mj*] { file delete -force $f } + foreach f [glob ${prefix}-mj*] { forcedelete $f } execsql "ATTACH '${prefix}2' AS aux" } {} do_execsql_test pager1-4.4.$tn.8 { SELECT * FROM a } {double-you why zed won too free} @@ -662,11 +662,11 @@ cd $pwd } db close tv delete -file delete -force $dirname +forcedelete $dirname # Set up a VFS to make a copy of the file-system just before deleting a # journal file to commit a transaction. The transaction modifies exactly # two database pages (and page 1 - the change counter). @@ -880,11 +880,11 @@ } {1 {unable to open database file}} do_test pager1.4.7.3 { db close catch {file attributes test.db-journal -permissions rw-rw-rw-} catch {file attributes test.db-journal -readonly 0} - file delete test.db-journal + delete_file test.db-journal file exists test.db-journal } {0} #------------------------------------------------------------------------- # The following tests deal with multi-file commits. @@ -2366,12 +2366,12 @@ # without being rolled back. And that the RESERVED lock obtained while # doing this is not released. # do_test pager1-30.1 { db close - file delete test.db - file delete test.db-journal + delete_file test.db + delete_file test.db-journal set fd [open test.db-journal w] seek $fd [expr 512+1032*2] puts -nonewline $fd x close $fd @@ -2407,16 +2407,16 @@ INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1; INSERT INTO t1 SELECT randomblob(1500), randomblob(1500) FROM t1; BEGIN; UPDATE t1 SET y = randomblob(1499); } - file copy test.db test.db2 - file copy test.db-journal test.db2-journal + copy_file test.db test.db2 + copy_file test.db-journal test.db2-journal hexio_write test.db2-journal 24 00000000 sqlite3 db2 test.db2 execsql { PRAGMA integrity_check } db2 } {ok} } finish_test Index: test/pagerfault.test ================================================================== --- test/pagerfault.test +++ test/pagerfault.test @@ -231,11 +231,11 @@ faultsim_integrity_check } do_faultsim_test pagerfault-5.3 -faults oom-transient -prep { faultsim_restore_and_reopen db func a_string a_string - file delete -force test2.db test2.db-journal test2.db-wal + forcedelete test2.db test2.db-journal test2.db-wal execsql { PRAGMA journal_mode = PERSIST; ATTACH 'test2.db' AS aux; PRAGMA aux.journal_mode = PERSIST; PRAGMA aux.journal_size_limit = 0; @@ -639,11 +639,11 @@ CREATE TABLE t1(x, y UNIQUE); INSERT INTO t1 VALUES(a_string(333), a_string(444)); COMMIT; } db close - file delete -force test.db + forcedelete test.db faultsim_save } {} do_faultsim_test pagerfault-13 -prep { faultsim_restore_and_reopen } -body { @@ -1104,11 +1104,11 @@ # PagerRollback() # PagerRollback() # do_faultsim_test pagerfault-23 -prep { sqlite3 db :memory: - foreach f [glob -nocomplain test.db*] { file delete -force $f } + foreach f [glob -nocomplain test.db*] { forcedelete $f } db eval { ATTACH 'test.db2' AS aux; CREATE TABLE t1(a, b); CREATE TABLE aux.t2(a, b); } Index: test/pagesize.test ================================================================== --- test/pagesize.test +++ test/pagesize.test @@ -40,11 +40,11 @@ } } 1024 do_test pagesize-1.4 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { PRAGMA page_size=511; PRAGMA page_size; } @@ -97,11 +97,11 @@ } } {1 2 3 2 3 4} } do_test pagesize-2.$PGSZ.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql "PRAGMA page_size=$PGSZ" execsql { CREATE TABLE t1(x); PRAGMA page_size; @@ -188,11 +188,11 @@ ifcapable {vacuum} {execsql VACUUM} } {} integrity_check pagesize-2.$PGSZ.17 db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db do_test pagesize-2.$PGSZ.30 { execsql " CREATE TABLE t1(x); PRAGMA temp.page_size=$PGSZ; @@ -201,11 +201,11 @@ PRAGMA temp.page_size; " } [list 1024 $PGSZ] db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db do_test pagesize-2.$PGSZ.40 { execsql " PRAGMA page_size=$PGSZ; CREATE TABLE t1(x); Index: test/pcache2.test ================================================================== --- test/pcache2.test +++ test/pcache2.test @@ -32,17 +32,17 @@ } {0 0 0} # Open up two database connections to separate files. # do_test pcache2-1.2 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db eval {PRAGMA cache_size=10} lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1 } {2} do_test pcache2-1.3 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal sqlite3 db2 test2.db db2 eval {PRAGMA cache_size=50} lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1 } {4} Index: test/pragma.test ================================================================== --- test/pragma.test +++ test/pragma.test @@ -49,12 +49,12 @@ # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # db close -file delete test.db test.db-journal -file delete test3.db test3.db-journal +delete_file test.db test.db-journal +delete_file test3.db test3.db-journal sqlite3 db test.db; set DB [sqlite3_connection_pointer db] ifcapable pager_pragmas { set DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}] @@ -219,12 +219,12 @@ } {} # Test modifying the safety_level of an attached database. ifcapable pager_pragmas&&attach { do_test pragma-2.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' AS aux; } } {} do_test pragma-2.2 { @@ -253,11 +253,11 @@ # # These tests won't work if the database is encrypted # do_test pragma-3.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql { PRAGMA auto_vacuum=OFF; BEGIN; CREATE TABLE t2(a,b,c); @@ -310,11 +310,11 @@ # Add additional corruption by appending unused pages to the end of # the database file testerr.db # do_test pragma-3.8 { execsql {DETACH t2} - file delete -force testerr.db testerr.db-journal + forcedelete testerr.db testerr.db-journal set out [open testerr.db w] fconfigure $out -translation binary set in [open test.db r] fconfigure $in -translation binary puts -nonewline $out [read $in] @@ -417,11 +417,11 @@ Page 5 is never used Page 6 is never used} {rowid 1 missing from index i2}} } do_test pragma-3.19 { catch {db close} - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db eval {PRAGMA integrity_check} } {ok} } #exit @@ -739,12 +739,12 @@ do_test pragma-8.1.10 { sqlite3_finalize $::STMT } SQLITE_SCHEMA # Make sure the schema-version can be manipulated in an attached database. -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal ifcapable attach { do_test pragma-8.1.11 { execsql { ATTACH 'test2.db' AS aux; CREATE TABLE aux.t1(a, b, c); @@ -1203,11 +1203,11 @@ } ;# ifcapable bloblit ifcapable pager_pragmas { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db do_test pragma-14.1 { execsql { pragma auto_vacuum = 0 } execsql { pragma page_count } @@ -1239,11 +1239,11 @@ PRAGMA page_count; } } {2} do_test pragma-14.6 { - file delete -force test2.db + forcedelete test2.db sqlite3 db2 test2.db execsql { PRAGMA auto_vacuum = 0; CREATE TABLE t1(a, b, c); CREATE TABLE t2(a, b, c); Index: test/pragma2.test ================================================================== --- test/pragma2.test +++ test/pragma2.test @@ -31,12 +31,12 @@ # Delete the preexisting database to avoid the special setup # that the "all.test" script does. # db close -file delete test.db test.db-journal -file delete test3.db test3.db-journal +delete_file test.db test.db-journal +delete_file test3.db test3.db-journal sqlite3 db test.db; set DB [sqlite3_connection_pointer db] db eval {PRAGMA auto_vacuum=0} do_test pragma2-1.1 { execsql { @@ -59,12 +59,12 @@ execsql { PRAGMA main.freelist_count; } } {1} -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal ifcapable attach { do_test pragma2-2.1 { execsql { ATTACH 'test2.db' AS aux; Index: test/quota.test ================================================================== --- test/quota.test +++ test/quota.test @@ -121,11 +121,11 @@ lappend ::quota [set limit] $size if {[info exists ::quota_request_ok]} { set limit $size } } do_test quota-3.1.1 { - file delete -force test.db + forcedelete test.db sqlite3_quota_initialize "" 1 sqlite3_quota_set *test.db 4096 quota_check } {SQLITE_OK} do_test quota-3.1.2 { sqlite3 db test.db @@ -156,11 +156,11 @@ db2 close sqlite3_quota_set *test.db 0 {} } {SQLITE_OK} do_test quota-3.2.1 { - file delete force test.db test2.db + delete_file force test.db test2.db sqlite3_quota_set * 4096 {} sqlite3 db1a test.db sqlite3 db2a test2.db @@ -255,11 +255,11 @@ do_test quota-4.1.5 { sqlite3_quota_set *test.db 0 {} quota_list } {*test2.db} do_test quota-4.1.6 { - file delete -force test2.db test2.db-journal test2.db-wal + forcedelete test2.db test2.db-journal test2.db-wal sqlite3 db test2.db db eval {CREATE TABLE t2(x); INSERT INTO t2 VALUES('tab-t2');} quota_list } {*test2.db} do_test quota-4.1.7 { @@ -355,11 +355,11 @@ } -body { sqlite3 db test.db } catch { db close } -file delete -force test.db +forcedelete test.db do_test quota-5.3.prep { sqlite3 db test.db execsql { PRAGMA auto_vacuum = 1; @@ -375,11 +375,11 @@ execsql { DELETE FROM t1 } } do_test quota-5.4.1 { catch { db close } - file delete -force test.db + forcedelete test.db file mkdir test.db list [catch { sqlite3 db test.db } msg] $msg } {1 {unable to open database file}} do_faultsim_test quota-5.5 -prep { Index: test/rollback.test ================================================================== --- test/rollback.test +++ test/rollback.test @@ -86,12 +86,12 @@ do_test rollback-2.1 { execsql { BEGIN; INSERT INTO t3 VALUES('hello world'); } - file copy -force test.db testA.db - file copy -force test.db-journal testA.db-journal + forcecopy test.db testA.db + forcecopy test.db-journal testA.db-journal execsql { COMMIT; } } {} Index: test/savepoint.test ================================================================== --- test/savepoint.test +++ test/savepoint.test @@ -369,11 +369,11 @@ # The following tests, savepoint-6.*, test an incr-vacuum inside of a # couple of nested savepoints. # ifcapable {autovacuum && pragma} { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db do_test savepoint-6.1 { execsql { PRAGMA auto_vacuum = incremental } wal_set_journal_mode @@ -417,11 +417,11 @@ #------------------------------------------------------------------------- # The following tests, savepoint-7.*, attempt to break the logic # surrounding savepoints by growing and shrinking the database file. # db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test savepoint-7.1 { execsql { PRAGMA auto_vacuum = incremental } wal_set_journal_mode @@ -488,11 +488,11 @@ } {ok} wal_check_journal_mode savepoint-7.3.3 do_test savepoint-7.4.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { PRAGMA auto_vacuum = incremental } wal_set_journal_mode execsql { CREATE TABLE t1(a, b, PRIMARY KEY(a, b)); @@ -638,12 +638,12 @@ set templockstate [lindex [db eval {PRAGMA lock_status}] 3] if {[wal_is_wal_mode]==0} { do_test savepoint-10.2.1 { - file delete -force test3.db - file delete -force test2.db + forcedelete test3.db + forcedelete test2.db execsql { ATTACH 'test2.db' AS aux1; ATTACH 'test3.db' AS aux2; DROP TABLE t1; CREATE TABLE main.t1(x, y); @@ -760,11 +760,11 @@ # savepoints and creating or dropping tables and indexes in # auto-vacuum mode. # do_test savepoint-11.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { PRAGMA auto_vacuum = full; } wal_set_journal_mode execsql { CREATE TABLE t1(a, b, UNIQUE(a, b)); @@ -866,11 +866,11 @@ # savepoints and "journal_mode = off". # if {[wal_is_wal_mode]==0} { do_test savepoint-13.1 { db close - catch {file delete -force test.db} + catch {forcedelete test.db} sqlite3 db test.db execsql { BEGIN; CREATE TABLE t1(a PRIMARY KEY, b); INSERT INTO t1 VALUES(1, 2); @@ -907,11 +907,11 @@ } } {1 2 3 4 5 6 7 8 9 10 11 12} } db close -file delete test.db +delete_file test.db do_multiclient_test tn { do_test savepoint-14.$tn.1 { sql1 { CREATE TABLE foo(x); INSERT INTO foo VALUES(1); Index: test/savepoint6.test ================================================================== --- test/savepoint6.test +++ test/savepoint6.test @@ -244,11 +244,11 @@ unset -nocomplain ::lSavepoint unset -nocomplain ::aEntry catch { db close } - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal eval $zSetup sql $DATABASE_SCHEMA wal_set_journal_mode Index: test/securedel.test ================================================================== --- test/securedel.test +++ test/securedel.test @@ -24,11 +24,11 @@ do_test securedel-1.0 { db eval {PRAGMA secure_delete;} } $DEFAULT_SECDEL -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal do_test securedel-1.1 { db eval { ATTACH 'test2.db' AS db2; PRAGMA main.secure_delete=ON; PRAGMA db2.secure_delete; Index: test/shared.test ================================================================== --- test/shared.test +++ test/shared.test @@ -25,11 +25,11 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1] foreach av [list 0 1] { # Open the database connection and execute the auto-vacuum pragma -file delete -force test.db +forcedelete test.db sqlite3 db test.db ifcapable autovacuum { do_test shared-[expr $av+1].1.0 { execsql "pragma auto_vacuum=$::av" @@ -291,13 +291,13 @@ # db.main -> ./test.db # db.test2 -> ./test2.db # db2.main -> ./test2.db # db2.test -> ./test.db # -file delete -force test.db -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test.db +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db test.db sqlite3 db2 test2.db do_test shared-$av.4.1.1 { set sqlite_open_file_count expr $sqlite_open_file_count-($extrafds_prelock*2) @@ -424,11 +424,11 @@ #-------------------------------------------------------------------------- # Tests shared-5.* # foreach db [list test.db test1.db test2.db test3.db] { - file delete -force $db ${db}-journal + forcedelete $db ${db}-journal } do_test shared-$av.5.1.1 { sqlite3 db1 test.db sqlite3 db2 test.db execsql { @@ -555,11 +555,11 @@ } {} catch {db1 close} catch {db2 close} foreach f [list test.db test2.db] { - file delete -force $f ${f}-journal + forcedelete $f ${f}-journal } #-------------------------------------------------------------------------- # Tests shared-7.* test auto-vacuum does not invalidate cursors from # other shared-cache users when it reorganizes the database on @@ -641,11 +641,11 @@ #-------------------------------------------------------------------------- # The following tests try to trick the shared-cache code into assuming # the wrong encoding for a database. # -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal ifcapable utf16 { do_test shared-$av.8.1.1 { sqlite3 db test.db execsql { PRAGMA encoding = 'UTF-16'; @@ -673,11 +673,11 @@ execsql { PRAGMA encoding; } } {UTF-8} - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal do_test shared-$av.8.2.1 { execsql { ATTACH 'test2.db' AS aux; SELECT * FROM aux.sqlite_master; } @@ -691,11 +691,11 @@ string range [execsql {PRAGMA encoding;} db2] 0 end-2 } {UTF-16} catch {db close} catch {db2 close} - file delete -force test.db test2.db + forcedelete test.db test2.db do_test shared-$av.8.3.2 { sqlite3 db test.db execsql { CREATE TABLE def(d, e, f) } execsql { PRAGMA encoding } @@ -730,11 +730,11 @@ } } catch {db close} catch {db2 close} -file delete -force test.db test2.db +forcedelete test.db test2.db #--------------------------------------------------------------------------- # The following tests - shared-9.* - test interactions between TEMP triggers # and shared-schemas. # @@ -770,11 +770,11 @@ # The following tests - shared-10.* - test that the library behaves # correctly when a connection to a shared-cache is closed. # do_test shared-$av.10.1 { # Create a small sample database with two connections to it (db and db2). - file delete -force test.db + forcedelete test.db sqlite3 db test.db sqlite3 db2 test.db execsql { CREATE TABLE ab(a PRIMARY KEY, b); CREATE TABLE de(d PRIMARY KEY, e); @@ -851,11 +851,11 @@ db close db3 close } {} do_test shared-$av.11.1 { - file delete -force test.db + forcedelete test.db sqlite3 db test.db sqlite3 db2 test.db execsql { CREATE TABLE abc(a, b, c); CREATE TABLE abc2(a, b, c); @@ -914,11 +914,11 @@ db2 close } {} # This tests that if it is impossible to free any pages, SQLite will # exceed the limit set by PRAGMA cache_size. -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db ifcapable pager_pragmas { do_test shared-$av.12.1 { execsql { PRAGMA cache_size = 10; @@ -961,11 +961,11 @@ # test case attempts to cause the order of the structures in memory # to be different from the order in which they are attached to a given # database handle. This covers an extra line or two. # do_test shared-$av.13.1 { - file delete -force test2.db test3.db test4.db test5.db + forcedelete test2.db test3.db test4.db test5.db sqlite3 db :memory: execsql { ATTACH 'test2.db' AS aux2; ATTACH 'test3.db' AS aux3; ATTACH 'test4.db' AS aux4; @@ -1024,11 +1024,11 @@ # # Mutexes are enabled for this test as that activates a couple of useful # assert() statements in the C code. # do_test shared-$av-15.1 { - file delete -force test.db + forcedelete test.db sqlite3 db test.db -fullmutex 1 sqlite3 db2 test.db -fullmutex 1 execsql { CREATE TABLE t1(a, b, c); CREATE INDEX i1 ON t1(a, b); Index: test/shared2.test ================================================================== --- test/shared2.test +++ test/shared2.test @@ -127,11 +127,11 @@ do_test shared2-3.2 { sqlite3_enable_shared_cache 1 } {1} -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test shared2-4.1 { execsql { CREATE TABLE t0(a, b); Index: test/shared3.test ================================================================== --- test/shared3.test +++ test/shared3.test @@ -22,11 +22,11 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1] # Ticket #1824 # do_test shared3-1.1 { - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db1 test.db db1 eval { PRAGMA encoding=UTF16; CREATE TABLE t1(x,y); INSERT INTO t1 VALUES('abc','This is a test string'); Index: test/shared4.test ================================================================== --- test/shared4.test +++ test/shared4.test @@ -28,14 +28,14 @@ set ::enable_shared_cache [sqlite3_enable_shared_cache 1] # Prepare multiple databases in shared cache mode. # do_test shared4-1.1 { - file delete -force test1.db test1.db-journal - file delete -force test2.db test2.db-journal - file delete -force test3.db test3.db-journal - file delete -force test4.db test4.db-journal + forcedelete test1.db test1.db-journal + forcedelete test2.db test2.db-journal + forcedelete test3.db test3.db-journal + forcedelete test4.db test4.db-journal sqlite3 db1 test1.db sqlite3 db2 test2.db sqlite3 db3 test3.db sqlite3 db4 test4.db db1 eval { Index: test/shared6.test ================================================================== --- test/shared6.test +++ test/shared6.test @@ -233,11 +233,11 @@ db2 close db3 close } {} do_test shared6-4.1 { - #file delete -force test.db test.db-journal + #forcedelete test.db test.db-journal sqlite3 db1 test.db sqlite3 db2 test.db set ::STMT [sqlite3_prepare_v2 db1 "SELECT * FROM t1" -1 DUMMY] execsql { CREATE TABLE t5(a, b) } db2 Index: test/shared7.test ================================================================== --- test/shared7.test +++ test/shared7.test @@ -33,11 +33,11 @@ ATTACH 'test.db' AS err1; } } {1 {database is already attached}} do_test shared7-1.3 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal db eval { ATTACH 'test2.db' AS test2; CREATE TABLE test2.t2(y); } catchsql { Index: test/speed3.test ================================================================== --- test/speed3.test +++ test/speed3.test @@ -114,11 +114,11 @@ ATTACH 'test2.db' AS 'aux'; PRAGMA aux.auto_vacuum = 'none'; } } -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal reset_db # Set up a database in auto-vacuum mode and create a database schema. # do_test speed3-0.1 { Index: test/sqllimits1.test ================================================================== --- test/sqllimits1.test +++ test/sqllimits1.test @@ -757,11 +757,11 @@ # ifcapable attach { do_test sqllimits1-12.1 { set max $::SQLITE_MAX_ATTACHED for {set i 0} {$i < ($max)} {incr i} { - file delete -force test${i}.db test${i}.db-journal + forcedelete test${i}.db test${i}.db-journal } for {set i 0} {$i < ($max)} {incr i} { execsql "ATTACH 'test${i}.db' AS aux${i}" } catchsql "ATTACH 'test${i}.db' AS aux${i}" Index: test/stat.test ================================================================== --- test/stat.test +++ test/stat.test @@ -137,11 +137,11 @@ i5 / 5 leaf 0 0 1016 0 \ t5 / 4 leaf 0 0 1016 0 \ ] db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db register_dbstat_vtab db breakpoint do_execsql_test stat-5.1 { PRAGMA auto_vacuum = OFF; Index: test/sync.test ================================================================== --- test/sync.test +++ test/sync.test @@ -40,12 +40,12 @@ } } do_test sync-1.1 { set sqlite_sync_count 0 - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { PRAGMA fullfsync=OFF; CREATE TABLE t1(a,b); ATTACH DATABASE 'test2.db' AS db2; CREATE TABLE db2.t2(x,y); Index: test/table.test ================================================================== --- test/table.test +++ test/table.test @@ -665,12 +665,12 @@ ifcapable attach { # Now attach a database and ensure that a table can be created in the # attached database whilst in a callback from a query on the main database. do_test table-14.3 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' as aux; } db eval {SELECT * FROM tablet8 LIMIT 1} {} { db eval {CREATE TABLE aux.t1(a, b, c)} Index: test/temptable.test ================================================================== --- test/temptable.test +++ test/temptable.test @@ -402,11 +402,11 @@ catchsql { SELECT * FROM t8,t9; } } {1 {no such table: t9}} -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal ifcapable attach { do_test temptable-7.1 { catchsql { ATTACH 'test2.db' AS two; CREATE TEMP TABLE two.abc(x,y); @@ -413,18 +413,18 @@ } } {1 {temporary table name must be unqualified}} } # Need to do the following for tcl 8.5 on mac. On that configuration, the -# -readonly flag is taken so seriously that a subsequent [file delete -force] +# -readonly flag is taken so seriously that a subsequent [forcedelete] # (required before the next test file can be executed) will fail. # catch {file attributes test.db -readonly 0} do_test temptable-8.0 { db close - catch {file delete -force test.db} + catch {forcedelete test.db} sqlite3 db test.db } {} do_test temptable-8.1 { execsql { CREATE TEMP TABLE tbl2(a, b); } execsql { Index: test/temptrigger.test ================================================================== --- test/temptrigger.test +++ test/temptrigger.test @@ -155,12 +155,12 @@ # correctly. # # temptrigger-3.4: Check that the temp trigger can be dropped without error. # do_test temptrigger-3.1 { - catch { file delete -force test2.db test2.db-journal } - catch { file delete -force test.db test.db-journal } + catch { forcedelete test2.db test2.db-journal } + catch { forcedelete test.db test.db-journal } sqlite3 db test.db sqlite3 db2 test2.db execsql { CREATE TABLE t2(a, b) } db2 execsql { ATTACH 'test2.db' AS aux; Index: test/tester.tcl ================================================================== --- test/tester.tcl +++ test/tester.tcl @@ -18,11 +18,13 @@ # test cases are as follows: # # Commands to manipulate the db and the file-system at a high level: # # copy_file FROM TO +# delete_file FILENAME # drop_all_tables ?DB? +# forcecopy FROM TO # forcedelete FILENAME # # Test the capability of the SQLite version built into the interpreter to # determine if a specific test can be run: # @@ -120,10 +122,125 @@ # uplevel 1 sqlite_orig $args } } } + +proc getFileRetries {} { + if {![info exists ::G(file-retries)]} { + # + # NOTE: Return the default number of retries for [file] operations. A + # value of zero or less here means "disabled". + # + return [expr {$::tcl_platform(platform) eq "windows" ? 10 : 0}] + } + return $::G(file-retries) +} + +proc getFileRetryDelay {} { + if {![info exists ::G(file-retry-delay)]} { + # + # NOTE: Return the default number of milliseconds to wait when retrying + # failed [file] operations. A value of zero or less means "do not + # wait". + # + return 100; # TODO: Good default? + } + return $::G(file-retry-delay) +} + +# 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} { + do_copy_file false $from $to +} + +proc forcecopy {from to} { + do_copy_file true $from $to +} + +proc do_copy_file {force from to} { + set nRetry [getFileRetries] ;# Maximum number of retries. + set nDelay [getFileRetryDelay] ;# Delay in ms before retrying. + + # On windows, sometimes even a [file copy -force] can fail. The cause is + # usually "tag-alongs" - programs like anti-virus software, automatic backup + # tools and various explorer extensions that keep a file open a little longer + # than we expect, causing the delete to fail. + # + # The solution is to wait a short amount of time before retrying the copy. + # + if {$nRetry > 0} { + for {set i 0} {$i<$nRetry} {incr i} { + set rc [catch { + if {$force} { + file copy -force $from $to + } else { + file copy $from $to + } + } msg] + if {$rc==0} break + if {$nDelay > 0} { after $nDelay } + } + if {$rc} { error $msg } + } else { + if {$force} { + file copy -force $from $to + } else { + file copy $from $to + } + } +} + +# Delete a file or directory +# +proc delete_file {args} { + do_delete_file false {*}$args +} + +proc forcedelete {args} { + do_delete_file true {*}$args +} + +proc do_delete_file {force args} { + set nRetry [getFileRetries] ;# Maximum number of retries. + set nDelay [getFileRetryDelay] ;# Delay in ms before retrying. + + foreach filename $args { + # On windows, sometimes even a [file delete -force] can fail just after + # a file is closed. The cause is usually "tag-alongs" - programs like + # anti-virus software, automatic backup tools and various explorer + # extensions that keep a file open a little longer than we expect, causing + # the delete to fail. + # + # The solution is to wait a short amount of time before retrying the + # delete. + # + if {$nRetry > 0} { + for {set i 0} {$i<$nRetry} {incr i} { + set rc [catch { + if {$force} { + file delete -force $filename + } else { + file delete $filename + } + } msg] + if {$rc==0} break + if {$nDelay > 0} { after $nDelay } + } + if {$rc} { error $msg } + } else { + if {$force} { + file delete -force $filename + } else { + file delete $filename + } + } + } +} proc execpresql {handle args} { trace remove execution $handle enter [list execpresql $handle] if {[info exists ::G(perm:presql)]} { $handle eval $::G(perm:presql) @@ -152,18 +269,22 @@ # --maxerror=NN # --malloctrace=N # --backtrace=N # --binarylog=N # --soak=N + # --file-retries=N + # --file-retry-delay=N # --start=[$permutation:]$testfile # set cmdlinearg(soft-heap-limit) 0 set cmdlinearg(maxerror) 1000 set cmdlinearg(malloctrace) 0 set cmdlinearg(backtrace) 10 set cmdlinearg(binarylog) 0 set cmdlinearg(soak) 0 + set cmdlinearg(file-retries) 0 + set cmdlinearg(file-retry-delay) 0 set cmdlinearg(start) "" set leftover [list] foreach a $argv { switch -regexp -- $a { @@ -195,10 +316,18 @@ } {^-+soak=.+$} { foreach {dummy cmdlinearg(soak)} [split $a =] break set ::G(issoak) $cmdlinearg(soak) } + {^-+file-retries=.+$} { + foreach {dummy cmdlinearg(file-retries)} [split $a =] break + set ::G(file-retries) $cmdlinearg(file-retries) + } + {^-+file-retry-delay=.+$} { + foreach {dummy cmdlinearg(file-retry-delay)} [split $a =] break + set ::G(file-retry-delay) $cmdlinearg(file-retry-delay) + } {^-+start=.+$} { foreach {dummy cmdlinearg(start)} [split $a =] break set ::G(start:file) $cmdlinearg(start) if {[regexp {(.*):(.*)} $cmdlinearg(start) -> s.perm s.file]} { @@ -244,13 +373,13 @@ # Create a test database # proc reset_db {} { catch {db close} - file delete -force test.db - file delete -force test.db-journal - file delete -force test.db-wal + forcedelete test.db + forcedelete test.db-journal + forcedelete test.db-wal sqlite3 db ./test.db set ::DB [sqlite3_connection_pointer db] if {[info exists ::SETUP_SQL]} { db eval $::SETUP_SQL } @@ -620,14 +749,14 @@ sqlite3_memdebug_log sync memdebug_log_sql leaks.sql } } foreach f [glob -nocomplain test.db-*-journal] { - file delete -force $f + forcedelete $f } foreach f [glob -nocomplain test.db-mj*] { - file delete -force $f + forcedelete $f } exit [expr {$nErr>0}] } # Display memory statistics for analysis and debugging purposes. @@ -738,34 +867,10 @@ } } return $r } -# Delete a file or directory -# -proc forcedelete {args} { - foreach filename $args { - # On windows, sometimes even a [file delete -force] can fail just after - # a file is closed. The cause is usually "tag-alongs" - programs like - # anti-virus software, automatic backup tools and various explorer - # extensions that keep a file open a little longer than we expect, causing - # the delete to fail. - # - # The solution is to wait a short amount of time before retrying the - # delete. - # - set nRetry 50 ;# Maximum number of retries. - set nDelay 100 ;# Delay in ms before retrying. - for {set i 0} {$i<$nRetry} {incr i} { - set rc [catch {file delete -force $filename} msg] - if {$rc==0} break - after $nDelay - } - if {$rc} { error $msg } - } -} - # Do an integrity check of the entire database # proc integrity_check {name {db db}} { ifcapable integrityck { do_test $name [list execsql {PRAGMA integrity_check} $db] {ok} @@ -962,14 +1067,14 @@ # 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 {db2 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} + catch {forcedelete test.db} + catch {forcedelete test.db-journal} + catch {forcedelete test2.db} + catch {forcedelete test2.db-journal} set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db] sqlite3_extended_result_codes $::DB $::ioerropts(-erc) if {[info exists ::ioerropts(-tclprep)]} { eval $::ioerropts(-tclprep) } @@ -1239,28 +1344,10 @@ set fd [open $filename w] puts $fd "BEGIN; ${tbl}${tbl2}${tbl3}${sql} ; COMMIT;" close $fd } -# 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 - } -} - # Drop all tables in database [db] proc drop_all_tables {{db db}} { ifcapable trigger&&foreignkey { set pk [$db one "PRAGMA foreign_keys"] $db eval "PRAGMA foreign_keys = OFF" @@ -1438,11 +1525,11 @@ proc db_save {} { foreach f [glob -nocomplain sv_test.db*] { forcedelete $f } foreach f [glob -nocomplain test.db*] { set f2 "sv_$f" - file copy -force $f $f2 + forcecopy $f $f2 } } proc db_save_and_close {} { db_save catch { db close } @@ -1450,25 +1537,25 @@ } proc db_restore {} { foreach f [glob -nocomplain test.db*] { forcedelete $f } foreach f2 [glob -nocomplain sv_test.db*] { set f [string range $f2 3 end] - file copy -force $f2 $f + forcecopy $f2 $f } } proc db_restore_and_reopen {{dbfile test.db}} { catch { db close } db_restore sqlite3 db $dbfile } proc db_delete_and_reopen {{file test.db}} { catch { db close } - foreach f [glob -nocomplain test.db*] { file delete -force $f } + foreach f [glob -nocomplain test.db*] { forcedelete $f } sqlite3 db $file } # 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) source $testdir/thread_common.tcl source $testdir/malloc_common.tcl Index: test/thread002.test ================================================================== --- test/thread002.test +++ test/thread002.test @@ -25,11 +25,11 @@ set ::NTHREAD 10 do_test thread002.1 { # Create 3 databases with identical schemas: for {set ii 0} {$ii < 3} {incr ii} { - file delete -force test${ii}.db + forcedelete test${ii}.db sqlite3 db test${ii}.db execsql { CREATE TABLE t1(k, v); CREATE INDEX t1_i ON t1(v); INSERT INTO t1(v) VALUES(1.0); Index: test/thread003.test ================================================================== --- test/thread003.test +++ test/thread003.test @@ -38,11 +38,11 @@ do_test thread003.1.2 { expr {([file size test.db] / 1024) > 2000} } {1} do_test thread003.1.3 { db close - file delete -force test2.db + forcedelete test2.db sqlite3 db test2.db } {} do_test thread003.1.4 { execsql { BEGIN; Index: test/thread005.test ================================================================== --- test/thread005.test +++ test/thread005.test @@ -119,11 +119,11 @@ # are a few more mutex grabs and releases during the window of time open # for the race-condition. Maybe this encourages the scheduler to context # switch or something... # -file delete -force test.db test2.db +forcedelete test.db test2.db unset -nocomplain finished do_test thread005-2.1 { sqlite3 db test.db execsql { ATTACH 'test2.db' AS aux } Index: test/tkt-2d1a5c67d.test ================================================================== --- test/tkt-2d1a5c67d.test +++ test/tkt-2d1a5c67d.test @@ -116,12 +116,12 @@ # Check that recovery works on the WAL file. # forcedelete test.db2-wal test.db2 do_test 3.6 { - file copy test.db-wal test.db2-wal - file copy test.db test.db2 + copy_file test.db-wal test.db2-wal + copy_file test.db test.db2 sqlite3 db2 test.db2 execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2 } {xyz} finish_test Index: test/tkt-5ee23731f.test ================================================================== --- test/tkt-5ee23731f.test +++ test/tkt-5ee23731f.test @@ -17,11 +17,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test tkt-5ee237-1.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db db eval { CREATE TABLE t1(x UNIQUE); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); Index: test/tkt-f3e5abed55.test ================================================================== --- test/tkt-f3e5abed55.test +++ test/tkt-f3e5abed55.test @@ -12,12 +12,12 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl -foreach f [glob -nocomplain test.db*mj*] { file delete -force $f } -file delete -force test.db2 +foreach f [glob -nocomplain test.db*mj*] { forcedelete $f } +forcedelete test.db2 do_test tkt-f3e5abed55-1.1 { execsql { ATTACH 'test.db2' AS aux; CREATE TABLE main.t1(a, b); @@ -49,11 +49,11 @@ } {} do_test tkt-f3e5abed55-1.6 { glob -nocomplain test.db*mj* } {} -foreach f [glob -nocomplain test.db*mj*] { file delete -force $f } +foreach f [glob -nocomplain test.db*mj*] { forcedelete $f } db close db2 close Index: test/tkt1667.test ================================================================== --- test/tkt1667.test +++ test/tkt1667.test @@ -23,11 +23,11 @@ finish_test return } db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal # Set the pending byte offset such that the page it is on is # the first autovacuum pointer map page in the file (assume a page # size of 1024). Index: test/tkt1873.test ================================================================== --- test/tkt1873.test +++ test/tkt1873.test @@ -22,11 +22,11 @@ ifcapable !attach { finish_test return } -file delete -force test2.db test2.db-journal +forcedelete test2.db test2.db-journal do_test tkt1873-1.1 { execsql { CREATE TABLE t1(x, y); ATTACH 'test2.db' AS aux; Index: test/tkt2686.test ================================================================== --- test/tkt2686.test +++ test/tkt2686.test @@ -47,11 +47,11 @@ integrity_check tkt2686-$i.3 catch {db eval COMMIT} } db close -file delete -force test.db test.db-journal +forcedelete test.db test.db-journal sqlite3 db test.db db eval { PRAGMA page_size=1024; PRAGMA max_page_count=50; Index: test/tkt2817.test ================================================================== --- test/tkt2817.test +++ test/tkt2817.test @@ -46,11 +46,11 @@ # These tests - tkt2817-2.* - are the same as the previous block, except # for the fact that the temp-table and the main table do not share the # same name. #2817 did not cause a problem with these tests. # db close -file delete -force test.db +forcedelete test.db sqlite3 db test.db do_test tkt2817-2.0 { execsql { CREATE TEMP TABLE tmp(a, b, c); INSERT INTO tmp VALUES(1, 'abc', 'def'); Index: test/tkt2820.test ================================================================== --- test/tkt2820.test +++ test/tkt2820.test @@ -23,11 +23,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl proc test_schema_change {testid init ddl res} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db execsql $init do_test tkt2820-$testid.1 { set STMT [sqlite3_prepare db {SELECT * FROM sqlite_master} -1 DUMMY] sqlite3_step $STMT @@ -68,11 +68,11 @@ # while a second statement was active, as long as we are in autocommit # mode. This is incorrect. # do_test tkt2820-4.1 { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db db eval { CREATE TABLE t1(a INTEGER PRIMARY KEY); INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(2); Index: test/tkt2854.test ================================================================== --- test/tkt2854.test +++ test/tkt2854.test @@ -126,11 +126,11 @@ # Check that if an attempt to obtain an exclusive lock fails because an # attached db cannot be locked, the internal exclusive flag used by # shared-cache users is correctly cleared. do_test tkt2854-1.19 { - file delete -force test2.db test2.db-journal + forcedelete test2.db test2.db-journal sqlite3 db4 test2.db execsql { CREATE TABLE def(d, e, f) } db4 execsql { ATTACH 'test2.db' AS aux } db } {} do_test tkt2854-1.20 { Index: test/tkt3457.test ================================================================== --- test/tkt3457.test +++ test/tkt3457.test @@ -44,12 +44,12 @@ INSERT INTO t1 VALUES(1, 2, 3); BEGIN; INSERT INTO t1 VALUES(4, 5, 6); } - file copy -force test.db bak.db - file copy -force test.db-journal bak.db-journal + forcecopy test.db bak.db + forcecopy test.db-journal bak.db-journal # Fix the first journal-header in the journal-file. Because the # journal file has not yet been synced, the 8-byte magic string at the # start of the first journal-header has not been written by SQLite. # So write it now. @@ -61,27 +61,27 @@ execsql COMMIT } {} do_test tkt3457-1.2 { - file copy -force bak.db-journal test.db-journal + forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions --------- catchsql { SELECT * FROM t1 } } {1 {unable to open database file}} do_test tkt3457-1.3 { - file copy -force bak.db-journal test.db-journal + forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions -w--w--w- catchsql { SELECT * FROM t1 } } {1 {unable to open database file}} do_test tkt3457-1.4 { - file copy -force bak.db-journal test.db-journal + forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions r--r--r-- catchsql { SELECT * FROM t1 } } {1 {unable to open database file}} do_test tkt3457-1.5 { - file copy -force bak.db-journal test.db-journal + forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions rw-rw-rw- catchsql { SELECT * FROM t1 } } {0 {1 2 3 4 5 6}} finish_test Index: test/tkt35xx.test ================================================================== --- test/tkt35xx.test +++ test/tkt35xx.test @@ -48,11 +48,11 @@ } {} # Trigger the problem using statement rollback. # db close -file delete test.db +delete_file test.db sqlite3 db test.db set big [string repeat abcdefghij 22] ;# 220 byte string do_test tkt35xx-1.2.1 { execsql { PRAGMA auto_vacuum = 0; Index: test/trigger1.test ================================================================== --- test/trigger1.test +++ test/trigger1.test @@ -532,12 +532,12 @@ # Also verify that references within trigger programs are resolved at # statement compile time, not trigger installation time. This means, for # example, that you can drop and re-create tables referenced by triggers. ifcapable tempdb&&attach { do_test trigger1-10.0 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' AS aux; } } {} do_test trigger1-10.1 { Index: test/trigger4.test ================================================================== --- test/trigger4.test +++ test/trigger4.test @@ -128,12 +128,12 @@ } } {7 99} do_test trigger4-4.1 { db close - file delete -force trigtest.db - file delete -force trigtest.db-journal + forcedelete trigtest.db + forcedelete trigtest.db-journal sqlite3 db trigtest.db catchsql {drop table tbl; drop view vw} execsql { create table tbl(a integer primary key, b integer); create view vw as select * from tbl; @@ -193,8 +193,8 @@ execsql {select a, b from vw where a<=102 or a>=227 order by a} } {101 1001 102 2002 227 2127 228 2128} integrity_check trigger4-99.9 db close -file delete -force trigtest.db trigtest.db-journal +forcedelete trigtest.db trigtest.db-journal finish_test Index: test/triggerA.test ================================================================== --- test/triggerA.test +++ test/triggerA.test @@ -203,20 +203,20 @@ source $testdir/malloc_common.tcl # Save a copy of the current database configuration. # db close -file delete -force test.db-triggerA -file copy test.db test.db-triggerA +forcedelete test.db-triggerA +copy_file test.db test.db-triggerA sqlite3 db test.db # Run malloc tests on the INSTEAD OF trigger firing. # do_malloc_test triggerA-3 -tclprep { db close - file delete -force test.db test.db-journal - file copy -force test.db-triggerA test.db + forcedelete test.db test.db-journal + forcecopy test.db-triggerA test.db sqlite3 db test.db sqlite3_extended_result_codes db 1 db eval {SELECT * FROM v5; -- warm up the cache} } -sqlbody { DELETE FROM v5 WHERE x=5; @@ -223,8 +223,8 @@ UPDATE v5 SET b=b+9900000 WHERE x BETWEEN 3 AND 5; } # Clean up the saved database copy. # -file delete -force test.db-triggerA +forcedelete test.db-triggerA finish_test Index: test/triggerC.test ================================================================== --- test/triggerC.test +++ test/triggerC.test @@ -916,11 +916,11 @@ } } {{} {} 1 1} do_test triggerC-12.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); Index: test/triggerD.test ================================================================== --- test/triggerD.test +++ test/triggerD.test @@ -191,11 +191,11 @@ # fix the system so that the "xyz." on "xyz.tab" is ignored. # Verify that this is the case. # do_test triggerD-4.1 { db close - file delete -force test.db test2.db + forcedelete test.db test2.db sqlite3 db test.db db eval { CREATE TABLE t1(x); ATTACH 'test2.db' AS db2; CREATE TABLE db2.t2(y); Index: test/vacuum.test ================================================================== --- test/vacuum.test +++ test/vacuum.test @@ -206,11 +206,11 @@ # pragma is turned on. # do_test vacuum-3.1 { db close db2 close - file delete test.db + delete_file test.db sqlite3 db test.db execsql { PRAGMA empty_result_callbacks=on; VACUUM; } @@ -232,11 +232,11 @@ # a view refers to. Omit this test if the library is not view-enabled. # ifcapable view { do_test vacuum-5.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db catchsql { CREATE TABLE Test (TestID int primary key); INSERT INTO Test VALUES (NULL); CREATE VIEW viewTest AS SELECT * FROM Test; @@ -288,14 +288,14 @@ } } {1} } # Check what happens when an in-memory database is vacuumed. The -# [file delete] command covers us in case the library was compiled +# [delete_file] command covers us in case the library was compiled # without in-memory database support. # -file delete -force :memory: +forcedelete :memory: do_test vacuum-7.0 { sqlite3 db2 :memory: execsql { CREATE TABLE t1(t); VACUUM; @@ -335,12 +335,12 @@ db2 close # Ticket #873. VACUUM a database that has ' in its name. # do_test vacuum-8.1 { - file delete -force a'z.db - file delete -force a'z.db-journal + forcedelete a'z.db + forcedelete a'z.db-journal sqlite3 db2 a'z.db execsql { CREATE TABLE t1(t); VACUUM; } db2 @@ -381,8 +381,8 @@ } cksum } $::cksum } -file delete -force {a'z.db} +forcedelete {a'z.db} finish_test Index: test/vacuum2.test ================================================================== --- test/vacuum2.test +++ test/vacuum2.test @@ -133,11 +133,11 @@ db2 close ifcapable autovacuum { do_test vacuum2-4.1 { db close - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { pragma auto_vacuum=1; create table t(a, b); insert into t values(1, 2); Index: test/vacuum3.test ================================================================== --- test/vacuum3.test +++ test/vacuum3.test @@ -194,11 +194,11 @@ incr I } do_test vacuum3-4.1 { db close - file delete test.db + delete_file test.db sqlite3 db test.db execsql { PRAGMA page_size=1024; CREATE TABLE abc(a, b, c); INSERT INTO abc VALUES(1, 2, 3); Index: test/view.test ================================================================== --- test/view.test +++ test/view.test @@ -456,11 +456,11 @@ } } {1 {parameters are not allowed in views}} ifcapable attach { do_test view-13.1 { - file delete -force test2.db + forcedelete test2.db catchsql { ATTACH 'test2.db' AS two; CREATE TABLE two.t2(x,y); CREATE VIEW v13 AS SELECT y FROM two.t2; } Index: test/vtab1.test ================================================================== --- test/vtab1.test +++ test/vtab1.test @@ -722,12 +722,12 @@ SELECT * FROM techo ORDER BY a; } } {} execsql {PRAGMA count_changes=OFF} -file delete -force test2.db -file delete -force test2.db-journal +forcedelete test2.db +forcedelete test2.db-journal sqlite3 db2 test2.db execsql { CREATE TABLE techo(a PRIMARY KEY, b, c); } db2 proc check_echo_table {tn} { Index: test/vtab7.test ================================================================== --- test/vtab7.test +++ test/vtab7.test @@ -132,12 +132,12 @@ execsql {DROP TABLE newtab} # Write to an attached database from xSync(). ifcapable attach { do_test vtab7-3.1 { - file delete -force test2.db - file delete -force test2.db-journal + forcedelete test2.db + forcedelete test2.db-journal execsql { ATTACH 'test2.db' AS db2; CREATE TABLE db2.stuff(description, shape, color); } set ::callbacks(xSync,abc) { Index: test/vtabC.test ================================================================== --- test/vtabC.test +++ test/vtabC.test @@ -29,11 +29,11 @@ # N will be the number of virtual tables we have defined. # unset -nocomplain N for {set N 1} {$N<=20} {incr N} { db close - file delete -force test.db test.db-journal + forcedelete test.db test.db-journal sqlite3 db test.db register_echo_module [sqlite3_connection_pointer db] # Create $N tables and $N virtual tables to echo them. # Index: test/wal.test ================================================================== --- test/wal.test +++ test/wal.test @@ -23,11 +23,11 @@ ifcapable !wal {finish_test ; return } proc reopen_db {} { catch { db close } - file delete -force test.db test.db-wal test.db-wal-summary + forcedelete test.db test.db-wal test.db-wal-summary sqlite3_wal db test.db } set ::blobcnt 0 proc blob {nByte} { @@ -209,12 +209,12 @@ } {1} do_test wal-4.4.5 { execsql { SELECT count(*) FROM t2 } } {1} do_test wal-4.4.6 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3 db2 test2.db execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2 } {1 2} do_test wal-4.4.7 { execsql { PRAGMA integrity_check } db2 @@ -267,12 +267,12 @@ } {1} do_test wal-4.5.5 { execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } } {1 2} do_test wal-4.5.6 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3 db2 test2.db execsql { SELECT count(*) FROM t2 ; SELECT count(*) FROM t1 } db2 } {1 2} do_test wal-4.5.7 { execsql { PRAGMA integrity_check } db2 @@ -332,11 +332,11 @@ db close foreach sector {512 4096} { sqlite3_simulate_device -sectorsize $sector foreach pgsz {512 1024 2048 4096} { - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal do_test wal-6.$sector.$pgsz.1 { sqlite3 db test.db -vfs devsym execsql " PRAGMA page_size = $pgsz; PRAGMA auto_vacuum = 0; @@ -355,11 +355,11 @@ } {1} } } do_test wal-7.1 { - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal sqlite3_wal db test.db execsql { PRAGMA page_size = 1024; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); @@ -375,11 +375,11 @@ # truncation. # do_test wal-8.1 { reopen_db catch { db close } - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal sqlite3 db test.db db function blob blob execsql { PRAGMA auto_vacuum = 1; @@ -433,13 +433,13 @@ sqlite3_wal db2 test.db execsql {PRAGMA integrity_check } db2 } {ok} do_test wal-9.3 { - file delete -force test2.db test2.db-wal - file copy test.db test2.db - file copy test.db-wal test2.db-wal + forcedelete test2.db test2.db-wal + copy_file test.db test2.db + copy_file test.db-wal test2.db-wal sqlite3_wal db3 test2.db execsql {PRAGMA integrity_check } db3 } {ok} db3 close @@ -784,12 +784,12 @@ do_test wal-12.3 { execsql { INSERT INTO t2 VALUES('B', 1) } list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044] } {3 2} do_test wal-12.4 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3_wal db2 test2.db execsql { SELECT * FROM t2 } db2 } {B 1} db2 close do_test wal-12.5 { @@ -802,12 +802,12 @@ UPDATE t1 SET y = 0 WHERE x = 'A'; } execsql { SELECT * FROM t2 } } {B 2} do_test wal-12.6 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3_wal db2 test2.db execsql { SELECT * FROM t2 } db2 } {B 2} db2 close db close @@ -907,11 +907,11 @@ # operate with an inconsistent cache. Leading to corruption. # catch { db close } catch { db2 close } catch { db3 close } -file delete -force test.db test.db-wal +forcedelete test.db test.db-wal sqlite3 db test.db sqlite3 db2 test.db do_test wal-14 { execsql { PRAGMA journal_mode = WAL; @@ -945,11 +945,11 @@ #------------------------------------------------------------------------- # The following block of tests - wal-15.* - focus on testing the # implementation of the sqlite3_wal_checkpoint() interface. # -file delete -force test.db test.db-wal +forcedelete test.db test.db-wal sqlite3 db test.db do_test wal-15.1 { execsql { PRAGMA auto_vacuum = 0; PRAGMA page_size = 1024; @@ -1041,12 +1041,12 @@ 7 {db eval "PRAGMA main.wal_checkpoint"} {0 10 10} 1 0 8 {db eval "PRAGMA aux.wal_checkpoint"} {0 16 16} 0 1 9 {db eval "PRAGMA temp.wal_checkpoint"} {0 -1 -1} 0 0 } { do_test wal-16.$tn.1 { - file delete -force test2.db test2.db-wal test2.db-journal - file delete -force test.db test.db-wal test.db-journal + forcedelete test2.db test2.db-wal test2.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { ATTACH 'test2.db' AS aux; PRAGMA main.auto_vacuum = 0; @@ -1114,11 +1114,11 @@ 4 1024 [wal_file_size 172 512] 5 2048 [wal_file_size 172 512] 6 4096 [wal_file_size 176 512] 7 8192 [wal_file_size 184 512] " { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3_simulate_device -sectorsize $sectorsize sqlite3 db test.db -vfs devsym do_test wal-17.$tn.1 { execsql { @@ -1158,11 +1158,11 @@ # the second 32-bits are false, and # # wal-18.2.* When the page-size field that occurs at the start of a log # file is a power of 2 greater than 16384 or smaller than 512. # -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal do_test wal-18.0 { sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA auto_vacuum = 0; @@ -1176,12 +1176,12 @@ INSERT INTO t1 VALUES(1, 2); -- frames 1 and 2 INSERT INTO t1 VALUES(3, 4); -- frames 3 and 4 INSERT INTO t1 VALUES(5, 6); -- frames 5 and 6 } - file copy -force test.db testX.db - file copy -force test.db-wal testX.db-wal + forcecopy test.db testX.db + forcecopy test.db-wal testX.db-wal db close list [file size testX.db] [file size testX.db-wal] } [list [expr 3*1024] [wal_file_size 6 1024]] unset -nocomplain nFrame result @@ -1193,12 +1193,12 @@ 4 {0 0 1 2 3 4} 5 {0 0 1 2 3 4} 6 {0 0 1 2 3 4 5 6} } { do_test wal-18.1.$nFrame { - file copy -force testX.db test.db - file copy -force testX.db-wal test.db-wal + forcecopy testX.db test.db + forcecopy testX.db-wal test.db-wal hexio_write test.db-wal [expr 24 + $nFrame*(24+1024) + 20] 00000000 sqlite3 db test.db execsql { @@ -1230,11 +1230,11 @@ set c1 [expr {($c1 + $v1 + $c2)&0xFFFFFFFF}] set c2 [expr {($c2 + $v2 + $c1)&0xFFFFFFFF}] } } -file copy -force test.db testX.db +forcecopy test.db testX.db foreach {tn pgsz works} { 1 128 0 2 256 0 3 512 1 4 1024 1 @@ -1251,12 +1251,12 @@ if {$::SQLITE_MAX_PAGE_SIZE < $pgsz} { set works 0 } for {set pg 1} {$pg <= 3} {incr pg} { - file copy -force testX.db test.db - file delete -force test.db-wal + forcecopy testX.db test.db + forcedelete test.db-wal # Check that the database now exists and consists of three pages. And # that there is no associated wal file. # do_test wal-18.2.$tn.$pg.1 { file exists test.db-wal } 0 @@ -1319,11 +1319,11 @@ # the connection was not updating its private copy of the wal-index # header before doing so, meaning that it could checkpoint an old # snapshot. # do_test wal-19.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db sqlite3 db2 test.db execsql { PRAGMA journal_mode = WAL; CREATE TABLE t1(a, b); @@ -1368,11 +1368,11 @@ # At one point, SQLite was failing to grow the mapping of the wal-index # file in step 3 and the checkpoint was corrupting the database file. # do_test wal-20.1 { catch {db close} - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { PRAGMA journal_mode = WAL; CREATE TABLE t1(x); INSERT INTO t1 VALUES(randomblob(900)); @@ -1474,11 +1474,11 @@ # Test that when 1 or more pages are recovered from a WAL file, # sqlite3_log() is invoked to report this to the user. # set walfile [file nativename [file join [pwd] test.db-wal]] catch {db close} -file delete -force test.db +forcedelete test.db do_test wal-23.1 { faultsim_delete_and_reopen execsql { CREATE TABLE t1(a, b); PRAGMA journal_mode = WAL; Index: test/wal2.test ================================================================== --- test/wal2.test +++ test/wal2.test @@ -162,11 +162,11 @@ } $wal_locks } db close db2 close tvfs delete -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal #------------------------------------------------------------------------- # This test case is very similar to the previous one, except, after # the reader reads the corrupt wal-index header, but before it has # a chance to re-read it under the cover of the RECOVER lock, the @@ -269,11 +269,11 @@ } $res1 } db close db2 close tvfs delete -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal if 0 { #------------------------------------------------------------------------- # This test case - wal2-3.* - tests the response of the library to an @@ -342,11 +342,11 @@ do_test wal2-3.5 { list [info exists ::sabotage] [info exists ::locked] } {0 0} db close tvfs delete -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal } #------------------------------------------------------------------------- # Test that a database connection using a VFS that does not support the @@ -439,11 +439,11 @@ # wal2-6.6.*: Check that if the xShmLock() to reaquire a WAL read-lock when # exiting exclusive mode fails (i.e. SQLITE_IOERR), then the # connection silently remains in exclusive mode. # do_test wal2-6.1.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { Pragma Journal_Mode = Wal; } } {wal} @@ -482,11 +482,11 @@ } } {main shared temp closed} db close do_test wal2-6.2.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { Pragma Locking_Mode = Exclusive; Pragma Journal_Mode = Wal; Pragma Lock_Status; @@ -550,11 +550,11 @@ } } {1 2 3 4 5 6 main shared temp closed} db close do_test wal2-6.3.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { PRAGMA journal_mode = WAL; PRAGMA locking_mode = exclusive; BEGIN; @@ -595,11 +595,11 @@ # This test - wal2-6.4.* - uses a single database connection and the # [testvfs] instrumentation to test that xShmLock() is being called # as expected when a WAL database is used with locking_mode=exclusive. # do_test wal2-6.4.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal proc tvfs_cb {method args} { set ::shm_file [lindex $args 0] if {$method == "xShmLock"} { lappend ::locks [lindex $args 2] } return "SQLITE_OK" } @@ -790,11 +790,11 @@ #------------------------------------------------------------------------- # Test a theory about the checksum algorithm. Theory was false and this # test did not provoke a bug. # -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal do_test wal2-7.1.1 { sqlite3 db test.db execsql { PRAGMA page_size = 4096; PRAGMA journal_mode = WAL; @@ -801,22 +801,22 @@ CREATE TABLE t1(a, b); } file size test.db } {4096} do_test wal2-7.1.2 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal hexio_write test2.db-wal 48 FF } {1} do_test wal2-7.1.3 { sqlite3 db2 test2.db execsql { PRAGMA wal_checkpoint } db2 execsql { SELECT * FROM sqlite_master } db2 } {} db close db2 close -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal do_test wal2-8.1.2 { sqlite3 db test.db execsql { PRAGMA auto_vacuum=OFF; PRAGMA page_size = 1024; @@ -868,11 +868,11 @@ proc get_name {method args} { set ::filename [lindex $args 0] ; tvfs filter {} } testvfs tvfs tvfs script get_name tvfs filter xShmOpen -file delete -force test.db test.db-wal test.db-journal +forcedelete test.db test.db-wal test.db-journal do_test wal2-9.1 { sqlite3 db test.db -vfs tvfs execsql { PRAGMA journal_mode = WAL; CREATE TABLE x(y); Index: test/wal3.test ================================================================== --- test/wal3.test +++ test/wal3.test @@ -92,13 +92,13 @@ } {ok} db2 close # Check that the file-system in its current state can be recovered. # - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal - file delete -force test2.db-journal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal + forcedelete test2.db-journal sqlite3 db2 test2.db do_test wal3-1.$i.5 { execsql { SELECT count(*) FROM t1 } db2 } 4018 do_test wal3-1.$i.6 { @@ -206,11 +206,11 @@ proc sync_counter {args} { foreach {method filename id flags} $args break lappend ::syncs [file tail $filename] $flags } do_test wal3-3.$tn { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal testvfs T T filter {} T script sync_counter sqlite3 db test.db -vfs T @@ -409,11 +409,11 @@ # obtain a different read-lock. # catch {db close} testvfs T -default 1 do_test wal3-6.1.1 { - file delete -force test.db test.db-journal test.db wal + forcedelete test.db test.db-journal test.db wal sqlite3 db test.db execsql { PRAGMA auto_vacuum = off } execsql { PRAGMA journal_mode = WAL } execsql { CREATE TABLE t1(a, b); @@ -490,11 +490,11 @@ db3 close db2 close db close do_test wal3-6.2.1 { - file delete -force test.db test.db-journal test.db wal + forcedelete test.db test.db-journal test.db wal sqlite3 db test.db sqlite3 db2 test.db execsql { PRAGMA auto_vacuum = off } execsql { PRAGMA journal_mode = WAL } execsql { @@ -556,11 +556,11 @@ # read. # catch {db close} testvfs T -default 1 do_test wal3-7.1.1 { - file delete -force test.db test.db-journal test.db wal + forcedelete test.db test.db-journal test.db wal sqlite3 db test.db execsql { PRAGMA journal_mode = WAL; CREATE TABLE blue(red PRIMARY KEY, green); } @@ -613,11 +613,11 @@ T delete #------------------------------------------------------------------------- # do_test wal3-8.1 { - file delete -force test.db test.db-journal test.db wal + forcedelete test.db test.db-journal test.db wal sqlite3 db test.db sqlite3 db2 test.db execsql { PRAGMA auto_vacuum = off; PRAGMA journal_mode = WAL; @@ -707,11 +707,11 @@ # and continues. # set nConn 50 if { [string match *BSD $tcl_platform(os)] } { set nConn 25 } do_test wal3-9.0 { - file delete -force test.db test.db-journal test.db wal + forcedelete test.db test.db-journal test.db wal sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA journal_mode = WAL; CREATE TABLE whoami(x); Index: test/wal4.test ================================================================== --- test/wal4.test +++ test/wal4.test @@ -29,11 +29,11 @@ do_test wal4-1.2 { # Save a copy of the file-system containing the wal and wal-index files # only (no database file). faultsim_save_and_close - file delete -force sv_test.db + forcedelete sv_test.db } {} do_test wal4-1.3 { faultsim_restore_and_reopen catchsql { SELECT * FROM t1 } Index: test/walbak.test ================================================================== --- test/walbak.test +++ test/walbak.test @@ -46,11 +46,11 @@ INSERT INTO t1 VALUES('I', 'one'); COMMIT; } } {wal} do_test walbak-1.1 { - file delete -force bak.db bak.db-journal bak.db-wal + forcedelete bak.db bak.db-journal bak.db-wal db backup bak.db file size bak.db } [expr 3*1024] do_test walbak-1.2 { sqlite3 db2 bak.db @@ -104,11 +104,11 @@ PRAGMA integrity_check; SELECT md5sum(a, b) FROM t1; } } db close -file delete test.db +delete_file test.db sqlite3 db test.db do_test walbak-2.1 { execsql { PRAGMA journal_mode = WAL } execsql { CREATE TABLE t1(a PRIMARY KEY, b); @@ -234,11 +234,11 @@ CREATE TABLE xx(x); } } } { - foreach f [glob -nocomplain test.db*] { file delete -force $f } + foreach f [glob -nocomplain test.db*] { forcedelete $f } eval $setup do_test walbak-3.$tn.1 { execsql { Index: test/walcksum.test ================================================================== --- test/walcksum.test +++ test/walcksum.test @@ -151,11 +151,11 @@ # Create a database. Leave some data in the log file. # do_test walcksum-1.$endian.1 { catch { db close } - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { PRAGMA page_size = 1024; PRAGMA auto_vacuum = 0; PRAGMA synchronous = NORMAL; @@ -170,12 +170,12 @@ INSERT INTO t1 VALUES(8, 'eight'); INSERT INTO t1 VALUES(13, 'thirteen'); INSERT INTO t1 VALUES(21, 'twentyone'); } - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal db close list [file size test2.db] [file size test2.db-wal] } [list [expr 1024*3] [wal_file_size 6 1024]] @@ -197,12 +197,12 @@ log_checksum_write test2.db-wal $f $endian log_checksum_verify test2.db-wal $f $endian } {1} } do_test walcksum-1.$endian.4.1 { - file copy -force test2.db test.db - file copy -force test2.db-wal test.db-wal + forcecopy test2.db test.db + forcecopy test2.db-wal test.db-wal sqlite3 db test.db execsql { SELECT a FROM t1 } } {1 2 3 5 8 13 21} # Following recovery, any frames written to the log should use the same @@ -246,12 +246,12 @@ } # Now that both the recoverer and non-recoverer have added frames to the # log file, check that it can still be recovered. # - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal do_test walcksum-1.$endian.7.11 { sqlite3 db3 test2.db execsql { PRAGMA integrity_check; SELECT a FROM t1; @@ -292,11 +292,11 @@ # back after frames are written to the WAL, and then (after writing some # more) the outer transaction is committed, the WAL file is still correctly # formatted (and can be recovered by a second process if required). # do_test walcksum-2.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { PRAGMA synchronous = NORMAL; PRAGMA page_size = 1024; PRAGMA journal_mode = WAL; @@ -320,12 +320,12 @@ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 128 */ INSERT INTO t1 SELECT randomblob(800) FROM t1; /* 256 */ COMMIT; } - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3 db2 test2.db execsql { PRAGMA integrity_check; SELECT count(*) FROM t1; @@ -338,11 +338,11 @@ # Test case walcksum-3.* tests that the checksum calculation detects single # byte changes to frame or frame-header data and considers the frame # invalid as a result. # do_test walcksum-3.1 { - file delete -force test.db test.db-wal test.db-journal + forcedelete test.db test.db-wal test.db-journal sqlite3 db test.db execsql { PRAGMA synchronous = NORMAL; PRAGMA page_size = 1024; @@ -354,25 +354,25 @@ } file size test.db-wal } [wal_file_size 1 1024] do_test walcksum-3.2 { - file copy -force test.db-wal test2.db-wal - file copy -force test.db test2.db + forcecopy test.db-wal test2.db-wal + forcecopy test.db test2.db sqlite3 db2 test2.db execsql { SELECT a FROM t1 } db2 } {1 2 3} db2 close -file copy -force test.db test2.db +forcecopy test.db test2.db foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} { do_test walcksum-3.3.$incr { set FAIL 0 for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} { - file copy -force test.db-wal test2.db-wal + forcecopy test.db-wal test2.db-wal set fd [open test2.db-wal r+] fconfigure $fd -encoding binary fconfigure $fd -translation binary seek $fd $iOff Index: test/walcrash.test ================================================================== --- test/walcrash.test +++ test/walcrash.test @@ -35,11 +35,11 @@ set REPEATS 100 # walcrash-1.* # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal do_test walcrash-1.$i.1 { crashsql -delay 4 -file test.db-wal -seed [incr seed] { PRAGMA journal_mode = WAL; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 1); @@ -72,11 +72,11 @@ } # walcrash-2.* # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal do_test walcrash-2.$i.1 { crashsql -delay 4 -file test.db-wal -seed [incr seed] { PRAGMA journal_mode = WAL; CREATE TABLE t1(a PRIMARY KEY, b); INSERT INTO t1 VALUES(1, 2); @@ -109,12 +109,12 @@ } # walcrash-3.* # # for {set i 1} {$i < $REPEATS} {incr i} { -# file delete -force test.db test.db-wal -# file delete -force test2.db test2.db-wal +# forcedelete test.db test.db-wal +# forcedelete test2.db test2.db-wal # # do_test walcrash-3.$i.1 { # crashsql -delay 2 -file test2.db-wal -seed [incr seed] { # PRAGMA journal_mode = WAL; # ATTACH 'test2.db' AS aux; @@ -141,12 +141,12 @@ # } # walcrash-4.* # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal - file delete -force test2.db test2.db-wal + forcedelete test.db test.db-wal + forcedelete test2.db test2.db-wal do_test walcrash-4.$i.1 { crashsql -delay 3 -file test.db-wal -seed [incr seed] -blocksize 4096 { PRAGMA journal_mode = WAL; PRAGMA page_size = 1024; @@ -169,12 +169,12 @@ } # walcrash-5.* # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal - file delete -force test2.db test2.db-wal + forcedelete test.db test.db-wal + forcedelete test2.db test2.db-wal do_test walcrash-5.$i.1 { crashsql -delay 11 -file test.db-wal -seed [incr seed] -blocksize 4096 { PRAGMA journal_mode = WAL; PRAGMA page_size = 1024; @@ -210,12 +210,12 @@ } # walcrash-6.* # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal - file delete -force test2.db test2.db-wal + forcedelete test.db test.db-wal + forcedelete test2.db test2.db-wal do_test walcrash-6.$i.1 { crashsql -delay 12 -file test.db-wal -seed [incr seed] -blocksize 512 { PRAGMA journal_mode = WAL; PRAGMA page_size = 1024; @@ -260,11 +260,11 @@ # (b) the database page-size # # based on the log file. # for {set i 1} {$i < $REPEATS} {incr i} { - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal # Select a page-size for this test. # set pgsz [lindex {512 1024 2048 4096 8192 16384} [expr $i%6]] Index: test/walfault.test ================================================================== --- test/walfault.test +++ test/walfault.test @@ -463,11 +463,11 @@ INSERT INTO abc VALUES(randomblob(1500)); INSERT INTO abc VALUES(randomblob(1500)); COMMIT; } faultsim_save_and_close - file delete sv_test.db-shm + delete_file sv_test.db-shm } {} do_faultsim_test walfault-13.1 -prep { faultsim_restore_and_reopen } -body { Index: test/walmode.test ================================================================== --- test/walmode.test +++ test/walmode.test @@ -293,11 +293,11 @@ # Test the effect of a "PRAGMA journal_mode" command being the first # thing executed by a new connection. This means that the schema is not # loaded when sqlite3_prepare_v2() is called to compile the statement. # do_test walmode-7.0 { - file delete -force test.db + forcedelete test.db sqlite3 db test.db execsql { PRAGMA journal_mode = WAL; CREATE TABLE t1(a, b); } Index: test/walnoshm.test ================================================================== --- test/walnoshm.test +++ test/walnoshm.test @@ -85,12 +85,12 @@ INSERT INTO t2 VALUES('e', 'f'); INSERT INTO t2 VALUES('g', 'h'); } {exclusive wal} do_test 2.1.3 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3 db2 test2.db catchsql { SELECT * FROM t2 } db2 } {1 {unable to open database file}} do_test 2.1.4 { catchsql { PRAGMA journal_mode = delete } db2 @@ -102,12 +102,12 @@ SELECT * FROM t2; } db2 } {exclusive delete a b c d e f g h} do_test 2.2.1 { - file copy -force test.db test2.db - file copy -force test.db-wal test2.db-wal + forcecopy test.db test2.db + forcecopy test.db-wal test2.db-wal sqlite3 db3 test2.db -vfs tvfsshm sqlite3 db2 test2.db execsql { SELECT * FROM t2 } db3 } {a b c d e f g h} Index: test/walslow.test ================================================================== --- test/walslow.test +++ test/walslow.test @@ -19,11 +19,11 @@ ifcapable !wal {finish_test ; return } proc reopen_db {} { catch { db close } - file delete -force test.db test.db-wal + forcedelete test.db test.db-wal sqlite3 db test.db execsql { PRAGMA journal_mode = wal } } db close @@ -51,13 +51,13 @@ execsql "PRAGMA wal_checkpoint;" execsql { PRAGMA integrity_check } } {ok} do_test walslow-1.seed=$seed.$iTest.3 { - file delete -force testX.db testX.db-wal - file copy test.db testX.db - file copy test.db-wal testX.db-wal + forcedelete testX.db testX.db-wal + copy_file test.db testX.db + copy_file test.db-wal testX.db-wal sqlite3 db2 testX.db execsql { PRAGMA journal_mode = WAL } db2 execsql { PRAGMA integrity_check } db2 } {ok} Index: test/walthread.test ================================================================== --- test/walthread.test +++ test/walthread.test @@ -127,11 +127,11 @@ } puts "Running $P(testname) for $P(seconds) seconds..." catch { db close } - file delete -force test.db test.db-journal test.db-wal + forcedelete test.db test.db-journal test.db-wal sqlite3 db test.db eval $P(init) catch { db close } @@ -506,16 +506,16 @@ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 32768 */ INSERT INTO t1 SELECT randomblob(900) FROM t1; /* 65536 */ COMMIT; } - file copy -force test.db-wal bak.db-wal - file copy -force test.db bak.db + forcecopy test.db-wal bak.db-wal + forcecopy test.db bak.db db close - file copy -force bak.db-wal test.db-wal - file copy -force bak.db test.db + forcecopy bak.db-wal test.db-wal + forcecopy bak.db test.db if {[file size test.db-wal] < [log_file_size [expr 64*1024] 1024]} { error "Somehow failed to create a large log file" } puts "Database with large log file recovered. Now running clients..." Index: test/win32lock.test ================================================================== --- test/win32lock.test +++ test/win32lock.test @@ -39,67 +39,83 @@ SELECT x, length(y) FROM t1 ORDER BY rowid; } } {1 100000 2 50000 3 25000 4 12500} unset -nocomplain delay1 rc msg -set delay1 50 -set rc 0 set old_pending_byte [sqlite3_test_control_pending_byte 0x40000000] + +set win32_lock_ok [list] +set win32_lock_error [list] +set delay1 25 while {1} { - sqlite3_sleep 10 lock_win32_file test.db 0 $::delay1 + set ::log {} set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg] if {$rc} { - do_test win32lock-1.2-$delay1-fin { + lappend win32_lock_error $::delay1 + do_test win32lock-1.2-$delay1-error { set ::msg } {disk I/O error} - break } else { - do_test win32lock-1.2-$delay1 { + lappend win32_lock_ok $::delay1 + do_test win32lock-1.2-$delay1-ok { set ::msg } {1 100000 2 50000 3 25000 4 12500} if {[info exists ::log] && $::log!=""} { do_test win32lock-1.2-$delay1-log1 { regsub {\d+} $::log # x set x } {{delayed #ms for lock/sharing conflict}} } - incr delay1 50 } - set ::log {} + if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break + incr delay1 25 + sqlite3_sleep 10 } do_test win32lock-2.0 { file_control_win32_av_retry db -1 -1 } {0 10 25} do_test win32lock-2.1 { file_control_win32_av_retry db 1 1 } {0 1 1} -set delay1 50 +# +# NOTE: It is known that the win32lock-2.2-* tests may fail if the system is +# experiencing heavy load (i.e. they are very timing sensitive). This is +# primarily due to the AV retry delay being set to 1 millisecond in the +# win32lock-2.1 test (above). While it is important to test this corner +# case for the AV retry logic, a failure of this test should probably not +# be interpreted as a bug in SQLite or these test cases. +# +set win32_lock_ok [list] +set win32_lock_error [list] +set delay1 1 while {1} { - sqlite3_sleep 10 lock_win32_file test.db 0 $::delay1 + set ::log {} set rc [catch {db eval {SELECT x, length(y) FROM t1 ORDER BY rowid}} msg] if {$rc} { - do_test win32lock-2.2-$delay1-fin { + lappend win32_lock_error $::delay1 + do_test win32lock-2.2-$delay1-error { set ::msg } {disk I/O error} - break } else { - do_test win32lock-2.2-$delay1 { + lappend win32_lock_ok $::delay1 + do_test win32lock-2.2-$delay1-ok { set ::msg } {1 100000 2 50000 3 25000 4 12500} - if {$::log!=""} { + if {[info exists ::log] && $::log!=""} { do_test win32lock-2.2-$delay1-log1 { regsub {\d+} $::log # x set x } {{delayed #ms for lock/sharing conflict}} } - incr delay1 50 } - set ::log {} + if {[llength $win32_lock_ok] && [llength $win32_lock_error]} break + incr delay1 1 + sqlite3_sleep 10 } file_control_win32_av_retry db 10 25 sqlite3_test_control_pending_byte $old_pending_byte sqlite3_shutdown