VACUUM returns SQLITE_INTERRUPT when interrupted. Ticket #593. (CVS 1228)
FossilOrigin-Name: 2fe9f5101cb0f743532912ece3d37f6c873e7025
This commit is contained in:
parent
ab9426e242
commit
93581642d2
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Only\sdefine\s_FILE_OFFSET_BITS\sif\sit\sis\snot\salready\sdefined.\s\sTicket\s#605.\s(CVS\s1227)
|
||||
D 2004-02-11T16:38:06
|
||||
C VACUUM\sreturns\sSQLITE_INTERRUPT\swhen\sinterrupted.\s\sTicket\s#593.\s(CVS\s1228)
|
||||
D 2004-02-12T13:02:56
|
||||
F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -60,8 +60,8 @@ F src/tokenize.c 8c95dcd2620b18dc0db1cdc97f9e111d11e55fe0
|
||||
F src/trigger.c ce83e017b407d046e909d05373d7f8ee70f9f7f9
|
||||
F src/update.c 24260b4fda00c9726d27699a0561d53c0dccc397
|
||||
F src/util.c 64995b5949a5d377629ffd2598747bc771cade1e
|
||||
F src/vacuum.c 717aa6da40105f0597edc9b81114c65860b60e69
|
||||
F src/vdbe.c dfd8b36fc51615f98eaa1d4e48e0c08a74ed4190
|
||||
F src/vacuum.c d9e80c2b36ee1f623dbf1bdf3cedad24a23f87ac
|
||||
F src/vdbe.c f665f4c1dcee0665f26b88b9e7ede74c4ab9edd5
|
||||
F src/vdbe.h 3957844e46fea71fd030e78f6a3bd2f7e320fb43
|
||||
F src/vdbeInt.h 8a3baf749115cba81a810b7a52208aef055eda7b
|
||||
F src/vdbeaux.c c55d87d6658487e87ef09ca80c1aa2f314024fed
|
||||
@ -94,6 +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 09926d4d851864c99390545bd498348a1bf509e9
|
||||
F test/intpkey.test 9320af48415c594afd4e15f8ef0daa272e05502e
|
||||
F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4
|
||||
F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd
|
||||
@ -183,7 +184,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 95989717e17d52b2306374f5cf7613c3bd4e7801
|
||||
R b0ef506232fcb43485a462696bd54cae
|
||||
P 300c5543dc83c6b7eacb0c81ed06f95004c0f6d8
|
||||
R 6e5176bc612d6cf5beab95037a0e3778
|
||||
U drh
|
||||
Z 354e64ccc1227b93fa380b7cc20e6771
|
||||
Z d702251833e256e19bf4070671ed3290
|
||||
|
@ -1 +1 @@
|
||||
300c5543dc83c6b7eacb0c81ed06f95004c0f6d8
|
||||
2fe9f5101cb0f743532912ece3d37f6c873e7025
|
20
src/vacuum.c
20
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.10 2004/02/11 09:46:33 drh Exp $
|
||||
** $Id: vacuum.c,v 1.11 2004/02/12 13:02:56 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -108,7 +108,6 @@ static int execsql(char **pzErrMsg, sqlite *db, const char *zSql){
|
||||
*/
|
||||
static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
vacuumStruct *p = (vacuumStruct*)pArg;
|
||||
int rc = 0;
|
||||
const char *zSep = "(";
|
||||
int i;
|
||||
|
||||
@ -127,8 +126,8 @@ static int vacuumCallback2(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
}
|
||||
}
|
||||
appendText(&p->s2,")", 1);
|
||||
rc = execsql(p->pzErrMsg, p->dbNew, p->s2.z);
|
||||
return rc;
|
||||
p->rc = execsql(p->pzErrMsg, p->dbNew, p->s2.z);
|
||||
return p->rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -160,6 +159,7 @@ static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
sqlite_freemem(zErrMsg);
|
||||
}
|
||||
}
|
||||
if( rc!=SQLITE_ABORT ) p->rc = rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -170,7 +170,6 @@ static int vacuumCallback1(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
*/
|
||||
static int vacuumCallback3(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
vacuumStruct *p = (vacuumStruct*)pArg;
|
||||
int rc = 0;
|
||||
char zBuf[200];
|
||||
assert( argc==1 );
|
||||
if( argv==0 ) return 0;
|
||||
@ -178,8 +177,8 @@ static int vacuumCallback3(void *pArg, int argc, char **argv, char **NotUsed){
|
||||
assert( strlen(p->zPragma)<100 );
|
||||
assert( strlen(argv[0])<30 );
|
||||
sprintf(zBuf,"PRAGMA %s=%s;", p->zPragma, argv[0]);
|
||||
rc = execsql(p->pzErrMsg, p->dbNew, zBuf);
|
||||
return rc;
|
||||
p->rc = execsql(p->pzErrMsg, p->dbNew, zBuf);
|
||||
return p->rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -273,8 +272,8 @@ int sqliteRunVacuum(char **pzErrMsg, sqlite *db){
|
||||
zTemp, " - ", zErrMsg, (char*)0);
|
||||
goto end_of_vacuum;
|
||||
}
|
||||
if( execsql(pzErrMsg, db, "BEGIN") ) goto end_of_vacuum;
|
||||
if( execsql(pzErrMsg, dbNew, "PRAGMA synchronous=off; BEGIN") ){
|
||||
if( (rc = execsql(pzErrMsg, db, "BEGIN"))!=0 ) goto end_of_vacuum;
|
||||
if( (rc = execsql(pzErrMsg, dbNew, "PRAGMA synchronous=off; BEGIN"))!=0 ){
|
||||
goto end_of_vacuum;
|
||||
}
|
||||
|
||||
@ -316,6 +315,7 @@ end_of_vacuum:
|
||||
sqliteFree(sVac.s2.z);
|
||||
if( zErrMsg ) sqlite_freemem(zErrMsg);
|
||||
if( rc==SQLITE_ABORT ) rc = SQLITE_ERROR;
|
||||
return rc;
|
||||
if( sVac.rc!=SQLITE_OK ) rc = sVac.rc;
|
||||
return sVac.rc;
|
||||
#endif
|
||||
}
|
||||
|
@ -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.259 2004/02/11 09:46:33 drh Exp $
|
||||
** $Id: vdbe.c,v 1.260 2004/02/12 13:02:56 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -509,6 +509,7 @@ int sqliteVdbeExec(
|
||||
popStack(&pTos, p->popStack);
|
||||
p->popStack = 0;
|
||||
}
|
||||
CHECK_FOR_INTERRUPT;
|
||||
for(pc=p->pc; rc==SQLITE_OK; pc++){
|
||||
assert( pc>=0 && pc<p->nOp );
|
||||
assert( pTos<=&p->aStack[pc] );
|
||||
|
109
test/interrupt.test
Normal file
109
test/interrupt.test
Normal file
@ -0,0 +1,109 @@
|
||||
# 2004 Feb 8
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is the sqlite_interrupt() API.
|
||||
#
|
||||
# $Id: interrupt.test,v 1.1 2004/02/12 13:02:57 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# Compute a checksum on the entire database.
|
||||
#
|
||||
proc cksum {{db db}} {
|
||||
set txt [$db eval {SELECT name, type, sql FROM sqlite_master}]\n
|
||||
foreach tbl [$db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
|
||||
append txt [$db eval "SELECT * FROM $tbl"]\n
|
||||
}
|
||||
foreach prag {default_synchronous default_cache_size} {
|
||||
append txt $prag-[$db eval "PRAGMA $prag"]\n
|
||||
}
|
||||
set cksum [string length $txt]-[md5 $txt]
|
||||
# puts $cksum-[file size test.db]
|
||||
return $cksum
|
||||
}
|
||||
|
||||
# This routine attempts to execute the sql in $sql. It triggers an
|
||||
# interrupt a progressively later and later points during the processing
|
||||
# and checks to make sure SQLITE_INTERRUPT is returned. Eventually,
|
||||
# the routine completes successfully.
|
||||
#
|
||||
proc interrupt_test {testid sql result {initcnt 0}} {
|
||||
set orig_sum [cksum]
|
||||
set i $initcnt
|
||||
while 1 {
|
||||
incr i
|
||||
set ::sqlite_interrupt_count $i
|
||||
do_test $testid.$i.1 [format {
|
||||
set ::r [catchsql %s]
|
||||
set ::code [db errorcode]
|
||||
expr {$::code==0 || $::code==9}
|
||||
} [list $sql]] 1
|
||||
if {$::code==9} {
|
||||
do_test $testid.$i.2 {
|
||||
cksum
|
||||
} $orig_sum
|
||||
} else {
|
||||
do_test $testid.$i.99 {
|
||||
set ::r
|
||||
} [list 0 $result]
|
||||
break
|
||||
}
|
||||
}
|
||||
set ::sqlite_interrupt_count 0
|
||||
}
|
||||
|
||||
do_test interrupt-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE t1(a,b);
|
||||
SELECT name FROM sqlite_master;
|
||||
}
|
||||
} {t1}
|
||||
interrupt_test interrupt-1.2 {DROP TABLE t1} {}
|
||||
do_test interrupt-1.3 {
|
||||
execsql {
|
||||
SELECT name FROM sqlite_master;
|
||||
}
|
||||
} {}
|
||||
integrity_check interrupt-1.4
|
||||
|
||||
do_test interrrupt-2.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a,b);
|
||||
INSERT INTO t1 VALUES(1,randstr(300,400));
|
||||
INSERT INTO t1 SELECT a+1, randstr(300,400) FROM t1;
|
||||
INSERT INTO t1 SELECT a+2, a || '-' || b FROM t1;
|
||||
INSERT INTO t1 SELECT a+4, a || '-' || b FROM t1;
|
||||
INSERT INTO t1 SELECT a+8, a || '-' || b FROM t1;
|
||||
INSERT INTO t1 SELECT a+16, a || '-' || b FROM t1;
|
||||
INSERT INTO t1 SELECT a+32, a || '-' || b FROM t1;
|
||||
COMMIT;
|
||||
UPDATE t1 SET b=substr(b,-5,5);
|
||||
SELECT count(*) from t1;
|
||||
}
|
||||
} 64
|
||||
set origsize [file size test.db]
|
||||
set cksum [db eval {SELECT md5sum(a || b) FROM t1}]
|
||||
interrupt_test interrupt-2.2 {VACUUM} {} 100
|
||||
do_test interrupt-2.3 {
|
||||
execsql {
|
||||
SELECT md5sum(a || b) FROM t1;
|
||||
}
|
||||
} $cksum
|
||||
do_test interrupt-2.4 {
|
||||
expr {$::origsize>[file size test.db]}
|
||||
} 1
|
||||
integrity_check interrupt-2.5
|
||||
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user