mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Fixes for snapshots API on this branch. Also ensure that the snapshots API
cannot be used with wal2 mode databases (for now anyhow). FossilOrigin-Name: d8c2d55fa4ec95c6506201edcd1cb2ef108a233bd87a6154f3593909977f7d3f
This commit is contained in:
13
src/wal.c
13
src/wal.c
@@ -3251,6 +3251,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
|
||||
int sqlite3WalSnapshotRecover(Wal *pWal){
|
||||
int rc;
|
||||
|
||||
/* Snapshots may not be used with wal2 mode databases. */
|
||||
if( isWalMode2(pWal) ) return SQLITE_ERROR;
|
||||
|
||||
assert( pWal->readLock>=0 );
|
||||
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -3325,6 +3328,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
|
||||
#ifdef SQLITE_ENABLE_SNAPSHOT
|
||||
int bChanged = 0;
|
||||
WalIndexHdr *pSnapshot = pWal->pSnapshot;
|
||||
if( pSnapshot && isWalMode2(pWal) ) return SQLITE_ERROR;
|
||||
if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
|
||||
bChanged = 1;
|
||||
}
|
||||
@@ -4794,9 +4798,12 @@ int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){
|
||||
WalIndexHdr *pRet;
|
||||
static const u32 aZero[4] = { 0, 0, 0, 0 };
|
||||
|
||||
/* Snapshots may not be used with wal2 mode databases. */
|
||||
if( isWalMode2(pWal) ) return SQLITE_ERROR;
|
||||
|
||||
assert( pWal->readLock>=0 && pWal->writeLock==0 );
|
||||
|
||||
if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){
|
||||
if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,8)==0 ){
|
||||
*ppSnapshot = 0;
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
@@ -4847,6 +4854,10 @@ int sqlite3_snapshot_cmp(sqlite3_snapshot *p1, sqlite3_snapshot *p2){
|
||||
*/
|
||||
int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){
|
||||
int rc;
|
||||
|
||||
/* Snapshots may not be used with wal2 mode databases. */
|
||||
if( isWalMode2(pWal) ) return SQLITE_ERROR;
|
||||
|
||||
rc = walLockShared(pWal, WAL_CKPT_LOCK);
|
||||
if( rc==SQLITE_OK ){
|
||||
WalIndexHdr *pNew = (WalIndexHdr*)pSnapshot;
|
||||
|
Reference in New Issue
Block a user