1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Merge in the latest changes from the trunk.

FossilOrigin-Name: 435b57dc2be7b071270a6cddece297758b8153aa
This commit is contained in:
drh
2011-04-06 22:33:50 +00:00
18 changed files with 270 additions and 90 deletions

112
test/attach4.test Normal file
View File

@@ -0,0 +1,112 @@
# 200 July 1
#
# 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 script is attaching many database files to a single
# connection.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix attach4
ifcapable !attach {
finish_test
return
}
puts "Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED"
set files {main test.db}
for {set ii 0} {$ii < $SQLITE_MAX_ATTACHED} {incr ii} {
lappend files aux$ii "test.db$ii"
}
do_test 1.1 {
sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
} $SQLITE_MAX_ATTACHED
do_test 1.2.1 {
db close
foreach {name f} $files { forcedelete $f }
sqlite3 db test.db
foreach {name f} $files {
if {$name == "main"} continue
execsql "ATTACH '$f' AS $name"
}
db eval {PRAGMA database_list} {
lappend L $name [file tail $file]
}
set L
} $files
do_catchsql_test 1.2.2 {
ATTACH 'x.db' AS next;
} [list 1 "too many attached databases - max $SQLITE_MAX_ATTACHED"]
do_test 1.3 {
execsql BEGIN;
foreach {name f} $files {
execsql "CREATE TABLE $name.tbl(x)"
execsql "INSERT INTO $name.tbl VALUES('$f')"
}
execsql COMMIT;
} {}
do_test 1.4 {
set L [list]
foreach {name f} $files {
lappend L $name [execsql "SELECT x FROM $name.tbl"]
}
set L
} $files
set L [list]
set S ""
foreach {name f} $files {
lappend L wal
append S "
PRAGMA $name.journal_mode = WAL;
UPDATE $name.tbl SET x = '$name';
"
}
do_execsql_test 1.5 $S $L
do_test 1.6 {
set L [list]
foreach {name f} $files {
lappend L [execsql "SELECT x FROM $name.tbl"] $f
}
set L
} $files
do_test 1.7 {
execsql BEGIN;
foreach {name f} $files {
execsql "UPDATE $name.tbl SET x = '$f'"
}
execsql COMMIT;
} {}
do_test 1.8 {
set L [list]
foreach {name f} $files {
lappend L $name [execsql "SELECT x FROM $name.tbl"]
}
set L
} $files
db close
foreach {name f} $files { forcedelete $f }
finish_test

View File

@@ -60,6 +60,11 @@ array set ::Configs {
"Default" {
-O2
}
"Ftrapv" {
-O2 -ftrapv
-DSQLITE_MAX_ATTACHED=55
-DSQLITE_TCL_DEFAULT_FULLMUTEX=1
}
"Unlock-Notify" {
-O2
-DSQLITE_ENABLE_UNLOCK_NOTIFY
@@ -144,6 +149,7 @@ array set ::Configs {
}
"Extra-Robustness" {
-DSQLITE_ENABLE_OVERSIZE_CELL_CHECK=1
-DSQLITE_MAX_ATTACHED=62
}
}
@@ -155,6 +161,7 @@ array set ::Platforms {
"Debug-One" test
"Extra-Robustness" test
"Device-Two" test
"Ftrapv" test
"Default" "threadtest test"
"Device-One" fulltest
}

View File

@@ -239,7 +239,6 @@ do_test 8.1 {
file_control_chunksize_test db main 4096
file size test.db
} {0}
foreach {tn hint size} {
1 1000 4096
2 1000 4096
@@ -253,5 +252,25 @@ foreach {tn hint size} {
} $size
}
do_test 8.3 {
db close
forcedelete test.db test.db2
sqlite3 db test.db
file_control_chunksize_test db main 16
file size test.db
} {0}
foreach {tn hint size} {
1 5 16
2 13 16
3 45 48
4 48 48
5 49 64
} {
do_test 8.4.$tn {
file_control_sizehint_test db main $hint
file size test.db
} $size
}
test_syscall reset
finish_test

View File

@@ -1530,26 +1530,26 @@ ifcapable autovacuum {
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
} {wal}
do_execsql_test 24.2 {
DELETE FROM t1;
PRAGMA wal_checkpoint;
} {0 109 109}
do_test 24.3 {
do_test 24.2 {
execsql {
DELETE FROM t1;
PRAGMA wal_checkpoint;
}
db close
sqlite3 db test.db
file exists test.db-wal
} 0
do_test 24.4 {
do_test 24.3 {
file size test.db
} [expr 84 * 1024]
do_test 24.5 {
do_test 24.4 {
execsql {
PRAGMA incremental_vacuum;
PRAGMA wal_checkpoint;
}
file size test.db
} [expr 3 * 1024]
do_test 24.6 {
do_test 24.5 {
file size test.db-wal
} 2128
}