-C Fix\san\sRBU\sproblem\scausing\sspurious\sSQLITE_CONSTRAINT\serrors\swhen\srestarting\nan\sRBU\supdate\sin\swhich\smore\sthan\sone\ssource\stable\swrites\sto\sa\ssingle\starget\ndatabase\stable.
-D 2018-04-28T18:20:01.187
+C Test\scases\sadded\sfor\sSQLITE_DBCONFIG_RESET_DATABASE.
+D 2018-04-28T19:08:02.897
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c
F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
F test/releasetest.tcl 5f15ab8056799e9a6e26a310d49236d2e774d6a30d0ec74601e18d4ce146b79c x
+F test/resetdb.test 7fda92e443233208ec5e1825b176a9df63fb5bf962248e08b76eb4296c630cdf
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa
F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a200a49edeaca5a787a3036070f7ced3cb6e9495f8afe7b74d5cde02c79b20dc
-R a57111df9a8d9421276a0abc4d9ce2ed
-U dan
-Z ad185b98451d11b0164183c41426fb3b
+P 564ae8297d417ba4b7978e430d41f125007177673163f6ed9adc3a3974f73d24
+R f62951ddf79b7c70897c7cedc3fc5902
+U drh
+Z d48406f4893f856e5db8717a8971e33f
--- /dev/null
+# 2018-04-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.
+#
+#***********************************************************************
+# Test cases for SQLITE_DBCONFIG_RESET_DATABASE
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix resetdb
+
+ifcapable !vtab||!compound {
+ finish_test
+ return
+}
+
+# Create a sample database
+do_execsql_test 100 {
+ PRAGMA page_size=4096;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(a,b) SELECT x, randomblob(300) FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_count;
+} {210 6000 ok delete 8}
+
+# Verify that the same content is seen from a separate database connection
+sqlite3 db2 test.db
+do_test 110 {
+ execsql {
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_count;
+ } db2
+} {210 6000 ok delete 8}
+
+do_test 200 {
+ # Thoroughly corrupt the database file by overwriting the first
+ # page with randomness.
+ catchsql {
+ UPDATE sqlite_dbpage SET data=randomblob(4096) WHERE pgno=1;
+ PRAGMA quick_check;
+ }
+} {1 {unsupported file format}}
+do_test 201 {
+ catchsql {
+ PRAGMA quick_check;
+ } db2
+} {1 {unsupported file format}}
+
+do_test 210 {
+ # Reset the database file using SQLITE_DBCONFIG_RESET_DATABASE
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+
+ # Verify that the reset took, even on the separate database connection
+ catchsql {
+ PRAGMA page_count;
+ PRAGMA page_size;
+ PRAGMA quick_check;
+ PRAGMA journal_mode;
+ } db2
+} {0 {1 4096 ok delete}}
+
+# Delete the old connections and database and start over again
+# with a different page size and in WAL mode.
+#
+db close
+db2 close
+forcedelete test.db
+sqlite3 db test.db
+do_execsql_test 300 {
+ PRAGMA page_size=8192;
+ PRAGMA journal_mode=WAL;
+ CREATE TABLE t1(a,b);
+ WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<20)
+ INSERT INTO t1(a,b) SELECT x, randomblob(1300) FROM c;
+ CREATE INDEX t1a ON t1(a);
+ CREATE INDEX t1b ON t1(b);
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_size;
+ PRAGMA page_count;
+} {wal 210 26000 ok wal 8192 12}
+sqlite3 db2 test.db
+do_test 310 {
+ execsql {
+ SELECT sum(a), sum(length(b)) FROM t1;
+ PRAGMA integrity_check;
+ PRAGMA journal_mode;
+ PRAGMA page_size;
+ PRAGMA page_count;
+ } db2
+} {210 26000 ok wal 8192 12}
+
+# Corrupt the database again
+do_catchsql_test 320 {
+ UPDATE sqlite_dbpage SET data=randomblob(8192) WHERE pgno=1;
+ PRAGMA quick_check
+} {1 {file is not a database}}
+
+do_test 330 {
+ catchsql {
+ PRAGMA quick_check
+ } db2
+} {1 {file is not a database}}
+
+# Reset the database yet again. Verify that the page size and
+# journal mode are preserved.
+#
+do_test 400 {
+ sqlite3_db_config db RESET_DB 1
+ db eval VACUUM
+ sqlite3_db_config db RESET_DB 0
+ catchsql {
+ PRAGMA page_count;
+ PRAGMA page_size;
+ PRAGMA journal_mode;
+ PRAGMA quick_check;
+ } db2
+} {0 {1 8192 wal ok}}
+db2 close
+
+
+finish_test