mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add tests for too-tiny appended DBs, clarify align macro.
FossilOrigin-Name: eb40a8dea6afe6890ddda989de83f3d4ae03b112bf78bfc818dfbd57cc5b5b2a
This commit is contained in:
@ -490,8 +490,9 @@ static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Round-up used to get appendvfs portion to begin at a page boundary. */
|
/* Round-up used to get appendvfs portion to begin at a page boundary. */
|
||||||
#define APND_START_ROUNDUP(fsz, nPageBits) \
|
#define APND_ALIGN_MASK(nbits) ((1<<nbits)-1)
|
||||||
(((fsz) + ((1<<nPageBits)-1)) & ~(sqlite3_int64)((1<<nPageBits)-1))
|
#define APND_START_ROUNDUP(fsz, nbits) \
|
||||||
|
( ((fsz)+APND_ALIGN_MASK(nbits)) & ~(sqlite3_int64)APND_ALIGN_MASK(nbits) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Open an apnd file handle.
|
** Open an apnd file handle.
|
||||||
|
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
|||||||
C Add\stest\scases\sfor\sALTER\sTABLE.
|
C Add\stests\sfor\stoo-tiny\sappended\sDBs,\sclarify\salign\smacro.
|
||||||
D 2021-03-08T17:22:01.712
|
D 2021-03-08T20:13:43.440
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@ -286,7 +286,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607
|
|||||||
F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240
|
F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240
|
||||||
F ext/misc/amatch.c e3ad5532799cee9a97647f483f67f43b38796b84b5a8c60594fe782a4338f358
|
F ext/misc/amatch.c e3ad5532799cee9a97647f483f67f43b38796b84b5a8c60594fe782a4338f358
|
||||||
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
||||||
F ext/misc/appendvfs.c cf3366965c99ad1e09a4b75e67b6c73e63bb608089b1da4bc55996854ed7ffd5
|
F ext/misc/appendvfs.c c7cd6cbd33965c5f66c4a53f800e9ccd7b5721a4dac65af6d505f1cf0fedf63e
|
||||||
F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a
|
F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a
|
||||||
F ext/misc/btreeinfo.c d28ce349b40054eaa9473e835837bad7a71deec33ba13e39f963d50933bfa0f9
|
F ext/misc/btreeinfo.c d28ce349b40054eaa9473e835837bad7a71deec33ba13e39f963d50933bfa0f9
|
||||||
F ext/misc/carray.c b75a0f207391038bf1540d3372f482a95c3613511c7c474db51ede1196321c7c
|
F ext/misc/carray.c b75a0f207391038bf1540d3372f482a95c3613511c7c474db51ede1196321c7c
|
||||||
@ -699,7 +699,7 @@ F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf
|
|||||||
F test/autoindex5.test a5d72fe8c217cc0ea356dc6fa06a282a8a3fc53aa807709d79dba07a8f248102
|
F test/autoindex5.test a5d72fe8c217cc0ea356dc6fa06a282a8a3fc53aa807709d79dba07a8f248102
|
||||||
F test/autovacuum.test 0831cd34e14695d297187f7f6519265e3121c5b0a1720e548e86829e796129e9
|
F test/autovacuum.test 0831cd34e14695d297187f7f6519265e3121c5b0a1720e548e86829e796129e9
|
||||||
F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
|
F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
|
||||||
F test/avfs.test fcef698d4363182e54f4288c09799313c7b8074db81804a8e0680d4739607ff0
|
F test/avfs.test dc53cf4cf6bb4d625dc697f09790dfed8cd217a1a4903c1a2a614f6449b2f57d
|
||||||
F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e
|
F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e
|
||||||
F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d
|
F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d
|
||||||
F test/backup.test dd4a5ff756e3df3931dacb1791db0584d4bad989
|
F test/backup.test dd4a5ff756e3df3931dacb1791db0584d4bad989
|
||||||
@ -1910,7 +1910,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P f13e0d12f137cd6b4e83e92bd36652431d8416e6eed4797313e061f2e390d39b
|
P 9c9ba36e859e330c50ed40ede4b93eeb0a5c3337240465d953a7be9115a81390
|
||||||
R f9de7ca9f057059fa9533f91ff672e89
|
R 4d1785eb4283241007d7b3b4a37989ad
|
||||||
U dan
|
U larrybr
|
||||||
Z e860451ea7454ca8ef2d0c3618d92e27
|
Z 2a5394d1d6ba424c40bac755be51427c
|
||||||
|
@ -1 +1 @@
|
|||||||
9c9ba36e859e330c50ed40ede4b93eeb0a5c3337240465d953a7be9115a81390
|
eb40a8dea6afe6890ddda989de83f3d4ae03b112bf78bfc818dfbd57cc5b5b2a
|
@ -12,16 +12,19 @@
|
|||||||
# This file implements tests for the appendvfs extension.
|
# This file implements tests for the appendvfs extension.
|
||||||
#
|
#
|
||||||
# Tests performed:
|
# Tests performed:
|
||||||
# avfs-1.0. Test that an appendvfs DB can be added to an empty file.
|
# avfs-1.0. Test that an appendvfs DB can be added to an empty (ZLF) file.
|
||||||
# avfs-1.1. Test that the DB can be read with correct content upon reopen.
|
# avfs-1.1. Test that the DB can be read with correct content upon reopen.
|
||||||
# avfs-1.2. Test that an appendvfs DB can be added to a simple text file.
|
# avfs-1.2. Test that an appendvfs DB can be added to a simple text file.
|
||||||
# avfs-1.3. Test that the DB can be read with correct content upon reopen.
|
# avfs-1.3. Test that the DB can be read with correct content upon reopen.
|
||||||
|
# avfs-1.4. Test that appended DB is aligned to default page boundary.
|
||||||
# avfs-2.1. Test that the simple text file retains its initial text.
|
# avfs-2.1. Test that the simple text file retains its initial text.
|
||||||
# avfs-3.1. Test that the appendvfs can grow and shrink, remaining intact.
|
# avfs-3.1. Test that the appendvfs can grow and shrink, remaining intact.
|
||||||
# avfs-3.2. Test that appendvfs is intact after grow/shrink/close/reopen.
|
# avfs-3.2. Test that appendvfs is intact after grow/shrink/close/reopen.
|
||||||
# avfs-4.1. Test shell's ability to append to a non-appendvfs file.
|
# avfs-4.1. Test shell's ability to append to a non-appendvfs file.
|
||||||
# avfs-4.2. Test shell's ability to append to empty or nonexistent file.
|
# avfs-4.2. Test shell's ability to append to empty or nonexistent file.
|
||||||
# avfs-4.3. Test shell's ability to reopen and alter an appendvfs file.
|
# avfs-4.3. Test shell's ability to reopen and alter an appendvfs file.
|
||||||
|
# avfs-5.1. Test appendvfs refusal to open too-tiny DB appended onto ZLF.
|
||||||
|
# avfs-5.2. Test appendvfs refusal to open too-tiny DB appended on other.
|
||||||
# ...
|
# ...
|
||||||
# (more to come)
|
# (more to come)
|
||||||
|
|
||||||
@ -115,9 +118,12 @@ do_test 1.3 {
|
|||||||
SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a DESC);
|
SELECT group_concat(a) as pets FROM (SELECT a FROM t1 ORDER BY a DESC);
|
||||||
} { lappend results $pets }
|
} { lappend results $pets }
|
||||||
adb close
|
adb close
|
||||||
lappend results [fosAvfs $fa]
|
|
||||||
set ::result [join $results " | "]
|
set ::result [join $results " | "]
|
||||||
} {pig,dog,cat | 4096}
|
} {pig,dog,cat}
|
||||||
|
|
||||||
|
do_test 1.4 {
|
||||||
|
set ::result [fosAvfs $fa]
|
||||||
|
} {4096}
|
||||||
|
|
||||||
do_test 2.1 {
|
do_test 2.1 {
|
||||||
set in [open $::fa r]
|
set in [open $::fa r]
|
||||||
@ -248,6 +254,46 @@ do_test 4.3 {
|
|||||||
set ::result [join $res " | "]
|
set ::result [join $res " | "]
|
||||||
} {0 | 1 | 1}
|
} {0 | 1 | 1}
|
||||||
|
|
||||||
|
do_test 5.1 {
|
||||||
|
set fake "faketiny.sdb"
|
||||||
|
forcedelete $fake
|
||||||
|
set ofd [open $fake wb]
|
||||||
|
puts -nonewline $ofd "SQLite format 3"
|
||||||
|
puts -nonewline $ofd [binary format "c" 0]
|
||||||
|
puts -nonewline $ofd "Start-Of-SQLite3-"
|
||||||
|
puts -nonewline $ofd [binary format "W" 0]
|
||||||
|
close $ofd
|
||||||
|
if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
|
||||||
|
set res "Open failed."
|
||||||
|
} else {
|
||||||
|
adb close
|
||||||
|
set res "Opened when should not."
|
||||||
|
}
|
||||||
|
forcedelete $fake
|
||||||
|
set ::result $res
|
||||||
|
} {Open failed.}
|
||||||
|
|
||||||
|
do_test 5.2 {
|
||||||
|
set fake "faketiny.sdb"
|
||||||
|
forcedelete $fake
|
||||||
|
set ofd [open $fake wb]
|
||||||
|
set fakeAppendee "Dog ate my homework.\n"
|
||||||
|
puts -nonewline $ofd $fakeAppendee
|
||||||
|
puts -nonewline $ofd "SQLite format 3"
|
||||||
|
puts -nonewline $ofd [binary format "c" 0]
|
||||||
|
puts -nonewline $ofd "Start-Of-SQLite3-"
|
||||||
|
puts -nonewline $ofd [binary format "W" [string length $fakeAppendee]]
|
||||||
|
close $ofd
|
||||||
|
if {[catch {sqlite3 adb "file:$fake?mode=rw$::vf" -uri 1}]} {
|
||||||
|
set res "Open failed."
|
||||||
|
} else {
|
||||||
|
adb close
|
||||||
|
set res "Opened when should not."
|
||||||
|
}
|
||||||
|
forcedelete $fake
|
||||||
|
set ::result $res
|
||||||
|
} {Open failed.}
|
||||||
|
|
||||||
forcedelete $::fa $::fza
|
forcedelete $::fa $::fza
|
||||||
|
|
||||||
unset -nocomplain ::fa ::fza ::tlo ::result ::randints
|
unset -nocomplain ::fa ::fza ::tlo ::result ::randints
|
||||||
|
Reference in New Issue
Block a user