mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +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:
24
src/main.c
24
src/main.c
@@ -4209,11 +4209,29 @@ int sqlite3_snapshot_open(
|
||||
iDb = sqlite3FindDbName(db, zDb);
|
||||
if( iDb==0 || iDb>1 ){
|
||||
Btree *pBt = db->aDb[iDb].pBt;
|
||||
if( 0==sqlite3BtreeIsInReadTrans(pBt) ){
|
||||
rc = sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), pSnapshot);
|
||||
if( sqlite3BtreeIsInTrans(pBt)==0 ){
|
||||
Pager *pPager = sqlite3BtreePager(pBt);
|
||||
int bUnlock = 0;
|
||||
if( sqlite3BtreeIsInReadTrans(pBt) ){
|
||||
if( db->nVdbeActive==0 ){
|
||||
rc = sqlite3PagerSnapshotCheck(pPager, pSnapshot);
|
||||
if( rc==SQLITE_OK ){
|
||||
bUnlock = 1;
|
||||
rc = sqlite3BtreeCommit(pBt);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
rc = SQLITE_OK;
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3PagerSnapshotOpen(pPager, pSnapshot);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3BtreeBeginTrans(pBt, 0, 0);
|
||||
sqlite3PagerSnapshotOpen(sqlite3BtreePager(pBt), 0);
|
||||
sqlite3PagerSnapshotOpen(pPager, 0);
|
||||
}
|
||||
if( bUnlock ){
|
||||
sqlite3PagerSnapshotUnlock(pPager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user