------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Make\ssure\sthe\smutex\sis\sheld\swhile\scalling\ssqlite3ApiExit()\sin\s\nsqlite3_wal_checkpoint().\s\sOther\scleanup\sof\sWAL\slogic.
-D 2010-05-03T13:37:30
+C If\sthe\ssqlite3_wal_checkpoint()\sAPI\sis\spassed\sa\sNULL\spointer\sin\splace\sof\sa\sdatabase\sname,\sattempt\sto\scheckpoint\sall\sattached\sdatabases.
+D 2010-05-03T14:05:43
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 0f66a2b0c2ce2c44ab4a5436e05064d39d8f5cbf
+F src/main.c 6bc746f6016e0a3e6a7089078d9feffc0aa24a5e
F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P ff234cf574c7ae384ab1ebc79b2171ef0541bc91
-R e7545824307d5d5af98e4766ae2a26ad
-U drh
-Z 9a835b2804bf8190a366f2e988463519
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFL3tGdoxKgR168RlERAkuOAJ96ZgqU19yVJ4CAdOh6a78a7JzGjwCfSnph
-d7jKPMvbqcd69IRRUWbjMNM=
-=vT7t
------END PGP SIGNATURE-----
+P 11a85b821abff1ecb7ec8c37bc7783be9fc4ea6d
+R 496e930fc5a775a552ace6c40959352e
+U dan
+Z 225bbd40c88bfb84bfc467a361edc728
return SQLITE_OK;
#else
int rc; /* Return code */
- int iDb = 0; /* sqlite3.aDb[] index of db to checkpoint */
+ int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */
sqlite3_mutex_enter(db->mutex);
if( zDb ){
** Run a checkpoint on database iDb. This is a no-op if database iDb is
** not currently open in WAL mode.
**
-** If a transaction is open at either the database handle (db) or b-tree
-** level, this function returns SQLITE_LOCKED and a checkpoint is not
-** attempted. If an error occurs while running the checkpoint, an SQLite
-** error code is returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.
+** If a transaction is open on the database being checkpointed, this
+** function returns SQLITE_LOCKED and a checkpoint is not attempted. If
+** an error occurs while running the checkpoint, an SQLite error code is
+** returned (i.e. SQLITE_IOERR). Otherwise, SQLITE_OK.
**
** The mutex on database handle db should be held by the caller. The mutex
** associated with the specific b-tree being checkpointed is taken by
** this function while the checkpoint is running.
+**
+** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are
+** checkpointed. If an error is encountered it is returned immediately -
+** no attempt is made to checkpoint any remaining databases.
*/
int sqlite3Checkpoint(sqlite3 *db, int iDb){
- Btree *pBt; /* Btree handle to checkpoint */
- int rc; /* Return code */
+ int rc = SQLITE_OK; /* Return code */
+ int i; /* Used to iterate through attached dbs */
assert( sqlite3_mutex_held(db->mutex) );
- pBt = db->aDb[iDb].pBt;
- if( sqlite3BtreeIsInReadTrans(pBt) ){
- rc = SQLITE_LOCKED;
- }else{
- sqlite3BtreeEnter(pBt);
- rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
- sqlite3BtreeLeave(pBt);
+ for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
+ if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){
+ Btree *pBt = db->aDb[i].pBt;
+ if( pBt ){
+ if( sqlite3BtreeIsInReadTrans(pBt) ){
+ rc = SQLITE_LOCKED;
+ }else{
+ sqlite3BtreeEnter(pBt);
+ rc = sqlite3PagerCheckpoint(sqlite3BtreePager(pBt));
+ sqlite3BtreeLeave(pBt);
+ }
+ }
+ }
}
return rc;