aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeapi.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2020-07-13 18:04:27 +0000
committerdan <dan@noemail.net>2020-07-13 18:04:27 +0000
commita7f82d9f47ca75a2f47dc14f8a8deb6730d718d0 (patch)
treee2000d1d8b1b14297c1a8790c65dd90c4a20e2b9 /src/vdbeapi.c
parent7465787b97a0a09841e343630a07ba80f1399e4a (diff)
parent5b107654e965973e68c88f90a09a3cc53bac9d8b (diff)
downloadsqlite-a7f82d9f47ca75a2f47dc14f8a8deb6730d718d0.tar.gz
sqlite-a7f82d9f47ca75a2f47dc14f8a8deb6730d718d0.zip
Merge latest trunk changes with this branch.
FossilOrigin-Name: 5ee3c27e20d12a126fb773b428bb864102b949a5b26a8d5c523753dcedf4be10
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r--src/vdbeapi.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 4337a33a5..2126318e0 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -655,6 +655,13 @@ static int sqlite3Step(Vdbe *p){
if( p->pc<0 && p->expired ){
p->rc = SQLITE_SCHEMA;
rc = SQLITE_ERROR;
+ if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 ){
+ /* If this statement was prepared using saved SQL and an
+ ** error has occurred, then return the error code in p->rc to the
+ ** caller. Set the error code in the database handle to the same value.
+ */
+ rc = sqlite3VdbeTransferError(p);
+ }
goto end_of_step;
}
if( p->pc<0 ){
@@ -710,35 +717,27 @@ static int sqlite3Step(Vdbe *p){
if( p->rc!=SQLITE_OK ){
rc = SQLITE_ERROR;
}
+ }else if( rc!=SQLITE_DONE && (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 ){
+ /* If this statement was prepared using saved SQL and an
+ ** error has occurred, then return the error code in p->rc to the
+ ** caller. Set the error code in the database handle to the same value.
+ */
+ rc = sqlite3VdbeTransferError(p);
}
}
db->errCode = rc;
if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){
p->rc = SQLITE_NOMEM_BKPT;
+ if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0 ) rc = p->rc;
}
end_of_step:
- /* At this point local variable rc holds the value that should be
- ** returned if this statement was compiled using the legacy
- ** sqlite3_prepare() interface. According to the docs, this can only
- ** be one of the values in the first assert() below. Variable p->rc
- ** contains the value that would be returned if sqlite3_finalize()
- ** were called on statement p.
- */
- assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
+ /* There are only a limited number of result codes allowed from the
+ ** statements prepared using the legacy sqlite3_prepare() interface */
+ assert( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
+ || rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
);
- assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
- if( rc!=SQLITE_ROW
- && rc!=SQLITE_DONE
- && (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
- ){
- /* If this statement was prepared using saved SQL and an
- ** error has occurred, then return the error code in p->rc to the
- ** caller. Set the error code in the database handle to the same value.
- */
- rc = sqlite3VdbeTransferError(p);
- }
return (rc&db->errMask);
}
@@ -1355,7 +1354,7 @@ static int vdbeUnbind(Vdbe *p, int i){
/* If the bit corresponding to this variable in Vdbe.expmask is set, then
** binding a new value to this variable invalidates the current query plan.
**
- ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host
+ ** IMPLEMENTATION-OF: R-57496-20354 If the specific value bound to a host
** parameter in the WHERE clause might influence the choice of query plan
** for a statement, then the statement will be automatically recompiled,
** as if there had been a schema change, on the first sqlite3_step() call