aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attach.c8
-rw-r--r--src/btree.c4
-rw-r--r--src/func.c4
-rw-r--r--src/main.c75
-rw-r--r--src/os_unix.c10
-rw-r--r--src/prepare.c73
-rw-r--r--src/test1.c6
-rw-r--r--src/test6.c6
-rw-r--r--src/util.c4
9 files changed, 101 insertions, 89 deletions
diff --git a/src/attach.c b/src/attach.c
index ef6f281d7..b63260c34 100644
--- a/src/attach.c
+++ b/src/attach.c
@@ -11,7 +11,7 @@
*************************************************************************
** This file contains code used to implement the ATTACH and DETACH commands.
**
-** $Id: attach.c,v 1.39 2006/01/05 11:34:33 danielk1977 Exp $
+** $Id: attach.c,v 1.40 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
@@ -335,8 +335,10 @@ void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
codeAttach(pParse, SQLITE_ATTACH, "sqlite_attach", 3, p, p, pDbname, pKey);
}
-void sqlite3AttachFunctions(sqlite3 *db)
-{
+/*
+** Register the functions sqlite_attach and sqlite_detach.
+*/
+void sqlite3AttachFunctions(sqlite3 *db){
static const int enc = SQLITE_UTF8;
sqlite3_create_function(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0);
sqlite3_create_function(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0);
diff --git a/src/btree.c b/src/btree.c
index 378e6eb3b..9847f72c8 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.283 2006/01/06 14:32:20 drh Exp $
+** $Id: btree.c,v 1.284 2006/01/06 21:52:50 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -1569,7 +1569,7 @@ int sqlite3BtreeOpen(
p->pSqlite = pSqlite;
/* Try to find an existing Btree structure opened on zFilename. */
-#ifndef SQLITE_OMIT_SHARED_CACHE
+#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
if( pTsd->useSharedData && zFilename && !isMemdb ){
char *zFullPathname = sqlite3OsFullPathname(zFilename);
if( !zFullPathname ){
diff --git a/src/func.c b/src/func.c
index a50c3a3ee..4744518a8 100644
--- a/src/func.c
+++ b/src/func.c
@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.113 2005/12/09 20:02:05 drh Exp $
+** $Id: func.c,v 1.114 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -1025,7 +1025,9 @@ void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
#ifndef SQLITE_OMIT_ALTERTABLE
sqlite3AlterFunctions(db);
#endif
+#ifndef SQLITE_OMIT_PARSER
sqlite3AttachFunctions(db);
+#endif
for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
void *pArg = 0;
switch( aAggs[i].argType ){
diff --git a/src/main.c b/src/main.c
index d9365d51a..d31439b92 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
-** $Id: main.c,v 1.317 2006/01/06 14:32:20 drh Exp $
+** $Id: main.c,v 1.318 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -96,77 +96,6 @@ int sqlite3_total_changes(sqlite3 *db){
}
/*
-** Free all resources held by the schema structure. The void* argument points
-** at a DbSchema struct. This function does not call sqliteFree() on the
-** pointer itself, it just cleans up subsiduary resources (i.e. the contents
-** of the schema hash tables).
-*/
-void sqlite3SchemaFree(void *p){
- Hash temp1;
- Hash temp2;
- HashElem *pElem;
- DbSchema *pSchema = (DbSchema *)p;
-
- temp1 = pSchema->tblHash;
- temp2 = pSchema->trigHash;
- sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0);
- sqlite3HashClear(&pSchema->aFKey);
- sqlite3HashClear(&pSchema->idxHash);
- for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
- sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem));
- }
- sqlite3HashClear(&temp2);
- sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0);
- for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
- Table *pTab = sqliteHashData(pElem);
- sqlite3DeleteTable(0, pTab);
- }
- sqlite3HashClear(&temp1);
- pSchema->pSeqTab = 0;
- pSchema->flags &= ~DB_SchemaLoaded;
-}
-
-DbSchema *sqlite3SchemaGet(Btree *pBt){
- DbSchema * p;
- if( pBt ){
- p = (DbSchema *)sqlite3BtreeSchema(pBt,sizeof(DbSchema),sqlite3SchemaFree);
- }else{
- p = (DbSchema *)sqliteMalloc(sizeof(DbSchema));
- }
- if( p && 0==p->file_format ){
- sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0);
- sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0);
- sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0);
- sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1);
- }
- return p;
-}
-
-int sqlite3SchemaToIndex(sqlite3 *db, DbSchema *pSchema){
- int i = -1000000;
-
- /* If pSchema is NULL, then return -1000000. This happens when code in
- ** expr.c is trying to resolve a reference to a transient table (i.e. one
- ** created by a sub-select). In this case the return value of this
- ** function should never be used.
- **
- ** We return -1000000 instead of the more usual -1 simply because using
- ** -1000000 as incorrectly using -1000000 index into db->aDb[] is much
- ** more likely to cause a segfault than -1 (of course there are assert()
- ** statements too, but it never hurts to play the odds).
- */
- if( pSchema ){
- for(i=0; i<db->nDb; i++){
- if( db->aDb[i].pSchema==pSchema ){
- break;
- }
- }
- assert( i>=0 &&i>=0 && i<db->nDb );
- }
- return i;
-}
-
-/*
** Close an existing SQLite database
*/
int sqlite3_close(sqlite3 *db){
@@ -844,8 +773,10 @@ static int openDatabase(
db->magic = SQLITE_MAGIC_CLOSED;
goto opendb_out;
}
+#ifndef SQLITE_OMIT_PARSER
db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt);
db->aDb[1].pSchema = sqlite3SchemaGet(0);
+#endif
/* The default safety_level for the main database is 'full'; for the temp
** database it is 'NONE'. This matches the pager layer defaults.
diff --git a/src/os_unix.c b/src/os_unix.c
index 26eb7039c..fa0cc1f9e 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -107,6 +107,11 @@ struct unixFile {
/*
+** Include code that is common to all os_*.c files
+*/
+#include "os_common.h"
+
+/*
** Do not include any of the File I/O interface procedures if the
** SQLITE_OMIT_DISKIO macro is defined (indicating that there database
** will be in-memory only)
@@ -142,11 +147,6 @@ struct unixFile {
#endif
/*
-** Include code that is common to all os_*.c files
-*/
-#include "os_common.h"
-
-/*
** The threadid macro resolves to the thread-id or to 0. Used for
** testing and debugging only.
*/
diff --git a/src/prepare.c b/src/prepare.c
index 564aff53b..4b86e7663 100644
--- a/src/prepare.c
+++ b/src/prepare.c
@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
-** $Id: prepare.c,v 1.14 2006/01/06 13:00:30 danielk1977 Exp $
+** $Id: prepare.c,v 1.15 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -424,6 +424,77 @@ static int schemaIsValid(sqlite3 *db){
}
/*
+** Free all resources held by the schema structure. The void* argument points
+** at a DbSchema struct. This function does not call sqliteFree() on the
+** pointer itself, it just cleans up subsiduary resources (i.e. the contents
+** of the schema hash tables).
+*/
+void sqlite3SchemaFree(void *p){
+ Hash temp1;
+ Hash temp2;
+ HashElem *pElem;
+ DbSchema *pSchema = (DbSchema *)p;
+
+ temp1 = pSchema->tblHash;
+ temp2 = pSchema->trigHash;
+ sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0);
+ sqlite3HashClear(&pSchema->aFKey);
+ sqlite3HashClear(&pSchema->idxHash);
+ for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
+ sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem));
+ }
+ sqlite3HashClear(&temp2);
+ sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0);
+ for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
+ Table *pTab = sqliteHashData(pElem);
+ sqlite3DeleteTable(0, pTab);
+ }
+ sqlite3HashClear(&temp1);
+ pSchema->pSeqTab = 0;
+ pSchema->flags &= ~DB_SchemaLoaded;
+}
+
+DbSchema *sqlite3SchemaGet(Btree *pBt){
+ DbSchema * p;
+ if( pBt ){
+ p = (DbSchema *)sqlite3BtreeSchema(pBt,sizeof(DbSchema),sqlite3SchemaFree);
+ }else{
+ p = (DbSchema *)sqliteMalloc(sizeof(DbSchema));
+ }
+ if( p && 0==p->file_format ){
+ sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0);
+ sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0);
+ sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0);
+ sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1);
+ }
+ return p;
+}
+
+int sqlite3SchemaToIndex(sqlite3 *db, DbSchema *pSchema){
+ int i = -1000000;
+
+ /* If pSchema is NULL, then return -1000000. This happens when code in
+ ** expr.c is trying to resolve a reference to a transient table (i.e. one
+ ** created by a sub-select). In this case the return value of this
+ ** function should never be used.
+ **
+ ** We return -1000000 instead of the more usual -1 simply because using
+ ** -1000000 as incorrectly using -1000000 index into db->aDb[] is much
+ ** more likely to cause a segfault than -1 (of course there are assert()
+ ** statements too, but it never hurts to play the odds).
+ */
+ if( pSchema ){
+ for(i=0; i<db->nDb; i++){
+ if( db->aDb[i].pSchema==pSchema ){
+ break;
+ }
+ }
+ assert( i>=0 &&i>=0 && i<db->nDb );
+ }
+ return i;
+}
+
+/*
** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
*/
int sqlite3_prepare(
diff --git a/src/test1.c b/src/test1.c
index a7e29fb37..f981708f8 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test1.c,v 1.181 2006/01/06 14:32:20 drh Exp $
+** $Id: test1.c,v 1.182 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -2951,7 +2951,7 @@ static int test_release_memory(
int objc,
Tcl_Obj *CONST objv[]
){
-#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
+#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
int N;
int amt;
if( objc!=1 && objc!=2 ){
@@ -2982,7 +2982,7 @@ static int test_soft_heap_limit(
int objc,
Tcl_Obj *CONST objv[]
){
-#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
+#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
int amt;
if( objc!=1 && objc!=2 ){
Tcl_WrongNumArgs(interp, 1, objv, "?N?");
diff --git a/src/test6.c b/src/test6.c
index 95b5190b6..608a140ee 100644
--- a/src/test6.c
+++ b/src/test6.c
@@ -19,6 +19,8 @@
#include "os.h"
#include "tcl.h"
+#ifndef SQLITE_OMIT_DISKIO /* This file is a no-op if disk I/O is disabled */
+
/*
** crashFile is a subclass of OsFile that is taylored for the
** crash test module.
@@ -534,11 +536,15 @@ static int crashParamsObjCmd(
return TCL_OK;
}
+#endif /* SQLITE_OMIT_DISKIO */
+
/*
** This procedure registers the TCL procedures defined in this file.
*/
int Sqlitetest6_Init(Tcl_Interp *interp){
+#ifndef SQLITE_OMIT_DISKIO
Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0);
+#endif
return TCL_OK;
}
diff --git a/src/util.c b/src/util.c
index a37b68938..ebdcfb597 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.161 2006/01/06 14:32:20 drh Exp $
+** $Id: util.c,v 1.162 2006/01/06 21:52:50 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -66,7 +66,7 @@
#define MAX(x,y) ((x)>(y)?(x):(y))
-#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
+#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
/*
** Set the soft heap-size limit for the current thread. Passing a negative
** value indicates no limit.