/ Check-in [9d71b7de]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changes so that SQLITE_OMIT_PARSER and SQLITE_OMIT_DISKIO work. (CVS 2878)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9d71b7deaffdd7eb9ddad1f03df3e4c51c2cbd98
User & Date: drh 2006-01-06 21:52:50
Context
2006-01-06
22:11
Fix bugs in test scripts that came of of sse testing. (CVS 2879) check-in: 22bf1a2f user: drh tags: trunk
21:52
Changes so that SQLITE_OMIT_PARSER and SQLITE_OMIT_DISKIO work. (CVS 2878) check-in: 9d71b7de user: drh tags: trunk
21:09
Additional changes for wince. (CVS 2877) check-in: b10343d9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/attach.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the ATTACH and DETACH commands.
    13     13   **
    14         -** $Id: attach.c,v 1.39 2006/01/05 11:34:33 danielk1977 Exp $
           14  +** $Id: attach.c,v 1.40 2006/01/06 21:52:50 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** Resolve an expression that was part of an ATTACH or DETACH statement. This
    20     20   ** is slightly different from resolving a normal SQL expression, because simple
    21     21   ** identifiers are treated as strings, not possible column names or aliases.
................................................................................
   331    331   **
   332    332   **     ATTACH p AS pDbname KEY pKey
   333    333   */
   334    334   void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *pKey){
   335    335     codeAttach(pParse, SQLITE_ATTACH, "sqlite_attach", 3, p, p, pDbname, pKey);
   336    336   }
   337    337   
   338         -void sqlite3AttachFunctions(sqlite3 *db)
   339         -{
          338  +/*
          339  +** Register the functions sqlite_attach and sqlite_detach.
          340  +*/
          341  +void sqlite3AttachFunctions(sqlite3 *db){
   340    342     static const int enc = SQLITE_UTF8;
   341    343     sqlite3_create_function(db, "sqlite_attach", 3, enc, db, attachFunc, 0, 0);
   342    344     sqlite3_create_function(db, "sqlite_detach", 1, enc, db, detachFunc, 0, 0);
   343    345   }
   344    346   
   345    347   /*
   346    348   ** Initialize a DbFixer structure.  This routine must be called prior

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.283 2006/01/06 14:32:20 drh Exp $
           12  +** $Id: btree.c,v 1.284 2006/01/06 21:52:50 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  1565   1565     if( !p ){
  1566   1566       return SQLITE_NOMEM;
  1567   1567     }
  1568   1568     p->inTrans = TRANS_NONE;
  1569   1569     p->pSqlite = pSqlite;
  1570   1570   
  1571   1571     /* Try to find an existing Btree structure opened on zFilename. */
  1572         -#ifndef SQLITE_OMIT_SHARED_CACHE
         1572  +#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
  1573   1573     if( pTsd->useSharedData && zFilename && !isMemdb ){
  1574   1574       char *zFullPathname = sqlite3OsFullPathname(zFilename);
  1575   1575       if( !zFullPathname ){
  1576   1576         sqliteFree(p);
  1577   1577         return SQLITE_NOMEM;
  1578   1578       }
  1579   1579       for(pBt=pTsd->pBtree; pBt; pBt=pBt->pNext){

Changes to src/func.c.

    12     12   ** This file contains the C functions that implement various SQL
    13     13   ** functions of SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: func.c,v 1.113 2005/12/09 20:02:05 drh Exp $
           19  +** $Id: func.c,v 1.114 2006/01/06 21:52:50 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <ctype.h>
    23     23   /* #include <math.h> */
    24     24   #include <stdlib.h>
    25     25   #include <assert.h>
    26     26   #include "vdbeInt.h"
................................................................................
  1021   1021           pFunc->needCollSeq = 1;
  1022   1022         }
  1023   1023       }
  1024   1024     }
  1025   1025   #ifndef SQLITE_OMIT_ALTERTABLE
  1026   1026     sqlite3AlterFunctions(db);
  1027   1027   #endif
         1028  +#ifndef SQLITE_OMIT_PARSER
  1028   1029     sqlite3AttachFunctions(db);
         1030  +#endif
  1029   1031     for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
  1030   1032       void *pArg = 0;
  1031   1033       switch( aAggs[i].argType ){
  1032   1034         case 1: pArg = db; break;
  1033   1035         case 2: pArg = (void *)(-1); break;
  1034   1036       }
  1035   1037       sqlite3_create_function(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8, 

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.317 2006/01/06 14:32:20 drh Exp $
           17  +** $Id: main.c,v 1.318 2006/01/06 21:52:50 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** The following constant value is used by the SQLITE_BIGENDIAN and
................................................................................
    91     91   /*
    92     92   ** Return the number of changes since the database handle was opened.
    93     93   */
    94     94   int sqlite3_total_changes(sqlite3 *db){
    95     95     return db->nTotalChange;
    96     96   }
    97     97   
    98         -/*
    99         -** Free all resources held by the schema structure. The void* argument points
   100         -** at a DbSchema struct. This function does not call sqliteFree() on the 
   101         -** pointer itself, it just cleans up subsiduary resources (i.e. the contents
   102         -** of the schema hash tables).
   103         -*/
   104         -void sqlite3SchemaFree(void *p){
   105         -  Hash temp1;
   106         -  Hash temp2;
   107         -  HashElem *pElem;
   108         -  DbSchema *pSchema = (DbSchema *)p;
   109         -
   110         -  temp1 = pSchema->tblHash;
   111         -  temp2 = pSchema->trigHash;
   112         -  sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0);
   113         -  sqlite3HashClear(&pSchema->aFKey);
   114         -  sqlite3HashClear(&pSchema->idxHash);
   115         -  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
   116         -    sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem));
   117         -  }
   118         -  sqlite3HashClear(&temp2);
   119         -  sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0);
   120         -  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
   121         -    Table *pTab = sqliteHashData(pElem);
   122         -    sqlite3DeleteTable(0, pTab);
   123         -  }
   124         -  sqlite3HashClear(&temp1);
   125         -  pSchema->pSeqTab = 0;
   126         -  pSchema->flags &= ~DB_SchemaLoaded;
   127         -}
   128         -
   129         -DbSchema *sqlite3SchemaGet(Btree *pBt){
   130         -  DbSchema * p;
   131         -  if( pBt ){
   132         -    p = (DbSchema *)sqlite3BtreeSchema(pBt,sizeof(DbSchema),sqlite3SchemaFree);
   133         -  }else{
   134         -    p = (DbSchema *)sqliteMalloc(sizeof(DbSchema));
   135         -  }
   136         -  if( p && 0==p->file_format ){
   137         -    sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0);
   138         -    sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0);
   139         -    sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0);
   140         -    sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1);
   141         -  }
   142         -  return p;
   143         -}
   144         -
   145         -int sqlite3SchemaToIndex(sqlite3 *db, DbSchema *pSchema){
   146         -  int i = -1000000;
   147         -
   148         -  /* If pSchema is NULL, then return -1000000. This happens when code in 
   149         -  ** expr.c is trying to resolve a reference to a transient table (i.e. one
   150         -  ** created by a sub-select). In this case the return value of this 
   151         -  ** function should never be used.
   152         -  **
   153         -  ** We return -1000000 instead of the more usual -1 simply because using
   154         -  ** -1000000 as incorrectly using -1000000 index into db->aDb[] is much 
   155         -  ** more likely to cause a segfault than -1 (of course there are assert()
   156         -  ** statements too, but it never hurts to play the odds).
   157         -  */
   158         -  if( pSchema ){
   159         -    for(i=0; i<db->nDb; i++){
   160         -      if( db->aDb[i].pSchema==pSchema ){
   161         -        break;
   162         -      }
   163         -    }
   164         -    assert( i>=0 &&i>=0 &&  i<db->nDb );
   165         -  }
   166         -  return i;
   167         -}
   168         -
   169     98   /*
   170     99   ** Close an existing SQLite database
   171    100   */
   172    101   int sqlite3_close(sqlite3 *db){
   173    102     HashElem *i;
   174    103     int j;
   175    104   
................................................................................
   840    769     /* Open the backend database driver */
   841    770     rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);
   842    771     if( rc!=SQLITE_OK ){
   843    772       sqlite3Error(db, rc, 0);
   844    773       db->magic = SQLITE_MAGIC_CLOSED;
   845    774       goto opendb_out;
   846    775     }
          776  +#ifndef SQLITE_OMIT_PARSER
   847    777     db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt);
   848    778     db->aDb[1].pSchema = sqlite3SchemaGet(0);
          779  +#endif
   849    780   
   850    781     /* The default safety_level for the main database is 'full'; for the temp
   851    782     ** database it is 'NONE'. This matches the pager layer defaults.  
   852    783     */
   853    784     db->aDb[0].zName = "main";
   854    785     db->aDb[0].safety_level = 3;
   855    786   #ifndef SQLITE_OMIT_TEMPDB

Changes to src/os_unix.c.

   102    102   # define CRASH_TEST_OVERRIDE(X,A,B,C) \
   103    103       if(sqlite3CrashTestEnable){ return X(A,B,C); }
   104    104   #else
   105    105   # define CRASH_TEST_OVERRIDE(X,A,B,C)  /* no-op */
   106    106   #endif
   107    107   
   108    108   
          109  +/*
          110  +** Include code that is common to all os_*.c files
          111  +*/
          112  +#include "os_common.h"
          113  +
   109    114   /*
   110    115   ** Do not include any of the File I/O interface procedures if the
   111    116   ** SQLITE_OMIT_DISKIO macro is defined (indicating that there database
   112    117   ** will be in-memory only)
   113    118   */
   114    119   #ifndef SQLITE_OMIT_DISKIO
   115    120   
................................................................................
   137    142   ** that always succeeds.  This means that locking does not occur under
   138    143   ** DJGPP.  But it's DOS - what did you expect?
   139    144   */
   140    145   #ifdef __DJGPP__
   141    146   # define fcntl(A,B,C) 0
   142    147   #endif
   143    148   
   144         -/*
   145         -** Include code that is common to all os_*.c files
   146         -*/
   147         -#include "os_common.h"
   148         -
   149    149   /*
   150    150   ** The threadid macro resolves to the thread-id or to 0.  Used for
   151    151   ** testing and debugging only.
   152    152   */
   153    153   #ifdef SQLITE_UNIX_THREADS
   154    154   #define threadid pthread_self()
   155    155   #else

Changes to src/prepare.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains the implementation of the sqlite3_prepare()
    13     13   ** interface, and routines that contribute to loading the database schema
    14     14   ** from disk.
    15     15   **
    16         -** $Id: prepare.c,v 1.14 2006/01/06 13:00:30 danielk1977 Exp $
           16  +** $Id: prepare.c,v 1.15 2006/01/06 21:52:50 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "os.h"
    20     20   #include <ctype.h>
    21     21   
    22     22   /*
    23     23   ** Fill the InitData structure with an error message that indicates
................................................................................
   418    418           allOk = 0;
   419    419         }
   420    420         sqlite3BtreeCloseCursor(curTemp);
   421    421       }
   422    422     }
   423    423     return allOk;
   424    424   }
          425  +
          426  +/*
          427  +** Free all resources held by the schema structure. The void* argument points
          428  +** at a DbSchema struct. This function does not call sqliteFree() on the 
          429  +** pointer itself, it just cleans up subsiduary resources (i.e. the contents
          430  +** of the schema hash tables).
          431  +*/
          432  +void sqlite3SchemaFree(void *p){
          433  +  Hash temp1;
          434  +  Hash temp2;
          435  +  HashElem *pElem;
          436  +  DbSchema *pSchema = (DbSchema *)p;
          437  +
          438  +  temp1 = pSchema->tblHash;
          439  +  temp2 = pSchema->trigHash;
          440  +  sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0);
          441  +  sqlite3HashClear(&pSchema->aFKey);
          442  +  sqlite3HashClear(&pSchema->idxHash);
          443  +  for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
          444  +    sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem));
          445  +  }
          446  +  sqlite3HashClear(&temp2);
          447  +  sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0);
          448  +  for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
          449  +    Table *pTab = sqliteHashData(pElem);
          450  +    sqlite3DeleteTable(0, pTab);
          451  +  }
          452  +  sqlite3HashClear(&temp1);
          453  +  pSchema->pSeqTab = 0;
          454  +  pSchema->flags &= ~DB_SchemaLoaded;
          455  +}
          456  +
          457  +DbSchema *sqlite3SchemaGet(Btree *pBt){
          458  +  DbSchema * p;
          459  +  if( pBt ){
          460  +    p = (DbSchema *)sqlite3BtreeSchema(pBt,sizeof(DbSchema),sqlite3SchemaFree);
          461  +  }else{
          462  +    p = (DbSchema *)sqliteMalloc(sizeof(DbSchema));
          463  +  }
          464  +  if( p && 0==p->file_format ){
          465  +    sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0);
          466  +    sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0);
          467  +    sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0);
          468  +    sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1);
          469  +  }
          470  +  return p;
          471  +}
          472  +
          473  +int sqlite3SchemaToIndex(sqlite3 *db, DbSchema *pSchema){
          474  +  int i = -1000000;
          475  +
          476  +  /* If pSchema is NULL, then return -1000000. This happens when code in 
          477  +  ** expr.c is trying to resolve a reference to a transient table (i.e. one
          478  +  ** created by a sub-select). In this case the return value of this 
          479  +  ** function should never be used.
          480  +  **
          481  +  ** We return -1000000 instead of the more usual -1 simply because using
          482  +  ** -1000000 as incorrectly using -1000000 index into db->aDb[] is much 
          483  +  ** more likely to cause a segfault than -1 (of course there are assert()
          484  +  ** statements too, but it never hurts to play the odds).
          485  +  */
          486  +  if( pSchema ){
          487  +    for(i=0; i<db->nDb; i++){
          488  +      if( db->aDb[i].pSchema==pSchema ){
          489  +        break;
          490  +      }
          491  +    }
          492  +    assert( i>=0 &&i>=0 &&  i<db->nDb );
          493  +  }
          494  +  return i;
          495  +}
   425    496   
   426    497   /*
   427    498   ** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
   428    499   */
   429    500   int sqlite3_prepare(
   430    501     sqlite3 *db,              /* Database handle. */
   431    502     const char *zSql,         /* UTF-8 encoded SQL statement. */

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the printf() interface to SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.181 2006/01/06 14:32:20 drh Exp $
           16  +** $Id: test1.c,v 1.182 2006/01/06 21:52:50 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
  2947   2947   */
  2948   2948   static int test_release_memory(
  2949   2949     void * clientData,
  2950   2950     Tcl_Interp *interp,
  2951   2951     int objc,
  2952   2952     Tcl_Obj *CONST objv[]
  2953   2953   ){
  2954         -#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
         2954  +#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
  2955   2955     int N;
  2956   2956     int amt;
  2957   2957     if( objc!=1 && objc!=2 ){
  2958   2958       Tcl_WrongNumArgs(interp, 1, objv, "?N?");
  2959   2959       return TCL_ERROR;
  2960   2960     }
  2961   2961     if( objc==2 ){
................................................................................
  2978   2978   */
  2979   2979   static int test_soft_heap_limit(
  2980   2980     void * clientData,
  2981   2981     Tcl_Interp *interp,
  2982   2982     int objc,
  2983   2983     Tcl_Obj *CONST objv[]
  2984   2984   ){
  2985         -#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
         2985  +#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
  2986   2986     int amt;
  2987   2987     if( objc!=1 && objc!=2 ){
  2988   2988       Tcl_WrongNumArgs(interp, 1, objv, "?N?");
  2989   2989       return TCL_ERROR;
  2990   2990     }
  2991   2991     amt = sqlite3Tsd()->nSoftHeapLimit;
  2992   2992     if( objc==2 ){

Changes to src/test6.c.

    15     15   ** is used to test the ability of SQLite to recover from those situations.
    16     16   */
    17     17   #if SQLITE_TEST          /* This file is used for the testing only */
    18     18   #include "sqliteInt.h"
    19     19   #include "os.h"
    20     20   #include "tcl.h"
    21     21   
           22  +#ifndef SQLITE_OMIT_DISKIO  /* This file is a no-op if disk I/O is disabled */
           23  +
    22     24   /*
    23     25   ** crashFile is a subclass of OsFile that is taylored for the
    24     26   ** crash test module.
    25     27   */
    26     28   typedef struct crashFile crashFile;
    27     29   struct crashFile {
    28     30     IoMethod const *pMethod; /* Must be first */
................................................................................
   530    532       return TCL_ERROR;
   531    533     }
   532    534     setCrashParams(delay, zFile);
   533    535     sqlite3CrashTestEnable = 1;
   534    536     return TCL_OK;
   535    537   }
   536    538   
          539  +#endif /* SQLITE_OMIT_DISKIO */
          540  +
   537    541   /*
   538    542   ** This procedure registers the TCL procedures defined in this file.
   539    543   */
   540    544   int Sqlitetest6_Init(Tcl_Interp *interp){
          545  +#ifndef SQLITE_OMIT_DISKIO
   541    546     Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0);
          547  +#endif
   542    548     return TCL_OK;
   543    549   }
   544    550   
   545    551   #endif /* SQLITE_TEST */

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.161 2006/01/06 14:32:20 drh Exp $
           17  +** $Id: util.c,v 1.162 2006/01/06 21:52:50 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <stdarg.h>
    22     22   #include <ctype.h>
    23     23   
    24     24   /*
................................................................................
    62     62   **     * Guardposts to detect overwrites.
    63     63   **     * Ability to cause a specific Malloc() or Realloc() to fail.
    64     64   **     * Audit outstanding memory allocations (i.e check for leaks).
    65     65   */
    66     66   
    67     67   #define MAX(x,y) ((x)>(y)?(x):(y))
    68     68   
    69         -#ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
           69  +#if !defined(SQLITE_OMIT_MEMORY_MANAGEMENT) && !defined(SQLITE_OMIT_DISKIO)
    70     70   /*
    71     71   ** Set the soft heap-size limit for the current thread. Passing a negative
    72     72   ** value indicates no limit.
    73     73   */
    74     74   void sqlite3_soft_heap_limit(sqlite_int64 n){
    75     75     sqlite3Tsd()->nSoftHeapLimit = n;
    76     76   }