-C Merge\stwo\swal\sleaves.
-D 2010-05-03T08:19:34
+C Add\sthe\s"PRAGMA\swal_autocheckpoint"\scommand.\sRename\s"PRAGMA\scheckpoint"\sto\s"PRAGMA\swal_checkpoint".
+D 2010-05-03T11:05:09
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
-F src/main.c 7aab969e23fea0140bdc2cc6d2b8978e8d9b0090
+F src/main.c d08f2f34e92e5ad7b5ab605a2d22d24e12567efa
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
F src/pcache1.c 6dc1871ce8ead9187161c370a58cd06c84221f76
-F src/pragma.c 97c6054d7867b8c5b13023d3dc566274057cd853
+F src/pragma.c 4540555271b98366a408289318c7c1e508d7c8a6
F src/prepare.c fd1398cb1da54385ba5bd68d93928f10d10a1d9c
F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
F src/sqlite.h.in 8097161ad63e2a00e26217da43327d396371c2e5
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
-F src/sqliteInt.h 1f81585797162269a0f18b77c815d552dad636c2
-F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6
+F src/sqliteInt.h cb2b63a9538b9e79fc41b6d5026703600ab84407
+F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
F src/status.c 4df6fe7dce2d256130b905847c6c60055882bdbe
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
F src/tclsqlite.c 4de81521174fedacd8393ea7b70b730ce17f8eae
F src/vdbe.c 8be37a1b18786b5c026adcb2e9edc93e3a940885
F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3
F src/vdbeInt.h 19ebc8c2a2e938340051ee65af3f377fb99102d1
-F src/vdbeapi.c 810abe698db3ccaf67c5a8982f8cd4f31c6c902f
+F src/vdbeapi.c cf1ff7cbcbd44d2082af71b98762407ae01ce009
F src/vdbeaux.c 395d21a1617553ea9b9f4abe0d302449d8549e1d
F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b
F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287
F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9
-F test/savepoint.test 500ef5afb383107fd3b7d055cdeb015d36d1bc76
+F test/savepoint.test 14f78c2c2538764850b38446957048113cc24f75
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
-F test/wal.test 4ff92f36495142420ce8c2bb45340dcad714a1e5
-F test/walbak.test fad10a10df78ab67e89a8779ddc3c0d230460693
-F test/walcrash.test 20ebd86c0ea1bfdec97987c3cf667118f5c74a84
-F test/walhook.test 5ee5fd35cdc3763d5674da0dd9974f6f70c07bed
+F test/wal.test 9f142c65c436b209ffdce0eba37b1b90d2998c1a
+F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c
+F test/walcrash.test 63edc6a9e05f645b54d649186a5818fc82953e2e
+F test/walhook.test 5f18e0fc8787f1f8889d7a9971af18f334f83786
F test/walmode.test bac6f06544a8554588a1543def996bbe2fc41792
-F test/walslow.test 9be52d033e871cb608a18fa4425a6dc64b625377
-F test/walthread.test 4ef06a22d0d207aecba8cd11add820f6e7e94c43
+F test/walslow.test d21625e2e99e11c032ce949e8a94661576548933
+F test/walthread.test cc3c5302dfd56361def4023b7f29d361f1f1602d
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554
F test/where3.test aa44a9b29e8c9f3d7bb94a3bb3a95b31627d520d
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 9803196dec85e3aa4105cc477e9cfe98d370e486 94dea5f9c11a68564220cec76ac3fae2ba90e907
-R 788341a84b9fc72cb664689f96e77759
+P 23c0e6c3f333e878fe5a2ae5d61df0d765f437b4
+R f8f9e7aa1d48de791ac4d31549cb2c66
U dan
-Z 74b01ac5f69a8df35f22fcc654a97307
+Z 864d996940b21341339cd035e1e7f0cc
-23c0e6c3f333e878fe5a2ae5d61df0d765f437b4
\ No newline at end of file
+714e5947264571386f966aa8fcdd5607b5832238
\ No newline at end of file
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
** Return non-zero, indicating to the caller that a checkpoint should be run,
** if the number of frames in the log file is greater than
-** sqlite3.nDefaultCheckpoint (the value configured by wal_autocheckpoint()).
+** sqlite3.nAutoCheckpoint (the value configured by wal_autocheckpoint()).
*/
static int defaultWalHook(void *p, sqlite3 *db, const char *z, int nFrame){
UNUSED_PARAMETER(p);
UNUSED_PARAMETER(z);
- return ( nFrame>=db->nDefaultCheckpoint );
+ return ( nFrame>=db->nAutoCheckpoint );
}
/*
int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
sqlite3_mutex_enter(db->mutex);
if( nFrame>0 ){
- db->nDefaultCheckpoint = nFrame;
sqlite3_wal_hook(db, defaultWalHook, 0);
+ db->nAutoCheckpoint = nFrame;
}else{
sqlite3_wal_hook(db, 0, 0);
}
pRet = db->pWalArg;
db->xWalCallback = xCallback;
db->pWalArg = pArg;
+ db->nAutoCheckpoint = 0;
sqlite3_mutex_leave(db->mutex);
return pRet;
}
setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,
sqlite3GlobalConfig.nLookaside);
- sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_CACHE_SIZE);
+ sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
opendb_out:
if( db ){
#ifndef SQLITE_OMIT_WAL
/*
- ** PRAGMA [database.]checkpoint
+ ** PRAGMA [database.]wal_checkpoint
**
** Checkpoint the database.
*/
- if( sqlite3StrICmp(zLeft, "checkpoint")==0 ){
+ if( sqlite3StrICmp(zLeft, "wal_checkpoint")==0 ){
+ if( sqlite3ReadSchema(pParse) ) goto pragma_out;
sqlite3VdbeAddOp3(v, OP_Checkpoint, iDb, 0, 0);
}else
+
+ /*
+ ** PRAGMA wal_autocheckpoint
+ ** PRAGMA wal_autocheckpoint = N
+ **
+ ** Configure a database connection to automatically checkpoint a database
+ ** after accumulating N frames in the log. Or query for the current value
+ ** of N.
+ */
+ if( sqlite3StrICmp(zLeft, "wal_autocheckpoint")==0 ){
+ if( zRight ){
+ int nAuto = atoi(zRight);
+ sqlite3_wal_autocheckpoint(db, nAuto);
+ }
+ returnSingleInt(pParse, "wal_autocheckpoint", db->nAutoCheckpoint);
+ }else
#endif
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
void *pUpdateArg;
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
#ifndef SQLITE_OMIT_WAL
- int nDefaultCheckpoint; /* Value configured by wal_autocheckpoint() */
+ int nAutoCheckpoint; /* Value configured by wal_autocheckpoint() */
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
void *pWalArg;
#endif
# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
#endif
+/*
+** The default number of frames to accumulate in the log file before
+** checkpointing the database in WAL mode.
+*/
+#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
+# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
+#endif
+
/*
** The maximum number of attached databases. This must be between 0
** and 30. The upper bound on 30 is because a 32-bit integer bitmap
if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK
&& db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry)
){
- rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
+ rc = sqlite3Checkpoint(db, i);
}
}
}
integrity_check savepoint-11.7
do_test savepoint-11.8 {
execsql { ROLLBACK }
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
file size test.db
} {8192}
list [file size test.db] [file size test.db-wal]
} [list 1024 [log_file_size 3 1024]]
do_test wal-7.2 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
list [file size test.db] [file size test.db-wal]
} [list 2048 [log_file_size 3 1024]]
INSERT INTO t1 SELECT blob(900) FROM t1; /* 16 */
INSERT INTO t1 SELECT blob(900) FROM t1; /* 32 */
INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
}
file size test.db
} [expr 68*1024]
do_test wal-8.3 {
execsql {
DELETE FROM t1 WHERE rowid<54;
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
}
file size test.db
} [expr 14*1024]
db3 close
do_test wal-9.4 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
db2 close
sqlite3_wal db2 test.db
execsql {PRAGMA integrity_check } db2
sql2 { BEGIN; SELECT * FROM t1 }
} {1 2 3 4 5 6 7 8 9 10}
do_test wal-10.$tn.12 {
- catchsql { PRAGMA checkpoint }
+ catchsql { PRAGMA wal_checkpoint }
} {1 {database is locked}}
do_test wal-10.$tn.13 {
execsql { INSERT INTO t1 VALUES(11, 12) }
}
db busy busyhandler
do_test wal-10.$tn.14 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
# Similar to the test above. Except this time, a new read transaction is
sql2 { BEGIN; SELECT * FROM t1; }
} {1 2 3 4 5 6 7 8 9 10 11 12}
do_test wal-10.$tn.16 {
- catchsql { PRAGMA checkpoint }
+ catchsql { PRAGMA wal_checkpoint }
} {1 {database is locked}}
proc busyhandler x {
if {$x==3} { sql3 { BEGIN; SELECT * FROM t1 } }
}
db busy busyhandler
do_test wal-10.$tn.17 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
do_test wal-10.$tn.18 {
sql3 { SELECT * FROM t1 }
# (as [db3] still has a snapshot locked).
#
do_test wal-10.$tn.23 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
do_test wal-10.$tn.24 {
sql2 { BEGIN; SELECT * FROM t1; }
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
do_test wal-10.$tn.25 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
do_test wal-10.$tn.26 {
catchsql { INSERT INTO t1 VALUES(15, 16) }
db busy {}
do_test wal-10.$tn.29 {
execsql { INSERT INTO t1 VALUES(17, 18) }
- catchsql { PRAGMA checkpoint }
+ catchsql { PRAGMA wal_checkpoint }
} {1 {database is locked}}
do_test wal-10.$tn.30 {
code3 { sqlite3_finalize $::STMT }
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
# At one point, if a reader failed to upgrade to a writer because it
proc busyhandler x { return 1 }
db busy busyhandler
do_test wal-10.$tn.36 {
- catchsql { PRAGMA checkpoint }
+ catchsql { PRAGMA wal_checkpoint }
} {1 {database is locked}}
do_test wal-10.$tn.36 {
sql3 { INSERT INTO t1 VALUES('e', 'f') }
} {a b c d}
do_test wal-10.$tn.37 {
sql2 COMMIT
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
} {}
catch { db close }
list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
} {1 3}
do_test wal-11.2 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 3 [log_file_size 3 1024]]
do_test wal-11.3 {
}
} {16 ok}
do_test wal-11.8 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
list [expr [file size test.db]/1024] [file size test.db-wal]
} [list 37 [log_file_size 41 1024]]
do_test wal-11.9 {
db2 close
do_test wal-12.5 {
execsql {
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
UPDATE t2 SET y = 2 WHERE x = 'B';
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
UPDATE t1 SET y = 1 WHERE x = 'A';
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
UPDATE t1 SET y = 0 WHERE x = 'A';
SELECT * FROM t2;
}
INSERT INTO t1 SELECT randomblob(10), randomblob(100);
}
- # After executing the "PRAGMA checkpoint", connection [db] was being
+ # After executing the "PRAGMA wal_checkpoint", connection [db] was being
# left with an inconsistent cache. Running the CREATE INDEX statement
# in this state led to database corruption.
catchsql {
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
CREATE INDEX i1 on t1(b);
}
list [file size test.db] [file size test.db-wal]
} [list 1024 [log_file_size 6 1024]]
do_test walbak-1.6 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
list [file size test.db] [file size test.db-wal]
} [list [expr 3*1024] [log_file_size 6 1024]]
do_test walbak-1.7 {
list [file size test.db] [file size test.db-wal]
} [list [expr 3*1024] [log_file_size 8 1024]]
do_test walbak-1.9 {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
list [file size test.db] [file size test.db-wal]
} [list [expr 2*1024] [log_file_size 8 1024]]
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
INSERT INTO t1 VALUES(randomblob(900));
INSERT INTO t1 VALUES(randomblob(900));
INSERT INTO t1 VALUES(randomblob(900));
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
INSERT INTO t1 VALUES(randomblob(900));
INSERT INTO t1 VALUES(randomblob(900));
INSERT INTO t1 VALUES(randomblob(900));
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
COMMIT;
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
CREATE INDEX i1 ON t1(a);
- PRAGMA checkpoint;
+ PRAGMA wal_checkpoint;
}
} {1 {child process exited abnormally}}
# This file implements regression tests for SQLite library. The
# focus of this file is testing the operation of the library in
# "PRAGMA journal_mode=WAL" mode.
+#
+# More specifically, this file contains regression tests for the
+# sqlite3_wal_hook() mechanism, including the sqlite3_wal_autocheckpoint()
+# and "PRAGMA wal_autocheckpoint" convenience interfaces.
#
set testdir [file dirname $argv0]
ifcapable !wal {finish_test ; return }
-proc sqlite3_wal {args} {
- eval sqlite3 $args
- [lindex $args 0] eval {
- PRAGMA journal_mode = wal;
- PRAGMA synchronous = normal;
- PRAGMA page_size = 1024;
- }
+proc log_file_size {nFrame pgsz} {
+ expr {12 + ($pgsz+16)*$nFrame}
}
-sqlite3_wal db test.db
-db wal_hook wal_hook
set ::wal_hook [list]
proc wal_hook {zDb nEntry} {
lappend ::wal_hook $zDb $nEntry
return 0
}
+db wal_hook wal_hook
do_test walhook-1.1 {
- execsql { CREATE TABLE t1(i PRIMARY KEY, j) }
+ execsql {
+ PRAGMA page_size = 1024;
+ PRAGMA journal_mode = wal;
+ PRAGMA synchronous = normal;
+ CREATE TABLE t1(i PRIMARY KEY, j);
+ }
set ::wal_hook
} {main 3}
+
do_test walhook-1.2 {
set ::wal_hook [list]
execsql { INSERT INTO t1 VALUES(1, 'one') }
execsql { INSERT INTO t1 VALUES(2, 'two') }
file size test.db
} [expr 3*1024]
-
do_test walhook-1.4 {
proc wal_hook {zDb nEntry} {
- execsql { PRAGMA checkpoint }
+ execsql { PRAGMA wal_checkpoint }
return 0
}
execsql { CREATE TABLE t2(a, b) }
} [expr 4*1024]
do_test walhook-1.5 {
- sqlite3_wal db2 test.db
- proc wal_hook {zDb nEntry} {
- execsql { PRAGMA checkpoint } db2
+ sqlite3 db2 test.db
+ proc wal_hook {zDb nEntry} {
+ execsql { PRAGMA wal_checkpoint } db2
return 0
}
execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
file size test.db
} [expr 6*1024]
+db2 close
+db close
+sqlite3 db test.db
+do_test walhook-2.1 {
+ execsql { PRAGMA synchronous = NORMAL }
+ execsql { PRAGMA wal_autocheckpoint }
+} {1000}
+do_test walhook-2.2 {
+ execsql { PRAGMA wal_autocheckpoint = 10}
+} {10}
+do_test walhook-2.3 {
+ execsql { PRAGMA wal_autocheckpoint }
+} {10}
+
+#
+# The database connection is configured with "PRAGMA wal_autocheckpoint = 10".
+# Check that transactions are written to the log file until it contains at
+# least 10 frames, then the database is checkpointed. Subsequent transactions
+# are written into the start of the log file.
+#
+foreach {tn sql dbpages logpages} {
+ 4 "CREATE TABLE t4(x PRIMARY KEY, y)" 6 3
+ 5 "INSERT INTO t4 VALUES(1, 'one')" 6 5
+ 6 "INSERT INTO t4 VALUES(2, 'two')" 6 7
+ 7 "INSERT INTO t4 VALUES(3, 'three')" 6 9
+ 8 "INSERT INTO t4 VALUES(4, 'four')" 8 11
+ 9 "INSERT INTO t4 VALUES(5, 'five')" 8 11
+} {
+ do_test walhook-2.$tn {
+ execsql $sql
+ list [file size test.db] [file size test.db-wal]
+ } [list [expr $dbpages*1024] [log_file_size $logpages 1024]]
+}
+
catch { db2 close }
catch { db close }
finish_test
} {ok}
do_test walslow-1.seed=$seed.$iTest.2 {
- execsql "PRAGMA checkpoint;"
+ execsql "PRAGMA wal_checkpoint;"
execsql { PRAGMA integrity_check }
} {ok}
#
# There is also a single checkpointer thread. It runs the following loop:
#
-# 1) Execute "PRAGMA checkpoint"
+# 1) Execute "PRAGMA wal_checkpoint"
# 2) Sleep for 500 ms.
#
do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {
} -thread ckpt 1 {
set nRun 0
while {[tt_continue]} {
- db eval "PRAGMA checkpoint"
+ db eval "PRAGMA wal_checkpoint"
usleep 500
incr nRun
}