mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Allow sqlite3_snapshot_open() to be called to change the snapshot after a
read transaction is already open on database. FossilOrigin-Name: 051ac0152048ef52723196c26ca5f2629dafb782aec1c66fc30531bf54335043
This commit is contained in:
32
src/pager.c
32
src/pager.c
@@ -7653,6 +7653,38 @@ int sqlite3PagerSnapshotRecover(Pager *pPager){
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** The caller currently has a read transaction open on the database.
|
||||
** If this is not a WAL database, SQLITE_ERROR is returned. Otherwise,
|
||||
** this function takes a SHARED lock on the CHECKPOINTER slot and then
|
||||
** checks if the snapshot passed as the second argument is still
|
||||
** available. If so, SQLITE_OK is returned.
|
||||
**
|
||||
** If the snapshot is not available, SQLITE_ERROR is returned. Or, if
|
||||
** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
|
||||
** occurs (any value other than SQLITE_OK is returned), the CHECKPOINTER
|
||||
** lock is released before returning.
|
||||
*/
|
||||
int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot){
|
||||
int rc;
|
||||
if( pPager->pWal ){
|
||||
rc = sqlite3WalSnapshotCheck(pPager->pWal, pSnapshot);
|
||||
}else{
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Release a lock obtained by an earlier successful call to
|
||||
** sqlite3PagerSnapshotCheck().
|
||||
*/
|
||||
void sqlite3PagerSnapshotUnlock(Pager *pPager){
|
||||
assert( pPager->pWal );
|
||||
return sqlite3WalSnapshotUnlock(pPager->pWal);
|
||||
}
|
||||
|
||||
#endif /* SQLITE_ENABLE_SNAPSHOT */
|
||||
#endif /* !SQLITE_OMIT_WAL */
|
||||
|
||||
|
Reference in New Issue
Block a user