diff options
author | drh <drh@noemail.net> | 2001-04-03 16:53:21 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2001-04-03 16:53:21 +0000 |
commit | 960e8c6317c3550faa1dab181a473d611f2fe378 (patch) | |
tree | c9716248e42d548ffe0f31bc8fbd34adf9832588 /src | |
parent | 15c29be81cd9b4691057125a007e73cd24377ac8 (diff) | |
download | sqlite-960e8c6317c3550faa1dab181a473d611f2fe378.tar.gz sqlite-960e8c6317c3550faa1dab181a473d611f2fe378.zip |
Bug fixes from Oleg Oleinick (CVS 195)
FossilOrigin-Name: 1f0197d504fa2bde15b287ac6c0102cacdb1e482
Diffstat (limited to 'src')
-rw-r--r-- | src/dbbe.h | 18 | ||||
-rw-r--r-- | src/dbbegdbm.c | 7 | ||||
-rw-r--r-- | src/dbbemem.c | 6 | ||||
-rw-r--r-- | src/pager.h | 56 | ||||
-rw-r--r-- | src/sqlite.h.in | 4 | ||||
-rw-r--r-- | src/tclsqlite.c | 15 | ||||
-rw-r--r-- | src/test.file | 1 |
7 files changed, 90 insertions, 17 deletions
diff --git a/src/dbbe.h b/src/dbbe.h index 6a386adf9..31c6252f5 100644 --- a/src/dbbe.h +++ b/src/dbbe.h @@ -28,7 +28,7 @@ ** This library was originally designed to support the following ** backends: GDBM, NDBM, SDBM, Berkeley DB. ** -** $Id: dbbe.h,v 1.11 2001/03/20 22:05:00 drh Exp $ +** $Id: dbbe.h,v 1.12 2001/04/03 16:53:22 drh Exp $ */ #ifndef _SQLITE_DBBE_H_ #define _SQLITE_DBBE_H_ @@ -75,18 +75,19 @@ struct DbbeMethods { /* Close the whole database. */ void (*Close)(Dbbe*); - /* Open a cursor into particular file of a previously opened database. - ** Create the file if it doesn't already exist and writeable!=0. zName - ** is the base name of the file to be opened. This routine will add - ** an appropriate path and extension to the filename to locate the + /* Open a cursor into a particular table of a previously opened database. + ** Create the table if it doesn't already exist and writeable!=0. zName + ** is the base name of the table to be opened. If the database is + ** implement as one file per table, then this routine will add an + ** appropriate path and extension to the table name to locate the ** actual file. ** - ** The keyType parameter is TRUE if this table will only be accessed + ** The intKeyOnly parameter is TRUE if this table will only be accessed ** using integer keys. This parameter allows the database backend to ** use a faster algorithm for the special case of integer keys, if it ** wants to. ** - ** If zName is 0 or "", then a temporary file is created that + ** If zName is 0 or "", then a temporary table is created that ** will be deleted when closed. */ int (*OpenCursor)(Dbbe*, const char *zName, int writeable, @@ -165,7 +166,8 @@ struct DbbeMethods { struct Dbbe { struct DbbeMethods *x; /* Backend-specific methods for database access */ /* There used to be other information here, but it has since - ** been removed. */ + ** been removed. We'll keep the same design, though, in case we + ** ever want to add some new fields in the future. */ }; #endif /* defined(_SQLITE_DBBE_H_) */ diff --git a/src/dbbegdbm.c b/src/dbbegdbm.c index 777c7dace..8aba06b32 100644 --- a/src/dbbegdbm.c +++ b/src/dbbegdbm.c @@ -30,7 +30,7 @@ ** relatively simple to convert to a different database such ** as NDBM, SDBM, or BerkeleyDB. ** -** $Id: dbbegdbm.c,v 1.4 2001/03/20 22:05:00 drh Exp $ +** $Id: dbbegdbm.c,v 1.5 2001/04/03 16:53:22 drh Exp $ */ #include "sqliteInt.h" #include <gdbm.h> @@ -46,6 +46,9 @@ ** for a self-join, for example) then two DbbeCursor structures are ** created but there is only a single BeFile structure with an ** nRef of 2. +** +** This backend uses a separate disk file for each database table +** and index. */ typedef struct BeFile BeFile; struct BeFile { @@ -545,7 +548,7 @@ static int sqliteGdbmDelete(DbbeCursor *pCursr, int nKey, char *pKey){ ** used to implement the GDBM backend. */ static struct DbbeMethods gdbmMethods = { - /* n Close */ sqliteGdbmClose, + /* Close */ sqliteGdbmClose, /* OpenCursor */ sqliteGdbmOpenCursor, /* DropTable */ sqliteGdbmDropTable, /* ReorganizeTable */ sqliteGdbmReorganizeTable, diff --git a/src/dbbemem.c b/src/dbbemem.c index 6bf1cc0f2..86ddcf570 100644 --- a/src/dbbemem.c +++ b/src/dbbemem.c @@ -27,8 +27,10 @@ ** of information to the disk. ** ** This file uses an in-memory hash table as the database backend. +** Nothing is ever written to disk using this backend. All information +** is forgotten when the program exits. ** -** $Id: dbbemem.c,v 1.11 2001/03/20 22:05:00 drh Exp $ +** $Id: dbbemem.c,v 1.12 2001/04/03 16:53:22 drh Exp $ */ #include "sqliteInt.h" #include <sys/stat.h> @@ -720,7 +722,7 @@ static int sqliteMemDelete(DbbeCursor *pCursr, int nKey, char *pKey){ ** used to implement the MEMORY backend. */ static struct DbbeMethods memoryMethods = { - /* n Close */ sqliteMemClose, + /* Close */ sqliteMemClose, /* OpenCursor */ sqliteMemOpenCursor, /* DropTable */ sqliteMemDropTable, /* ReorganizeTable */ sqliteMemReorganizeTable, diff --git a/src/pager.h b/src/pager.h new file mode 100644 index 000000000..cec8f4ea7 --- /dev/null +++ b/src/pager.h @@ -0,0 +1,56 @@ +/* +** Copyright (c) 2001 D. Richard Hipp +** +** This program is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public +** License as published by the Free Software Foundation; either +** version 2 of the License, or (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** +** You should have received a copy of the GNU General Public +** License along with this library; if not, write to the +** Free Software Foundation, Inc., 59 Temple Place - Suite 330, +** Boston, MA 02111-1307, USA. +** +** Author contact information: +** drh@hwaci.com +** http://www.hwaci.com/drh/ +** +************************************************************************* +** This header file defines the interface that the sqlite page cache +** subsystem. The page cache subsystem reads and writes a file a page +** at a time and provides a journal for rollback. +** +** @(#) $Id: pager.h,v 1.1 2001/04/03 16:53:22 drh Exp $ +*/ +#include "sqliteInt.h" + +/* +** The size of one page +*/ +#define SQLITE_PAGE_SIZE 1024 + +/* +** The type used to represent a page number. The first page in a file +** is called page 1. 0 is used to represent "not a page". +*/ +typedef unsigned int Pgno; + +/* +** Each open file is managed by a separate instance of the "Pager" structure. +*/ +typedef struct Pager Pager; + +int sqlite_pager_open(Pager **ppPager, const char *zFilename); +int sqlite_pager_close(Pager *pPager); +int sqlite_pager_get(Pager *pPager, Pgno pgno, void **ppPage); +int sqlite_pager_unref(void*); +Pgno sqlite_pager_pagenumber(void*); +int sqlite_pager_write(void*); +int sqlite_pager_pagecount(Pager*); +int sqlite_pager_commit(Pager*); +int sqlite_pager_rollback(Pager*); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1f1980dc1..59332dcf9 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -24,7 +24,7 @@ ** This header file defines the interface that the sqlite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.9 2001/01/20 19:52:49 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.10 2001/04/03 16:53:22 drh Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ @@ -142,6 +142,8 @@ int sqlite_exec( #define SQLITE_CORRUPT 10 /* The database disk image is malformed */ #define SQLITE_NOTFOUND 11 /* Table or record not found */ #define SQLITE_FULL 12 /* Insertion failed because database is full */ +#define SQLITE_CANTOPEN 13 /* Unable to open the database file */ +#define SQLITE_PROTOCOL 14 /* Database lock protocol error */ /* This function causes any pending database operation to abort and ** return at its earliest opportunity. This routine is typically diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 81c9ddb7e..c88052422 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -23,7 +23,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.13 2001/01/31 13:28:09 drh Exp $ +** $Id: tclsqlite.c,v 1.14 2001/04/03 16:53:22 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -53,6 +53,7 @@ struct CallbackData { char *zArray; /* The array into which data is written */ Tcl_Obj *pCode; /* The code to execute for each row */ int once; /* Set only for the first invocation of callback */ + int tcl_rc; /* Return code from TCL script */ }; /* @@ -88,7 +89,9 @@ static int DbEvalCallback( } cbData->once = 0; rc = Tcl_EvalObj(cbData->interp, cbData->pCode); - return rc!=TCL_OK && rc!=TCL_CONTINUE; + if( rc==TCL_CONTINUE ) rc = TCL_OK; + cbData->tcl_rc = rc; + return rc!=TCL_OK; } /* @@ -171,7 +174,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ SqliteDb *pDb = (SqliteDb*)cd; int choice; static char *DB_optStrs[] = { - "busy", "close", "complete", "eval", "timeout" + "busy", "close", "complete", "eval", "timeout", 0 }; enum DB_opts { DB_BUSY, DB_CLOSE, DB_COMPLETE, DB_EVAL, DB_TIMEOUT @@ -278,20 +281,26 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ cbData.once = 1; cbData.zArray = Tcl_GetStringFromObj(objv[3], 0); cbData.pCode = objv[4]; + cbData.tcl_rc = TCL_OK; zErrMsg = 0; Tcl_IncrRefCount(objv[3]); Tcl_IncrRefCount(objv[4]); rc = sqlite_exec(pDb->db, zSql, DbEvalCallback, &cbData, &zErrMsg); Tcl_DecrRefCount(objv[4]); Tcl_DecrRefCount(objv[3]); + if( cbData.tcl_rc==TCL_BREAK ){ cbData.tcl_rc = TCL_OK; } }else{ Tcl_Obj *pList = Tcl_NewObj(); + cbData.tcl_rc = TCL_OK; rc = sqlite_exec(pDb->db, zSql, DbEvalCallback2, pList, &zErrMsg); Tcl_SetObjResult(interp, pList); } if( zErrMsg ){ Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE); free(zErrMsg); + rc = TCL_ERROR; + }else{ + rc = cbData.tcl_rc; } Tcl_DecrRefCount(objv[2]); return rc; diff --git a/src/test.file b/src/test.file deleted file mode 100644 index 45b983be3..000000000 --- a/src/test.file +++ /dev/null @@ -1 +0,0 @@ -hi |