1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Allow read transactions to be freely opened and closed by SQL statements run from within the implementation of user-functions if the user-function is called by a SELECT statement that does not access any database tables (e.g. "SELECT user_function();").

FossilOrigin-Name: f308c4851726b4b75636f714466f2314f56e3ec0
This commit is contained in:
dan
2013-06-28 19:41:43 +00:00
parent 40aa936f7f
commit c0537fe59b
6 changed files with 26 additions and 20 deletions

View File

@@ -2686,6 +2686,7 @@ case OP_Savepoint: {
assert( p1==SAVEPOINT_BEGIN||p1==SAVEPOINT_RELEASE||p1==SAVEPOINT_ROLLBACK );
assert( db->pSavepoint || db->isTransactionSavepoint==0 );
assert( checkSavepointCount(db) );
assert( p->bIsReader );
if( p1==SAVEPOINT_BEGIN ){
if( db->nVdbeWrite>0 ){
@@ -2847,6 +2848,7 @@ case OP_AutoCommit: {
assert( desiredAutoCommit==1 || desiredAutoCommit==0 );
assert( desiredAutoCommit==1 || iRollback==0 );
assert( db->nVdbeActive>0 ); /* At least this one VM is active */
assert( p->bIsReader );
#if 0
if( turnOnAC && iRollback && db->nVdbeActive>1 ){
@@ -2953,7 +2955,7 @@ case OP_Transaction: {
}
if( pOp->p2 && p->usesStmtJournal
&& (db->autoCommit==0 || db->nVdbeActive>1)
&& (db->autoCommit==0 || db->nVdbeRead>1)
){
assert( sqlite3BtreeIsInTrans(pBt) );
if( p->iStatement==0 ){
@@ -4744,12 +4746,14 @@ case OP_Destroy: { /* out2-prerelease */
#ifndef SQLITE_OMIT_VIRTUALTABLE
iCnt = 0;
for(pVdbe=db->pVdbe; pVdbe; pVdbe = pVdbe->pNext){
if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->inVtabMethod<2 && pVdbe->pc>=0 ){
if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->bIsReader
&& pVdbe->inVtabMethod<2 && pVdbe->pc>=0
){
iCnt++;
}
}
#else
iCnt = db->nVdbeActive;
iCnt = db->nVdbeRead;
#endif
pOut->flags = MEM_Null;
if( iCnt>1 ){
@@ -5572,7 +5576,7 @@ case OP_JournalMode: { /* out2-prerelease */
if( (eNew!=eOld)
&& (eOld==PAGER_JOURNALMODE_WAL || eNew==PAGER_JOURNALMODE_WAL)
){
if( !db->autoCommit || db->nVdbeActive>1 ){
if( !db->autoCommit || db->nVdbeRead>1 ){
rc = SQLITE_ERROR;
sqlite3SetString(&p->zErrMsg, db,
"cannot change %s wal mode from within a transaction",