Fix a problem causing spurious SQLITE_CORRUPT errors when using the snapshot

API to read from old database snapshots.

FossilOrigin-Name: 535155be584ad8c1836e6b1c62de836d9872056d39608c995221c928cb5b365d
This commit is contained in:
dan 2018-08-28 11:23:52 +00:00
parent 5965fed24e
commit f5778751f7
4 changed files with 85 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Add\ssupport\sfor\sthe\sGeopoly\sextension\sto\sthe\sR-Tree\sextension.\s\sThis\salso\ninvolves\sadding\sthe\sSQLITE_INDEX_CONSTRAINT_FUNCTION\scapability\sto\sthe\s\nxFindFunction\smethod\sof\sthe\ssqlite3_module\sobject,\sand\sto\sthe\nsqlite3_index_info.aConstraint.op\sfield\sin\sthe\sxBestIndex\simplementation\sof\nvirtual\stables. C Fix\sa\sproblem\scausing\sspurious\sSQLITE_CORRUPT\serrors\swhen\susing\sthe\ssnapshot\nAPI\sto\sread\sfrom\sold\sdatabase\ssnapshots.
D 2018-08-27T17:13:12.965 D 2018-08-28T11:23:52.641
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 Makefile.in d06f463c5b623a61ac27f5cb8214fca9e53a6704d34d6b8f2124e2b1b293c88f F Makefile.in d06f463c5b623a61ac27f5cb8214fca9e53a6704d34d6b8f2124e2b1b293c88f
@ -582,7 +582,7 @@ F src/vdbesort.c 90aad5a92608f2dd771c96749beabdb562c9d881131a860a7a5bccf66dc3be7
F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392 F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392
F src/vtab.c 678992ac8ec677a3f9b08126aaf891441083805e3b42574e3654d44538381c14 F src/vtab.c 678992ac8ec677a3f9b08126aaf891441083805e3b42574e3654d44538381c14
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c e4bcbd90072e9626126d6f3b8411159a0b984c1b9628d15237776578d5eda12d F src/wal.c 46bfc9427d527099c17ce00a343a1c3fb8b050b00ddaf90a94398cda44070bf8
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
F src/walker.c ba7225773931760cf60bf22f34d0cce2588df7ce5ce0f215a52eb88234b55ac4 F src/walker.c ba7225773931760cf60bf22f34d0cce2588df7ce5ce0f215a52eb88234b55ac4
F src/where.c 155809967fbab889374dedf970ea6561b8fb519fcb165d6ba00776552ecc5cde F src/where.c 155809967fbab889374dedf970ea6561b8fb519fcb165d6ba00776552ecc5cde
@ -1274,6 +1274,7 @@ F test/skipscan6.test 0b4cd1b4ac9f84d91454df513c99a4932fa07e8f27b8049bea605068b3
F test/snapshot.test fef12fc5c16ff21c4748509401cfba7d9a3d91156f1bfe23fb881d3bfc65ddfe F test/snapshot.test fef12fc5c16ff21c4748509401cfba7d9a3d91156f1bfe23fb881d3bfc65ddfe
F test/snapshot2.test 925e42427e923262db63c9d7155183f889e3e99feaedec4075f659e51608344f F test/snapshot2.test 925e42427e923262db63c9d7155183f889e3e99feaedec4075f659e51608344f
F test/snapshot3.test 9719443594a04778861bd20d12596c5f880af177d6cd62f111da3198cafc6096 F test/snapshot3.test 9719443594a04778861bd20d12596c5f880af177d6cd62f111da3198cafc6096
F test/snapshot4.test 0f7e6bd6f1370d112ee820c541d0dd0e7b8ab4ea77429e65106d81c9ad2185a6
F test/snapshot_fault.test 52c5e97ebd218846a8ae2da4d147d3e77d71f963 F test/snapshot_fault.test 52c5e97ebd218846a8ae2da4d147d3e77d71f963
F test/snapshot_up.test b778a04561a67b8bfde828f473a8d31dbde23e3f648e36237e0369421e08f23c F test/snapshot_up.test b778a04561a67b8bfde828f473a8d31dbde23e3f648e36237e0369421e08f23c
F test/soak.test 18944cf21b94a7fe0df02016a6ee1e9632bc4e8d095a0cb49d95e15d5cca2d5c F test/soak.test 18944cf21b94a7fe0df02016a6ee1e9632bc4e8d095a0cb49d95e15d5cca2d5c
@ -1757,8 +1758,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 d158e5b12eec5b81d54c8f5902a972795423947a21d0212b6cceb2810aa6cc5c 4bc28eed32154be0e62fe69acd30f828c2e6f59c6579618ecad8ecf632a90517 P 666133e32ca8e95807f8437dc8401bc93e2e6508ab8e6ae1e6031b7cee1584ae
R 8e52d60c2558b132e89c46c2b2e927ee R 64c8500a3b3b1576c0a05df68a2057d2
T +closed 4bc28eed32154be0e62fe69acd30f828c2e6f59c6579618ecad8ecf632a90517 U dan
U drh Z 4febad62a4c0de1b34fab12b530aa165
Z 29251fdcd22ade960e4bf01a9382ce41

View File

@ -1 +1 @@
666133e32ca8e95807f8437dc8401bc93e2e6508ab8e6ae1e6031b7cee1584ae 535155be584ad8c1836e6b1c62de836d9872056d39608c995221c928cb5b365d

View File

@ -2798,6 +2798,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
/* Release the shared CKPT lock obtained above. */ /* Release the shared CKPT lock obtained above. */
walUnlockShared(pWal, WAL_CKPT_LOCK); walUnlockShared(pWal, WAL_CKPT_LOCK);
pWal->minFrame = 1;
} }

75
test/snapshot4.test Normal file
View File

@ -0,0 +1,75 @@
# 2018 August 28
#
# 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 the sqlite3_snapshot_xxx() APIs.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !snapshot {finish_test; return}
set testprefix snapshot4
# This test does not work with the inmemory_journal permutation. The reason
# is that each connection opened as part of this permutation executes
# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
# and there are one or more existing connections.
if {[permutation]=="inmemory_journal"} {
finish_test
return
}
sqlite3 db2 test.db
do_execsql_test 1.0 {
PRAGMA cache_size = 10;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, randomblob(400));
PRAGMA journal_mode = wal;
WITH s(i) AS (
SELECT 2 UNION ALL SELECT i+1 FROM s WHERE i<100
)
INSERT INTO t1 SELECT i, randomblob(400) FROM s;
} {wal}
do_test 1.1 {
execsql {
BEGIN;
SELECT count(*) FROM t1;
}
} {100}
do_test 1.2 {
db2 eval {
SELECT count(*) FROM t1;
CREATE TABLE t2(x);
}
} {100}
do_test 1.3 {
set ::snap [sqlite3_snapshot_get_blob db main]
db2 eval { PRAGMA wal_checkpoint }
} {0 54 52}
do_test 1.4 {
execsql {
COMMIT;
SELECT * FROM sqlite_master;
BEGIN;
}
sqlite3_snapshot_open_blob db main $::snap
execsql {
SELECT count(*) FROM t1
}
} {100}
finish_test