]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Small performance improvement in the sqlite3_step() interface.
authordrh <drh@noemail.net>
Mon, 29 Jun 2020 13:12:42 +0000 (13:12 +0000)
committerdrh <drh@noemail.net>
Mon, 29 Jun 2020 13:12:42 +0000 (13:12 +0000)
FossilOrigin-Name: 61400ef9f1337c77263b4d3e43a1983b0c4cf7137f066a2691768c98877035ef

manifest
manifest.uuid
src/vdbeapi.c

index d98b681ad8ff2b82afb336ecd6295d063105ce67..fa7b4824c6ed5d14ab5b531120bb5db3cac466ee 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,6 +1,6 @@
 B 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
-C Fix\sa\sproblem\sthat\scould\scause\san\sinfinite\sloop\sin\sthe\sfts3\s'merge'\scommand.
-D 2020-06-26T20:41:18.958
+C Small\sperformance\simprovement\sin\sthe\ssqlite3_step()\sinterface.
+D 2020-06-29T13:12:42.266
 F Makefile.in 19374a5db06c3199ec1bab71ab74a103d8abf21053c05e9389255dc58083f806
 F Makefile.msc 48f5a3fc32672c09ad73795749f6253e406a31526935fbbffd8f021108d54574
 F autoconf/Makefile.am a8d1d24affe52ebf8d7ddcf91aa973fa0316618ab95bb68c87cabf8faf527dc8
@@ -13,6 +13,7 @@ F src/build.c ba1bbe563a3dc02d5fed20537603181e5289c13ea30ae5e775f552e7557adbfa
 F src/expr.c a3ab84399b3415f66d2d0c25f5bcd98ef465c0c07ea1f19bf2a418b1c8fcad74
 F src/shell.c.in d663152487d4bfddea0f6d21ebc2ed51575d22657a02c6828afd344bbd4651af
 F src/test1.c fe56c4bcaa2685ca9aa25d817a0ee9345e189aff4a5a71a3d8ba946c7776feb8
+F src/vdbeapi.c c1a9004ac554d8d48794d2ce5f80397f8e419fd28643a543cc1e004c7713c3ef
 F test/decimal.test 12739a01bdba4c4d79f95b323e6b67b9fad1ab6ffb56116bd2b9c81a5b19e1d9
 F test/fts3corrupt4.test 21632b7d118833739715f89cf930ee8bbcfba52877e37786dc8ca375360d578c
 F test/fuzzdata8.db 0ae860b36b79fd41cafddc9e6602358b2d5c331cf200283221e659f86e196c0c
@@ -23,7 +24,7 @@ F tool/mksqlite3c.tcl f4ef476510eca4124c874a72029f1e01bc54a896b1724e8f9eef0d8bfa
 F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
 F tool/showlocks.c 9cc5e66d4ebbf2d194f39db2527ece92077e86ae627ddd233ee48e16e8142564
 F tool/speed-check.sh 615cbdf50f1409ef3bbf9f682e396df80f49d97ed93ed3e61c8e91fae6afde58
-P e12225d59c63ba392db4fa8dc26700ac26b20c8b98ea5107eef0e0b5138ace87
-R 8648f88fe9cf53ead409a3c8323d8ebd
-U dan
-Z 776105c92ba8eb650aef6a142c51b9bd
+P be545f85a6ef09cc6c762f7d2ab7a0b3adf5590c3fbdc9903e6b5b5cec6e823f
+R 9c35047475325526f2679b4ad3fed8bb
+U drh
+Z 841383906d65732bca5d23afa02166d8
index 9f3f9b6c380bcc21eed0e7ffac7d1e8fd5f506a5..4a7ef1e815b4d825c835026ff9ebab648d1071a5 100644 (file)
@@ -1 +1 @@
-be545f85a6ef09cc6c762f7d2ab7a0b3adf5590c3fbdc9903e6b5b5cec6e823f
\ No newline at end of file
+61400ef9f1337c77263b4d3e43a1983b0c4cf7137f066a2691768c98877035ef
\ No newline at end of file
index b9ac9fa797b1eae564fac896a18501a7b5fca9e8..2126318e05109057e23786094e23ae7df0221004 100644 (file)
@@ -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);
 }