Change blocking-checkpoint tests so that they run once using "PRAGMA wal_checkpoint" and once using calls to sqlite3_wal_checkpoint_v2(). Also fix edge cases surrounding the output variables set by wal_checkpoint_v2().
FossilOrigin-Name: 5a4b6652cf3780ffed6fe0fe669e8090b0b71e81
diff --git a/src/main.c b/src/main.c
index 9f7d4b1..b202ac9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1356,6 +1356,10 @@
int rc; /* Return code */
int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */
+ /* Initialize the output variables to -1 in case an error occurs. */
+ if( pnLog ) *pnLog = -1;
+ if( pnCkpt ) *pnCkpt = -1;
+
if( eMode!=SQLITE_CHECKPOINT_PASSIVE
&& eMode!=SQLITE_CHECKPOINT_FULL
&& eMode!=SQLITE_CHECKPOINT_RESTART
@@ -1416,6 +1420,8 @@
int bBusy = 0; /* True if SQLITE_BUSY has been encountered */
assert( sqlite3_mutex_held(db->mutex) );
+ assert( !pnLog || *pnLog==-1 );
+ assert( !pnCkpt || *pnCkpt==-1 );
for(i=0; i<db->nDb && rc==SQLITE_OK; i++){
if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){