mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Add the "PRAGMA wal_autocheckpoint" command. Rename "PRAGMA checkpoint" to "PRAGMA wal_checkpoint".
FossilOrigin-Name: 714e5947264571386f966aa8fcdd5607b5832238
This commit is contained in:
34
manifest
34
manifest
@ -1,5 +1,5 @@
|
|||||||
C Merge\stwo\swal\sleaves.
|
C Add\sthe\s"PRAGMA\swal_autocheckpoint"\scommand.\sRename\s"PRAGMA\scheckpoint"\sto\s"PRAGMA\swal_checkpoint".
|
||||||
D 2010-05-03T08:19:34
|
D 2010-05-03T11:05:09
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -131,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c
|
|||||||
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
|
||||||
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
|
F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
|
||||||
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
|
F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
|
||||||
F src/main.c 7aab969e23fea0140bdc2cc6d2b8978e8d9b0090
|
F src/main.c d08f2f34e92e5ad7b5ab605a2d22d24e12567efa
|
||||||
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
|
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
|
||||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||||
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
|
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
|
||||||
@ -158,7 +158,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
|
|||||||
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
|
F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
|
||||||
F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
|
F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
|
||||||
F src/pcache1.c 6dc1871ce8ead9187161c370a58cd06c84221f76
|
F src/pcache1.c 6dc1871ce8ead9187161c370a58cd06c84221f76
|
||||||
F src/pragma.c 97c6054d7867b8c5b13023d3dc566274057cd853
|
F src/pragma.c 4540555271b98366a408289318c7c1e508d7c8a6
|
||||||
F src/prepare.c fd1398cb1da54385ba5bd68d93928f10d10a1d9c
|
F src/prepare.c fd1398cb1da54385ba5bd68d93928f10d10a1d9c
|
||||||
F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7
|
F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7
|
||||||
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
||||||
@ -168,8 +168,8 @@ F src/select.c c03d8a0565febcde8c6a12c5d77d065fddae889b
|
|||||||
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
|
F src/shell.c c40427c7245535a04a9cb4a417b6cc05c022e6a4
|
||||||
F src/sqlite.h.in 8097161ad63e2a00e26217da43327d396371c2e5
|
F src/sqlite.h.in 8097161ad63e2a00e26217da43327d396371c2e5
|
||||||
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
|
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
|
||||||
F src/sqliteInt.h 1f81585797162269a0f18b77c815d552dad636c2
|
F src/sqliteInt.h cb2b63a9538b9e79fc41b6d5026703600ab84407
|
||||||
F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6
|
F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
|
||||||
F src/status.c 4df6fe7dce2d256130b905847c6c60055882bdbe
|
F src/status.c 4df6fe7dce2d256130b905847c6c60055882bdbe
|
||||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||||
F src/tclsqlite.c 4de81521174fedacd8393ea7b70b730ce17f8eae
|
F src/tclsqlite.c 4de81521174fedacd8393ea7b70b730ce17f8eae
|
||||||
@ -215,7 +215,7 @@ F src/vacuum.c 8e7d9a6fd076774bb6e211cad335c7337948a164
|
|||||||
F src/vdbe.c 8be37a1b18786b5c026adcb2e9edc93e3a940885
|
F src/vdbe.c 8be37a1b18786b5c026adcb2e9edc93e3a940885
|
||||||
F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3
|
F src/vdbe.h 471f6a3dcec4817ca33596fe7f6654d56c0e75f3
|
||||||
F src/vdbeInt.h 19ebc8c2a2e938340051ee65af3f377fb99102d1
|
F src/vdbeInt.h 19ebc8c2a2e938340051ee65af3f377fb99102d1
|
||||||
F src/vdbeapi.c 810abe698db3ccaf67c5a8982f8cd4f31c6c902f
|
F src/vdbeapi.c cf1ff7cbcbd44d2082af71b98762407ae01ce009
|
||||||
F src/vdbeaux.c 395d21a1617553ea9b9f4abe0d302449d8549e1d
|
F src/vdbeaux.c 395d21a1617553ea9b9f4abe0d302449d8549e1d
|
||||||
F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
|
F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
|
||||||
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
|
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
|
||||||
@ -548,7 +548,7 @@ F test/rollback.test 73355ad4492ff9a3a31e61c7e5eb5e01a1de94ca
|
|||||||
F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b
|
F test/rowhash.test 97f56043ba11f0679920416c0cdbc72e5272267b
|
||||||
F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287
|
F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287
|
||||||
F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9
|
F test/rtree.test 55466a200af3591946c5da77ad5dbfbc1e5e05f9
|
||||||
F test/savepoint.test 500ef5afb383107fd3b7d055cdeb015d36d1bc76
|
F test/savepoint.test 14f78c2c2538764850b38446957048113cc24f75
|
||||||
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
|
F test/savepoint2.test 9b8543940572a2f01a18298c3135ad0c9f4f67d7
|
||||||
F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
|
F test/savepoint3.test e328085853b14898d78ceea00dfe7db18bb6a9ec
|
||||||
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
|
F test/savepoint4.test c8f8159ade6d2acd9128be61e1230f1c1edc6cc0
|
||||||
@ -758,13 +758,13 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61
|
|||||||
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
|
||||||
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
|
||||||
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
|
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
|
||||||
F test/wal.test 4ff92f36495142420ce8c2bb45340dcad714a1e5
|
F test/wal.test 9f142c65c436b209ffdce0eba37b1b90d2998c1a
|
||||||
F test/walbak.test fad10a10df78ab67e89a8779ddc3c0d230460693
|
F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c
|
||||||
F test/walcrash.test 20ebd86c0ea1bfdec97987c3cf667118f5c74a84
|
F test/walcrash.test 63edc6a9e05f645b54d649186a5818fc82953e2e
|
||||||
F test/walhook.test 5ee5fd35cdc3763d5674da0dd9974f6f70c07bed
|
F test/walhook.test 5f18e0fc8787f1f8889d7a9971af18f334f83786
|
||||||
F test/walmode.test bac6f06544a8554588a1543def996bbe2fc41792
|
F test/walmode.test bac6f06544a8554588a1543def996bbe2fc41792
|
||||||
F test/walslow.test 9be52d033e871cb608a18fa4425a6dc64b625377
|
F test/walslow.test d21625e2e99e11c032ce949e8a94661576548933
|
||||||
F test/walthread.test 4ef06a22d0d207aecba8cd11add820f6e7e94c43
|
F test/walthread.test cc3c5302dfd56361def4023b7f29d361f1f1602d
|
||||||
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
|
F test/where.test de337a3fe0a459ec7c93db16a519657a90552330
|
||||||
F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554
|
F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554
|
||||||
F test/where3.test aa44a9b29e8c9f3d7bb94a3bb3a95b31627d520d
|
F test/where3.test aa44a9b29e8c9f3d7bb94a3bb3a95b31627d520d
|
||||||
@ -808,7 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
|||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
P 9803196dec85e3aa4105cc477e9cfe98d370e486 94dea5f9c11a68564220cec76ac3fae2ba90e907
|
P 23c0e6c3f333e878fe5a2ae5d61df0d765f437b4
|
||||||
R 788341a84b9fc72cb664689f96e77759
|
R f8f9e7aa1d48de791ac4d31549cb2c66
|
||||||
U dan
|
U dan
|
||||||
Z 74b01ac5f69a8df35f22fcc654a97307
|
Z 864d996940b21341339cd035e1e7f0cc
|
||||||
|
@ -1 +1 @@
|
|||||||
23c0e6c3f333e878fe5a2ae5d61df0d765f437b4
|
714e5947264571386f966aa8fcdd5607b5832238
|
@ -1191,12 +1191,12 @@ void *sqlite3_rollback_hook(
|
|||||||
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
|
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
|
||||||
** Return non-zero, indicating to the caller that a checkpoint should be run,
|
** 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
|
** 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){
|
static int defaultWalHook(void *p, sqlite3 *db, const char *z, int nFrame){
|
||||||
UNUSED_PARAMETER(p);
|
UNUSED_PARAMETER(p);
|
||||||
UNUSED_PARAMETER(z);
|
UNUSED_PARAMETER(z);
|
||||||
return ( nFrame>=db->nDefaultCheckpoint );
|
return ( nFrame>=db->nAutoCheckpoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1213,8 +1213,8 @@ static int defaultWalHook(void *p, sqlite3 *db, const char *z, int nFrame){
|
|||||||
int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
|
int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
|
||||||
sqlite3_mutex_enter(db->mutex);
|
sqlite3_mutex_enter(db->mutex);
|
||||||
if( nFrame>0 ){
|
if( nFrame>0 ){
|
||||||
db->nDefaultCheckpoint = nFrame;
|
|
||||||
sqlite3_wal_hook(db, defaultWalHook, 0);
|
sqlite3_wal_hook(db, defaultWalHook, 0);
|
||||||
|
db->nAutoCheckpoint = nFrame;
|
||||||
}else{
|
}else{
|
||||||
sqlite3_wal_hook(db, 0, 0);
|
sqlite3_wal_hook(db, 0, 0);
|
||||||
}
|
}
|
||||||
@ -1236,6 +1236,7 @@ void *sqlite3_wal_hook(
|
|||||||
pRet = db->pWalArg;
|
pRet = db->pWalArg;
|
||||||
db->xWalCallback = xCallback;
|
db->xWalCallback = xCallback;
|
||||||
db->pWalArg = pArg;
|
db->pWalArg = pArg;
|
||||||
|
db->nAutoCheckpoint = 0;
|
||||||
sqlite3_mutex_leave(db->mutex);
|
sqlite3_mutex_leave(db->mutex);
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
@ -1870,7 +1871,7 @@ static int openDatabase(
|
|||||||
setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,
|
setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside,
|
||||||
sqlite3GlobalConfig.nLookaside);
|
sqlite3GlobalConfig.nLookaside);
|
||||||
|
|
||||||
sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_CACHE_SIZE);
|
sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT);
|
||||||
|
|
||||||
opendb_out:
|
opendb_out:
|
||||||
if( db ){
|
if( db ){
|
||||||
|
21
src/pragma.c
21
src/pragma.c
@ -1402,13 +1402,30 @@ void sqlite3Pragma(
|
|||||||
|
|
||||||
#ifndef SQLITE_OMIT_WAL
|
#ifndef SQLITE_OMIT_WAL
|
||||||
/*
|
/*
|
||||||
** PRAGMA [database.]checkpoint
|
** PRAGMA [database.]wal_checkpoint
|
||||||
**
|
**
|
||||||
** Checkpoint the database.
|
** 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);
|
sqlite3VdbeAddOp3(v, OP_Checkpoint, iDb, 0, 0);
|
||||||
}else
|
}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
|
#endif
|
||||||
|
|
||||||
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
|
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
|
||||||
|
@ -824,7 +824,7 @@ struct sqlite3 {
|
|||||||
void *pUpdateArg;
|
void *pUpdateArg;
|
||||||
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
|
void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
|
||||||
#ifndef SQLITE_OMIT_WAL
|
#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);
|
int (*xWalCallback)(void *, sqlite3 *, const char *, int);
|
||||||
void *pWalArg;
|
void *pWalArg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,6 +108,14 @@
|
|||||||
# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
|
# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
|
||||||
#endif
|
#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
|
** 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
|
** and 30. The upper bound on 30 is because a 32-bit integer bitmap
|
||||||
|
@ -321,7 +321,7 @@ static int doWalCallbacks(sqlite3 *db){
|
|||||||
if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK
|
if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK
|
||||||
&& db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry)
|
&& db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry)
|
||||||
){
|
){
|
||||||
rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
|
rc = sqlite3Checkpoint(db, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -792,7 +792,7 @@ do_test savepoint-11.6 {
|
|||||||
integrity_check savepoint-11.7
|
integrity_check savepoint-11.7
|
||||||
do_test savepoint-11.8 {
|
do_test savepoint-11.8 {
|
||||||
execsql { ROLLBACK }
|
execsql { ROLLBACK }
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
file size test.db
|
file size test.db
|
||||||
} {8192}
|
} {8192}
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ do_test wal-7.1 {
|
|||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list 1024 [log_file_size 3 1024]]
|
} [list 1024 [log_file_size 3 1024]]
|
||||||
do_test wal-7.2 {
|
do_test wal-7.2 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list 2048 [log_file_size 3 1024]]
|
} [list 2048 [log_file_size 3 1024]]
|
||||||
|
|
||||||
@ -380,14 +380,14 @@ do_test wal-8.2 {
|
|||||||
INSERT INTO t1 SELECT blob(900) FROM t1; /* 16 */
|
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; /* 32 */
|
||||||
INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */
|
INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
}
|
}
|
||||||
file size test.db
|
file size test.db
|
||||||
} [expr 68*1024]
|
} [expr 68*1024]
|
||||||
do_test wal-8.3 {
|
do_test wal-8.3 {
|
||||||
execsql {
|
execsql {
|
||||||
DELETE FROM t1 WHERE rowid<54;
|
DELETE FROM t1 WHERE rowid<54;
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
}
|
}
|
||||||
file size test.db
|
file size test.db
|
||||||
} [expr 14*1024]
|
} [expr 14*1024]
|
||||||
@ -426,7 +426,7 @@ do_test wal-9.3 {
|
|||||||
db3 close
|
db3 close
|
||||||
|
|
||||||
do_test wal-9.4 {
|
do_test wal-9.4 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
db2 close
|
db2 close
|
||||||
sqlite3_wal db2 test.db
|
sqlite3_wal db2 test.db
|
||||||
execsql {PRAGMA integrity_check } db2
|
execsql {PRAGMA integrity_check } db2
|
||||||
@ -549,7 +549,7 @@ foreach code [list {
|
|||||||
sql2 { BEGIN; SELECT * FROM t1 }
|
sql2 { BEGIN; SELECT * FROM t1 }
|
||||||
} {1 2 3 4 5 6 7 8 9 10}
|
} {1 2 3 4 5 6 7 8 9 10}
|
||||||
do_test wal-10.$tn.12 {
|
do_test wal-10.$tn.12 {
|
||||||
catchsql { PRAGMA checkpoint }
|
catchsql { PRAGMA wal_checkpoint }
|
||||||
} {1 {database is locked}}
|
} {1 {database is locked}}
|
||||||
do_test wal-10.$tn.13 {
|
do_test wal-10.$tn.13 {
|
||||||
execsql { INSERT INTO t1 VALUES(11, 12) }
|
execsql { INSERT INTO t1 VALUES(11, 12) }
|
||||||
@ -568,7 +568,7 @@ foreach code [list {
|
|||||||
}
|
}
|
||||||
db busy busyhandler
|
db busy busyhandler
|
||||||
do_test wal-10.$tn.14 {
|
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
|
# Similar to the test above. Except this time, a new read transaction is
|
||||||
@ -582,7 +582,7 @@ foreach code [list {
|
|||||||
sql2 { BEGIN; SELECT * FROM t1; }
|
sql2 { BEGIN; SELECT * FROM t1; }
|
||||||
} {1 2 3 4 5 6 7 8 9 10 11 12}
|
} {1 2 3 4 5 6 7 8 9 10 11 12}
|
||||||
do_test wal-10.$tn.16 {
|
do_test wal-10.$tn.16 {
|
||||||
catchsql { PRAGMA checkpoint }
|
catchsql { PRAGMA wal_checkpoint }
|
||||||
} {1 {database is locked}}
|
} {1 {database is locked}}
|
||||||
proc busyhandler x {
|
proc busyhandler x {
|
||||||
if {$x==3} { sql3 { BEGIN; SELECT * FROM t1 } }
|
if {$x==3} { sql3 { BEGIN; SELECT * FROM t1 } }
|
||||||
@ -592,7 +592,7 @@ foreach code [list {
|
|||||||
}
|
}
|
||||||
db busy busyhandler
|
db busy busyhandler
|
||||||
do_test wal-10.$tn.17 {
|
do_test wal-10.$tn.17 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
} {}
|
} {}
|
||||||
do_test wal-10.$tn.18 {
|
do_test wal-10.$tn.18 {
|
||||||
sql3 { SELECT * FROM t1 }
|
sql3 { SELECT * FROM t1 }
|
||||||
@ -616,13 +616,13 @@ foreach code [list {
|
|||||||
# (as [db3] still has a snapshot locked).
|
# (as [db3] still has a snapshot locked).
|
||||||
#
|
#
|
||||||
do_test wal-10.$tn.23 {
|
do_test wal-10.$tn.23 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
} {}
|
} {}
|
||||||
do_test wal-10.$tn.24 {
|
do_test wal-10.$tn.24 {
|
||||||
sql2 { BEGIN; SELECT * FROM t1; }
|
sql2 { BEGIN; SELECT * FROM t1; }
|
||||||
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
|
} {1 2 3 4 5 6 7 8 9 10 11 12 13 14}
|
||||||
do_test wal-10.$tn.25 {
|
do_test wal-10.$tn.25 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
} {}
|
} {}
|
||||||
do_test wal-10.$tn.26 {
|
do_test wal-10.$tn.26 {
|
||||||
catchsql { INSERT INTO t1 VALUES(15, 16) }
|
catchsql { INSERT INTO t1 VALUES(15, 16) }
|
||||||
@ -641,11 +641,11 @@ foreach code [list {
|
|||||||
db busy {}
|
db busy {}
|
||||||
do_test wal-10.$tn.29 {
|
do_test wal-10.$tn.29 {
|
||||||
execsql { INSERT INTO t1 VALUES(17, 18) }
|
execsql { INSERT INTO t1 VALUES(17, 18) }
|
||||||
catchsql { PRAGMA checkpoint }
|
catchsql { PRAGMA wal_checkpoint }
|
||||||
} {1 {database is locked}}
|
} {1 {database is locked}}
|
||||||
do_test wal-10.$tn.30 {
|
do_test wal-10.$tn.30 {
|
||||||
code3 { sqlite3_finalize $::STMT }
|
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
|
# At one point, if a reader failed to upgrade to a writer because it
|
||||||
@ -685,7 +685,7 @@ foreach code [list {
|
|||||||
proc busyhandler x { return 1 }
|
proc busyhandler x { return 1 }
|
||||||
db busy busyhandler
|
db busy busyhandler
|
||||||
do_test wal-10.$tn.36 {
|
do_test wal-10.$tn.36 {
|
||||||
catchsql { PRAGMA checkpoint }
|
catchsql { PRAGMA wal_checkpoint }
|
||||||
} {1 {database is locked}}
|
} {1 {database is locked}}
|
||||||
do_test wal-10.$tn.36 {
|
do_test wal-10.$tn.36 {
|
||||||
sql3 { INSERT INTO t1 VALUES('e', 'f') }
|
sql3 { INSERT INTO t1 VALUES('e', 'f') }
|
||||||
@ -693,7 +693,7 @@ foreach code [list {
|
|||||||
} {a b c d}
|
} {a b c d}
|
||||||
do_test wal-10.$tn.37 {
|
do_test wal-10.$tn.37 {
|
||||||
sql2 COMMIT
|
sql2 COMMIT
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
} {}
|
} {}
|
||||||
|
|
||||||
catch { db close }
|
catch { db close }
|
||||||
@ -718,7 +718,7 @@ do_test wal-11.1 {
|
|||||||
list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
|
list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044]
|
||||||
} {1 3}
|
} {1 3}
|
||||||
do_test wal-11.2 {
|
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 [expr [file size test.db]/1024] [file size test.db-wal]
|
||||||
} [list 3 [log_file_size 3 1024]]
|
} [list 3 [log_file_size 3 1024]]
|
||||||
do_test wal-11.3 {
|
do_test wal-11.3 {
|
||||||
@ -753,7 +753,7 @@ do_test wal-11.7 {
|
|||||||
}
|
}
|
||||||
} {16 ok}
|
} {16 ok}
|
||||||
do_test wal-11.8 {
|
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 [expr [file size test.db]/1024] [file size test.db-wal]
|
||||||
} [list 37 [log_file_size 41 1024]]
|
} [list 37 [log_file_size 41 1024]]
|
||||||
do_test wal-11.9 {
|
do_test wal-11.9 {
|
||||||
@ -829,11 +829,11 @@ do_test wal-12.4 {
|
|||||||
db2 close
|
db2 close
|
||||||
do_test wal-12.5 {
|
do_test wal-12.5 {
|
||||||
execsql {
|
execsql {
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
UPDATE t2 SET y = 2 WHERE x = 'B';
|
UPDATE t2 SET y = 2 WHERE x = 'B';
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
UPDATE t1 SET y = 1 WHERE x = 'A';
|
UPDATE t1 SET y = 1 WHERE x = 'A';
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
UPDATE t1 SET y = 0 WHERE x = 'A';
|
UPDATE t1 SET y = 0 WHERE x = 'A';
|
||||||
SELECT * FROM t2;
|
SELECT * FROM t2;
|
||||||
}
|
}
|
||||||
@ -955,11 +955,11 @@ do_test wal-14 {
|
|||||||
INSERT INTO t1 SELECT randomblob(10), randomblob(100);
|
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
|
# left with an inconsistent cache. Running the CREATE INDEX statement
|
||||||
# in this state led to database corruption.
|
# in this state led to database corruption.
|
||||||
catchsql {
|
catchsql {
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
CREATE INDEX i1 on t1(b);
|
CREATE INDEX i1 on t1(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ do_test walbak-1.5 {
|
|||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list 1024 [log_file_size 6 1024]]
|
} [list 1024 [log_file_size 6 1024]]
|
||||||
do_test walbak-1.6 {
|
do_test walbak-1.6 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list [expr 3*1024] [log_file_size 6 1024]]
|
} [list [expr 3*1024] [log_file_size 6 1024]]
|
||||||
do_test walbak-1.7 {
|
do_test walbak-1.7 {
|
||||||
@ -87,7 +87,7 @@ do_test walbak-1.8 {
|
|||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list [expr 3*1024] [log_file_size 8 1024]]
|
} [list [expr 3*1024] [log_file_size 8 1024]]
|
||||||
do_test walbak-1.9 {
|
do_test walbak-1.9 {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
list [file size test.db] [file size test.db-wal]
|
list [file size test.db] [file size test.db-wal]
|
||||||
} [list [expr 2*1024] [log_file_size 8 1024]]
|
} [list [expr 2*1024] [log_file_size 8 1024]]
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ for {set i 1} {$i < $REPEATS} {incr i} {
|
|||||||
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
|
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
|
||||||
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
|
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 VALUES(randomblob(900));
|
||||||
INSERT INTO t1 VALUES(randomblob(900));
|
INSERT INTO t1 VALUES(randomblob(900));
|
||||||
@ -233,7 +233,7 @@ for {set i 1} {$i < $REPEATS} {incr i} {
|
|||||||
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
|
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */
|
||||||
INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */
|
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 VALUES(randomblob(900));
|
||||||
INSERT INTO t1 VALUES(randomblob(900));
|
INSERT INTO t1 VALUES(randomblob(900));
|
||||||
@ -260,9 +260,9 @@ for {set i 1} {$i < $REPEATS} {incr i} {
|
|||||||
CREATE TABLE t1(a, b);
|
CREATE TABLE t1(a, b);
|
||||||
INSERT INTO t1 VALUES(1, 2);
|
INSERT INTO t1 VALUES(1, 2);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
CREATE INDEX i1 ON t1(a);
|
CREATE INDEX i1 ON t1(a);
|
||||||
PRAGMA checkpoint;
|
PRAGMA wal_checkpoint;
|
||||||
}
|
}
|
||||||
} {1 {child process exited abnormally}}
|
} {1 {child process exited abnormally}}
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing the operation of the library in
|
# focus of this file is testing the operation of the library in
|
||||||
# "PRAGMA journal_mode=WAL" mode.
|
# "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]
|
set testdir [file dirname $argv0]
|
||||||
@ -18,27 +22,27 @@ source $testdir/tester.tcl
|
|||||||
|
|
||||||
ifcapable !wal {finish_test ; return }
|
ifcapable !wal {finish_test ; return }
|
||||||
|
|
||||||
proc sqlite3_wal {args} {
|
proc log_file_size {nFrame pgsz} {
|
||||||
eval sqlite3 $args
|
expr {12 + ($pgsz+16)*$nFrame}
|
||||||
[lindex $args 0] eval {
|
|
||||||
PRAGMA journal_mode = wal;
|
|
||||||
PRAGMA synchronous = normal;
|
|
||||||
PRAGMA page_size = 1024;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sqlite3_wal db test.db
|
|
||||||
db wal_hook wal_hook
|
|
||||||
|
|
||||||
set ::wal_hook [list]
|
set ::wal_hook [list]
|
||||||
proc wal_hook {zDb nEntry} {
|
proc wal_hook {zDb nEntry} {
|
||||||
lappend ::wal_hook $zDb $nEntry
|
lappend ::wal_hook $zDb $nEntry
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
db wal_hook wal_hook
|
||||||
|
|
||||||
do_test walhook-1.1 {
|
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
|
set ::wal_hook
|
||||||
} {main 3}
|
} {main 3}
|
||||||
|
|
||||||
do_test walhook-1.2 {
|
do_test walhook-1.2 {
|
||||||
set ::wal_hook [list]
|
set ::wal_hook [list]
|
||||||
execsql { INSERT INTO t1 VALUES(1, 'one') }
|
execsql { INSERT INTO t1 VALUES(1, 'one') }
|
||||||
@ -49,10 +53,9 @@ do_test walhook-1.3 {
|
|||||||
execsql { INSERT INTO t1 VALUES(2, 'two') }
|
execsql { INSERT INTO t1 VALUES(2, 'two') }
|
||||||
file size test.db
|
file size test.db
|
||||||
} [expr 3*1024]
|
} [expr 3*1024]
|
||||||
|
|
||||||
do_test walhook-1.4 {
|
do_test walhook-1.4 {
|
||||||
proc wal_hook {zDb nEntry} {
|
proc wal_hook {zDb nEntry} {
|
||||||
execsql { PRAGMA checkpoint }
|
execsql { PRAGMA wal_checkpoint }
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
execsql { CREATE TABLE t2(a, b) }
|
execsql { CREATE TABLE t2(a, b) }
|
||||||
@ -60,15 +63,49 @@ do_test walhook-1.4 {
|
|||||||
} [expr 4*1024]
|
} [expr 4*1024]
|
||||||
|
|
||||||
do_test walhook-1.5 {
|
do_test walhook-1.5 {
|
||||||
sqlite3_wal db2 test.db
|
sqlite3 db2 test.db
|
||||||
proc wal_hook {zDb nEntry} {
|
proc wal_hook {zDb nEntry} {
|
||||||
execsql { PRAGMA checkpoint } db2
|
execsql { PRAGMA wal_checkpoint } db2
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
|
execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
|
||||||
file size test.db
|
file size test.db
|
||||||
} [expr 6*1024]
|
} [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 { db2 close }
|
||||||
catch { db close }
|
catch { db close }
|
||||||
finish_test
|
finish_test
|
||||||
|
@ -48,7 +48,7 @@ for {set seed 1} {$seed<10} {incr seed} {
|
|||||||
} {ok}
|
} {ok}
|
||||||
|
|
||||||
do_test walslow-1.seed=$seed.$iTest.2 {
|
do_test walslow-1.seed=$seed.$iTest.2 {
|
||||||
execsql "PRAGMA checkpoint;"
|
execsql "PRAGMA wal_checkpoint;"
|
||||||
execsql { PRAGMA integrity_check }
|
execsql { PRAGMA integrity_check }
|
||||||
} {ok}
|
} {ok}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ proc do_thread_test2 {args} {
|
|||||||
#
|
#
|
||||||
# There is also a single checkpointer thread. It runs the following loop:
|
# 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.
|
# 2) Sleep for 500 ms.
|
||||||
#
|
#
|
||||||
do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {
|
do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {
|
||||||
@ -295,7 +295,7 @@ do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init {
|
|||||||
} -thread ckpt 1 {
|
} -thread ckpt 1 {
|
||||||
set nRun 0
|
set nRun 0
|
||||||
while {[tt_continue]} {
|
while {[tt_continue]} {
|
||||||
db eval "PRAGMA checkpoint"
|
db eval "PRAGMA wal_checkpoint"
|
||||||
usleep 500
|
usleep 500
|
||||||
incr nRun
|
incr nRun
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user