]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix for #2415. The progress handler should abandon only the current query, not all...
authordanielk1977 <danielk1977@noemail.net>
Fri, 15 Jun 2007 14:53:53 +0000 (14:53 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 15 Jun 2007 14:53:53 +0000 (14:53 +0000)
FossilOrigin-Name: 115e19fe22b9e79fcc400f3a59c80dd9828100e7

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

index a09da3981f65b88ce5315910b5bc928698cd2bed..11fda9ac71e79165bdc54634c762fd2d3c595555 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Do\snot\stry\sto\srun\sthe\sfuzz_malloc\stests\sif\sSQLITE_MEMDEBUG\sis\snot\senabled.\s(CVS\s4066)
-D 2007-06-15T13:57:20
+C Fix\sfor\s#2415.\sThe\sprogress\shandler\sshould\sabandon\sonly\sthe\scurrent\squery,\snot\sall\sactive\squeries.\s(CVS\s4067)
+D 2007-06-15T14:53:53
 F Makefile.in b9971ab07868cf2b3209fe3bf8c52e7e25af4193
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -134,11 +134,11 @@ F src/update.c 3359041db390a8f856d67272f299600e2104f350
 F src/utf.c 01b2aba02b10d12903e9e1ff897215c9faf6b662
 F src/util.c 80cdf6b68d03b8f0ab3237a390842e039cff66c6
 F src/vacuum.c 8bd895d29e7074e78d4e80f948e35ddc9cf2beef
-F src/vdbe.c 2653777a2bcef952150fbf8112966d66f7bc416a
+F src/vdbe.c 4f3e83218359fd51ae0b6efc445a97bd5f658ae4
 F src/vdbe.h 001c5b257567c1d3de7feb2203aac71d0d7b16a3
 F src/vdbeInt.h 7d2bf163d6d4e815724a457f2216dd8e38c3955c
 F src/vdbeapi.c 3747e4c3bc3139ff688bb3df462b10e42c084d16
-F src/vdbeaux.c 97dcf9659cbbad54189d5a3ec0cbab111073ab2e
+F src/vdbeaux.c b4eda47b713aa8fbe70dce4922852fd48b919555
 F src/vdbeblob.c 96f3572fdc45eda5be06e6372b612bc30742d9f0
 F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
 F src/vdbemem.c d86c25bbfe8102499ff7505fca44a779c68694d8
@@ -325,7 +325,7 @@ F test/pageropt.test b4b38eb3cf76be2be444326856248898bb0e3fc9
 F test/pagesize.test e0a8b3fe80f8b8e808d94a00734c7a18c76c407e
 F test/pragma.test b0e73879206934a835856a8b8c4cc884cd8562f3
 F test/printf.test 69d8cb0771a1a5e4d9d5dece12fc2c16179ac5e5
-F test/progress.test 45ac03936cf2ff2a7af9e078e6559b314a394037 x
+F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 x
 F test/ptrchng.test 1c712dd6516e1377471744fa765e41c79a357da6
 F test/quick.test 73a81a29fc28661c9c3fee2dcc3ded83cb1f1834
 F test/quote.test 215897dbe8de1a6f701265836d6601cc6ed103e6
@@ -505,7 +505,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 0f944cb9fbe30c2a7ec36b7dc7e21fb39a60e810
-R 513948dc0704883d2813a8aa6ecdf882
-U drh
-Z 73dfb0f1e49edb37791017acd88acfae
+P 452115959f1bd22bfe64ed10724d6d08d4cbe3f5
+R d9eb09dec49e726a53ec8218b08b7938
+U danielk1977
+Z bb53f3bafee11aa837339c883edc6674
index e302729c7de77d1d3b673686ca6ec03ec72c516f..8554fe99a94b259e82d607b9eaed0eaae6cb819e 100644 (file)
@@ -1 +1 @@
-452115959f1bd22bfe64ed10724d6d08d4cbe3f5
\ No newline at end of file
+115e19fe22b9e79fcc400f3a59c80dd9828100e7
\ No newline at end of file
index 9a575db64bc3599e037501dfc4c6cb0c5bfd288b..cdee71465038ccd1ea172c0c1f131aea9c20cad2 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.625 2007/06/13 16:49:49 danielk1977 Exp $
+** $Id: vdbe.c,v 1.626 2007/06/15 14:53:53 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -545,12 +545,14 @@ int sqlite3VdbeExec(
     */
     if( db->xProgress ){
       if( db->nProgressOps==nProgressOps ){
+        int prc;
         if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
-        if( db->xProgress(db->pProgressArg)!=0 ){
-          sqlite3_interrupt(db);
-        }
+        prc =db->xProgress(db->pProgressArg);
         if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
-        CHECK_FOR_INTERRUPT;
+        if( prc!=0 ){
+          rc = SQLITE_INTERRUPT;
+          goto vdbe_halt;
+        }
         nProgressOps = 0;
       }
       nProgressOps++;
index 7457045f5c5f8f27c59dee4556b2d3cc55319014..318632c3bd4e5b9925aba1ef270c90e7de2213d2 100644 (file)
@@ -1380,7 +1380,19 @@ int sqlite3VdbeHalt(Vdbe *p){
       for(i=0; i<p->nOp; i++){ 
         switch( p->aOp[i].opcode ){
           case OP_Transaction:
-            isReadOnly = 0;
+            /* This is a bit strange. If we hit a malloc() or IO error and
+            ** the statement did not open a statement transaction, we will
+            ** rollback any active transaction and abort all other active
+            ** statements. Or, if this is an SQLITE_INTERRUPT error, we
+            ** will only rollback if the interrupted statement was a write.
+            **
+            ** It could be argued that read-only statements should never
+            ** rollback anything. But careful analysis is required before
+            ** making this change
+            */
+            if( p->aOp[i].p2 || mrc!=SQLITE_INTERRUPT ){
+              isReadOnly = 0;
+            }
             break;
           case OP_Statement:
             isStatement = 1;
index ca30b26abbf042330de75a3a509b118041e23ed8..b25a100530ba63d45d13cdb763136c4cca2d85e3 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.7 2007/06/13 16:49:49 danielk1977 Exp $
+# $Id: progress.test,v 1.8 2007/06/15 14:53:53 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -153,4 +153,25 @@ do_test progress-1.6 {
   set ::rx
 } {10}
 
+# Check that abandoning a query using the progress handler does
+# not cause other queries to abort. Ticket #2415.
+do_test progress-1.7 {
+  execsql {
+    CREATE TABLE abc(a, b, c);
+    INSERT INTO abc VALUES(1, 2, 3);
+    INSERT INTO abc VALUES(4, 5, 6);
+    INSERT INTO abc VALUES(7, 8, 9);
+  }
+
+  set ::res [list]
+  db eval {SELECT a, b, c FROM abc} {
+    lappend ::res $a $b $c
+    db progress 10 "expr 1"
+    catch {db eval {SELECT a, b, c FROM abc} { }} msg
+    lappend ::res $msg
+  }
+
+  set ::res
+} {1 2 3 interrupted 4 5 6 interrupted 7 8 9 interrupted}
+
 finish_test