diff options
author | drh <drh@noemail.net> | 2002-08-18 20:28:06 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2002-08-18 20:28:06 +0000 |
commit | 6b8b8749d477000b70575a78f6b54adcf322febb (patch) | |
tree | ccd87fd2d143e2eaa68d27e8d61746e0333f8b42 /src | |
parent | d8acdb3c36e1f061f19afd8bfc22c89dd669493d (diff) | |
download | sqlite-6b8b8749d477000b70575a78f6b54adcf322febb.tar.gz sqlite-6b8b8749d477000b70575a78f6b54adcf322febb.zip |
Fix for ticket #110: return an error if trying to start a transaction within a
transaction or when attempting to commit or rollback outside of a transaction. (CVS 721)
FossilOrigin-Name: df51cb166bf7c5b8b0530cc86df8d2d68de81a40
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/build.c b/src/build.c index 2d2d55bc3..f1073d531 100644 --- a/src/build.c +++ b/src/build.c @@ -25,7 +25,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.108 2002/08/15 01:26:09 drh Exp $ +** $Id: build.c,v 1.109 2002/08/18 20:28:07 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1729,7 +1729,12 @@ void sqliteBeginTransaction(Parse *pParse, int onError){ if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; if( pParse->nErr || sqlite_malloc_failed ) return; - if( db->flags & SQLITE_InTrans ) return; + if( db->flags & SQLITE_InTrans ){ + pParse->nErr++; + sqliteSetString(&pParse->zErrMsg, "cannot start a transaction " + "within a transaction", 0); + return; + } sqliteBeginWriteOperation(pParse, 0); db->flags |= SQLITE_InTrans; db->onError = onError; @@ -1743,7 +1748,12 @@ void sqliteCommitTransaction(Parse *pParse){ if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; if( pParse->nErr || sqlite_malloc_failed ) return; - if( (db->flags & SQLITE_InTrans)==0 ) return; + if( (db->flags & SQLITE_InTrans)==0 ){ + pParse->nErr++; + sqliteSetString(&pParse->zErrMsg, + "cannot commit - no transaction is active", 0); + return; + } db->flags &= ~SQLITE_InTrans; sqliteEndWriteOperation(pParse); db->onError = OE_Default; @@ -1758,7 +1768,12 @@ void sqliteRollbackTransaction(Parse *pParse){ if( pParse==0 || (db=pParse->db)==0 || db->pBe==0 ) return; if( pParse->nErr || sqlite_malloc_failed ) return; - if( (db->flags & SQLITE_InTrans)==0 ) return; + if( (db->flags & SQLITE_InTrans)==0 ){ + pParse->nErr++; + sqliteSetString(&pParse->zErrMsg, + "cannot rollback - no transaction is active", 0); + return; + } v = sqliteGetVdbe(pParse); if( v ){ sqliteVdbeAddOp(v, OP_Rollback, 0, 0); |