]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Allow SQL statements to be executed from within a progress callback.
authordrh <drh@noemail.net>
Fri, 26 May 2006 19:57:19 +0000 (19:57 +0000)
committerdrh <drh@noemail.net>
Fri, 26 May 2006 19:57:19 +0000 (19:57 +0000)
Be warned, however, that the progress callback might be called
recursively in this case.  It is up to the program to disable the
progress callback to prevent recursive invocations.
Ticket #1827. (CVS 3193)

FossilOrigin-Name: ffc4730c05ea64b8c32f64b323db9b96b26bcb88

manifest
manifest.uuid
src/vdbe.c
test/progress.test

index 98e165fa77bc7750bc4394e04fcf38fa612e41f9..bfa81fa9cc4511a51acd274437538f0407acd04e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Syntax\serrors\soverride\serrors\sfrom\sthe\scode\sgenerator,\snot\sthe\sother\nway\saround.\s(CVS\s3192)
-D 2006-05-25T12:17:31
+C Allow\sSQL\sstatements\sto\sbe\sexecuted\sfrom\swithin\sa\sprogress\scallback.\nBe\swarned,\showever,\sthat\sthe\sprogress\scallback\smight\sbe\scalled\nrecursively\sin\sthis\scase.\s\sIt\sis\sup\sto\sthe\sprogram\sto\sdisable\sthe\nprogress\scallback\sto\sprevent\srecursive\sinvocations.\nTicket\s#1827.\s(CVS\s3193)
+D 2006-05-26T19:57:20
 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
 F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -89,7 +89,7 @@ F src/update.c 34add66fcd3301b33b6e4c4c813f4e408f7ee4a0
 F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
 F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
 F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
-F src/vdbe.c a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba
+F src/vdbe.c b28d2da3235e42beebf2fc50450e17511dc855cf
 F src/vdbe.h 44ff995a8b4e87016794095273e9e7300f0001bb
 F src/vdbeInt.h 85cd5f81d38edb1b8f4786f407c77a7a3ba636fb
 F src/vdbeapi.c 7dc662e7c905ce666bb506dced932e0307115cbf
@@ -214,7 +214,7 @@ F test/pager3.test 2323bf27fd5bd887b580247e5bce500ceee994b4
 F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2
 F test/pragma.test 2ca8f71989dc4b9ad68210d1943040321c663a19
 F test/printf.test cdd8e20dd901382a385afcbaa777b9377815c2ad
-F test/progress.test 16496001da445e6534afb94562c286708316d82f x
+F test/progress.test 8b22b4974b0a95272566385f8cb8c341c7130df8 x
 F test/quick.test e220b3b6e62fe4fb4e2a703ab2ba730fedfe0424
 F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
@@ -356,7 +356,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 79a818bb05bc95c4c83375a679955dd18659b2b8
-R 6afc2153b06fc7cd8865c6e7fb5353fb
+P 5031ffc665782e7b300c498fb8be168443505add
+R 2cfd5505821ed35ab79a1cd8d40513fb
 U drh
-Z eed30d1789873390dba60e245702f077
+Z efb45abaf10add9abf49d6724472d8b2
index 40606009ee5ea7c625a608e1a81bf2b7da6d2491..a194f8def3ba37ef5ab5669262fbcf008f6285fc 100644 (file)
@@ -1 +1 @@
-5031ffc665782e7b300c498fb8be168443505add
\ No newline at end of file
+ffc4730c05ea64b8c32f64b323db9b96b26bcb88
\ No newline at end of file
index 239e3649c577699774b13d8e909781e3890e3d5a..c011f1986d776f898f222ff91652524ee8f57699 100644 (file)
@@ -43,7 +43,7 @@
 ** in this file for details.  If in doubt, do not deviate from existing
 ** commenting and indentation practices when changing or adding code.
 **
-** $Id: vdbe.c,v 1.548 2006/03/22 22:10:08 drh Exp $
+** $Id: vdbe.c,v 1.549 2006/05/26 19:57:20 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -495,11 +495,15 @@ int sqlite3VdbeExec(
     */
     if( db->xProgress ){
       if( db->nProgressOps==nProgressOps ){
+        int rc1, rc2;
+        if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
         if( db->xProgress(db->pProgressArg)!=0 ){
+          sqlite3SafetyOn(db);
           rc = SQLITE_ABORT;
           continue; /* skip to the next iteration of the for loop */
         }
         nProgressOps = 0;
+        if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
       }
       nProgressOps++;
     }
index 5a0d186480ee06b920ca0f7e2d549bc5fd378aa9..5616a7afdaab725ee43822df27cd853a53674c7a 100755 (executable)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the 'progress callback'.
 #
-# $Id: progress.test,v 1.5 2005/01/20 02:17:02 danielk1977 Exp $
+# $Id: progress.test,v 1.6 2006/05/26 19:57:20 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -129,4 +129,23 @@ do_test progress-1.4 {
 
 db progress 0 ""
 
+# Make sure other queries can be run from within the progress
+# handler.  Ticket #1827
+#
+do_test progress-1.5 {
+  set rx 0
+  proc set_rx {args} {
+    db progress 0 {}
+    set ::rx [db eval {SELECT count(*) FROM t1}]
+    return [expr 0]
+  }
+  db progress 10 set_rx
+  db eval {
+    SELECT sum(a) FROM t1
+  }
+} {66}
+do_test progress-1.6 {
+  set ::rx
+} {11}
+
 finish_test