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

Require that the database handle be in autocommit mode for

sqlite3_snapshot_get() to succeed. This is because it may open a read
transaction on the database file.

FossilOrigin-Name: 83b658dad091211ade3594d1e8d00ce525882506
This commit is contained in:
dan
2016-11-18 18:43:39 +00:00
parent 93006cdd85
commit edace5d4f1
5 changed files with 57 additions and 24 deletions

View File

@@ -3981,7 +3981,6 @@ int sqlite3_snapshot_get(
){
int rc = SQLITE_ERROR;
#ifndef SQLITE_OMIT_WAL
int iDb;
#ifdef SQLITE_ENABLE_API_ARMOR
if( !sqlite3SafetyCheckOk(db) ){
@@ -3990,13 +3989,15 @@ int sqlite3_snapshot_get(
#endif
sqlite3_mutex_enter(db->mutex);
iDb = sqlite3FindDbName(db, zDb);
if( iDb==0 || iDb>1 ){
Btree *pBt = db->aDb[iDb].pBt;
if( 0==sqlite3BtreeIsInTrans(pBt) ){
rc = sqlite3BtreeBeginTrans(pBt, 0);
if( rc==SQLITE_OK ){
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
if( db->autoCommit==0 ){
int iDb = sqlite3FindDbName(db, zDb);
if( iDb==0 || iDb>1 ){
Btree *pBt = db->aDb[iDb].pBt;
if( 0==sqlite3BtreeIsInTrans(pBt) ){
rc = sqlite3BtreeBeginTrans(pBt, 0);
if( rc==SQLITE_OK ){
rc = sqlite3PagerSnapshotGet(sqlite3BtreePager(pBt), ppSnapshot);
}
}
}
}