1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add experimental sqlite3_snapshot_recover() API.

FossilOrigin-Name: 174a6076a8d7bebe5efebf55f3fdc5d87c589cc7
This commit is contained in:
dan
2016-11-18 20:49:43 +00:00
parent edace5d4f1
commit 1158498dce
10 changed files with 221 additions and 15 deletions

View File

@@ -4044,6 +4044,34 @@ int sqlite3_snapshot_open(
return rc;
}
/*
** Recover as many snapshots as possible from the wal file associated with
** schema zDb of database db.
*/
int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb){
int rc = SQLITE_ERROR;
int iDb;
#ifndef SQLITE_OMIT_WAL
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ){
return SQLITE_MISUSE_BKPT;
}
#endif
sqlite3_mutex_enter(db->mutex);
iDb = sqlite3FindDbName(db, zDb);
if( iDb==0 || iDb>1 ){
Btree *pBt = db->aDb[iDb].pBt;
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
rc = sqlite3PagerSnapshotRecover(sqlite3BtreePager(pBt));
}
}
sqlite3_mutex_leave(db->mutex);
#endif /* SQLITE_OMIT_WAL */
return rc;
}
/*
** Free a snapshot handle obtained from sqlite3_snapshot_get().
*/