From de523acceb06573417d3cad10d0061eb0a42a965 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Fri, 15 Jun 2007 14:53:53 +0000 Subject: [PATCH] Fix for #2415. The progress handler should abandon only the current query, not all active queries. (CVS 4067) FossilOrigin-Name: 115e19fe22b9e79fcc400f3a59c80dd9828100e7 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/vdbe.c | 12 +++++++----- src/vdbeaux.c | 14 +++++++++++++- test/progress.test | 23 ++++++++++++++++++++++- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index a09da3981f..11fda9ac71 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index e302729c7d..8554fe99a9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -452115959f1bd22bfe64ed10724d6d08d4cbe3f5 \ No newline at end of file +115e19fe22b9e79fcc400f3a59c80dd9828100e7 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 9a575db64b..cdee714650 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -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++; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 7457045f5c..318632c3bd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1380,7 +1380,19 @@ int sqlite3VdbeHalt(Vdbe *p){ for(i=0; inOp; 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; diff --git a/test/progress.test b/test/progress.test index ca30b26abb..b25a100530 100755 --- a/test/progress.test +++ b/test/progress.test @@ -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 -- 2.47.3