1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

More work toward getting sqlite3_interrupt() to work from separate

threads.  Ticket #1897. (CVS 3336)

FossilOrigin-Name: e431131d47481f9fc64c498e8934b10a96b0a931
This commit is contained in:
drh
2006-07-26 13:43:30 +00:00
parent 881feaa043
commit 15ca1df1bf
8 changed files with 37 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
C Initial\sattempt\sat\smaking\ssqlite3_interrupt()\swork\seven\swhen\scalled\sfrom\na\sseparate\sthread.\s(CVS\s3335)
D 2006-07-26T01:39:30
C More\swork\stoward\sgetting\ssqlite3_interrupt()\sto\swork\sfrom\sseparate\nthreads.\s\sTicket\s#1897.\s(CVS\s3336)
D 2006-07-26T13:43:31
F Makefile.in 9c2a76055c305868cc5f5b73e29a252ff3632c0a
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -66,7 +66,7 @@ F src/pager.c 2ae998a64f98bc2fa14893e08537365865a09519
F src/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818
F src/parse.y ecac666005bec0c813681a81de88d1de5d27577f
F src/pragma.c 27d5e395c5d950931c7ac4fe610e7c2993e2fa55
F src/prepare.c e477df44112e3ce167f048226432fca9d9cba6a0
F src/prepare.c 06fdfea0920f2fe67df29ce6b2eebc83a9e6aedf
F src/printf.c b179b6ed12f793e028dd169e2e2e2b2a37eedc63
F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
F src/select.c aeec8efbe83bc1e50e9b49ada19b34eda5de05bd
@@ -74,7 +74,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 359551ab5cdd8f8fe5f3fe170fd330b108b08d7d
F src/sqlite.h.in 432848ac7f8d7e6fea727668acccec62bdd86cc4
F src/sqlite3ext.h c611255287e9a11ce4f1fe6251c2a0b9d32a828b
F src/sqliteInt.h 670d36af1fe0fe1933e0a5abf26558873f3ff481
F src/sqliteInt.h 85975cbb95777f619fd76f1ba728022f13321e1b
F src/table.c d8817f43a6c6bf139487db161760b9e1e02da3f1
F src/tclsqlite.c 92a997ee5caca4923a6452ff8ebfaa8d37334f4a
F src/test1.c 535294d7f21a4127082c4f7a57f225482df9cc36
@@ -91,17 +91,17 @@ F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
F src/test_schema.c 8b2aaa9136edf3187a51166849c2de0aaaa27ce5
F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/test_tclvar.c 6611657977c69bccd32b4ff7ccfb221a403ca2f0
F src/tokenize.c 288e860be49a20a18dfe7456e7a8948aee5d2c26
F src/tokenize.c 3454200eeec5b917efa513f0c5b093e1c81c72d3
F src/trigger.c 0fc40125820409a6274834a6e04ad804d96e2793
F src/update.c 951f95ef044cf6d28557c48dc35cb0711a0b9129
F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
F src/util.c 5409031819ee4672c5f9c3ac7cf517e267a25845
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
F src/vdbe.c c20911652577abc0afb683b5214e04fab6659a0f
F src/vdbe.c 106bc6216f1bf0176ae645813647b7c496ace962
F src/vdbe.h 258b5d1c0aaa72192f09ff0568ce42b383f156fa
F src/vdbeInt.h e3eaab262b67b84474625cfc38aec1125c32834b
F src/vdbeapi.c 6af0e7160af260052a7a4500464221a03dada75f
F src/vdbeaux.c 1047944652093a6583a308ec89e8e517e8951d2e
F src/vdbeapi.c a2274726d16893337c60937235040fc36792cb48
F src/vdbeaux.c f3d25be011aa5b883166466ed06c7c40dbc6cc2e
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3
F src/vtab.c 1fe25b3e59f92ed1f29b63ac9c6f954eb6907a29
@@ -376,7 +376,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P d5a608d0a412e13dfced6a3827574a2cff802f25
R 8e7083ca7f3cd7ca6f02160c3ed214e7
P 35fd67d7a0c55797eb460e3bd02c96afe619f026
R 81058f7cc0073e22a60fae6f780adbf1
U drh
Z f2c6da8c85bcdb4581d0e12508de1697
Z 506916b1bf3ff2edf2b1a6a42bca76f1

View File

@@ -1 +1 @@
35fd67d7a0c55797eb460e3bd02c96afe619f026
e431131d47481f9fc64c498e8934b10a96b0a931

View File

@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.36 2006/06/26 12:50:09 drh Exp $
** $Id: prepare.c,v 1.37 2006/07/26 13:43:31 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -28,6 +28,7 @@ static void corruptSchema(InitData *pData, const char *zExtra){
sqlite3SetString(pData->pzErrMsg, "malformed database schema",
zExtra!=0 && zExtra[0]!=0 ? " - " : (char*)0, zExtra, (char*)0);
}
pData->rc = SQLITE_CORRUPT;
}
/*
@@ -49,6 +50,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
sqlite3 *db = pData->db;
int iDb;
pData->rc = SQLITE_OK;
if( sqlite3MallocFailed() ){
return SQLITE_NOMEM;
}
@@ -76,13 +78,14 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
db->init.iDb = 0;
assert( rc!=SQLITE_OK || zErr==0 );
if( SQLITE_OK!=rc ){
pData->rc = rc;
if( rc==SQLITE_NOMEM ){
sqlite3FailedMalloc();
}else{
}else if( rc!=SQLITE_INTERRUPT ){
corruptSchema(pData, zErr);
}
sqlite3_free(zErr);
return rc;
return 1;
}
}else{
/* If the SQL column is blank it means this is an index that
@@ -179,9 +182,9 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
initData.db = db;
initData.pzErrMsg = pzErrMsg;
rc = sqlite3InitCallback(&initData, 4, (char **)azArg, 0);
if( rc!=SQLITE_OK ){
if( rc ){
sqlite3SafetyOn(db);
return rc;
return initData.rc;
}
pTab = sqlite3FindTable(db, zMasterName, db->aDb[iDb].zName);
if( pTab ){
@@ -295,6 +298,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
zDbNum, db->aDb[iDb].zName, zMasterName);
sqlite3SafetyOff(db);
rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
if( rc==SQLITE_ABORT ) rc = initData.rc;
sqlite3SafetyOn(db);
sqliteFree(zSql);
#ifndef SQLITE_OMIT_ANALYZE

View File

@@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.522 2006/07/26 01:39:30 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.523 2006/07/26 13:43:31 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@@ -1513,6 +1513,7 @@ struct DbFixer {
typedef struct {
sqlite3 *db; /* The database being initialized */
char **pzErrMsg; /* Error message stored here */
int rc; /* Result code stored here */
} InitData;
/*

View File

@@ -15,7 +15,7 @@
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.122 2006/07/26 01:39:30 drh Exp $
** $Id: tokenize.c,v 1.123 2006/07/26 13:43:31 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -394,7 +394,9 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
extern void sqlite3ParserFree(void*, void(*)(void*));
extern int sqlite3Parser(void*, int, Token, Parse*);
if( db->activeVdbeCnt==0 ){
db->u1.isInterrupted = 0;
}
pParse->rc = SQLITE_OK;
i = 0;
pEngine = sqlite3ParserAlloc((void*(*)(int))sqlite3MallocX);

View 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.571 2006/07/26 01:39:30 drh Exp $
** $Id: vdbe.c,v 1.572 2006/07/26 13:43:31 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -4048,6 +4048,7 @@ case OP_ParseSchema: { /* no-push */
db->init.busy = 1;
assert( !sqlite3MallocFailed() );
rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
if( rc==SQLITE_ABORT ) rc = initData.rc;
sqliteFree(zSql);
db->init.busy = 0;
sqlite3SafetyOn(db);
@@ -4971,7 +4972,6 @@ abort_due_to_error:
*/
abort_due_to_interrupt:
assert( db->u1.isInterrupted );
db->u1.isInterrupted = 0;
if( db->magic!=SQLITE_MAGIC_BUSY ){
rc = SQLITE_MISUSE;
}else{

View File

@@ -180,6 +180,14 @@ int sqlite3_step(sqlite3_stmt *pStmt){
return SQLITE_MISUSE;
}
if( p->pc<0 ){
/* If there are no other statements currently running, then
** reset the interrupt flag. This prevents a call to sqlite3_interrupt
** from interrupting a statement that has not yet started.
*/
if( db->activeVdbeCnt==0 ){
db->u1.isInterrupted = 0;
}
#ifndef SQLITE_OMIT_TRACE
/* Invoke the trace callback if there is one
*/

View File

@@ -671,7 +671,6 @@ int sqlite3VdbeList(
p->rc = SQLITE_OK;
rc = SQLITE_DONE;
}else if( db->u1.isInterrupted ){
db->u1.isInterrupted = 0;
p->rc = SQLITE_INTERRUPT;
rc = SQLITE_ERROR;
sqlite3SetString(&p->zErrMsg, sqlite3ErrStr(p->rc), (char*)0);