Merge the latest trunk changes into the sessions branch.
FossilOrigin-Name: eb036d6f81e15bac013316bf5b1b2ba3e0bd4605
This commit is contained in:
+4
-4
@@ -67,8 +67,8 @@ 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;
|
||||
@@ -101,8 +101,8 @@ 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;
|
||||
|
||||
+4
-4
@@ -221,8 +221,8 @@ do_test alter-1.7 {
|
||||
#
|
||||
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;
|
||||
}
|
||||
@@ -412,8 +412,8 @@ do_test alter-3.1.8 {
|
||||
|
||||
# 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 {
|
||||
|
||||
+2
-2
@@ -315,8 +315,8 @@ do_test alter2-6.1 {
|
||||
} {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);
|
||||
|
||||
+3
-3
@@ -196,7 +196,7 @@ ifcapable schema_version {
|
||||
|
||||
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;
|
||||
@@ -237,8 +237,8 @@ do_test alter3-4.99 {
|
||||
|
||||
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');
|
||||
|
||||
+3
-3
@@ -178,7 +178,7 @@ ifcapable schema_version {
|
||||
|
||||
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);
|
||||
@@ -213,8 +213,8 @@ do_test alter4-4.99 {
|
||||
|
||||
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');
|
||||
|
||||
@@ -287,6 +287,64 @@ do_test analyze-4.3 {
|
||||
}
|
||||
} {}
|
||||
|
||||
# Verify that DROP TABLE and DROP INDEX remove entries from the
|
||||
# sqlite_stat1 and sqlite_stat2 tables.
|
||||
#
|
||||
do_test analyze-5.0 {
|
||||
execsql {
|
||||
DELETE FROM t3;
|
||||
DELETE FROM t4;
|
||||
INSERT INTO t3 VALUES(1,2,3,4);
|
||||
INSERT INTO t3 VALUES(5,6,7,8);
|
||||
INSERT INTO t3 SELECT a+8, b+8, c+8, d+8 FROM t3;
|
||||
INSERT INTO t3 SELECT a+16, b+16, c+16, d+16 FROM t3;
|
||||
INSERT INTO t3 SELECT a+32, b+32, c+32, d+32 FROM t3;
|
||||
INSERT INTO t3 SELECT a+64, b+64, c+64, d+64 FROM t3;
|
||||
INSERT INTO t4 SELECT a, b, c FROM t3;
|
||||
ANALYZE;
|
||||
SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
|
||||
}
|
||||
} {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}
|
||||
ifcapable stat2 {
|
||||
do_test analyze-5.1 {
|
||||
execsql {
|
||||
SELECT DISTINCT idx FROM sqlite_stat2 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat2 ORDER BY 1;
|
||||
}
|
||||
} {t3i1 t3i2 t3i3 t4i1 t4i2 t3 t4}
|
||||
}
|
||||
do_test analyze-5.2 {
|
||||
execsql {
|
||||
DROP INDEX t3i2;
|
||||
SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
|
||||
}
|
||||
} {t3i1 t3i3 t4i1 t4i2 t3 t4}
|
||||
ifcapable stat2 {
|
||||
do_test analyze-5.3 {
|
||||
execsql {
|
||||
SELECT DISTINCT idx FROM sqlite_stat2 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat2 ORDER BY 1;
|
||||
}
|
||||
} {t3i1 t3i3 t4i1 t4i2 t3 t4}
|
||||
}
|
||||
do_test analyze-5.4 {
|
||||
execsql {
|
||||
DROP TABLE t3;
|
||||
SELECT DISTINCT idx FROM sqlite_stat1 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat1 ORDER BY 1;
|
||||
}
|
||||
} {t4i1 t4i2 t4}
|
||||
ifcapable stat2 {
|
||||
do_test analyze-5.5 {
|
||||
execsql {
|
||||
SELECT DISTINCT idx FROM sqlite_stat2 ORDER BY 1;
|
||||
SELECT DISTINCT tbl FROM sqlite_stat2 ORDER BY 1;
|
||||
}
|
||||
} {t4i1 t4i2 t4}
|
||||
}
|
||||
|
||||
# This test corrupts the database file so it must be the last test
|
||||
# in the series.
|
||||
#
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
|
||||
|
||||
# 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
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ foreach err [list ioerr malloc-transient malloc-persistent] {
|
||||
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
|
||||
|
||||
+2
-2
@@ -41,8 +41,8 @@ set paths {
|
||||
|
||||
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 {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ if {[info commands sqlite3async_initialize] eq ""} {
|
||||
}
|
||||
|
||||
db close
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
sqlite3async_initialize "" 1
|
||||
sqlite3async_control halt never
|
||||
sqlite3 db test.db
|
||||
|
||||
+11
-11
@@ -24,8 +24,8 @@ ifcapable !attach {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -628,7 +628,7 @@ 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;
|
||||
@@ -725,7 +725,7 @@ if {$tcl_platform(platform)=="unix"} {
|
||||
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 {
|
||||
@@ -735,7 +735,7 @@ if {$tcl_platform(platform)=="unix"} {
|
||||
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
|
||||
@@ -749,12 +749,12 @@ 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
|
||||
@@ -777,7 +777,7 @@ do_test attach-8.1 {
|
||||
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}
|
||||
@@ -789,13 +789,13 @@ 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);
|
||||
|
||||
+4
-4
@@ -33,8 +33,8 @@ do_test attach2-1.1 {
|
||||
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);
|
||||
@@ -327,7 +327,7 @@ do_test attach2-4.15 {
|
||||
|
||||
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
|
||||
@@ -335,7 +335,7 @@ sqlite3_soft_heap_limit $soft_limit
|
||||
#
|
||||
# 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 {
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ execsql {
|
||||
}
|
||||
|
||||
# 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);
|
||||
|
||||
@@ -29,8 +29,8 @@ 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}]} {
|
||||
@@ -48,8 +48,8 @@ do_malloc_test attachmalloc-1 -tclprep {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
+3
-3
@@ -427,8 +427,8 @@ ifcapable tempdb {
|
||||
#
|
||||
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);
|
||||
@@ -520,7 +520,7 @@ do_test autoinc-7.2 {
|
||||
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 {
|
||||
|
||||
@@ -467,7 +467,7 @@ do_test autovacuum-3.3 {
|
||||
|
||||
do_test autovacuum-3.4 {
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
PRAGMA auto_vacuum;
|
||||
@@ -502,7 +502,7 @@ do_test autovacuum-4.0 {
|
||||
# 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;
|
||||
@@ -599,8 +599,8 @@ do_test autovacuum-6.1 {
|
||||
#
|
||||
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 {
|
||||
|
||||
@@ -75,7 +75,7 @@ do_ioerr_test autovacuum-ioerr2-3 -sqlprep {
|
||||
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]} {
|
||||
@@ -99,9 +99,9 @@ ifcapable subquery {
|
||||
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;
|
||||
|
||||
@@ -61,7 +61,7 @@ foreach bin $binaries {
|
||||
|
||||
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]
|
||||
@@ -152,7 +152,7 @@ proc read_file_system {} {
|
||||
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
|
||||
}
|
||||
|
||||
+26
-26
@@ -73,7 +73,7 @@ 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}
|
||||
@@ -168,8 +168,8 @@ 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
|
||||
@@ -279,8 +279,8 @@ 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
|
||||
|
||||
@@ -327,8 +327,8 @@ foreach nDestPgsz {512 1024 2048 4096} {
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
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
|
||||
|
||||
@@ -392,8 +392,8 @@ do_test backup-4.1.4 {
|
||||
} {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);
|
||||
@@ -439,7 +439,7 @@ 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 {
|
||||
@@ -491,12 +491,12 @@ db2 close
|
||||
# 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
|
||||
|
||||
@@ -597,9 +597,9 @@ foreach {writer file} {db test.db db3 test.db db :memory:} {
|
||||
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 {
|
||||
@@ -644,8 +644,8 @@ foreach {writer file} {db test.db db3 test.db db :memory:} {
|
||||
# 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 {
|
||||
@@ -701,8 +701,8 @@ catch {db2 close}
|
||||
# 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 {
|
||||
@@ -754,7 +754,7 @@ 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
|
||||
|
||||
@@ -783,8 +783,8 @@ catch { db3 close }
|
||||
# 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
|
||||
|
||||
@@ -865,8 +865,8 @@ 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
|
||||
@@ -918,7 +918,7 @@ ifcapable memorymanage {
|
||||
# 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
|
||||
@@ -948,7 +948,7 @@ foreach {tn file rc} {
|
||||
} {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
|
||||
|
||||
+9
-9
@@ -61,7 +61,7 @@ set cksum [dbcksum db main]
|
||||
# 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
|
||||
@@ -72,7 +72,7 @@ do_test backup2-2 {
|
||||
#
|
||||
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]
|
||||
@@ -82,7 +82,7 @@ do_test backup2-3.1 {
|
||||
} {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
|
||||
@@ -96,7 +96,7 @@ do_test backup2-4 {
|
||||
} $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
|
||||
@@ -127,7 +127,7 @@ do_test backup2-7 {
|
||||
# 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}}
|
||||
@@ -143,7 +143,7 @@ do_test backup2-9 {
|
||||
#
|
||||
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
|
||||
@@ -151,7 +151,7 @@ if {$tcl_platform(platform)=="windows"} {
|
||||
}
|
||||
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
|
||||
@@ -172,7 +172,7 @@ do_test backup2-12 {
|
||||
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}}
|
||||
@@ -184,6 +184,6 @@ do_test backup2-14 {
|
||||
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
|
||||
|
||||
@@ -60,7 +60,7 @@ do_test backup_ioerr-1.2 {
|
||||
} {1}
|
||||
do_test backup_ioerr-1.3 {
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
} {}
|
||||
|
||||
# Turn off IO error simulation.
|
||||
@@ -155,8 +155,8 @@ for {set iError 1} {$bStop == 0} {incr iError} {
|
||||
|
||||
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
|
||||
|
||||
+4
-4
@@ -697,7 +697,7 @@ 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);
|
||||
@@ -722,7 +722,7 @@ if {![sqlite3 -has-codec]} {
|
||||
# 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);
|
||||
@@ -739,8 +739,8 @@ if {![sqlite3 -has-codec]} {
|
||||
} {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
|
||||
|
||||
+4
-4
@@ -670,7 +670,7 @@ 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);
|
||||
@@ -695,7 +695,7 @@ if {![sqlite3 -has-codec]} {
|
||||
# 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);
|
||||
@@ -712,8 +712,8 @@ if {![sqlite3 -has-codec]} {
|
||||
} {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
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ do_test collate7-1.4 {
|
||||
} {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 {
|
||||
|
||||
+10
-22
@@ -15,7 +15,7 @@
|
||||
#
|
||||
# $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
|
||||
@@ -51,22 +51,10 @@ do_test corrupt-1.1 {
|
||||
} {}
|
||||
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}
|
||||
@@ -79,7 +67,7 @@ set junk [string range $junk 0 255]
|
||||
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
|
||||
@@ -132,7 +120,7 @@ for {set i [expr {1*256}]} {$i<$fsize-256} {incr i 256} {
|
||||
#
|
||||
do_test corrupt-3.1 {
|
||||
db close
|
||||
copy_file test.bu test.db
|
||||
forcecopy test.bu test.db
|
||||
sqlite3 db test.db
|
||||
list
|
||||
} {}
|
||||
@@ -181,7 +169,7 @@ do_test corrupt-3.6 {
|
||||
|
||||
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;
|
||||
@@ -213,7 +201,7 @@ do_test corrupt-4.2 {
|
||||
|
||||
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 }
|
||||
@@ -236,7 +224,7 @@ do_test corrupt-5.2 {
|
||||
# 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);
|
||||
@@ -264,7 +252,7 @@ do_test corrupt-6.1 {
|
||||
|
||||
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);
|
||||
@@ -317,7 +305,7 @@ ifcapable oversize_cell_check {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -335,7 +323,7 @@ do_test corrupt-8.1 {
|
||||
} {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 {
|
||||
|
||||
+21
-21
@@ -41,9 +41,9 @@ do_test corrupt2-1.1 {
|
||||
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
|
||||
@@ -60,9 +60,9 @@ 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
|
||||
@@ -80,9 +80,9 @@ 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
|
||||
@@ -100,9 +100,9 @@ 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
|
||||
@@ -123,9 +123,9 @@ 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 "
|
||||
@@ -150,8 +150,8 @@ do_test corrupt2-2.1 {
|
||||
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 "
|
||||
@@ -200,8 +200,8 @@ 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 "
|
||||
@@ -257,8 +257,8 @@ proc corruption_test {args} {
|
||||
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
|
||||
|
||||
+3
-3
@@ -86,7 +86,7 @@ integrity_check corrupt9-1.2
|
||||
# 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
|
||||
@@ -103,7 +103,7 @@ do_test corrupt9-2.2 {
|
||||
|
||||
|
||||
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 {
|
||||
@@ -118,7 +118,7 @@ do_test corrupt9-3.2 {
|
||||
} {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 {
|
||||
|
||||
+5
-5
@@ -40,12 +40,12 @@ integrity_check corruptA-1.2
|
||||
# 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}
|
||||
@@ -53,7 +53,7 @@ do_test corruptA-2.1 {
|
||||
|
||||
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}
|
||||
@@ -61,7 +61,7 @@ do_test corruptA-2.2 {
|
||||
|
||||
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}
|
||||
@@ -69,7 +69,7 @@ do_test corruptA-2.3 {
|
||||
|
||||
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}
|
||||
|
||||
+8
-8
@@ -46,7 +46,7 @@ do_test corruptB-1.1 {
|
||||
} {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.
|
||||
#
|
||||
@@ -65,7 +65,7 @@ do_test corruptB-1.3.2 {
|
||||
#
|
||||
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}
|
||||
@@ -78,7 +78,7 @@ do_test corruptB-1.4.2 {
|
||||
#
|
||||
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;
|
||||
@@ -91,7 +91,7 @@ do_test corruptB-1.5.1 {
|
||||
}
|
||||
} {}
|
||||
|
||||
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.
|
||||
@@ -112,7 +112,7 @@ do_test corruptB-1.6.2 {
|
||||
#
|
||||
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}
|
||||
@@ -140,7 +140,7 @@ do_test corruptB-1.8.2 {
|
||||
#
|
||||
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}
|
||||
@@ -153,7 +153,7 @@ do_test corruptB-1.9.2 {
|
||||
|
||||
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 {
|
||||
@@ -167,7 +167,7 @@ do_test corruptB-2.1.2 {
|
||||
#
|
||||
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 {
|
||||
|
||||
+18
-24
@@ -17,7 +17,7 @@
|
||||
#
|
||||
# $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
|
||||
@@ -58,16 +58,10 @@ 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]
|
||||
|
||||
@@ -92,7 +86,7 @@ expr srand($qseed)
|
||||
# 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]
|
||||
@@ -104,7 +98,7 @@ do_test corruptC-2.1 {
|
||||
# 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]
|
||||
@@ -125,7 +119,7 @@ do_test corruptC-2.2 {
|
||||
# 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]
|
||||
@@ -137,7 +131,7 @@ do_test corruptC-2.3 {
|
||||
# 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]
|
||||
@@ -149,7 +143,7 @@ do_test corruptC-2.4 {
|
||||
# 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]
|
||||
@@ -169,7 +163,7 @@ Page 4: btreeInitPage() returns error code 11}}}
|
||||
# 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]
|
||||
@@ -182,7 +176,7 @@ do_test corruptC-2.6 {
|
||||
# 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]
|
||||
@@ -194,7 +188,7 @@ do_test corruptC-2.7 {
|
||||
# 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]
|
||||
@@ -210,7 +204,7 @@ do_test corruptC-2.8 {
|
||||
# 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]
|
||||
@@ -222,7 +216,7 @@ do_test corruptC-2.9 {
|
||||
# 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]
|
||||
@@ -234,7 +228,7 @@ do_test corruptC-2.10 {
|
||||
# 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]
|
||||
@@ -246,7 +240,7 @@ do_test corruptC-2.11 {
|
||||
# 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]
|
||||
@@ -258,7 +252,7 @@ do_test corruptC-2.12 {
|
||||
# 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]
|
||||
@@ -269,7 +263,7 @@ do_test corruptC-2.13 {
|
||||
|
||||
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]
|
||||
@@ -286,7 +280,7 @@ do_test corruptC-2.14 {
|
||||
#
|
||||
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;}
|
||||
@@ -300,7 +294,7 @@ 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
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ do_test corruptD-1.0 {
|
||||
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 {} {
|
||||
@@ -96,7 +96,7 @@ proc incr_change_counter {} {
|
||||
|
||||
proc restore_file {} {
|
||||
db close
|
||||
copy_file test.bu test.db
|
||||
forcecopy test.bu test.db
|
||||
sqlite3 db test.db
|
||||
}
|
||||
|
||||
|
||||
+7
-13
@@ -16,7 +16,7 @@
|
||||
#
|
||||
# $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
|
||||
@@ -60,23 +60,17 @@ 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]
|
||||
@@ -92,7 +86,7 @@ do_test corruptE-2.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]
|
||||
@@ -108,7 +102,7 @@ do_test corruptE-2.2 {
|
||||
|
||||
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]
|
||||
@@ -124,7 +118,7 @@ do_test corruptE-2.3 {
|
||||
|
||||
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]
|
||||
@@ -165,7 +159,7 @@ 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]]
|
||||
|
||||
+3
-3
@@ -215,8 +215,8 @@ for {set i 1} {$i < $repeats} {incr i} {
|
||||
#
|
||||
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;
|
||||
@@ -318,7 +318,7 @@ ifcapable attach {
|
||||
# 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 {
|
||||
|
||||
+3
-3
@@ -73,7 +73,7 @@ foreach {sql res2} [list \
|
||||
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 {
|
||||
@@ -106,7 +106,7 @@ foreach {sql res2} [list \
|
||||
# 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 {
|
||||
@@ -177,7 +177,7 @@ foreach {::crashfile ::delay ::char} {
|
||||
#
|
||||
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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ foreach cmd $sql_cmd_list {
|
||||
#
|
||||
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}]
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ for {set ii 0} {$ii < 10} {incr ii} {
|
||||
# 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 {
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ ifcapable !crashtest {
|
||||
|
||||
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;
|
||||
@@ -40,7 +40,7 @@ for {set ii 0} {$ii < 10} {incr 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;
|
||||
@@ -66,7 +66,7 @@ proc signature {} {
|
||||
#
|
||||
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)]
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ proc signature {} {
|
||||
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)]
|
||||
|
||||
+7
-7
@@ -243,7 +243,7 @@ do_test crash8-3.11 {
|
||||
#
|
||||
ifcapable pragma {
|
||||
reset_db
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
|
||||
do_test crash8-4.1 {
|
||||
execsql {
|
||||
@@ -336,14 +336,14 @@ ifcapable pragma {
|
||||
} {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 {
|
||||
@@ -367,7 +367,7 @@ for {set i 1} {$i < 10} {incr i} {
|
||||
} {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 {
|
||||
@@ -383,9 +383,9 @@ for {set i 1} {$i < 10} {incr i} {
|
||||
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] {
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ ifcapable 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
|
||||
|
||||
@@ -223,5 +223,16 @@ do_test ctime-2.5.$tc {
|
||||
} ]
|
||||
} {0 {{}}}
|
||||
|
||||
ifcapable blockalloc {
|
||||
do_test ctime-3.1a {
|
||||
db eval {SELECT sqlite_compileoption_used('PAGECACHE_BLOCKALLOC')}
|
||||
} {1}
|
||||
} else {
|
||||
do_test ctime-3.1b {
|
||||
db eval {SELECT sqlite_compileoption_used('PAGECACHE_BLOCKALLOC')}
|
||||
} {0}
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ foreach ::lookaside_buffer_size {0 64 120} {
|
||||
|
||||
# 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
|
||||
@@ -287,7 +287,7 @@ foreach ::lookaside_buffer_size {0 64 120} {
|
||||
|
||||
# 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
|
||||
|
||||
+3
-3
@@ -275,7 +275,7 @@ do_test delete-8.0 {
|
||||
}
|
||||
} {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
|
||||
@@ -312,12 +312,12 @@ do_test delete-8.6 {
|
||||
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
|
||||
|
||||
+3
-3
@@ -297,14 +297,14 @@ do_test descidx1-5.9 {
|
||||
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}
|
||||
@@ -328,7 +328,7 @@ ifcapable vacuum {
|
||||
}
|
||||
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}
|
||||
|
||||
+2
-2
@@ -82,8 +82,8 @@ proc do_diskfull_test {prefix sql} {
|
||||
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 {
|
||||
|
||||
+3
-3
@@ -657,7 +657,7 @@ 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);
|
||||
@@ -1675,7 +1675,7 @@ db3 close
|
||||
# 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 {
|
||||
@@ -1756,7 +1756,7 @@ foreach {tn e1 e2} {
|
||||
#
|
||||
|
||||
catch { db close }
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
do_test e_expr-35.0 {
|
||||
execsql {
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ foreach {DO_MALLOC_TEST enc} {
|
||||
# [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'"
|
||||
@@ -637,7 +637,7 @@ read_test 8.2.2 { PRAGMA table_info(t9c) } {0 c\"1 {} 0 {} 0 1 c'2 {} 0 {} 0}
|
||||
#
|
||||
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 }
|
||||
|
||||
|
||||
+13
-13
@@ -142,7 +142,7 @@ 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
|
||||
@@ -172,13 +172,13 @@ foreach enc $encodings {
|
||||
# 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);"
|
||||
@@ -206,7 +206,7 @@ proc test_collate {enc lhs rhs} {
|
||||
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 {
|
||||
@@ -235,7 +235,7 @@ do_test enc2-5.3 {
|
||||
} {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 {
|
||||
@@ -265,7 +265,7 @@ do_test enc2-5.7 {
|
||||
} {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 {
|
||||
@@ -311,7 +311,7 @@ do_test enc2-5.14 {
|
||||
} 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]
|
||||
@@ -333,7 +333,7 @@ proc test_function {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 {
|
||||
@@ -366,7 +366,7 @@ do_test enc2-6.3 {
|
||||
} {{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 {
|
||||
@@ -399,7 +399,7 @@ do_test enc2-6.6 {
|
||||
} {{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 {
|
||||
@@ -433,7 +433,7 @@ do_test enc2-6.10 {
|
||||
|
||||
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
|
||||
# The following tests - enc2-7.* - function as follows:
|
||||
#
|
||||
@@ -493,7 +493,7 @@ ifcapable {complete} {
|
||||
|
||||
# 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 {
|
||||
@@ -537,7 +537,7 @@ do_test enc2-9.5 {
|
||||
#
|
||||
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;
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ ifcapable {bloblit && utf16} {
|
||||
#
|
||||
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
|
||||
@@ -100,7 +100,7 @@ ifcapable {utf16 && shared_cache} {
|
||||
} 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
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ set vals [list\
|
||||
set i 1
|
||||
foreach enc $encodings {
|
||||
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
db eval "PRAGMA encoding = \"$enc\""
|
||||
|
||||
@@ -93,7 +93,7 @@ foreach enc $encodings {
|
||||
incr i
|
||||
}
|
||||
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
do_test enc4-4.1 {
|
||||
|
||||
+8
-8
@@ -22,12 +22,12 @@ ifcapable {!pager_pragmas} {
|
||||
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.
|
||||
@@ -481,8 +481,8 @@ do_execsql_test exclusive-6.1 {
|
||||
}
|
||||
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
|
||||
} {}
|
||||
|
||||
|
||||
@@ -259,8 +259,8 @@ do_test exclusive2-2.8 {
|
||||
|
||||
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
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ 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]
|
||||
|
||||
|
||||
+1
-1
@@ -37,5 +37,5 @@ do_test filectrl-1.5 {
|
||||
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
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@ source $testdir/tester.tcl
|
||||
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.
|
||||
#
|
||||
@@ -63,7 +63,7 @@ ifcapable pager_pragmas {
|
||||
&& $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"
|
||||
@@ -105,7 +105,7 @@ do_test filefmt-1.7 {
|
||||
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
|
||||
@@ -125,7 +125,7 @@ ifcapable pager_pragmas {
|
||||
# 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} {
|
||||
@@ -157,7 +157,7 @@ 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
|
||||
|
||||
|
||||
+3
-3
@@ -19,8 +19,8 @@ ifcapable !fts1 {
|
||||
}
|
||||
|
||||
# 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 {
|
||||
@@ -84,6 +84,6 @@ do_test fts1j-1.3 {
|
||||
catch {db eval {DETACH DATABASE two}}
|
||||
|
||||
catch {db2 close}
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ do_test fts1o-3.6 {
|
||||
# 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 {
|
||||
|
||||
+3
-3
@@ -19,8 +19,8 @@ ifcapable !fts2 {
|
||||
}
|
||||
|
||||
# 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 {
|
||||
@@ -84,6 +84,6 @@ do_test fts2j-1.3 {
|
||||
catch {db eval {DETACH DATABASE two}}
|
||||
|
||||
catch {db2 close}
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ do_test fts2o-2.12 {
|
||||
# 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 {
|
||||
@@ -134,7 +134,7 @@ do_test fts2o-3.2 {
|
||||
# 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 {
|
||||
|
||||
+3
-3
@@ -19,8 +19,8 @@ ifcapable !fts3 {
|
||||
}
|
||||
|
||||
# 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 {
|
||||
@@ -84,6 +84,6 @@ do_test fts3aj-1.3 {
|
||||
catch {db eval {DETACH DATABASE two}}
|
||||
|
||||
catch {db2 close}
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ do_test fts3ao-2.12 {
|
||||
# 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 {
|
||||
@@ -136,7 +136,7 @@ do_test fts3ao-3.2 {
|
||||
# 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 {
|
||||
|
||||
@@ -131,7 +131,7 @@ foreach {DO_MALLOC_TEST enc} {
|
||||
} {
|
||||
|
||||
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\""
|
||||
|
||||
+1
-1
@@ -1686,7 +1686,7 @@ foreach {q r} [array get fts4aa_res] {
|
||||
#
|
||||
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;
|
||||
|
||||
@@ -47,7 +47,7 @@ proc do_fuzzy_malloc_test {testname 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
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ do_test hook-3.9 {
|
||||
# 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}]
|
||||
@@ -218,7 +218,7 @@ ifcapable trigger {
|
||||
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);
|
||||
|
||||
+3
-3
@@ -120,7 +120,7 @@ foreach AutoVacuumMode [list 0 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 = $AutoVacuumMode"
|
||||
@@ -379,7 +379,7 @@ ifcapable vtab {
|
||||
#
|
||||
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;
|
||||
@@ -584,7 +584,7 @@ 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 {
|
||||
|
||||
@@ -331,7 +331,7 @@ proc compare_dbs {A B tname} {
|
||||
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
|
||||
@@ -475,7 +475,7 @@ do_test incrvacuum-8.1 {
|
||||
#
|
||||
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 {
|
||||
@@ -593,7 +593,7 @@ do_test incrvacuum-10.8 {
|
||||
# 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 {
|
||||
@@ -651,7 +651,7 @@ do_test incrvacuum-11.7 {
|
||||
# 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 {
|
||||
@@ -692,7 +692,7 @@ do_test incrvacuum-12.5 {
|
||||
#
|
||||
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
|
||||
|
||||
@@ -743,7 +743,7 @@ if {[permutation] == ""} {
|
||||
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]
|
||||
|
||||
@@ -70,7 +70,7 @@ do_test incrvacuum2-1.4 {
|
||||
#
|
||||
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;
|
||||
|
||||
@@ -108,7 +108,7 @@ do_ioerr_test incrvacuum-ioerr-3 -start 1 -cksum 1 -tclprep {
|
||||
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:
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# 2011 July 9
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CREATE INDEX statement.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
set testprefix index4
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(102));
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 64
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 128
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 256
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 512
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 1024
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 2048
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 4096
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 8192
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 16384
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 32768
|
||||
INSERT INTO t1 SELECT randomblob(102) FROM t1; -- 65536
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
}
|
||||
do_execsql_test 1.3 {
|
||||
PRAGMA integrity_check
|
||||
} {ok}
|
||||
|
||||
# The same test again - this time with limited memory.
|
||||
#
|
||||
ifcapable memorymanage {
|
||||
set soft_limit [sqlite3_soft_heap_limit 50000]
|
||||
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
|
||||
do_execsql_test 1.4 {
|
||||
PRAGMA cache_size = 10;
|
||||
CREATE INDEX i2 ON t1(x);
|
||||
}
|
||||
do_execsql_test 1.5 {
|
||||
PRAGMA integrity_check
|
||||
} {ok}
|
||||
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
|
||||
do_execsql_test 1.6 {
|
||||
BEGIN;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES('a');
|
||||
INSERT INTO t1 VALUES('b');
|
||||
INSERT INTO t1 VALUES('c');
|
||||
INSERT INTO t1 VALUES('d');
|
||||
INSERT INTO t1 VALUES('e');
|
||||
INSERT INTO t1 VALUES('f');
|
||||
INSERT INTO t1 VALUES('g');
|
||||
INSERT INTO t1 VALUES(NULL);
|
||||
INSERT INTO t1 SELECT randomblob(1202) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(2202) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(3202) FROM t1; -- 64
|
||||
INSERT INTO t1 SELECT randomblob(4202) FROM t1; -- 128
|
||||
INSERT INTO t1 SELECT randomblob(5202) FROM t1; -- 256
|
||||
COMMIT;
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
PRAGMA integrity_check
|
||||
} {ok}
|
||||
|
||||
do_execsql_test 1.7 {
|
||||
BEGIN;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES('a');
|
||||
COMMIT;
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
PRAGMA integrity_check
|
||||
} {ok}
|
||||
|
||||
do_execsql_test 1.8 {
|
||||
BEGIN;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(x);
|
||||
COMMIT;
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
PRAGMA integrity_check
|
||||
} {ok}
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,342 @@
|
||||
# 2011 August 08
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
|
||||
ifcapable !mergesort {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
set testprefix indexfault
|
||||
|
||||
# Set up the custom fault-injector. This is further configured by using
|
||||
# different values for $::custom_filter and different implementations
|
||||
# of Tcl proc [xCustom] for each test case.
|
||||
#
|
||||
proc install_custom_faultsim {} {
|
||||
set ::FAULTSIM(custom) [list \
|
||||
-injectinstall custom_injectinstall \
|
||||
-injectstart custom_injectstart \
|
||||
-injectstop custom_injectstop \
|
||||
-injecterrlist {{1 {disk I/O error}}} \
|
||||
-injectuninstall custom_injectuninstall \
|
||||
]
|
||||
proc custom_injectinstall {} {
|
||||
testvfs shmfault -default true
|
||||
shmfault filter $::custom_filter
|
||||
shmfault script xCustom
|
||||
}
|
||||
proc custom_injectuninstall {} {
|
||||
catch {db close}
|
||||
catch {db2 close}
|
||||
shmfault delete
|
||||
}
|
||||
set ::custom_ifail -1
|
||||
set ::custom_nfail -1
|
||||
proc custom_injectstart {iFail} {
|
||||
set ::custom_ifail $iFail
|
||||
set ::custom_nfail 0
|
||||
}
|
||||
proc custom_injectstop {} {
|
||||
set ::custom_ifail -1
|
||||
return $::custom_nfail
|
||||
}
|
||||
}
|
||||
proc uninstall_custom_faultsim {} {
|
||||
unset -nocomplain ::FAULTSIM(custom)
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# These tests - indexfault-1.* - Build an index on a smallish table with
|
||||
# all different kinds of fault-injection. The CREATE INDEX is run once
|
||||
# with default options and once with a 50KB soft-heap-limit.
|
||||
#
|
||||
do_execsql_test 1.0 {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(202));
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 64
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 128
|
||||
INSERT INTO t1 SELECT randomblob(202) FROM t1; -- 256
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test 1.1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_integrity_check
|
||||
}
|
||||
ifcapable memorymanage {
|
||||
set soft_limit [sqlite3_soft_heap_limit 50000]
|
||||
do_faultsim_test 2.1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# These are similar to the indexfault-1.* tests, except they create an
|
||||
# index with more than one column.
|
||||
#
|
||||
sqlite3 db test.db
|
||||
do_execsql_test 2.0 {
|
||||
BEGIN;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(t,u,v,w,x,y,z);
|
||||
INSERT INTO t1 VALUES(
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30)
|
||||
);
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 64
|
||||
INSERT INTO t1 SELECT
|
||||
randomblob(30), randomblob(30), randomblob(30), randomblob(30),
|
||||
randomblob(30), randomblob(30), randomblob(30) FROM t1; -- 128
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
do_faultsim_test 2.1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_integrity_check
|
||||
}
|
||||
ifcapable memorymanage {
|
||||
set soft_limit [sqlite3_soft_heap_limit 50000]
|
||||
do_faultsim_test 2.2 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(t,u,v,w,x,y,z) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The following tests - indexfault-2.* - all attempt to build a index
|
||||
# on table t1 in the main database with injected IO errors. Individual
|
||||
# test cases work as follows:
|
||||
#
|
||||
# 3.1: IO errors injected into xOpen() calls.
|
||||
# 3.2: As 7.1, but with a low (50KB) soft-heap-limit.
|
||||
#
|
||||
# 3.3: IO errors injected into the first 200 write() calls made on the
|
||||
# second temporary file.
|
||||
# 3.4: As 7.3, but with a low (50KB) soft-heap-limit.
|
||||
#
|
||||
# 3.5: After a certain amount of data has been read from the main database
|
||||
# file (and written into the temporary b-tree), sqlite3_release_memory()
|
||||
# is called to free as much memory as possible. This causes the temp
|
||||
# b-tree to be flushed to disk. So that before its contents can be
|
||||
# transfered to a PMA they must be read back from disk - creating extra
|
||||
# opportunities for IO errors.
|
||||
#
|
||||
install_custom_faultsim
|
||||
|
||||
# Set up a table to build indexes on. Save the setup using the
|
||||
# [faultsim_save_and_close] mechanism.
|
||||
#
|
||||
sqlite3 db test.db
|
||||
do_execsql_test 3.0 {
|
||||
BEGIN;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(11000));
|
||||
INSERT INTO t1 SELECT randomblob(11001) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT randomblob(11002) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT randomblob(11003) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT randomblob(11004) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(11006) FROM t1; -- 64
|
||||
INSERT INTO t1 SELECT randomblob(11007) FROM t1; -- 128
|
||||
INSERT INTO t1 SELECT randomblob(11008) FROM t1; -- 256
|
||||
INSERT INTO t1 SELECT randomblob(11009) FROM t1; -- 512
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
set ::custom_filter xOpen
|
||||
proc xCustom {args} {
|
||||
incr ::custom_ifail -1
|
||||
if {$::custom_ifail==0} {
|
||||
incr ::custom_nfail
|
||||
return "SQLITE_IOERR"
|
||||
}
|
||||
return "SQLITE_OK"
|
||||
}
|
||||
do_faultsim_test 3.1 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
ifcapable memorymanage {
|
||||
set soft_limit [sqlite3_soft_heap_limit 50000]
|
||||
do_faultsim_test 3.2 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
set ::custom_filter {xOpen xWrite}
|
||||
proc xCustom {method args} {
|
||||
if {$method == "xOpen"} {
|
||||
if {[lindex $args 0] == ""} {
|
||||
incr ::nTmpOpen 1
|
||||
if {$::nTmpOpen == 3} { return "failme" }
|
||||
}
|
||||
return "SQLITE_OK"
|
||||
}
|
||||
if {$::custom_ifail<200 && [lindex $args 1] == "failme"} {
|
||||
incr ::custom_ifail -1
|
||||
if {$::custom_ifail==0} {
|
||||
incr ::custom_nfail
|
||||
return "SQLITE_IOERR"
|
||||
}
|
||||
}
|
||||
return "SQLITE_OK"
|
||||
}
|
||||
|
||||
do_faultsim_test 3.3 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
set ::nTmpOpen 0
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
ifcapable memorymanage {
|
||||
set soft_limit [sqlite3_soft_heap_limit 50000]
|
||||
do_faultsim_test 3.4 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
set ::nTmpOpen 0
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
sqlite3_soft_heap_limit $soft_limit
|
||||
}
|
||||
|
||||
uninstall_custom_faultsim
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test 4: After a certain amount of data has been read from the main database
|
||||
# file (and written into the temporary b-tree), sqlite3_release_memory() is
|
||||
# called to free as much memory as possible. This causes the temp b-tree to be
|
||||
# flushed to disk. So that before its contents can be transfered to a PMA they
|
||||
# must be read back from disk - creating extra opportunities for IO errors.
|
||||
#
|
||||
install_custom_faultsim
|
||||
|
||||
catch { db close }
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
do_execsql_test 4.0 {
|
||||
BEGIN;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(11000));
|
||||
INSERT INTO t1 SELECT randomblob(11001) FROM t1; -- 2
|
||||
INSERT INTO t1 SELECT randomblob(11002) FROM t1; -- 4
|
||||
INSERT INTO t1 SELECT randomblob(11003) FROM t1; -- 8
|
||||
INSERT INTO t1 SELECT randomblob(11004) FROM t1; -- 16
|
||||
INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 32
|
||||
INSERT INTO t1 SELECT randomblob(11005) FROM t1; -- 64
|
||||
COMMIT;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
|
||||
testvfs tvfs
|
||||
tvfs script xRead
|
||||
tvfs filter xRead
|
||||
set ::nRead 0
|
||||
proc xRead {method file args} {
|
||||
if {[file tail $file] == "test.db"} { incr ::nRead }
|
||||
}
|
||||
|
||||
do_test 4.1 {
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
} {}
|
||||
|
||||
db close
|
||||
tvfs delete
|
||||
|
||||
set ::custom_filter xRead
|
||||
proc xCustom {method file args} {
|
||||
incr ::nReadCall
|
||||
if {$::nReadCall >= ($::nRead/5)} {
|
||||
if {$::nReadCall == ($::nRead/5)} {
|
||||
set nByte [sqlite3_release_memory [expr 64*1024*1024]]
|
||||
sqlite3_soft_heap_limit 20000
|
||||
}
|
||||
if {$file == ""} {
|
||||
incr ::custom_ifail -1
|
||||
if {$::custom_ifail==0} {
|
||||
incr ::custom_nfail
|
||||
return "SQLITE_IOERR"
|
||||
}
|
||||
}
|
||||
}
|
||||
return "SQLITE_OK"
|
||||
}
|
||||
|
||||
do_faultsim_test 4.2 -faults custom -prep {
|
||||
faultsim_restore_and_reopen
|
||||
set ::nReadCall 0
|
||||
sqlite3_soft_heap_limit 0
|
||||
} -body {
|
||||
execsql { CREATE INDEX i1 ON t1(x) }
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
uninstall_custom_faultsim
|
||||
|
||||
finish_test
|
||||
+1
-1
@@ -34,7 +34,7 @@ proc uses_temp_table {sql} {
|
||||
# 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);
|
||||
|
||||
+6
-6
@@ -225,7 +225,7 @@ do_test io-2.6.2 {
|
||||
}
|
||||
} {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 {
|
||||
@@ -237,7 +237,7 @@ do_test io-2.6.4 {
|
||||
# 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 {
|
||||
@@ -261,7 +261,7 @@ ifcapable attach {
|
||||
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 {
|
||||
@@ -304,7 +304,7 @@ do_test io-2.9.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;
|
||||
@@ -375,7 +375,7 @@ 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;
|
||||
@@ -544,7 +544,7 @@ foreach {char sectorsize pgsize} {
|
||||
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 {
|
||||
|
||||
+4
-4
@@ -183,8 +183,8 @@ if {$tcl_platform(platform)!="windows"} {
|
||||
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
|
||||
@@ -219,11 +219,11 @@ if {$tcl_platform(platform)=="unix"} {
|
||||
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"
|
||||
|
||||
+5
-5
@@ -31,7 +31,7 @@ do_test ioerr4-1.1 {
|
||||
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 {
|
||||
@@ -79,12 +79,12 @@ do_test ioerr4-1.6 {
|
||||
#
|
||||
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}
|
||||
@@ -94,7 +94,7 @@ do_ioerr_test ioerr4-2 -tclprep {
|
||||
}
|
||||
|
||||
db2 close
|
||||
file delete -force test.db-bu
|
||||
forcedelete test.db-bu
|
||||
sqlite3_enable_shared_cache $::enable_shared_cache
|
||||
|
||||
finish_test
|
||||
|
||||
+4
-4
@@ -20,7 +20,7 @@ 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
|
||||
@@ -51,13 +51,13 @@ do_test journal1-1.2 {
|
||||
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
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ do_test journal2-1.13 {
|
||||
} {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 {
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ if {$::tcl_platform(platform) == "unix"} {
|
||||
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
|
||||
|
||||
+6
-6
@@ -200,7 +200,7 @@ ifcapable attach {
|
||||
}
|
||||
|
||||
ifcapable attach {
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
do_test jrnlmode-2.1 {
|
||||
execsql {
|
||||
ATTACH 'test2.db' AS aux;
|
||||
@@ -242,8 +242,8 @@ ifcapable attach {
|
||||
# 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 {
|
||||
@@ -270,7 +270,7 @@ ifcapable attach {
|
||||
|
||||
ifcapable autovacuum&&pragma {
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
do_test jrnlmode-4.1 {
|
||||
execsql {
|
||||
@@ -303,7 +303,7 @@ ifcapable autovacuum&&pragma {
|
||||
# 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 {
|
||||
@@ -511,7 +511,7 @@ ifcapable pragma {
|
||||
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;
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ do_test jrnlmode2-2.4 {
|
||||
|
||||
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
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ do_test jrnlmode3-1.2 {
|
||||
} {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 {
|
||||
@@ -85,7 +85,7 @@ foreach fromjmode $all_journal_modes {
|
||||
# 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.
|
||||
|
||||
+4
-2
@@ -308,8 +308,8 @@ do_test like-3.18 {
|
||||
#
|
||||
do_test like-3.19 {
|
||||
set sqlite_like_count 0
|
||||
db eval {CREATE INDEX i1 ON t1(x);}
|
||||
queryplan {
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
SELECT x FROM t1 WHERE x GLOB 'abc*' ORDER BY 1;
|
||||
}
|
||||
} {abc abcd nosort {} i1}
|
||||
@@ -522,7 +522,7 @@ do_test like-5.24 {
|
||||
}
|
||||
} {zz-lower-lower zZ-lower-upper Zz-upper-lower ZZ-upper-upper nosort {} i2}
|
||||
do_test like-5.25 {
|
||||
queryplan {
|
||||
db eval {
|
||||
PRAGMA case_sensitive_like=on;
|
||||
CREATE TABLE t3(x TEXT);
|
||||
CREATE INDEX i3 ON t3(x);
|
||||
@@ -530,6 +530,8 @@ do_test like-5.25 {
|
||||
INSERT INTO t3 VALUES('zZ-lower-upper');
|
||||
INSERT INTO t3 VALUES('Zz-upper-lower');
|
||||
INSERT INTO t3 VALUES('zz-lower-lower');
|
||||
}
|
||||
queryplan {
|
||||
SELECT x FROM t3 WHERE x LIKE 'zz%';
|
||||
}
|
||||
} {zz-lower-lower nosort {} i3}
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ 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]
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ do_test lock4-1.1 {
|
||||
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;
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ if {[catch {sqlite3 db test.db -vfs unix-none} msg]} {
|
||||
return
|
||||
}
|
||||
db close
|
||||
file delete -force test.db.lock
|
||||
forcedelete test.db.lock
|
||||
|
||||
ifcapable lock_proxy_pragmas {
|
||||
set ::using_proxy 0
|
||||
@@ -100,7 +100,7 @@ do_test lock5-dotfile.X {
|
||||
|
||||
#####################################################################
|
||||
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
if {[catch {sqlite3 db test.db -vfs unix-flock} msg]} {
|
||||
finish_test
|
||||
return
|
||||
|
||||
+7
-7
@@ -301,7 +301,7 @@ ifcapable {trigger} {
|
||||
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
|
||||
@@ -314,16 +314,16 @@ if {[permutation] == ""} {
|
||||
#
|
||||
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
|
||||
@@ -442,8 +442,8 @@ do_test main-3.2.30 {
|
||||
|
||||
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 */
|
||||
|
||||
+4
-4
@@ -270,7 +270,7 @@ do_malloc_test 9 -sqlprep {
|
||||
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)}
|
||||
@@ -341,8 +341,8 @@ if {$tcl_platform(platform)!="windows"} {
|
||||
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
|
||||
@@ -499,7 +499,7 @@ unset static_string
|
||||
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);}
|
||||
|
||||
+2
-2
@@ -463,7 +463,7 @@ TEST 29 {
|
||||
|
||||
# Test a simple multi-file transaction
|
||||
#
|
||||
file delete -force test2.db
|
||||
forcedelete test2.db
|
||||
ifcapable attach {
|
||||
SQL {ATTACH 'test2.db' AS aux;}
|
||||
SQL {BEGIN}
|
||||
@@ -650,7 +650,7 @@ 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]
|
||||
|
||||
+2
-2
@@ -275,7 +275,7 @@ proc nPage {db} {
|
||||
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.
|
||||
@@ -304,7 +304,7 @@ do_test malloc5-6.1.1 {
|
||||
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]
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ if {!$MEMDEBUG} {
|
||||
|
||||
# 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);
|
||||
@@ -38,7 +38,7 @@ db eval {
|
||||
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 {
|
||||
@@ -74,5 +74,5 @@ do_test malloc-99.X {
|
||||
set sqlite_open_file_count
|
||||
} {0}
|
||||
|
||||
file delete -force test.db.bu
|
||||
forcedelete test.db.bu
|
||||
finish_test
|
||||
|
||||
@@ -408,7 +408,7 @@ proc do_malloc_test {tn args} {
|
||||
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} {
|
||||
|
||||
@@ -425,7 +425,7 @@ proc do_malloc_test {tn args} {
|
||||
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 ""} {
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ foreach fd $filehandles {
|
||||
close $fd
|
||||
}
|
||||
catch {
|
||||
file delete -force testfile.1
|
||||
forcedelete testfile.1
|
||||
}
|
||||
set N [expr $i / $num_fd_per_openwrite_db]
|
||||
|
||||
@@ -92,7 +92,7 @@ for {set i 0} {$i<$N} {incr i} {
|
||||
for {set i 0} {$i<$N} {incr i} {
|
||||
do_test manydb-3.$i {
|
||||
db$i close
|
||||
file delete -force $dbname($i)
|
||||
forcedelete $dbname($i)
|
||||
} {}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -407,7 +407,7 @@ do_test memdb-8.2 {
|
||||
|
||||
# Test that auto-vacuum works with in-memory databases.
|
||||
#
|
||||
ifcapable autovacuum {
|
||||
ifcapable autovacuum&&!blockalloc {
|
||||
do_test memdb-9.1 {
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
|
||||
@@ -25,6 +25,13 @@ if {[permutation] == "memsubsys1"} {
|
||||
return
|
||||
}
|
||||
|
||||
# Nor will it work if the pager is allocating memory in blocks.
|
||||
#
|
||||
ifcapable blockalloc {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# This procedure constructs a new database in test.db. It fills
|
||||
# this database with many small records (enough to force multiple
|
||||
# rebalance operations in the btree-layer and to require a large
|
||||
@@ -32,7 +39,7 @@ if {[permutation] == "memsubsys1"} {
|
||||
#
|
||||
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
|
||||
|
||||
@@ -24,7 +24,7 @@ sqlite3_reset_auto_extension
|
||||
#
|
||||
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 {
|
||||
|
||||
+1
-1
@@ -491,7 +491,7 @@ do_test misc1-14.2b {
|
||||
} {1}
|
||||
do_test misc1-14.3 {
|
||||
cd ..
|
||||
file delete -force tempdir
|
||||
forcedelete tempdir
|
||||
execsql {COMMIT}
|
||||
file exists ./test.db-journal
|
||||
} {0}
|
||||
|
||||
+3
-3
@@ -165,7 +165,7 @@ do_test misc2-6.1 {
|
||||
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);
|
||||
@@ -265,7 +265,7 @@ ifcapable tclvar {
|
||||
#
|
||||
do_test misc2-7.11 {
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
CREATE TABLE t1(x);
|
||||
@@ -361,7 +361,7 @@ ifcapable tclvar {
|
||||
}
|
||||
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
catchsql { pragma recursive_triggers = off }
|
||||
|
||||
|
||||
+2
-2
@@ -514,7 +514,7 @@ ifcapable subquery {
|
||||
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
|
||||
@@ -544,7 +544,7 @@ do_test misc5-5.4 {
|
||||
# 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 {
|
||||
|
||||
+15
-15
@@ -30,7 +30,7 @@ do_test misc7-3 {
|
||||
# Try to open a directory:
|
||||
#
|
||||
do_test misc7-4 {
|
||||
file delete mydir
|
||||
delete_file mydir
|
||||
file mkdir mydir
|
||||
set rc [catch {
|
||||
sqlite3 db2 ./mydir
|
||||
@@ -41,7 +41,7 @@ do_test misc7-4 {
|
||||
# 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 {
|
||||
@@ -152,8 +152,8 @@ db2 close
|
||||
# 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;
|
||||
@@ -254,8 +254,8 @@ ifcapable vtab {
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -278,8 +278,8 @@ ifcapable explain {
|
||||
}
|
||||
|
||||
db close
|
||||
file delete -force test.db
|
||||
file delete -force test.db-journal
|
||||
forcedelete test.db
|
||||
forcedelete test.db-journal
|
||||
sqlite3 db test.db
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
@@ -323,8 +323,8 @@ do_test misc7-15.2 {
|
||||
} {}
|
||||
|
||||
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 {
|
||||
@@ -385,15 +385,15 @@ if {$tcl_platform(platform)!="windows" && $tcl_platform(platform)!="os2"} {
|
||||
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--------}
|
||||
@@ -484,6 +484,6 @@ do_test misc7-21.1 {
|
||||
|
||||
|
||||
db close
|
||||
file delete -force test.db
|
||||
forcedelete test.db
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ proc catchsql2 {sql} {
|
||||
#
|
||||
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);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user