]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the progress handler so that it keeps track of the number of VDBE
authordrh <drh@noemail.net>
Thu, 25 Jul 2013 16:27:51 +0000 (16:27 +0000)
committerdrh <drh@noemail.net>
Thu, 25 Jul 2013 16:27:51 +0000 (16:27 +0000)
cycles across sqlite3_step() calls and issues callbacks when the cumulative
instruction count reaches threshold.

FossilOrigin-Name: 4698a82ef855a8e56163622283fb25317d7efdc4

manifest
manifest.uuid
src/sqlite.h.in
src/vdbe.c

index 156319adc0f7f1dd8e2919a56c067b6f1faff9e4..91234f232bf8033fb01d035f7a4dfbfc4a451aa6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\s'queryplantest'\starget\sto\sthe\sMSVC\smakefile.
-D 2013-07-20T00:34:31.920
+C Enhance\sthe\sprogress\shandler\sso\sthat\sit\skeeps\strack\sof\sthe\snumber\sof\sVDBE\ncycles\sacross\ssqlite3_step()\scalls\sand\sissues\scallbacks\swhen\sthe\scumulative\ninstruction\scount\sreaches\sthreshold.
+D 2013-07-25T16:27:51.835
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -218,7 +218,7 @@ F src/resolve.c 89f9003e8316ee3a172795459efc2a0274e1d5a8
 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
 F src/select.c 91b62654caf8dfe292fb8882715e575d34ad3874
 F src/shell.c 7da98ff9cbb19d7ef213a295178039bcb457804a
-F src/sqlite.h.in ba19609c0dab076a169b0cd2e7d4a479c5b3f664
+F src/sqlite.h.in d6a7523d6795317aac574fccc67d9df25253771c
 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
 F src/sqliteInt.h 6d3115f774aa3e87737f9447c9c0cea992c5bdbf
@@ -277,7 +277,7 @@ F src/update.c 8e76c3d03e4b7b21cb250bd2df0c05e12993e577
 F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
 F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9
 F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8
-F src/vdbe.c 816e686198c7d83a71545dfb4b34ec65f8071d23
+F src/vdbe.c d6048a720c197db2f0e7d618e918bd2e2eff0322
 F src/vdbe.h f380af2a7fab32ba8a8b05bf042497636afec66d
 F src/vdbeInt.h e9b7c6b165a31a4715c5aa97223d20d265515231
 F src/vdbeapi.c 4d13580bd058b39623e8fcfc233b7df4b8191e8b
@@ -1103,7 +1103,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P f755b4b21c885f3e897c2a79fc7ac1220210e653
-R c94bb34849c12b79ab21d48a7e4bfef4
-U mistachkin
-Z e904e41c59c0106f85082fb614ea3828
+P ad0551e039ccaa9e7a28682b756b56ac2b8fef0d
+R d2338440342f7943c0617ebcafb61de4
+U drh
+Z 47bbc05204d6969b9fef882b748d56a7
index 7a0ddc57b55e7a663bd7c4ddf087999ee0d7e946..21d84aac97e518c0fab601684760e6dc3117686a 100644 (file)
@@ -1 +1 @@
-ad0551e039ccaa9e7a28682b756b56ac2b8fef0d
\ No newline at end of file
+4698a82ef855a8e56163622283fb25317d7efdc4
\ No newline at end of file
index a87e8810f2b17f87dbd2ce97958f1dc5190c8ee7..2fc3e80a4a9e9f05650dbe9aaad45714c0ddad66 100644 (file)
@@ -2556,7 +2556,8 @@ SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
 ** ^The parameter P is passed through as the only parameter to the 
 ** callback function X.  ^The parameter N is the approximate number of 
 ** [virtual machine instructions] that are evaluated between successive
-** invocations of the callback X.
+** invocations of the callback X.  ^If N is less than one then the progress
+** handler is disabled.
 **
 ** ^Only a single progress handler may be defined at one time per
 ** [database connection]; setting a new progress handler cancels the
index af135f5309ec8b9bf4eb0c81cea11fdb0f54ca5e..4752c1a8829b7d077038bad1cfbbdba415aa97ed 100644 (file)
@@ -555,7 +555,7 @@ int sqlite3VdbeExec(
   int iCompare = 0;          /* Result of last OP_Compare operation */
   unsigned nVmStep = 0;      /* Number of virtual machine steps */
 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
-  unsigned nProgressOps = 0; /* nVmStep at last progress callback. */
+  unsigned nProgressLimit;   /* Invoke xProgress() when nVmStep reaches this */
 #endif
   Mem *aMem = p->aMem;       /* Copy of p->aMem */
   Mem *pIn1 = 0;             /* 1st input operand */
@@ -585,6 +585,17 @@ int sqlite3VdbeExec(
   db->busyHandler.nBusy = 0;
   CHECK_FOR_INTERRUPT;
   sqlite3VdbeIOTraceSql(p);
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+  if( db->xProgress ){
+    assert( 0 < db->nProgressOps );
+    nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1];
+    if( nProgressLimit==0 ){
+      nProgressLimit = db->nProgressOps;
+    }else{
+      nProgressLimit %= (unsigned)db->nProgressOps;
+    }
+  }
+#endif
 #ifdef SQLITE_DEBUG
   sqlite3BeginBenignMalloc();
   if( p->pc==0  && (p->db->flags & SQLITE_VdbeListing)!=0 ){
@@ -745,14 +756,16 @@ check_for_interrupt:
   ** If the progress callback returns non-zero, exit the virtual machine with
   ** a return code SQLITE_ABORT.
   */
-  if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){
+  if( db->xProgress!=0 && nVmStep>=nProgressLimit ){
     int prc;
     prc = db->xProgress(db->pProgressArg);
     if( prc!=0 ){
       rc = SQLITE_INTERRUPT;
       goto vdbe_error_halt;
     }
-    nProgressOps = nVmStep;
+    if( db->xProgress!=0 ){
+      nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps);
+    }
   }
 #endif