From: drh Date: Mon, 10 May 2004 20:27:41 +0000 (+0000) Subject: Improvements to testing of sqlite_interrupt. More checking for interrupt X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9ec81c84ddbd7b1ee9db804a33a02ee19dd3e2f;p=thirdparty%2Fsqlite.git Improvements to testing of sqlite_interrupt. More checking for interrupt inside of VACUUM. (CVS 1344) FossilOrigin-Name: d596f513c3acfe0d297dc3f5c66f4b0ea2d12a34 --- diff --git a/manifest b/manifest index 34bc81e833..543f3efa81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\smemory\sleak\sin\sDETACH\swhen\susing\sthe\scodec.\s(CVS\s1317) -D 2004-05-07T01:46:01 +C Improvements\sto\stesting\sof\ssqlite_interrupt.\s\sMore\schecking\sfor\sinterrupt\ninside\sof\sVACUUM.\s(CVS\s1344) +D 2004-05-10T20:27:41 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -60,8 +60,8 @@ F src/tokenize.c 6676b946fd8825b67ab52140af4fdc57a70bda48 F src/trigger.c a9927b57c865b6f3df3fb5e40c9824d722660ded F src/update.c bd391079138e67d09c9af34528ca4137c29242d1 F src/util.c 122bc174f6c8c2eb6a9127d9f13c4c74f83b85e4 -F src/vacuum.c a4e8464c9f6d60659c5343e9d62c742463227820 -F src/vdbe.c f006200348ef3feded56bef8714e052da74a885a +F src/vacuum.c d34374a2d6d5b3d36419a7b87e0a15d2bf31fdd3 +F src/vdbe.c 0853ab9983b7adbba8c012bb8b152d8453bf8a97 F src/vdbe.h ac987945e4dd6f987bca534c6005899f089fc270 F src/vdbeInt.h b40ff02ce39fd076e6ff3369e19c1bbfe1986682 F src/vdbeaux.c e2cdd1ab63604a390612c73e26bdd2ef910e9438 @@ -94,7 +94,7 @@ F test/in.test 0de39b02ceeca90993b096822fb5a884661c5b47 F test/index.test 9295deefbdb6dedbe01be8905f0c448fe5bd4079 F test/insert.test a17b7f7017097afb2727aa5b67ceeb7ab0a120a1 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f -F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91 +F test/interrupt.test 0d50985f1aa6c39fe2cca4cf4a272c79ff1648e8 F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4 F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd @@ -188,7 +188,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P c90ed20dc4f95eb06a5259578597593f5968bfb7 -R d8249d1567d218e36b49e8c43150a27b +P c4bd99b79c66217140781309ed06e1ff3ef4a206 +R c633b9f2c50e2f0204a65c82493f0a7e U drh -Z 024ab278400ed22150e07d78741f9bbc +Z bb900cf181dd7b4856d93e8f07ef13c0 diff --git a/manifest.uuid b/manifest.uuid index 9df63d03f9..1e06c2674b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4bd99b79c66217140781309ed06e1ff3ef4a206 \ No newline at end of file +d596f513c3acfe0d297dc3f5c66f4b0ea2d12a34 \ No newline at end of file diff --git a/src/vacuum.c b/src/vacuum.c index 038d2d85ed..8699108de4 100644 --- a/src/vacuum.c +++ b/src/vacuum.c @@ -14,7 +14,7 @@ ** Most of the code in this file may be omitted by defining the ** SQLITE_OMIT_VACUUM macro. ** -** $Id: vacuum.c,v 1.13 2004/03/10 18:57:32 drh Exp $ +** $Id: vacuum.c,v 1.13.2.1 2004/05/10 20:27:41 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -239,6 +239,9 @@ int sqliteRunVacuum(char **pzErrMsg, sqlite *db){ (char*)0); return SQLITE_ERROR; } + if( db->flags & SQLITE_Interrupt ){ + return SQLITE_INTERRUPT; + } memset(&sVac, 0, sizeof(sVac)); /* Get the full pathname of the database file and create two @@ -308,13 +311,17 @@ end_of_vacuum: zErrMsg, (char*)0); } sqlite_exec(db, "ROLLBACK", 0, 0, 0); + if( (dbNew && (dbNew->flags & SQLITE_Interrupt)) + || (db->flags & SQLITE_Interrupt) ){ + rc = SQLITE_INTERRUPT; + } if( dbNew ) sqlite_close(dbNew); sqliteOsDelete(zTemp); sqliteFree(zTemp); sqliteFree(sVac.s1.z); sqliteFree(sVac.s2.z); if( zErrMsg ) sqlite_freemem(zErrMsg); - if( rc==SQLITE_ABORT ) sVac.rc = SQLITE_ERROR; + if( rc==SQLITE_ABORT && sVac.rc==SQLITE_OK ) sVac.rc = SQLITE_ERROR; return sVac.rc; #endif } diff --git a/src/vdbe.c b/src/vdbe.c index ce71f8d0b2..28761d3009 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.268.2.1 2004/04/29 16:16:30 drh Exp $ +** $Id: vdbe.c,v 1.268.2.2 2004/05/10 20:27:41 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -62,7 +62,7 @@ int sqlite_search_count = 0; /* ** When this global variable is positive, it gets decremented once before ** each instruction in the VDBE. When reaches zero, the SQLITE_Interrupt -** of the db.flags field is set in order to simulate and interrupt. +** of the db.flags field is set in order to simulate an interrupt. ** ** This facility is used for testing purposes only. It does not function ** in an ordinary build. @@ -4865,6 +4865,7 @@ default: { /* If we reach this point, it means that execution is finished. */ vdbe_halt: + CHECK_FOR_INTERRUPT if( rc ){ p->rc = rc; rc = SQLITE_ERROR; diff --git a/test/interrupt.test b/test/interrupt.test index 456cf48a17..878cc2a6ce 100644 --- a/test/interrupt.test +++ b/test/interrupt.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is the sqlite_interrupt() API. # -# $Id: interrupt.test,v 1.4 2004/02/18 16:57:23 drh Exp $ +# $Id: interrupt.test,v 1.4.2.1 2004/05/10 20:27:42 drh Exp $ set testdir [file dirname $argv0] @@ -37,12 +37,13 @@ proc cksum {{db db}} { # and checks to make sure SQLITE_INTERRUPT is returned. Eventually, # the routine completes successfully. # -proc interrupt_test {testid sql result {initcnt 0}} { +proc interrupt_test {testid sql result {initcnt 0} {maxcnt 1000000}} { set orig_sum [cksum] set i $initcnt - while 1 { + global sqlite_interrupt_count + while {$i<$maxcnt} { incr i - set ::sqlite_interrupt_count $i + set sqlite_interrupt_count $i do_test $testid.$i.1 [format { set ::r [catchsql %s] set ::code [db errorcode] @@ -52,14 +53,14 @@ proc interrupt_test {testid sql result {initcnt 0}} { do_test $testid.$i.2 { cksum } $orig_sum - } else { + } elseif {$sqlite_interrupt_count>0} { do_test $testid.$i.99 { set ::r } [list 0 $result] break } } - set ::sqlite_interrupt_count 0 + set sqlite_interrupt_count 0 } do_test interrupt-1.1 { @@ -68,7 +69,7 @@ do_test interrupt-1.1 { SELECT name FROM sqlite_master; } } {t1} -interrupt_test interrupt-1.2 {DROP TABLE t1} {} +interrupt_test interrupt-1.2 {DROP TABLE t1} {} 1 14 do_test interrupt-1.3 { execsql { SELECT name FROM sqlite_master; @@ -162,4 +163,5 @@ for {set i 1} {$i<$max_count-5} {incr i 1} { } {1 interrupted} } + finish_test