aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-02-13 12:05:56 +0000
committerdrh <drh@noemail.net>2015-02-13 12:05:56 +0000
commit983b5ee73df642d1bfe5a1fcf61219c1608aec88 (patch)
tree9b1b3079990f30aba3da0683f4cacf64e4829db7 /src
parenta0efb1ae110ca9627afd7fbe88b8523105819e4e (diff)
downloadsqlite-983b5ee73df642d1bfe5a1fcf61219c1608aec88.tar.gz
sqlite-983b5ee73df642d1bfe5a1fcf61219c1608aec88.zip
Make sure the prepared statement auto-resets on extended error codes
of SQLITE_BUSY and SQLITE_LOCKED even when compiled using SQLITE_OMIT_AUTORESET. FossilOrigin-Name: 3c6ca414879feb1f5d31d5fd95a1737530aca624
Diffstat (limited to 'src')
-rw-r--r--src/vdbeInt.h3
-rw-r--r--src/vdbeapi.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/src/vdbeInt.h b/src/vdbeInt.h
index 1a7297e94..877da1143 100644
--- a/src/vdbeInt.h
+++ b/src/vdbeInt.h
@@ -344,6 +344,9 @@ struct Vdbe {
u32 cacheCtr; /* VdbeCursor row cache generation counter */
int pc; /* The program counter */
int rc; /* Value to return */
+#ifdef SQLITE_DEBUG
+ int rcApp; /* errcode set by sqlite3_result_error_code() */
+#endif
u16 nResColumn; /* Number of columns in one row of the result set */
u8 errorAction; /* Recovery action to do in case of an error */
u8 minWriteFileFormat; /* Minimum file format for writable database files */
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 21c537d77..b29338eb3 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -365,6 +365,9 @@ void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
pCtx->isError = errCode;
pCtx->fErrorOrAux = 1;
+#ifdef SQLITE_DEBUG
+ pCtx->pVdbe->rcApp = errCode;
+#endif
if( pCtx->pOut->flags & MEM_Null ){
sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
SQLITE_UTF8, SQLITE_STATIC);
@@ -445,7 +448,7 @@ static int sqlite3Step(Vdbe *p){
** or SQLITE_BUSY error.
*/
#ifdef SQLITE_OMIT_AUTORESET
- if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){
+ if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){
sqlite3_reset((sqlite3_stmt*)p);
}else{
return SQLITE_MISUSE_BKPT;
@@ -491,6 +494,9 @@ static int sqlite3Step(Vdbe *p){
if( p->bIsReader ) db->nVdbeRead++;
p->pc = 0;
}
+#ifdef SQLITE_DEBUG
+ p->rcApp = SQLITE_OK;
+#endif
#ifndef SQLITE_OMIT_EXPLAIN
if( p->explain ){
rc = sqlite3VdbeList(p);
@@ -535,7 +541,7 @@ end_of_step:
assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
|| rc==SQLITE_BUSY || rc==SQLITE_MISUSE
);
- assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );
+ assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
/* If this statement was prepared using sqlite3_prepare_v2(), and an
** error has occurred, then return the error code in p->rc to the