aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordrh <>2021-03-10 16:35:37 +0000
committerdrh <>2021-03-10 16:35:37 +0000
commit099b385d17d424ab6fba5ed46e9735dc4b04f79b (patch)
tree78b2afaff140f54913678d2553a0b71a428469d1 /src/main.c
parentbc3c4e0830151a44d1ebd3f36c151d171d6dcf2a (diff)
downloadsqlite-099b385d17d424ab6fba5ed46e9735dc4b04f79b.tar.gz
sqlite-099b385d17d424ab6fba5ed46e9735dc4b04f79b.zip
Do not confuse the constant SQLITE_MAX_ATTACHED with the maximum number of
schemas. Add the new SQLITE_MAX_DB constant for the maximum number of schemas. [forum:/forumpost/a006d86f72|Forum post a006d86f72]. FossilOrigin-Name: 7b65fb9f7bd616f834633afd64b3448bf9ca2b6e4cc6d6c01e75d1d877c88a79
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 0f3989d9d..131f21b11 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2374,7 +2374,7 @@ int sqlite3_wal_checkpoint_v2(
return SQLITE_OK;
#else
int rc; /* Return code */
- int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */
+ int iDb; /* Schema to checkpoint */
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -2397,6 +2397,9 @@ int sqlite3_wal_checkpoint_v2(
sqlite3_mutex_enter(db->mutex);
if( zDb && zDb[0] ){
iDb = sqlite3FindDbName(db, zDb);
+ testcase( iDb==SQLITE_MAX_ATTACHED ); /* See forum post a006d86f72 */
+ }else{
+ iDb = SQLITE_MAX_DB; /* This means process all schemas */
}
if( iDb<0 ){
rc = SQLITE_ERROR;
@@ -2445,7 +2448,7 @@ int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
** 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
+** If iDb is passed SQLITE_MAX_DB then all attached databases are
** checkpointed. If an error is encountered it is returned immediately -
** no attempt is made to checkpoint any remaining databases.
**
@@ -2462,7 +2465,7 @@ int sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog, int *pnCkpt){
assert( !pnCkpt || *pnCkpt==-1 );
for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
- if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){
+ if( i==iDb || iDb==SQLITE_MAX_DB ){
rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt);
pnLog = 0;
pnCkpt = 0;