diff options
author | drh <drh@noemail.net> | 2006-01-06 21:52:49 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2006-01-06 21:52:49 +0000 |
commit | 198bf391287b72ce27348e48d2e8cc2848c34c03 (patch) | |
tree | a233cf7a63d02b5399a1b97cd5f9eabe045b9114 /src/main.c | |
parent | 9e9fe6f87717465d9d05608dba4833a5b1bfae61 (diff) | |
download | sqlite-198bf391287b72ce27348e48d2e8cc2848c34c03.tar.gz sqlite-198bf391287b72ce27348e48d2e8cc2848c34c03.zip |
Changes so that SQLITE_OMIT_PARSER and SQLITE_OMIT_DISKIO work. (CVS 2878)
FossilOrigin-Name: 9d71b7deaffdd7eb9ddad1f03df3e4c51c2cbd98
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 75 |
1 files changed, 3 insertions, 72 deletions
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. |