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

Update the sqlite3_snapshot_get() API so that if the caller does not have an open read transaction on the named database, one is automatically opened.

FossilOrigin-Name: b9c90f10297d8516a661449e8af898e682c930aa
This commit is contained in:
dan
2015-12-10 20:03:08 +00:00
parent 745c14eb15
commit 7116dc60dc
5 changed files with 48 additions and 26 deletions

View File

@@ -3891,10 +3891,11 @@ int sqlite3_snapshot_get(
iDb = sqlite3FindDbName(db, zDb);
if( iDb==0 || iDb>1 ){
Btree *pBt = db->aDb[iDb].pBt;
if( 0!=sqlite3BtreeIsInReadTrans(pBt)
&& 0==sqlite3BtreeIsInTrans(pBt)
){
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
if( 0==sqlite3BtreeIsInTrans(pBt) ){
rc = sqlite3BtreeBeginTrans(pBt, 0);
if( rc==SQLITE_OK ){
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
}
}
}