/ Check-in [3ddf5a9d]
Login

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

Overview
Comment:Fix a naming conflict between sqlite versions 2 and 3. An open sqlite3 connection now *must* be called "sqlite3". You cannot call it "sqlite". This might break existing code. (CVS 1941)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3ddf5a9d1c480a2e3aa32685879063b11afddbe1
User & Date: drh 2004-09-06 17:24:12
Context
2004-09-06
17:34
Fix more name collisions. Allow sqlite.h and sqlite3.h to both be included in the same C/C++ source file. (CVS 1942) check-in: 23e5bed1 user: drh tags: trunk
17:24
Fix a naming conflict between sqlite versions 2 and 3. An open sqlite3 connection now *must* be called "sqlite3". You cannot call it "sqlite". This might break existing code. (CVS 1941) check-in: 3ddf5a9d user: drh tags: trunk
2004-09-05
23:23
Comment changes and minor code cleanup. (CVS 1940) check-in: dfa9ea89 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace 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.27 2004/09/05 23:23:42 drh Exp $
           14  +** $Id: attach.c,v 1.28 2004/09/06 17:24:12 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** This routine is called by the parser to process an ATTACH statement:
    20     20   **
    21     21   **     ATTACH DATABASE filename AS dbname
................................................................................
    29     29     Token *pDbname,      /* Name of the database to use internally */
    30     30     int keyType,         /* 0: no key.  1: TEXT,  2: BLOB */
    31     31     Token *pKey          /* Text of the key for keytype 1 and 2 */
    32     32   ){
    33     33     Db *aNew;
    34     34     int rc, i;
    35     35     char *zFile, *zName;
    36         -  sqlite *db;
           36  +  sqlite3 *db;
    37     37     Vdbe *v;
    38     38   
    39     39     v = sqlite3GetVdbe(pParse);
    40     40     if( !v ) return;
    41     41     sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
    42     42     if( pParse->explain ) return;
    43     43     db = pParse->db;
................................................................................
   150    150   **
   151    151   **    DETACH DATABASE dbname
   152    152   **
   153    153   ** The pDbname argument is the name of the database in the DETACH statement.
   154    154   */
   155    155   void sqlite3Detach(Parse *pParse, Token *pDbname){
   156    156     int i;
   157         -  sqlite *db;
          157  +  sqlite3 *db;
   158    158     Vdbe *v;
   159    159     Db *pDb = 0;
   160    160   
   161    161     v = sqlite3GetVdbe(pParse);
   162    162     if( !v ) return;
   163    163     sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
   164    164     if( pParse->explain ) return;
................................................................................
   202    202   int sqlite3FixInit(
   203    203     DbFixer *pFix,      /* The fixer to be initialized */
   204    204     Parse *pParse,      /* Error messages will be written here */
   205    205     int iDb,            /* This is the database that must be used */
   206    206     const char *zType,  /* "view", "trigger", or "index" */
   207    207     const Token *pName  /* Name of the view, trigger, or index */
   208    208   ){
   209         -  sqlite *db;
          209  +  sqlite3 *db;
   210    210   
   211    211     if( iDb<0 || iDb==1 ) return 0;
   212    212     db = pParse->db;
   213    213     assert( db->nDb>iDb );
   214    214     pFix->pParse = pParse;
   215    215     pFix->zDb = db->aDb[iDb].zName;
   216    216     pFix->zType = zType;

Changes to src/auth.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the sqlite3_set_authorizer()
    13     13   ** API.  This facility is an optional feature of the library.  Embedded
    14     14   ** systems that do not need this facility may omit it by recompiling
    15     15   ** the library with -DSQLITE_OMIT_AUTHORIZATION=1
    16     16   **
    17         -** $Id: auth.c,v 1.16 2004/06/19 16:06:11 drh Exp $
           17  +** $Id: auth.c,v 1.17 2004/09/06 17:24:12 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   /*
    22     22   ** All of the code in this file may be omitted by defining a single
    23     23   ** macro.
    24     24   */
................................................................................
    66     66   ** should run but attempts to read the specified column will return NULL
    67     67   ** and attempts to write the column will be ignored.
    68     68   **
    69     69   ** Setting the auth function to NULL disables this hook.  The default
    70     70   ** setting of the auth function is NULL.
    71     71   */
    72     72   int sqlite3_set_authorizer(
    73         -  sqlite *db,
           73  +  sqlite3 *db,
    74     74     int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
    75     75     void *pArg
    76     76   ){
    77     77     db->xAuth = xAuth;
    78     78     db->pAuthArg = pArg;
    79     79     return SQLITE_OK;
    80     80   }
................................................................................
   100    100   ** then generate an error.
   101    101   */
   102    102   void sqlite3AuthRead(
   103    103     Parse *pParse,        /* The parser context */
   104    104     Expr *pExpr,          /* The expression to check authorization on */
   105    105     SrcList *pTabList     /* All table that pExpr might refer to */
   106    106   ){
   107         -  sqlite *db = pParse->db;
          107  +  sqlite3 *db = pParse->db;
   108    108     int rc;
   109    109     Table *pTab;          /* The table being read */
   110    110     const char *zCol;     /* Name of the column of the table */
   111    111     int iSrc;             /* Index in pTabList->a[] of table being read */
   112    112     const char *zDBase;   /* Name of database being accessed */
   113    113   
   114    114     if( db->xAuth==0 ) return;
................................................................................
   166    166   int sqlite3AuthCheck(
   167    167     Parse *pParse,
   168    168     int code,
   169    169     const char *zArg1,
   170    170     const char *zArg2,
   171    171     const char *zArg3
   172    172   ){
   173         -  sqlite *db = pParse->db;
          173  +  sqlite3 *db = pParse->db;
   174    174     int rc;
   175    175   
   176    176     /* Don't do any authorization checks if the database is initialising. */
   177    177     if( db->init.busy ){
   178    178       return SQLITE_OK;
   179    179     }
   180    180   

Changes to src/build.c.

    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **     PRAGMA
    25     25   **
    26         -** $Id: build.c,v 1.250 2004/08/31 13:45:11 drh Exp $
           26  +** $Id: build.c,v 1.251 2004/09/06 17:24:12 drh Exp $
    27     27   */
    28     28   #include "sqliteInt.h"
    29     29   #include <ctype.h>
    30     30   
    31     31   /*
    32     32   ** This routine is called when a new SQL statement is beginning to
    33     33   ** be parsed.  Check to see if the schema for the database needs
................................................................................
    46     46   ** VDBE program and resets the pParse structure for the next
    47     47   ** parse.
    48     48   **
    49     49   ** Note that if an error occurred, it might be the case that
    50     50   ** no VDBE code was generated.
    51     51   */
    52     52   void sqlite3FinishCoding(Parse *pParse){
    53         -  sqlite *db;
           53  +  sqlite3 *db;
    54     54     Vdbe *v;
    55     55   
    56     56     if( sqlite3_malloc_failed ) return;
    57     57   
    58     58     /* Begin by generating some termination code at the end of the
    59     59     ** vdbe program
    60     60     */
................................................................................
   120    120   ** If zDatabase is 0, all databases are searched for the table and the
   121    121   ** first matching table is returned.  (No checking for duplicate table
   122    122   ** names is done.)  The search order is TEMP first, then MAIN, then any
   123    123   ** auxiliary databases added using the ATTACH command.
   124    124   **
   125    125   ** See also sqlite3LocateTable().
   126    126   */
   127         -Table *sqlite3FindTable(sqlite *db, const char *zName, const char *zDatabase){
          127  +Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
   128    128     Table *p = 0;
   129    129     int i;
   130    130     assert( zName!=0 );
   131    131     assert( (db->flags & SQLITE_Initialized) || db->init.busy );
   132    132     for(i=0; i<db->nDb; i++){
   133    133       int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   134    134       if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue;
................................................................................
   180    180   **
   181    181   ** If zDatabase is 0, all databases are searched for the
   182    182   ** table and the first matching index is returned.  (No checking
   183    183   ** for duplicate index names is done.)  The search order is
   184    184   ** TEMP first, then MAIN, then any auxiliary databases added
   185    185   ** using the ATTACH command.
   186    186   */
   187         -Index *sqlite3FindIndex(sqlite *db, const char *zName, const char *zDb){
          187  +Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){
   188    188     Index *p = 0;
   189    189     int i;
   190    190     assert( (db->flags & SQLITE_Initialized) || db->init.busy );
   191    191     for(i=0; i<db->nDb; i++){
   192    192       int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */
   193    193       if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zName) ) continue;
   194    194       p = sqlite3HashFind(&db->aDb[j].idxHash, zName, strlen(zName)+1);
................................................................................
   209    209   ** Remove the given index from the index hash table, and free
   210    210   ** its memory structures.
   211    211   **
   212    212   ** The index is removed from the database hash tables but
   213    213   ** it is not unlinked from the Table that it indexes.
   214    214   ** Unlinking from the Table must be done by the calling function.
   215    215   */
   216         -static void sqliteDeleteIndex(sqlite *db, Index *p){
          216  +static void sqliteDeleteIndex(sqlite3 *db, Index *p){
   217    217     Index *pOld;
   218    218   
   219    219     assert( db!=0 && p->zName!=0 );
   220    220     pOld = sqlite3HashInsert(&db->aDb[p->iDb].idxHash, p->zName,
   221    221                             strlen(p->zName)+1, 0);
   222    222     if( pOld!=0 && pOld!=p ){
   223    223       sqlite3HashInsert(&db->aDb[p->iDb].idxHash, pOld->zName,
................................................................................
   227    227   }
   228    228   
   229    229   /*
   230    230   ** Unlink the given index from its table, then remove
   231    231   ** the index from the index hash table and free its memory
   232    232   ** structures.
   233    233   */
   234         -void sqlite3UnlinkAndDeleteIndex(sqlite *db, int iDb, const char *zIdxName){
          234  +void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){
   235    235     Index *pIndex;
   236    236     int len;
   237    237   
   238    238     len = strlen(zIdxName);
   239    239     pIndex = sqlite3HashInsert(&db->aDb[iDb].idxHash, zIdxName, len+1, 0);
   240    240     if( pIndex ){
   241    241       if( pIndex->pTable->pIndex==pIndex ){
................................................................................
   259    259   ** if there were schema changes during the transaction or if a
   260    260   ** schema-cookie mismatch occurs.
   261    261   **
   262    262   ** If iDb<=0 then reset the internal schema tables for all database
   263    263   ** files.  If iDb>=2 then reset the internal schema for only the
   264    264   ** single file indicated.
   265    265   */
   266         -void sqlite3ResetInternalSchema(sqlite *db, int iDb){
          266  +void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
   267    267     HashElem *pElem;
   268    268     Hash temp1;
   269    269     Hash temp2;
   270    270     int i, j;
   271    271   
   272    272     assert( iDb>=0 && iDb<db->nDb );
   273    273     db->flags &= ~SQLITE_Initialized;
................................................................................
   330    330   }
   331    331   
   332    332   /*
   333    333   ** This routine is called whenever a rollback occurs.  If there were
   334    334   ** schema changes during the transaction, then we have to reset the
   335    335   ** internal hash tables and reload them from disk.
   336    336   */
   337         -void sqlite3RollbackInternalChanges(sqlite *db){
          337  +void sqlite3RollbackInternalChanges(sqlite3 *db){
   338    338     if( db->flags & SQLITE_InternChanges ){
   339    339       sqlite3ResetInternalSchema(db, 0);
   340    340     }
   341    341   }
   342    342   
   343    343   /*
   344    344   ** This routine is called when a commit occurs.
   345    345   */
   346         -void sqlite3CommitInternalChanges(sqlite *db){
          346  +void sqlite3CommitInternalChanges(sqlite3 *db){
   347    347     db->flags &= ~SQLITE_InternChanges;
   348    348   }
   349    349   
   350    350   /*
   351    351   ** Clear the column names from a table or view.
   352    352   */
   353    353   static void sqliteResetColumnNames(Table *pTable){
................................................................................
   375    375   ** the table.
   376    376   **
   377    377   ** Indices associated with the table are unlinked from the "db"
   378    378   ** data structure if db!=NULL.  If db==NULL, indices attached to
   379    379   ** the table are deleted, but it is assumed they have already been
   380    380   ** unlinked.
   381    381   */
   382         -void sqlite3DeleteTable(sqlite *db, Table *pTable){
          382  +void sqlite3DeleteTable(sqlite3 *db, Table *pTable){
   383    383     Index *pIndex, *pNext;
   384    384     FKey *pFKey, *pNextFKey;
   385    385   
   386    386     if( pTable==0 ) return;
   387    387   
   388    388     /* Delete all indices associated with this table
   389    389     */
................................................................................
   413    413     sqliteFree(pTable);
   414    414   }
   415    415   
   416    416   /*
   417    417   ** Unlink the given table from the hash tables and the delete the
   418    418   ** table structure with all its indices and foreign keys.
   419    419   */
   420         -void sqlite3UnlinkAndDeleteTable(sqlite *db, int iDb, const char *zTabName){
          420  +void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){
   421    421     Table *p;
   422    422     FKey *pF1, *pF2;
   423    423     Db *pDb;
   424    424   
   425    425     assert( db!=0 );
   426    426     assert( iDb>=0 && iDb<db->nDb );
   427    427     assert( zTabName && zTabName[0] );
................................................................................
   575    575     Token *pName2,   /* Second part of the name of the table or view */
   576    576     int isTemp,      /* True if this is a TEMP table */
   577    577     int isView       /* True if this is a VIEW */
   578    578   ){
   579    579     Table *pTable;
   580    580     Index *pIdx;
   581    581     char *zName;
   582         -  sqlite *db = pParse->db;
          582  +  sqlite3 *db = pParse->db;
   583    583     Vdbe *v;
   584    584     int iDb;         /* Database number to create the table in */
   585    585     Token *pName;    /* Unqualified name of the table to create */
   586    586   
   587    587     /* The table or view name to create is passed to this routine via tokens
   588    588     ** pName1 and pName2. If the table name was fully qualified, for example:
   589    589     **
................................................................................
   918    918   ** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
   919    919   **
   920    920   ** Stored immediately after the three collation sequences is a copy of
   921    921   ** the collation sequence name. A pointer to this string is stored in
   922    922   ** each collation sequence structure.
   923    923   */
   924    924   static CollSeq * findCollSeqEntry(
   925         -  sqlite *db,
          925  +  sqlite3 *db,
   926    926     const char *zName,
   927    927     int nName,
   928    928     int create
   929    929   ){
   930    930     CollSeq *pColl;
   931    931     if( nName<0 ) nName = strlen(zName);
   932    932     pColl = sqlite3HashFind(&db->aCollSeq, zName, nName);
................................................................................
   953    953   ** Return the CollSeq* pointer for the collation sequence named zName
   954    954   ** for the encoding 'enc' from the database 'db'.
   955    955   **
   956    956   ** If the entry specified is not found and 'create' is true, then create a
   957    957   ** new entry.  Otherwise return NULL.
   958    958   */
   959    959   CollSeq *sqlite3FindCollSeq(
   960         -  sqlite *db,
          960  +  sqlite3 *db,
   961    961     u8 enc,
   962    962     const char *zName,
   963    963     int nName,
   964    964     int create
   965    965   ){
   966    966     CollSeq *pColl = findCollSeqEntry(db, zName, nName, create);
   967    967     assert( SQLITE_UTF8==1 && SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
................................................................................
   971    971   }
   972    972   
   973    973   /*
   974    974   ** Invoke the 'collation needed' callback to request a collation sequence
   975    975   ** in the database text encoding of name zName, length nName.
   976    976   ** If the collation sequence
   977    977   */
   978         -static void callCollNeeded(sqlite *db, const char *zName, int nName){
          978  +static void callCollNeeded(sqlite3 *db, const char *zName, int nName){
   979    979     assert( !db->xCollNeeded || !db->xCollNeeded16 );
   980    980     if( nName<0 ) nName = strlen(zName);
   981    981     if( db->xCollNeeded ){
   982    982       char *zExternal = sqliteStrNDup(zName, nName);
   983    983       if( !zExternal ) return;
   984    984       db->xCollNeeded(db->pCollNeededArg, db, (int)db->enc, zExternal);
   985    985       sqliteFree(zExternal);
................................................................................
  1001   1001   ** of these instead if they exist. Avoid a UTF-8 <-> UTF-16 conversion if
  1002   1002   ** possible.
  1003   1003   */
  1004   1004   static int synthCollSeq(Parse *pParse, CollSeq *pColl){
  1005   1005     CollSeq *pColl2;
  1006   1006     char *z = pColl->zName;
  1007   1007     int n = strlen(z);
  1008         -  sqlite *db = pParse->db;
         1008  +  sqlite3 *db = pParse->db;
  1009   1009     int i;
  1010   1010     static const u8 aEnc[] = { SQLITE_UTF16BE, SQLITE_UTF16LE, SQLITE_UTF8 };
  1011   1011     for(i=0; i<3; i++){
  1012   1012       pColl2 = sqlite3FindCollSeq(db, aEnc[i], z, n, 0);
  1013   1013       if( pColl2->xCmp!=0 ){
  1014   1014         memcpy(pColl, pColl2, sizeof(CollSeq));
  1015   1015         return SQLITE_OK;
................................................................................
  1161   1161   **
  1162   1162   ** This plan is not completely bullet-proof.  It is possible for
  1163   1163   ** the schema to change multiple times and for the cookie to be
  1164   1164   ** set back to prior value.  But schema changes are infrequent
  1165   1165   ** and the probability of hitting the same cookie value is only
  1166   1166   ** 1 chance in 2^32.  So we're safe enough.
  1167   1167   */
  1168         -void sqlite3ChangeCookie(sqlite *db, Vdbe *v, int iDb){
         1168  +void sqlite3ChangeCookie(sqlite3 *db, Vdbe *v, int iDb){
  1169   1169     sqlite3VdbeAddOp(v, OP_Integer, db->aDb[iDb].schema_cookie+1, 0);
  1170   1170     sqlite3VdbeAddOp(v, OP_SetCookie, iDb, 0);
  1171   1171   }
  1172   1172   
  1173   1173   /*
  1174   1174   ** Measure the number of characters needed to output the given
  1175   1175   ** identifier.  The number returned includes any quotes used
................................................................................
  1277   1277   ** If the pSelect argument is not NULL, it means that this routine
  1278   1278   ** was called to create a table generated from a 
  1279   1279   ** "CREATE TABLE ... AS SELECT ..." statement.  The column names of
  1280   1280   ** the new table will match the result set of the SELECT.
  1281   1281   */
  1282   1282   void sqlite3EndTable(Parse *pParse, Token *pEnd, Select *pSelect){
  1283   1283     Table *p;
  1284         -  sqlite *db = pParse->db;
         1284  +  sqlite3 *db = pParse->db;
  1285   1285   
  1286   1286     if( (pEnd==0 && pSelect==0) || pParse->nErr || sqlite3_malloc_failed ) return;
  1287   1287     p = pParse->pNewTable;
  1288   1288     if( p==0 ) return;
  1289   1289   
  1290   1290     assert( !db->init.busy || !pSelect );
  1291   1291   
................................................................................
  1538   1538     pSel->pEList = pEList;
  1539   1539     return nErr;  
  1540   1540   }
  1541   1541   
  1542   1542   /*
  1543   1543   ** Clear the column names from every VIEW in database idx.
  1544   1544   */
  1545         -static void sqliteViewResetAll(sqlite *db, int idx){
         1545  +static void sqliteViewResetAll(sqlite3 *db, int idx){
  1546   1546     HashElem *i;
  1547   1547     if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;
  1548   1548     for(i=sqliteHashFirst(&db->aDb[idx].tblHash); i; i=sqliteHashNext(i)){
  1549   1549       Table *pTab = sqliteHashData(i);
  1550   1550       if( pTab->pSelect ){
  1551   1551         sqliteResetColumnNames(pTab);
  1552   1552       }
................................................................................
  1558   1558   ** This routine is called to do the work of a DROP TABLE statement.
  1559   1559   ** pName is the name of the table to be dropped.
  1560   1560   */
  1561   1561   void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView){
  1562   1562     Table *pTab;
  1563   1563     Vdbe *v;
  1564   1564     int base;
  1565         -  sqlite *db = pParse->db;
         1565  +  sqlite3 *db = pParse->db;
  1566   1566     int iDb;
  1567   1567   
  1568   1568     if( pParse->nErr || sqlite3_malloc_failed ) goto exit_drop_table;
  1569   1569     assert( pName->nSrc==1 );
  1570   1570     pTab = sqlite3LocateTable(pParse, pName->a[0].zName, pName->a[0].zDatabase);
  1571   1571   
  1572   1572     if( pTab==0 ) goto exit_drop_table;
................................................................................
  1831   1831     Table *pTab = 0; /* Table to be indexed */
  1832   1832     Index *pIndex = 0; /* The index to be created */
  1833   1833     char *zName = 0;
  1834   1834     int i, j;
  1835   1835     Token nullId;    /* Fake token for an empty ID list */
  1836   1836     DbFixer sFix;    /* For assigning database names to pTable */
  1837   1837     int isTemp;      /* True for a temporary index */
  1838         -  sqlite *db = pParse->db;
         1838  +  sqlite3 *db = pParse->db;
  1839   1839   
  1840   1840     int iDb;          /* Index of the database that is being written */
  1841   1841     Token *pName = 0; /* Unqualified name of the index to create */
  1842   1842   
  1843   1843     if( pParse->nErr || sqlite3_malloc_failed ) goto exit_create_index;
  1844   1844   
  1845   1845     /*
................................................................................
  2178   2178   /*
  2179   2179   ** This routine will drop an existing named index.  This routine
  2180   2180   ** implements the DROP INDEX statement.
  2181   2181   */
  2182   2182   void sqlite3DropIndex(Parse *pParse, SrcList *pName){
  2183   2183     Index *pIndex;
  2184   2184     Vdbe *v;
  2185         -  sqlite *db = pParse->db;
         2185  +  sqlite3 *db = pParse->db;
  2186   2186   
  2187   2187     if( pParse->nErr || sqlite3_malloc_failed ) return;
  2188   2188     assert( pName->nSrc==1 );
  2189   2189     if( SQLITE_OK!=sqlite3ReadSchema(pParse) ) return;
  2190   2190     pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);
  2191   2191     if( pIndex==0 ){
  2192   2192       sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0);
................................................................................
  2401   2401     sqliteFree(pList);
  2402   2402   }
  2403   2403   
  2404   2404   /*
  2405   2405   ** Begin a transaction
  2406   2406   */
  2407   2407   void sqlite3BeginTransaction(Parse *pParse){
  2408         -  sqlite *db;
         2408  +  sqlite3 *db;
  2409   2409     Vdbe *v;
  2410   2410   
  2411   2411     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2412   2412     if( pParse->nErr || sqlite3_malloc_failed ) return;
  2413   2413     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ) return;
  2414   2414   
  2415   2415     v = sqlite3GetVdbe(pParse);
................................................................................
  2417   2417     sqlite3VdbeAddOp(v, OP_AutoCommit, 0, 0);
  2418   2418   }
  2419   2419   
  2420   2420   /*
  2421   2421   ** Commit a transaction
  2422   2422   */
  2423   2423   void sqlite3CommitTransaction(Parse *pParse){
  2424         -  sqlite *db;
         2424  +  sqlite3 *db;
  2425   2425     Vdbe *v;
  2426   2426   
  2427   2427     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2428   2428     if( pParse->nErr || sqlite3_malloc_failed ) return;
  2429   2429     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ) return;
  2430   2430   
  2431   2431     v = sqlite3GetVdbe(pParse);
................................................................................
  2434   2434     }
  2435   2435   }
  2436   2436   
  2437   2437   /*
  2438   2438   ** Rollback a transaction
  2439   2439   */
  2440   2440   void sqlite3RollbackTransaction(Parse *pParse){
  2441         -  sqlite *db;
         2441  +  sqlite3 *db;
  2442   2442     Vdbe *v;
  2443   2443   
  2444   2444     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2445   2445     if( pParse->nErr || sqlite3_malloc_failed ) return;
  2446   2446     if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ) return;
  2447   2447   
  2448   2448     v = sqlite3GetVdbe(pParse);
................................................................................
  2497   2497   ** cookie verification subroutine code happens in sqlite3FinishCoding().
  2498   2498   **
  2499   2499   ** If iDb<0 then code the OP_Goto only - don't set flag to verify the
  2500   2500   ** schema on any databases.  This can be used to position the OP_Goto
  2501   2501   ** early in the code, before we know if any database tables will be used.
  2502   2502   */
  2503   2503   void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  2504         -  sqlite *db;
         2504  +  sqlite3 *db;
  2505   2505     Vdbe *v;
  2506   2506     int mask;
  2507   2507   
  2508   2508     v = sqlite3GetVdbe(pParse);
  2509   2509     if( v==0 ) return;  /* This only happens if there was a prior error */
  2510   2510     db = pParse->db;
  2511   2511     if( pParse->cookieGoto==0 ){
................................................................................
  2572   2572     return;
  2573   2573   }
  2574   2574   
  2575   2575   /* 
  2576   2576   ** Return the transient sqlite3_value object used for encoding conversions
  2577   2577   ** during SQL compilation.
  2578   2578   */
  2579         -sqlite3_value *sqlite3GetTransientValue(sqlite *db){
         2579  +sqlite3_value *sqlite3GetTransientValue(sqlite3 *db){
  2580   2580     if( !db->pValue ){
  2581   2581       db->pValue = sqlite3ValueNew();
  2582   2582     }
  2583   2583     return db->pValue;
  2584   2584   }

Changes to src/date.c.

    12     12   ** This file contains the C functions that implement date and time
    13     13   ** functions for SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: date.c,v 1.34 2004/08/17 10:42:55 drh Exp $
           19  +** $Id: date.c,v 1.35 2004/09/06 17:24:12 drh Exp $
    20     20   **
    21     21   ** NOTES:
    22     22   **
    23     23   ** SQLite processes all times and dates as Julian Day numbers.  The
    24     24   ** dates and times are stored as the number of days since noon
    25     25   ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
    26     26   ** calendar system.
................................................................................
   866    866   #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
   867    867   
   868    868   /*
   869    869   ** This function registered all of the above C functions as SQL
   870    870   ** functions.  This should be the only routine in this file with
   871    871   ** external linkage.
   872    872   */
   873         -void sqlite3RegisterDateTimeFunctions(sqlite *db){
          873  +void sqlite3RegisterDateTimeFunctions(sqlite3 *db){
   874    874   #ifndef SQLITE_OMIT_DATETIME_FUNCS
   875    875     static struct {
   876    876        char *zName;
   877    877        int nArg;
   878    878        void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
   879    879     } aFuncs[] = {
   880    880       { "julianday", -1, juliandayFunc   },

Changes to src/delete.c.

     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 C code routines that are called by the parser
    13     13   ** to handle DELETE FROM statements.
    14     14   **
    15         -** $Id: delete.c,v 1.79 2004/08/31 13:45:12 drh Exp $
           15  +** $Id: delete.c,v 1.80 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Look up every table that is named in pSrc.  If any table is not found,
    21     21   ** add an error message to pParse->zErrMsg and return NULL.  If all tables
    22     22   ** are found, return a pointer to the last table.
................................................................................
    61     61     Table *pTab;           /* The table from which records will be deleted */
    62     62     const char *zDb;       /* Name of database holding pTab */
    63     63     int end, addr = 0;     /* A couple addresses of generated code */
    64     64     int i;                 /* Loop counter */
    65     65     WhereInfo *pWInfo;     /* Information about the WHERE clause */
    66     66     Index *pIdx;           /* For looping over indices of the table */
    67     67     int iCur;              /* VDBE Cursor number for pTab */
    68         -  sqlite *db;            /* Main database structure */
           68  +  sqlite3 *db;           /* Main database structure */
    69     69     int isView;            /* True if attempting to delete from a view */
    70     70     AuthContext sContext;  /* Authorization context */
    71     71   
    72     72     int row_triggers_exist = 0;  /* True if any triggers exist */
    73     73     int before_triggers;         /* True if there are BEFORE triggers */
    74     74     int after_triggers;          /* True if there are AFTER triggers */
    75     75     int oldIdx = -1;             /* Cursor for the OLD table of AFTER triggers */
................................................................................
   331    331   **       of the stack.
   332    332   **
   333    333   ** This routine pops the top of the stack to remove the record number
   334    334   ** and then generates code to remove both the table record and all index
   335    335   ** entries that point to that record.
   336    336   */
   337    337   void sqlite3GenerateRowDelete(
   338         -  sqlite *db,        /* The database containing the index */
          338  +  sqlite3 *db,       /* The database containing the index */
   339    339     Vdbe *v,           /* Generate code into this VDBE */
   340    340     Table *pTab,       /* Table containing the row to be deleted */
   341    341     int iCur,          /* Cursor number for the table */
   342    342     int count          /* Increment the row change counter */
   343    343   ){
   344    344     int addr;
   345    345     addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0);
................................................................................
   361    361   **   2.  Read/write cursors for all indices of pTab must be open as
   362    362   **       cursor number iCur+i for the i-th index.
   363    363   **
   364    364   **   3.  The "iCur" cursor must be pointing to the row that is to be
   365    365   **       deleted.
   366    366   */
   367    367   void sqlite3GenerateRowIndexDelete(
   368         -  sqlite *db,        /* The database containing the index */
          368  +  sqlite3 *db,       /* The database containing the index */
   369    369     Vdbe *v,           /* Generate code into this VDBE */
   370    370     Table *pTab,       /* Table containing the row to be deleted */
   371    371     int iCur,          /* Cursor number for the table */
   372    372     char *aIdxUsed     /* Only delete if aIdxUsed!=0 && aIdxUsed[i]!=0 */
   373    373   ){
   374    374     int i;
   375    375     Index *pIdx;

Changes to src/expr.c.

     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 routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.159 2004/09/01 03:06:35 drh Exp $
           15  +** $Id: expr.c,v 1.160 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   char const *sqlite3AffinityString(char affinity){
    21     21     switch( affinity ){
    22     22       case SQLITE_AFF_INTEGER: return "i";
................................................................................
   597    597   ){
   598    598     char *zDb = 0;       /* Name of the database.  The "X" in X.Y.Z */
   599    599     char *zTab = 0;      /* Name of the table.  The "Y" in X.Y.Z or Y.Z */
   600    600     char *zCol = 0;      /* Name of the column.  The "Z" */
   601    601     int i, j;            /* Loop counters */
   602    602     int cnt = 0;         /* Number of matching column names */
   603    603     int cntTab = 0;      /* Number of matching table names */
   604         -  sqlite *db = pParse->db;  /* The database */
          604  +  sqlite3 *db = pParse->db;  /* The database */
   605    605   
   606    606     assert( pColumnToken && pColumnToken->z ); /* The Z in X.Y.Z cannot be NULL */
   607    607     zDb = sqlite3NameFromToken(pDbToken);
   608    608     zTab = sqlite3NameFromToken(pTableToken);
   609    609     zCol = sqlite3NameFromToken(pColumnToken);
   610    610     if( sqlite3_malloc_failed ){
   611    611       return 1;  /* Leak memory (zDb and zTab) if malloc fails */
................................................................................
  1763   1763   ** or xStep is non-zero.
  1764   1764   **
  1765   1765   ** If createFlag is false, then a function with the required name and
  1766   1766   ** number of arguments may be returned even if the eTextRep flag does not
  1767   1767   ** match that requested.
  1768   1768   */
  1769   1769   FuncDef *sqlite3FindFunction(
  1770         -  sqlite *db,        /* An open database */
         1770  +  sqlite3 *db,       /* An open database */
  1771   1771     const char *zName, /* Name of the function.  Not null-terminated */
  1772   1772     int nName,         /* Number of characters in the name */
  1773   1773     int nArg,          /* Number of arguments.  -1 means any number */
  1774   1774     u8 enc,            /* Preferred text encoding */
  1775   1775     int createFlag     /* Create new entry if true and does not otherwise exist */
  1776   1776   ){
  1777   1777     FuncDef *p;         /* Iterator variable */

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.82 2004/09/02 15:53:57 drh Exp $
           19  +** $Id: func.c,v 1.83 2004/09/06 17:24:13 drh Exp $
    20     20   */
    21     21   #include <ctype.h>
    22     22   #include <math.h>
    23     23   #include <stdlib.h>
    24     24   #include <assert.h>
    25     25   #include "sqliteInt.h"
    26     26   #include "vdbeInt.h"
................................................................................
   264    264   ** value is the same as the sqlite3_last_insert_rowid() API function.
   265    265   */
   266    266   static void last_insert_rowid(
   267    267     sqlite3_context *context, 
   268    268     int arg, 
   269    269     sqlite3_value **argv
   270    270   ){
   271         -  sqlite *db = sqlite3_user_data(context);
          271  +  sqlite3 *db = sqlite3_user_data(context);
   272    272     sqlite3_result_int64(context, sqlite3_last_insert_rowid(db));
   273    273   }
   274    274   
   275    275   /*
   276    276   ** Implementation of the changes() SQL function.  The return value is the
   277    277   ** same as the sqlite3_changes() API function.
   278    278   */
   279    279   static void changes(
   280    280     sqlite3_context *context,
   281    281     int arg,
   282    282     sqlite3_value **argv
   283    283   ){
   284         -  sqlite *db = sqlite3_user_data(context);
          284  +  sqlite3 *db = sqlite3_user_data(context);
   285    285     sqlite3_result_int(context, sqlite3_changes(db));
   286    286   }
   287    287   
   288    288   /*
   289    289   ** Implementation of the total_changes() SQL function.  The return value is
   290    290   ** the same as the sqlite3_total_changes() API function.
   291    291   */
   292    292   static void total_changes(
   293    293     sqlite3_context *context,
   294    294     int arg,
   295    295     sqlite3_value **argv
   296    296   ){
   297         -  sqlite *db = sqlite3_user_data(context);
          297  +  sqlite3 *db = sqlite3_user_data(context);
   298    298     sqlite3_result_int(context, sqlite3_total_changes(db));
   299    299   }
   300    300   
   301    301   /*
   302    302   ** A structure defining how to do GLOB-style comparisons.
   303    303   */
   304    304   struct compareInfo {
................................................................................
   686    686   static void test_destructor(
   687    687     sqlite3_context *pCtx, 
   688    688     int nArg,
   689    689     sqlite3_value **argv
   690    690   ){
   691    691     char *zVal;
   692    692     int len;
   693         -  sqlite *db = sqlite3_user_data(pCtx);
          693  +  sqlite3 *db = sqlite3_user_data(pCtx);
   694    694    
   695    695     test_destructor_count_var++;
   696    696     assert( nArg==1 );
   697    697     if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
   698    698     len = sqlite3ValueBytes(argv[0], db->enc); 
   699    699     zVal = sqliteMalloc(len+3);
   700    700     zVal[len] = 0;
................................................................................
   913    913   
   914    914   
   915    915   /*
   916    916   ** This function registered all of the above C functions as SQL
   917    917   ** functions.  This should be the only routine in this file with
   918    918   ** external linkage.
   919    919   */
   920         -void sqlite3RegisterBuiltinFunctions(sqlite *db){
          920  +void sqlite3RegisterBuiltinFunctions(sqlite3 *db){
   921    921     static struct {
   922    922        char *zName;
   923    923        signed char nArg;
   924    924        u8 argType;           /* 0: none.  1: db  2: (-1) */
   925    925        u8 eTextRep;          /* 1: UTF-16.  0: UTF-8 */
   926    926        u8 needCollSeq;
   927    927        void (*xFunc)(sqlite3_context*,int,sqlite3_value **);

Changes to src/insert.c.

     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 C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.115 2004/08/21 17:54:45 drh Exp $
           15  +** $Id: insert.c,v 1.116 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P3 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
   175    175     const char *zDb;      /* Name of the database holding this table */
   176    176     int i, j, idx;        /* Loop counters */
   177    177     Vdbe *v;              /* Generate code into this virtual machine */
   178    178     Index *pIdx;          /* For looping over indices of the table */
   179    179     int nColumn;          /* Number of columns in the data */
   180    180     int base = 0;         /* VDBE Cursor number for pTab */
   181    181     int iCont=0,iBreak=0; /* Beginning and end of the loop over srcTab */
   182         -  sqlite *db;           /* The main database structure */
          182  +  sqlite3 *db;          /* The main database structure */
   183    183     int keyColumn = -1;   /* Column that is the INTEGER PRIMARY KEY */
   184    184     int endOfLoop;        /* Label for the end of the insertion loop */
   185    185     int useTempTable;     /* Store SELECT results in intermediate table */
   186    186     int srcTab = 0;       /* Data comes from this temporary cursor if >=0 */
   187    187     int iSelectLoop = 0;  /* Address of code that implements the SELECT */
   188    188     int iCleanup = 0;     /* Address of the cleanup code */
   189    189     int iInsertBlock = 0; /* Address of the subroutine used to insert data */

Changes to src/legacy.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: legacy.c,v 1.5 2004/08/08 23:39:19 drh Exp $
           17  +** $Id: legacy.c,v 1.6 2004/09/06 17:24:13 drh Exp $
    18     18   */
    19     19   
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   
    24     24   /*
................................................................................
    28     28   **
    29     29   ** If the SQL is a query, then for each row in the query result
    30     30   ** the xCallback() function is called.  pArg becomes the first
    31     31   ** argument to xCallback().  If xCallback=NULL then no callback
    32     32   ** is invoked, even for queries.
    33     33   */
    34     34   int sqlite3_exec(
    35         -  sqlite *db,                 /* The database on which the SQL executes */
           35  +  sqlite3 *db,                /* The database on which the SQL executes */
    36     36     const char *zSql,           /* The SQL to be executed */
    37     37     sqlite_callback xCallback,  /* Invoke this callback routine */
    38     38     void *pArg,                 /* First argument to xCallback() */
    39     39     char **pzErrMsg             /* Write error messages here */
    40     40   ){
    41     41     int rc = SQLITE_OK;
    42     42     const char *zLeftover;

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.258 2004/09/02 15:53:57 drh Exp $
           17  +** $Id: main.c,v 1.259 2004/09/06 17:24:13 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
................................................................................
    49     49   **     argv[2] = SQL text for the CREATE statement.
    50     50   **     argv[3] = "1" for temporary files, "0" for main database, "2" or more
    51     51   **               for auxiliary database files.
    52     52   **
    53     53   */
    54     54   int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
    55     55     InitData *pData = (InitData*)pInit;
    56         -  sqlite *db = pData->db;
           56  +  sqlite3 *db = pData->db;
    57     57     int iDb;
    58     58   
    59     59     assert( argc==4 );
    60     60     if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
    61     61     if( argv[1]==0 || argv[3]==0 ){
    62     62       corruptSchema(pData, 0);
    63     63       return 1;
................................................................................
   109    109   ** Attempt to read the database schema and initialize internal
   110    110   ** data structures for a single database file.  The index of the
   111    111   ** database file is given by iDb.  iDb==0 is used for the main
   112    112   ** database.  iDb==1 should never be used.  iDb>=2 is used for
   113    113   ** auxiliary databases.  Return one of the SQLITE_ error codes to
   114    114   ** indicate success or failure.
   115    115   */
   116         -static int sqlite3InitOne(sqlite *db, int iDb, char **pzErrMsg){
          116  +static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
   117    117     int rc;
   118    118     BtCursor *curMain;
   119    119     int size;
   120    120     Table *pTab;
   121    121     char const *azArg[5];
   122    122     char zDbNum[30];
   123    123     int meta[10];
................................................................................
   305    305   ** used to store temporary tables, and any additional database files
   306    306   ** created using ATTACH statements.  Return a success code.  If an
   307    307   ** error occurs, write an error message into *pzErrMsg.
   308    308   **
   309    309   ** After the database is initialized, the SQLITE_Initialized
   310    310   ** bit is set in the flags field of the sqlite structure. 
   311    311   */
   312         -int sqlite3Init(sqlite *db, char **pzErrMsg){
          312  +int sqlite3Init(sqlite3 *db, char **pzErrMsg){
   313    313     int i, rc;
   314    314     
   315    315     if( db->init.busy ) return SQLITE_OK;
   316    316     assert( (db->flags & SQLITE_Initialized)==0 );
   317    317     rc = SQLITE_OK;
   318    318     db->init.busy = 1;
   319    319     for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
................................................................................
   413    413     }
   414    414     return r;
   415    415   }
   416    416   
   417    417   /*
   418    418   ** Return the ROWID of the most recent insert
   419    419   */
   420         -sqlite_int64 sqlite3_last_insert_rowid(sqlite *db){
          420  +sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
   421    421     return db->lastRowid;
   422    422   }
   423    423   
   424    424   /*
   425    425   ** Return the number of changes in the most recent call to sqlite3_exec().
   426    426   */
   427         -int sqlite3_changes(sqlite *db){
          427  +int sqlite3_changes(sqlite3 *db){
   428    428     return db->nChange;
   429    429   }
   430    430   
   431    431   /*
   432    432   ** Return the number of changes since the database handle was opened.
   433    433   */
   434    434   int sqlite3_total_changes(sqlite3 *db){
   435    435     return db->nTotalChange;
   436    436   }
   437    437   
   438    438   /*
   439    439   ** Close an existing SQLite database
   440    440   */
   441         -int sqlite3_close(sqlite *db){
          441  +int sqlite3_close(sqlite3 *db){
   442    442     HashElem *i;
   443    443     int j;
   444    444   
   445    445     if( !db ){
   446    446       return SQLITE_OK;
   447    447     }
   448    448   
................................................................................
   508    508     sqliteFree(db);
   509    509     return SQLITE_OK;
   510    510   }
   511    511   
   512    512   /*
   513    513   ** Rollback all database files.
   514    514   */
   515         -void sqlite3RollbackAll(sqlite *db){
          515  +void sqlite3RollbackAll(sqlite3 *db){
   516    516     int i;
   517    517     for(i=0; i<db->nDb; i++){
   518    518       if( db->aDb[i].pBt ){
   519    519         sqlite3BtreeRollback(db->aDb[i].pBt);
   520    520         db->aDb[i].inTrans = 0;
   521    521       }
   522    522     }
................................................................................
   621    621   #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
   622    622   /*
   623    623   ** This routine sets the progress callback for an Sqlite database to the
   624    624   ** given callback function with the given argument. The progress callback will
   625    625   ** be invoked every nOps opcodes.
   626    626   */
   627    627   void sqlite3_progress_handler(
   628         -  sqlite *db, 
          628  +  sqlite3 *db, 
   629    629     int nOps,
   630    630     int (*xProgress)(void*), 
   631    631     void *pArg
   632    632   ){
   633    633     if( nOps>0 ){
   634    634       db->xProgress = xProgress;
   635    635       db->nProgressOps = nOps;
................................................................................
   655    655     }
   656    656     return SQLITE_OK;
   657    657   }
   658    658   
   659    659   /*
   660    660   ** Cause any pending operation to stop at its earliest opportunity.
   661    661   */
   662         -void sqlite3_interrupt(sqlite *db){
          662  +void sqlite3_interrupt(sqlite3 *db){
   663    663     db->flags |= SQLITE_Interrupt;
   664    664   }
   665    665   
   666    666   /*
   667    667   ** Windows systems should call this routine to free memory that
   668    668   ** is returned in the in the errmsg parameter of sqlite3_open() when
   669    669   ** SQLite is a DLL.  For some reason, it does not work to call free()
................................................................................
   757    757   ** Register a trace function.  The pArg from the previously registered trace
   758    758   ** is returned.  
   759    759   **
   760    760   ** A NULL trace function means that no tracing is executes.  A non-NULL
   761    761   ** trace is a pointer to a function that is invoked at the start of each
   762    762   ** sqlite3_exec().
   763    763   */
   764         -void *sqlite3_trace(sqlite *db, void (*xTrace)(void*,const char*), void *pArg){
          764  +void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
   765    765     void *pOld = db->pTraceArg;
   766    766     db->xTrace = xTrace;
   767    767     db->pTraceArg = pArg;
   768    768     return pOld;
   769    769   }
   770    770   
   771    771   /*** EXPERIMENTAL ***
   772    772   **
   773    773   ** Register a function to be invoked when a transaction comments.
   774    774   ** If either function returns non-zero, then the commit becomes a
   775    775   ** rollback.
   776    776   */
   777    777   void *sqlite3_commit_hook(
   778         -  sqlite *db,               /* Attach the hook to this database */
          778  +  sqlite3 *db,              /* Attach the hook to this database */
   779    779     int (*xCallback)(void*),  /* Function to invoke on each commit */
   780    780     void *pArg                /* Argument to the function */
   781    781   ){
   782    782     void *pOld = db->pCommitArg;
   783    783     db->xCommitCallback = xCallback;
   784    784     db->pCommitArg = pArg;
   785    785     return pOld;
................................................................................
   808    808   **           1                0              file
   809    809   **           2                1              file
   810    810   **           2                2              memory
   811    811   **           2                0              memory
   812    812   **           3               any             memory
   813    813   */
   814    814   int sqlite3BtreeFactory(
   815         -  const sqlite *db,	    /* Main database when opening aux otherwise 0 */
          815  +  const sqlite3 *db,        /* Main database when opening aux otherwise 0 */
   816    816     const char *zFilename,    /* Name of the file containing the BTree database */
   817    817     int omitJournal,          /* if TRUE then do not journal this file */
   818    818     int nCache,               /* How many pages in the page cache */
   819    819     Btree **ppBtree           /* Pointer to new Btree object written here */
   820    820   ){
   821    821     int btree_flags = 0;
   822    822     int rc;
................................................................................
   926    926     return db->errCode;
   927    927   }
   928    928   
   929    929   /*
   930    930   ** Check schema cookies in all databases.  If any cookie is out
   931    931   ** of date, return 0.  If all schema cookies are current, return 1.
   932    932   */
   933         -static int schemaIsValid(sqlite *db){
          933  +static int schemaIsValid(sqlite3 *db){
   934    934     int iDb;
   935    935     int rc;
   936    936     BtCursor *curTemp;
   937    937     int cookie;
   938    938     int allOk = 1;
   939    939   
   940    940     for(iDb=0; allOk && iDb<db->nDb; iDb++){
................................................................................
  1114   1114     sqlite3 **ppDb         /* OUT: Returned database handle */
  1115   1115   ){
  1116   1116     sqlite3 *db;
  1117   1117     int rc, i;
  1118   1118     char *zErrMsg = 0;
  1119   1119   
  1120   1120     /* Allocate the sqlite data structure */
  1121         -  db = sqliteMalloc( sizeof(sqlite) );
         1121  +  db = sqliteMalloc( sizeof(sqlite3) );
  1122   1122     if( db==0 ) goto opendb_out;
  1123   1123     db->priorNewRowid = 0;
  1124   1124     db->magic = SQLITE_MAGIC_BUSY;
  1125   1125     db->nDb = 2;
  1126   1126     db->aDb = db->aDbStatic;
  1127   1127     db->enc = SQLITE_UTF8;
  1128   1128     db->autoCommit = 1;

Changes to src/pragma.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 PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.63 2004/09/05 23:23:42 drh Exp $
           14  +** $Id: pragma.c,v 1.64 2004/09/06 17:24:13 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
    20     20   # include "pager.h"
    21     21   # include "btree.h"
................................................................................
    91     91   /*
    92     92   ** If the TEMP database is open, close it and mark the database schema
    93     93   ** as needing reloading.  This must be done when using the TEMP_STORE
    94     94   ** or DEFAULT_TEMP_STORE pragmas.
    95     95   */
    96     96   static int changeTempStorage(Parse *pParse, const char *zStorageType){
    97     97     int ts = getTempStore(zStorageType);
    98         -  sqlite *db = pParse->db;
           98  +  sqlite3 *db = pParse->db;
    99     99     if( db->temp_store==ts ) return SQLITE_OK;
   100    100     if( db->aDb[1].pBt!=0 ){
   101    101       if( db->flags & SQLITE_InTrans ){
   102    102         sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
   103    103           "from within a transaction");
   104    104         return SQLITE_ERROR;
   105    105       }
................................................................................
   143    143       { "count_changes",            SQLITE_CountRows     },
   144    144       { "empty_result_callbacks",   SQLITE_NullCallback  },
   145    145   #endif
   146    146     };
   147    147     int i;
   148    148     for(i=0; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
   149    149       if( sqlite3StrICmp(zLeft, aPragma[i].zName)==0 ){
   150         -      sqlite *db = pParse->db;
          150  +      sqlite3 *db = pParse->db;
   151    151         Vdbe *v;
   152    152         if( zRight==0 ){
   153    153           v = sqlite3GetVdbe(pParse);
   154    154           if( v ){
   155    155             returnSingleInt(pParse,
   156    156                  aPragma[i].zName, (db->flags&aPragma[i].mask)!=0);
   157    157           }
................................................................................
   189    189     int minusFlag       /* True if a '-' sign preceded <value> */
   190    190   ){
   191    191     char *zLeft = 0;       /* Nul-terminated UTF-8 string <id> */
   192    192     char *zRight = 0;      /* Nul-terminated UTF-8 string <value>, or NULL */
   193    193     const char *zDb = 0;   /* The database name */
   194    194     Token *pId;            /* Pointer to <id> token */
   195    195     int iDb;               /* Database index for <database> */
   196         -  sqlite *db = pParse->db;
          196  +  sqlite3 *db = pParse->db;
   197    197     Db *pDb;
   198    198     Vdbe *v = sqlite3GetVdbe(pParse);
   199    199     if( v==0 ) return;
   200    200   
   201    201     /* Interpret the [database.] part of the pragma statement. iDb is the
   202    202     ** index of the database this pragma is being applied to in db.aDb[]. */
   203    203     iDb = sqlite3TwoPartName(pParse, pId1, pId2, &pId);

Changes to src/select.c.

     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 C code routines that are called by the parser
    13     13   ** to handle SELECT statements in SQLite.
    14     14   **
    15         -** $Id: select.c,v 1.206 2004/09/01 03:06:35 drh Exp $
           15  +** $Id: select.c,v 1.207 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   
    20     20   /*
    21     21   ** Allocate a new Select structure and return a pointer to that
    22     22   ** structure.
................................................................................
   561    561   ){
   562    562     int end1 = sqlite3VdbeMakeLabel(v);
   563    563     int end2 = sqlite3VdbeMakeLabel(v);
   564    564     int addr;
   565    565     KeyInfo *pInfo;
   566    566     ExprList *pOrderBy;
   567    567     int nCol, i;
   568         -  sqlite *db = pParse->db;
          568  +  sqlite3 *db = pParse->db;
   569    569   
   570    570     if( eDest==SRT_Sorter ) return;
   571    571     pOrderBy = p->pOrderBy;
   572    572     nCol = pOrderBy->nExpr;
   573    573     pInfo = sqliteMalloc( sizeof(*pInfo) + nCol*(sizeof(CollSeq*)+1) );
   574    574     if( pInfo==0 ) return;
   575    575     pInfo->aSortOrder = (char*)&pInfo->aColl[nCol];
................................................................................
   716    716   static void generateColumnNames(
   717    717     Parse *pParse,      /* Parser context */
   718    718     SrcList *pTabList,  /* List of tables */
   719    719     ExprList *pEList    /* Expressions defining the result set */
   720    720   ){
   721    721     Vdbe *v = pParse->pVdbe;
   722    722     int i, j;
   723         -  sqlite *db = pParse->db;
          723  +  sqlite3 *db = pParse->db;
   724    724     int fullNames, shortNames;
   725    725   
   726    726     /* If this is an EXPLAIN, skip this step */
   727    727     if( pParse->explain ){
   728    728       return;
   729    729     }
   730    730   
................................................................................
  1249   1249   ** Make the new table a KeyAsData table if keyAsData is true.
  1250   1250   **
  1251   1251   ** The value returned is the address of the OP_OpenTemp instruction.
  1252   1252   */
  1253   1253   static int openTempIndex(Parse *pParse, Select *p, int iTab, int keyAsData){
  1254   1254     KeyInfo *pKeyInfo;
  1255   1255     int nColumn;
  1256         -  sqlite *db = pParse->db;
         1256  +  sqlite3 *db = pParse->db;
  1257   1257     int i;
  1258   1258     Vdbe *v = pParse->pVdbe;
  1259   1259     int addr;
  1260   1260   
  1261   1261     if( fillInColumnList(pParse, p) ){
  1262   1262       return 0;
  1263   1263     }

Changes to src/sqlite.h.in.

     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 header file defines the interface that the SQLite library
    13     13   ** presents to client programs.
    14     14   **
    15         -** @(#) $Id: sqlite.h.in,v 1.116 2004/08/29 23:42:14 drh Exp $
           15  +** @(#) $Id: sqlite.h.in,v 1.117 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #ifndef _SQLITE_H_
    18     18   #define _SQLITE_H_
    19     19   #include <stdarg.h>     /* Needed for the definition of va_list */
    20     20   
    21     21   /*
    22     22   ** Make sure we can call this stuff from C++.
................................................................................
    40     40   extern const char sqlite3_version[];
    41     41   const char *sqlite3_libversion();
    42     42   
    43     43   /*
    44     44   ** Each open sqlite database is represented by an instance of the
    45     45   ** following opaque structure.
    46     46   */
    47         -typedef struct sqlite sqlite3;
           47  +typedef struct sqlite3 sqlite3;
    48     48   
    49     49   
    50     50   /*
    51     51   ** Some compilers do not support the "long long" datatype.  So we have
    52     52   ** to do a typedef that for 64-bit integers that depends on what compiler
    53     53   ** is being used.
    54     54   */

Changes to src/sqliteInt.h.

     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   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.318 2004/09/01 03:06:35 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.319 2004/09/06 17:24:13 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   #include "config.h"
    20     20   #include "sqlite3.h"
    21     21   #include "hash.h"
................................................................................
   139    139   ** Macros to determine whether the machine is big or little endian,
   140    140   ** evaluated at runtime.
   141    141   */
   142    142   extern const int sqlite3one;
   143    143   #define SQLITE_BIGENDIAN    (*(char *)(&sqlite3one)==0)
   144    144   #define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
   145    145   
   146         -typedef struct sqlite sqlite;
   147         -
   148    146   /*
   149    147   ** An instance of the following structure is used to store the busy-handler
   150    148   ** callback for a given sqlite handle. 
   151    149   **
   152    150   ** The sqlite.busyHandler member of the sqlite struct contains the busy
   153    151   ** callback for the database handle. Each pager opened via the sqlite
   154    152   ** handle is passed a pointer to sqlite.busyHandler. The busy-handler
................................................................................
   343    341   ** the last statement) and is used to update sqlite_lsChange.
   344    342   **
   345    343   ** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16
   346    344   ** store the most recent error code and, if applicable, string. The
   347    345   ** internal function sqlite3Error() is used to set these variables
   348    346   ** consistently.
   349    347   */
   350         -struct sqlite {
          348  +struct sqlite3 {
   351    349     int nDb;                      /* Number of backends currently in use */
   352    350     Db *aDb;                      /* All backends */
   353    351     Db aDbStatic[2];              /* Static space for the 2 default backends */
   354    352     int flags;                    /* Miscellanous flags. See below */
   355    353     u8 file_format;               /* What file format version is this database? */
   356    354     u8 temp_store;                /* 1: file 2: memory 0: default */
   357    355     int nTable;                   /* Number of tables in the database */
................................................................................
   966    964   
   967    965   /*
   968    966   ** An SQL parser context.  A copy of this structure is passed through
   969    967   ** the parser and down into all the parser action routine in order to
   970    968   ** carry around information that is global to the entire parse.
   971    969   */
   972    970   struct Parse {
   973         -  sqlite *db;          /* The main database structure */
          971  +  sqlite3 *db;         /* The main database structure */
   974    972     int rc;              /* Return code from execution */
   975    973     char *zErrMsg;       /* An error message */
   976    974     Token sErrToken;     /* The token at which the error occurred */
   977    975     Token sNameToken;    /* Token with unqualified schema object name */
   978    976     Token sLastToken;    /* The last token parsed */
   979    977     const char *zSql;    /* All SQL text */
   980    978     const char *zTail;   /* All SQL text past the last semicolon parsed */
................................................................................
  1018   1016   #define OPFLAG_LASTROWID 2    /* Set to update db->lastRowid */
  1019   1017   
  1020   1018   /*
  1021   1019    * Each trigger present in the database schema is stored as an instance of
  1022   1020    * struct Trigger. 
  1023   1021    *
  1024   1022    * Pointers to instances of struct Trigger are stored in two ways.
  1025         - * 1. In the "trigHash" hash table (part of the sqlite* that represents the 
         1023  + * 1. In the "trigHash" hash table (part of the sqlite3* that represents the 
  1026   1024    *    database). This allows Trigger structures to be retrieved by name.
  1027   1025    * 2. All triggers associated with a single table form a linked list, using the
  1028   1026    *    pNext member of struct Trigger. A pointer to the first element of the
  1029   1027    *    linked list is stored as the "pTrigger" member of the associated
  1030   1028    *    struct Table.
  1031   1029    *
  1032   1030    * The "step_list" member points to the first element of a linked list
................................................................................
  1154   1152   };
  1155   1153   
  1156   1154   /*
  1157   1155   ** A pointer to this structure is used to communicate information
  1158   1156   ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
  1159   1157   */
  1160   1158   typedef struct {
  1161         -  sqlite *db;         /* The database being initialized */
         1159  +  sqlite3 *db;        /* The database being initialized */
  1162   1160     char **pzErrMsg;    /* Error message stored here */
  1163   1161   } InitData;
  1164   1162   
  1165   1163   
  1166   1164   /*
  1167   1165    * This global flag is set for performance testing of triggers. When it is set
  1168   1166    * SQLite will perform the overhead of building new and old trigger references 
................................................................................
  1210   1208   Expr *sqlite3Expr(int, Expr*, Expr*, Token*);
  1211   1209   Expr *sqlite3ExprAnd(Expr*, Expr*);
  1212   1210   void sqlite3ExprSpan(Expr*,Token*,Token*);
  1213   1211   Expr *sqlite3ExprFunction(ExprList*, Token*);
  1214   1212   void sqlite3ExprDelete(Expr*);
  1215   1213   ExprList *sqlite3ExprListAppend(ExprList*,Expr*,Token*);
  1216   1214   void sqlite3ExprListDelete(ExprList*);
  1217         -int sqlite3Init(sqlite*, char**);
         1215  +int sqlite3Init(sqlite3*, char**);
  1218   1216   int sqlite3InitCallback(void*, int, char**, char**);
  1219   1217   void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
  1220         -void sqlite3ResetInternalSchema(sqlite*, int);
         1218  +void sqlite3ResetInternalSchema(sqlite3*, int);
  1221   1219   void sqlite3BeginParse(Parse*,int);
  1222         -void sqlite3RollbackInternalChanges(sqlite*);
  1223         -void sqlite3CommitInternalChanges(sqlite*);
         1220  +void sqlite3RollbackInternalChanges(sqlite3*);
         1221  +void sqlite3CommitInternalChanges(sqlite3*);
  1224   1222   Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*);
  1225   1223   void sqlite3OpenMasterTable(Vdbe *v, int);
  1226   1224   void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int);
  1227   1225   void sqlite3AddColumn(Parse*,Token*);
  1228   1226   void sqlite3AddNotNull(Parse*, int);
  1229   1227   void sqlite3AddPrimaryKey(Parse*, ExprList*, int);
  1230   1228   void sqlite3AddColumnType(Parse*,Token*,Token*);
  1231   1229   void sqlite3AddDefaultValue(Parse*,Token*,int);
  1232   1230   void sqlite3AddCollateType(Parse*, const char*, int);
  1233   1231   void sqlite3EndTable(Parse*,Token*,Select*);
  1234   1232   void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int);
  1235   1233   int sqlite3ViewGetColumnNames(Parse*,Table*);
  1236   1234   void sqlite3DropTable(Parse*, SrcList*, int);
  1237         -void sqlite3DeleteTable(sqlite*, Table*);
         1235  +void sqlite3DeleteTable(sqlite3*, Table*);
  1238   1236   void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);
  1239   1237   IdList *sqlite3IdListAppend(IdList*, Token*);
  1240   1238   int sqlite3IdListIndex(IdList*,const char*);
  1241   1239   SrcList *sqlite3SrcListAppend(SrcList*, Token*, Token*);
  1242   1240   void sqlite3SrcListAddAlias(SrcList*, Token*);
  1243   1241   void sqlite3SrcListAssignCursors(Parse*, SrcList*);
  1244   1242   void sqlite3IdListDelete(IdList*);
................................................................................
  1259   1257   void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
  1260   1258   WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, int, ExprList**);
  1261   1259   void sqlite3WhereEnd(WhereInfo*);
  1262   1260   void sqlite3ExprCode(Parse*, Expr*);
  1263   1261   int sqlite3ExprCodeExprList(Parse*, ExprList*);
  1264   1262   void sqlite3ExprIfTrue(Parse*, Expr*, int, int);
  1265   1263   void sqlite3ExprIfFalse(Parse*, Expr*, int, int);
  1266         -Table *sqlite3FindTable(sqlite*,const char*, const char*);
         1264  +Table *sqlite3FindTable(sqlite3*,const char*, const char*);
  1267   1265   Table *sqlite3LocateTable(Parse*,const char*, const char*);
  1268         -Index *sqlite3FindIndex(sqlite*,const char*, const char*);
  1269         -void sqlite3UnlinkAndDeleteTable(sqlite*,int,const char*);
  1270         -void sqlite3UnlinkAndDeleteIndex(sqlite*,int,const char*);
  1271         -void sqlite3UnlinkAndDeleteTrigger(sqlite*,int,const char*);
         1266  +Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
         1267  +void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
         1268  +void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
         1269  +void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
  1272   1270   void sqlite3Vacuum(Parse*, Token*);
  1273         -int sqlite3RunVacuum(char**, sqlite*);
         1271  +int sqlite3RunVacuum(char**, sqlite3*);
  1274   1272   char *sqlite3NameFromToken(Token*);
  1275   1273   int sqlite3ExprCheck(Parse*, Expr*, int, int*);
  1276   1274   int sqlite3ExprCompare(Expr*, Expr*);
  1277   1275   int sqliteFuncId(Token*);
  1278   1276   int sqlite3ExprResolveIds(Parse*, SrcList*, ExprList*, Expr*);
  1279   1277   int sqlite3ExprResolveAndCheck(Parse*,SrcList*,ExprList*,Expr*,int,int*);
  1280   1278   int sqlite3ExprAnalyzeAggregates(Parse*, Expr*);
  1281   1279   Vdbe *sqlite3GetVdbe(Parse*);
  1282   1280   void sqlite3Randomness(int, void*);
  1283         -void sqlite3RollbackAll(sqlite*);
         1281  +void sqlite3RollbackAll(sqlite3*);
  1284   1282   void sqlite3CodeVerifySchema(Parse*, int);
  1285   1283   void sqlite3BeginTransaction(Parse*);
  1286   1284   void sqlite3CommitTransaction(Parse*);
  1287   1285   void sqlite3RollbackTransaction(Parse*);
  1288   1286   int sqlite3ExprIsConstant(Expr*);
  1289   1287   int sqlite3ExprIsInteger(Expr*, int*);
  1290   1288   int sqlite3IsRowid(const char*);
  1291         -void sqlite3GenerateRowDelete(sqlite*, Vdbe*, Table*, int, int);
  1292         -void sqlite3GenerateRowIndexDelete(sqlite*, Vdbe*, Table*, int, char*);
         1289  +void sqlite3GenerateRowDelete(sqlite3*, Vdbe*, Table*, int, int);
         1290  +void sqlite3GenerateRowIndexDelete(sqlite3*, Vdbe*, Table*, int, char*);
  1293   1291   void sqlite3GenerateIndexKey(Vdbe*, Index*, int);
  1294   1292   void sqlite3GenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int);
  1295   1293   void sqlite3CompleteInsertion(Parse*, Table*, int, char*, int, int, int);
  1296   1294   void sqlite3OpenTableAndIndices(Parse*, Table*, int, int);
  1297   1295   void sqlite3BeginWriteOperation(Parse*, int, int);
  1298   1296   void sqlite3EndWriteOperation(Parse*);
  1299   1297   Expr *sqlite3ExprDup(Expr*);
  1300   1298   void sqlite3TokenCopy(Token*, Token*);
  1301   1299   ExprList *sqlite3ExprListDup(ExprList*);
  1302   1300   SrcList *sqlite3SrcListDup(SrcList*);
  1303   1301   IdList *sqlite3IdListDup(IdList*);
  1304   1302   Select *sqlite3SelectDup(Select*);
  1305         -FuncDef *sqlite3FindFunction(sqlite*,const char*,int,int,u8,int);
  1306         -void sqlite3RegisterBuiltinFunctions(sqlite*);
  1307         -void sqlite3RegisterDateTimeFunctions(sqlite*);
  1308         -int sqlite3SafetyOn(sqlite*);
  1309         -int sqlite3SafetyOff(sqlite*);
  1310         -int sqlite3SafetyCheck(sqlite*);
  1311         -void sqlite3ChangeCookie(sqlite*, Vdbe*, int);
         1303  +FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,int,u8,int);
         1304  +void sqlite3RegisterBuiltinFunctions(sqlite3*);
         1305  +void sqlite3RegisterDateTimeFunctions(sqlite3*);
         1306  +int sqlite3SafetyOn(sqlite3*);
         1307  +int sqlite3SafetyOff(sqlite3*);
         1308  +int sqlite3SafetyCheck(sqlite3*);
         1309  +void sqlite3ChangeCookie(sqlite3*, Vdbe*, int);
  1312   1310   void sqlite3BeginTrigger(Parse*, Token*,Token*,int,int,IdList*,SrcList*,
  1313   1311                            int,Expr*,int);
  1314   1312   void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*);
  1315   1313   void sqlite3DropTrigger(Parse*, SrcList*);
  1316   1314   void sqlite3DropTriggerPtr(Parse*, Trigger*, int);
  1317   1315   int sqlite3TriggersExist(Parse* , Trigger* , int , int , int, ExprList*);
  1318   1316   int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, 
................................................................................
  1336   1334   # define sqlite3AuthRead(a,b,c)
  1337   1335   # define sqlite3AuthCheck(a,b,c,d,e)    SQLITE_OK
  1338   1336   # define sqlite3AuthContextPush(a,b,c)
  1339   1337   # define sqlite3AuthContextPop(a)  ((void)(a))
  1340   1338   #endif
  1341   1339   void sqlite3Attach(Parse*, Token*, Token*, int, Token*);
  1342   1340   void sqlite3Detach(Parse*, Token*);
  1343         -int sqlite3BtreeFactory(const sqlite *db, const char *zFilename,
         1341  +int sqlite3BtreeFactory(const sqlite3 *db, const char *zFilename,
  1344   1342                          int omitJournal, int nCache, Btree **ppBtree);
  1345   1343   int sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Token*);
  1346   1344   int sqlite3FixSrcList(DbFixer*, SrcList*);
  1347   1345   int sqlite3FixSelect(DbFixer*, Select*);
  1348   1346   int sqlite3FixExpr(DbFixer*, Expr*);
  1349   1347   int sqlite3FixExprList(DbFixer*, ExprList*);
  1350   1348   int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
................................................................................
  1363   1361   void sqlite3IndexAffinityStr(Vdbe *, Index *);
  1364   1362   void sqlite3TableAffinityStr(Vdbe *, Table *);
  1365   1363   char sqlite3CompareAffinity(Expr *pExpr, char aff2);
  1366   1364   char const *sqlite3AffinityString(char affinity);
  1367   1365   int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity);
  1368   1366   char sqlite3ExprAffinity(Expr *pExpr);
  1369   1367   int sqlite3atoi64(const char*, i64*);
  1370         -void sqlite3Error(sqlite *, int, const char*,...);
         1368  +void sqlite3Error(sqlite3*, int, const char*,...);
  1371   1369   void *sqlite3HexToBlob(const char *z);
  1372   1370   int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
  1373   1371   const char *sqlite3ErrStr(int);
  1374   1372   int sqlite3ReadUniChar(const char *zStr, int *pOffset, u8 *pEnc, int fold);
  1375   1373   int sqlite3ReadSchema(Parse *pParse);
  1376         -CollSeq *sqlite3FindCollSeq(sqlite *,u8 enc, const char *,int,int);
         1374  +CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char *,int,int);
  1377   1375   CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName, int nName);
  1378   1376   CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
  1379   1377   int sqlite3CheckCollSeq(Parse *, CollSeq *);
  1380   1378   int sqlite3CheckIndexCollSeq(Parse *, Index *);
  1381   1379   int sqlite3CheckObjectName(Parse *, const char *);
  1382   1380   void sqlite3VdbeSetChanges(sqlite3 *, int);
  1383   1381   void sqlite3utf16Substr(sqlite3_context *,int,sqlite3_value **);
  1384   1382   
  1385   1383   const void *sqlite3ValueText(sqlite3_value*, u8);
  1386   1384   int sqlite3ValueBytes(sqlite3_value*, u8);
  1387   1385   void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, void(*)(void*));
  1388   1386   void sqlite3ValueFree(sqlite3_value*);
  1389   1387   sqlite3_value *sqlite3ValueNew();
  1390         -sqlite3_value *sqlite3GetTransientValue(sqlite *db);
         1388  +sqlite3_value *sqlite3GetTransientValue(sqlite3*db);
  1391   1389   extern const unsigned char sqlite3UpperToLower[];
  1392   1390   
  1393   1391   #endif

Changes to src/table.c.

   114    114   **
   115    115   ** The result that is written to ***pazResult is held in memory obtained
   116    116   ** from malloc().  But the caller cannot free this memory directly.  
   117    117   ** Instead, the entire table should be passed to sqlite3_free_table() when
   118    118   ** the calling procedure is finished using it.
   119    119   */
   120    120   int sqlite3_get_table(
   121         -  sqlite *db,                 /* The database on which the SQL executes */
          121  +  sqlite3 *db,                /* The database on which the SQL executes */
   122    122     const char *zSql,           /* The SQL to be executed */
   123    123     char ***pazResult,          /* Write the result table here */
   124    124     int *pnRow,                 /* Write the number of rows in the result here */
   125    125     int *pnColumn,              /* Write the number of columns of result here */
   126    126     char **pzErrMsg             /* Write error messages here */
   127    127   ){
   128    128     int rc;

Changes to src/tclsqlite.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   ** A TCL Interface to SQLite
    13     13   **
    14         -** $Id: tclsqlite.c,v 1.103 2004/08/26 00:56:05 drh Exp $
           14  +** $Id: tclsqlite.c,v 1.104 2004/09/06 17:24:13 drh Exp $
    15     15   */
    16     16   #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "hash.h"
    20     20   #include "tcl.h"
    21     21   #include <stdlib.h>
................................................................................
   201    201       return 1;
   202    202     }
   203    203     return 0;
   204    204   }
   205    205   
   206    206   static void tclCollateNeeded(
   207    207     void *pCtx,
   208         -  sqlite *db,
          208  +  sqlite3 *db,
   209    209     int enc,
   210    210     const char *zName
   211    211   ){
   212    212     SqliteDb *pDb = (SqliteDb *)pCtx;
   213    213     Tcl_Obj *pScript = Tcl_DuplicateObj(pDb->pCollateNeeded);
   214    214     Tcl_IncrRefCount(pScript);
   215    215     Tcl_ListObjAppendElement(0, pScript, Tcl_NewStringObj(zName, -1));
................................................................................
   363    363   
   364    364   /*
   365    365   ** The "sqlite" command below creates a new Tcl command for each
   366    366   ** connection it opens to an SQLite database.  This routine is invoked
   367    367   ** whenever one of those connection-specific commands is executed
   368    368   ** in Tcl.  For example, if you run Tcl code like this:
   369    369   **
   370         -**       sqlite db1  "my_database"
          370  +**       sqlite3 db1  "my_database"
   371    371   **       db1 close
   372    372   **
   373    373   ** The first command opens a connection to the "my_database" database
   374    374   ** and calls that connection "db1".  The second command causes this
   375    375   ** subroutine to be invoked.
   376    376   */
   377    377   static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
................................................................................
  1069   1069     }
  1070   1070   
  1071   1071     } /* End of the SWITCH statement */
  1072   1072     return rc;
  1073   1073   }
  1074   1074   
  1075   1075   /*
  1076         -**   sqlite DBNAME FILENAME ?MODE? ?-key KEY?
         1076  +**   sqlite3 DBNAME FILENAME ?MODE? ?-key KEY?
  1077   1077   **
  1078   1078   ** This is the main Tcl command.  When the "sqlite" Tcl command is
  1079   1079   ** invoked, this routine runs to process that command.
  1080   1080   **
  1081   1081   ** The first argument, DBNAME, is an arbitrary name for a new
  1082   1082   ** database connection.  This command creates a new command named
  1083   1083   ** DBNAME that is used to control that connection.  The database
................................................................................
  1084   1084   ** connection is deleted when the DBNAME command is deleted.
  1085   1085   **
  1086   1086   ** The second argument is the name of the directory that contains
  1087   1087   ** the sqlite database that is to be accessed.
  1088   1088   **
  1089   1089   ** For testing purposes, we also support the following:
  1090   1090   **
  1091         -**  sqlite -encoding
         1091  +**  sqlite3 -encoding
  1092   1092   **
  1093   1093   **       Return the encoding used by LIKE and GLOB operators.  Choices
  1094   1094   **       are UTF-8 and iso8859.
  1095   1095   **
  1096         -**  sqlite -version
         1096  +**  sqlite3 -version
  1097   1097   **
  1098   1098   **       Return the version number of the SQLite library.
  1099   1099   **
  1100         -**  sqlite -tcl-uses-utf
         1100  +**  sqlite3 -tcl-uses-utf
  1101   1101   **
  1102   1102   **       Return "1" if compiled with a Tcl uses UTF-8.  Return "0" if
  1103   1103   **       not.  Used by tests to make sure the library was compiled 
  1104   1104   **       correctly.
  1105   1105   */
  1106   1106   static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
  1107   1107     SqliteDb *p;
................................................................................
  1186   1186     Tcl_AppendResult(interp, zBuf, 0);
  1187   1187   
  1188   1188     /* If compiled with SQLITE_TEST turned on, then register the "md5sum"
  1189   1189     ** SQL function.
  1190   1190     */
  1191   1191   #ifdef SQLITE_TEST
  1192   1192     {
  1193         -    extern void Md5_Register(sqlite*);
         1193  +    extern void Md5_Register(sqlite3*);
  1194   1194   #ifdef SQLITE_DEBUG
  1195   1195       int mallocfail = sqlite3_iMallocFail;
  1196   1196       sqlite3_iMallocFail = 0;
  1197   1197   #endif
  1198   1198       Md5_Register(p->db);
  1199   1199   #ifdef SQLITE_DEBUG
  1200   1200       sqlite3_iMallocFail = mallocfail;

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.100 2004/08/29 23:42:14 drh Exp $
           16  +** $Id: test1.c,v 1.101 2004/09/06 17:24:13 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   
................................................................................
    61     61       case SQLITE_NOTADB:     zName = "SQLITE_NOTADB";        break;
    62     62       default:                zName = "SQLITE_Unknown";     break;
    63     63     }
    64     64     return zName;
    65     65   }
    66     66   
    67     67   /*
    68         -** Decode a pointer to an sqlite object.
           68  +** Decode a pointer to an sqlite3 object.
    69     69   */
    70         -static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite **ppDb){
           70  +static int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb){
    71     71     if( sscanf(zA, PTR_FMT, (void**)ppDb)!=1 && 
    72     72         (zA[0]!='0' || zA[1]!='x' || sscanf(&zA[2], PTR_FMT, (void**)ppDb)!=1)
    73     73     ){
    74     74       Tcl_AppendResult(interp, "\"", zA, "\" is not a valid pointer value", 0);
    75     75       return TCL_ERROR;
    76     76     }
    77     77     return TCL_OK;
................................................................................
   164    164   */
   165    165   static int test_exec_printf(
   166    166     void *NotUsed,
   167    167     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   168    168     int argc,              /* Number of arguments */
   169    169     char **argv            /* Text of each argument */
   170    170   ){
   171         -  sqlite *db;
          171  +  sqlite3 *db;
   172    172     Tcl_DString str;
   173    173     int rc;
   174    174     char *zErr = 0;
   175    175     char *zSql;
   176    176     char zBuf[30];
   177    177     if( argc!=4 ){
   178    178       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
................................................................................
   225    225   */
   226    226   static int test_get_table_printf(
   227    227     void *NotUsed,
   228    228     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   229    229     int argc,              /* Number of arguments */
   230    230     char **argv            /* Text of each argument */
   231    231   ){
   232         -  sqlite *db;
          232  +  sqlite3 *db;
   233    233     Tcl_DString str;
   234    234     int rc;
   235    235     char *zErr = 0;
   236    236     int nRow, nCol;
   237    237     char **aResult;
   238    238     int i;
   239    239     char zBuf[30];
................................................................................
   274    274   */
   275    275   static int test_last_rowid(
   276    276     void *NotUsed,
   277    277     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   278    278     int argc,              /* Number of arguments */
   279    279     char **argv            /* Text of each argument */
   280    280   ){
   281         -  sqlite *db;
          281  +  sqlite3 *db;
   282    282     char zBuf[30];
   283    283   
   284    284     if( argc!=2 ){
   285    285       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0);
   286    286       return TCL_ERROR;
   287    287     }
   288    288     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
................................................................................
   298    298   */
   299    299   static int test_key(
   300    300     void *NotUsed,
   301    301     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   302    302     int argc,              /* Number of arguments */
   303    303     char **argv            /* Text of each argument */
   304    304   ){
   305         -  sqlite *db;
          305  +  sqlite3 *db;
   306    306     const char *zKey;
   307    307     int nKey;
   308    308     if( argc!=3 ){
   309    309       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   310    310          " FILENAME\"", 0);
   311    311       return TCL_ERROR;
   312    312     }
................................................................................
   326    326   */
   327    327   static int test_rekey(
   328    328     void *NotUsed,
   329    329     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   330    330     int argc,              /* Number of arguments */
   331    331     char **argv            /* Text of each argument */
   332    332   ){
   333         -  sqlite *db;
          333  +  sqlite3 *db;
   334    334     const char *zKey;
   335    335     int nKey;
   336    336     if( argc!=3 ){
   337    337       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   338    338          " FILENAME\"", 0);
   339    339       return TCL_ERROR;
   340    340     }
................................................................................
   354    354   */
   355    355   static int sqlite_test_close(
   356    356     void *NotUsed,
   357    357     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   358    358     int argc,              /* Number of arguments */
   359    359     char **argv            /* Text of each argument */
   360    360   ){
   361         -  sqlite *db;
          361  +  sqlite3 *db;
   362    362     int rc;
   363    363     if( argc!=2 ){
   364    364       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   365    365          " FILENAME\"", 0);
   366    366       return TCL_ERROR;
   367    367     }
   368    368     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
................................................................................
   448    448   static void sqlite3ExecFunc(
   449    449     sqlite3_context *context, 
   450    450     int argc,  
   451    451     sqlite3_value **argv
   452    452   ){
   453    453     struct dstr x;
   454    454     memset(&x, 0, sizeof(x));
   455         -  sqlite3_exec((sqlite*)sqlite3_user_data(context),
          455  +  sqlite3_exec((sqlite3*)sqlite3_user_data(context),
   456    456         sqlite3_value_text(argv[0]),
   457    457         execFuncCallback, &x, 0);
   458    458     sqlite3_result_text(context, x.z, x.nUsed, SQLITE_TRANSIENT);
   459    459     sqliteFree(x.z);
   460    460   }
   461    461   
   462    462   /*
................................................................................
   476    476   */
   477    477   static int test_create_function(
   478    478     void *NotUsed,
   479    479     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   480    480     int argc,              /* Number of arguments */
   481    481     char **argv            /* Text of each argument */
   482    482   ){
   483         -  sqlite *db;
          483  +  sqlite3 *db;
   484    484     sqlite3_value *pVal;
   485         -  extern void Md5_Register(sqlite*);
          485  +  extern void Md5_Register(sqlite3*);
   486    486   
   487    487     if( argc!=2 ){
   488    488       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   489    489          " FILENAME\"", 0);
   490    490       return TCL_ERROR;
   491    491     }
   492    492     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
................................................................................
   536    536   */
   537    537   static int test_create_aggregate(
   538    538     void *NotUsed,
   539    539     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   540    540     int argc,              /* Number of arguments */
   541    541     char **argv            /* Text of each argument */
   542    542   ){
   543         -  sqlite *db;
          543  +  sqlite3 *db;
   544    544     if( argc!=2 ){
   545    545       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   546    546          " FILENAME\"", 0);
   547    547       return TCL_ERROR;
   548    548     }
   549    549     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
   550    550     sqlite3_create_function(db, "x_count", 0, SQLITE_UTF8, 0, 0,
................................................................................
   842    842   */
   843    843   static int test_register_func(
   844    844     void *NotUsed,
   845    845     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   846    846     int argc,              /* Number of arguments */
   847    847     char **argv            /* Text of each argument */
   848    848   ){
   849         -  sqlite *db;
          849  +  sqlite3 *db;
   850    850     int rc;
   851    851     if( argc!=3 ){
   852    852       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 
   853    853          " DB FUNCTION-NAME", 0);
   854    854       return TCL_ERROR;
   855    855     }
   856    856     if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
................................................................................
  1677   1677   */
  1678   1678   static int test_errmsg(
  1679   1679     void * clientData,
  1680   1680     Tcl_Interp *interp,
  1681   1681     int objc,
  1682   1682     Tcl_Obj *CONST objv[]
  1683   1683   ){
  1684         -  sqlite *db;
         1684  +  sqlite3 *db;
  1685   1685     const char *zErr;
  1686   1686   
  1687   1687     if( objc!=2 ){
  1688   1688       Tcl_AppendResult(interp, "wrong # args: should be \"", 
  1689   1689          Tcl_GetString(objv[0]), " DB", 0);
  1690   1690       return TCL_ERROR;
  1691   1691     }
................................................................................
  1706   1706   */
  1707   1707   static int test_errmsg16(
  1708   1708     void * clientData,
  1709   1709     Tcl_Interp *interp,
  1710   1710     int objc,
  1711   1711     Tcl_Obj *CONST objv[]
  1712   1712   ){
  1713         -  sqlite *db;
         1713  +  sqlite3 *db;
  1714   1714     const void *zErr;
  1715   1715     int bytes;
  1716   1716   
  1717   1717     if( objc!=2 ){
  1718   1718       Tcl_AppendResult(interp, "wrong # args: should be \"", 
  1719   1719          Tcl_GetString(objv[0]), " DB", 0);
  1720   1720       return TCL_ERROR;

Changes to src/test4.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   ** Code for testing the the SQLite library in a multithreaded environment.
    13     13   **
    14         -** $Id: test4.c,v 1.11 2004/08/08 20:22:18 drh Exp $
           14  +** $Id: test4.c,v 1.12 2004/09/06 17:24:13 drh Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include "tcl.h"
    18     18   #include "os.h"
    19     19   #if defined(OS_UNIX) && OS_UNIX==1 && defined(THREADSAFE) && THREADSAFE==1
    20     20   #include <stdlib.h>
    21     21   #include <string.h>
................................................................................
    36     36     char *zArg;            /* argument usable by xOp */
    37     37     int opnum;             /* Operation number */
    38     38     int busy;              /* True if this thread is in use */
    39     39   
    40     40     /* The next group of fields are writable by the thread but read-only to the
    41     41     ** master. */
    42     42     int completed;        /* Number of operations completed */
    43         -  sqlite *db;           /* Open database */
           43  +  sqlite3 *db;           /* Open database */
    44     44     sqlite3_stmt *pStmt;     /* Pending operation */
    45     45     char *zErr;           /* operation error */
    46     46     char *zStaticErr;     /* Static error message */
    47     47     int rc;               /* operation return code */
    48     48     int argc;             /* number of columns in result */
    49     49     const char *argv[100];    /* result columns */
    50     50     const char *colv[100];    /* result column names */
................................................................................
   587    587   static int tcl_thread_swap(
   588    588     void *NotUsed,
   589    589     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
   590    590     int argc,              /* Number of arguments */
   591    591     const char **argv      /* Text of each argument */
   592    592   ){
   593    593     int i, j;
   594         -  sqlite *temp;
          594  +  sqlite3 *temp;
   595    595     if( argc!=3 ){
   596    596       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   597    597          " ID1 ID2", 0);
   598    598       return TCL_ERROR;
   599    599     }
   600    600     i = parse_thread_id(interp, argv[1]);
   601    601     if( i<0 ) return TCL_ERROR;

Changes to src/tokenize.c.

    11     11   *************************************************************************
    12     12   ** An tokenizer for SQL
    13     13   **
    14     14   ** This file contains C code that splits an SQL input string up into
    15     15   ** individual tokens and sends those tokens one-by-one over to the
    16     16   ** parser for analysis.
    17     17   **
    18         -** $Id: tokenize.c,v 1.84 2004/08/25 04:07:02 drh Exp $
           18  +** $Id: tokenize.c,v 1.85 2004/09/06 17:24:13 drh Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   
    25     25   /*
................................................................................
   457    457   */
   458    458   int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
   459    459     int nErr = 0;
   460    460     int i;
   461    461     void *pEngine;
   462    462     int tokenType;
   463    463     int lastTokenParsed = -1;
   464         -  sqlite *db = pParse->db;
          464  +  sqlite3 *db = pParse->db;
   465    465     extern void *sqlite3ParserAlloc(void*(*)(int));
   466    466     extern void sqlite3ParserFree(void*, void(*)(void*));
   467    467     extern int sqlite3Parser(void*, int, Token, Parse*);
   468    468   
   469    469     db->flags &= ~SQLITE_Interrupt;
   470    470     pParse->rc = SQLITE_OK;
   471    471     i = 0;

Changes to src/trigger.c.

    49     49     int foreach,        /* One of TK_ROW or TK_STATEMENT */
    50     50     Expr *pWhen,        /* WHEN clause */
    51     51     int isTemp          /* True if the TEMPORARY keyword is present */
    52     52   ){
    53     53     Trigger *pTrigger;
    54     54     Table *pTab;
    55     55     char *zName = 0;        /* Name of the trigger */
    56         -  sqlite *db = pParse->db;
           56  +  sqlite3 *db = pParse->db;
    57     57     int iDb;                /* The database to store the trigger in */
    58     58     Token *pName;           /* The unqualified db name */
    59     59     DbFixer sFix;
    60     60   
    61     61     if( isTemp ){
    62     62       /* If TEMP was specified, then the trigger name may not be qualified. */
    63     63       if( pName2 && pName2->n>0 ){
................................................................................
   187    187   */
   188    188   void sqlite3FinishTrigger(
   189    189     Parse *pParse,          /* Parser context */
   190    190     TriggerStep *pStepList, /* The triggered program */
   191    191     Token *pAll             /* Token that describes the complete CREATE TRIGGER */
   192    192   ){
   193    193     Trigger *nt = 0;          /* The trigger whose construction is finishing up */
   194         -  sqlite *db = pParse->db;  /* The database */
          194  +  sqlite3 *db = pParse->db;  /* The database */
   195    195     DbFixer sFix;
   196    196   
   197    197     if( pParse->nErr || pParse->pNewTrigger==0 ) goto triggerfinish_cleanup;
   198    198     nt = pParse->pNewTrigger;
   199    199     pParse->pNewTrigger = 0;
   200    200     nt->step_list = pStepList;
   201    201     while( pStepList ){
................................................................................
   415    415   **/
   416    416   void sqlite3DropTrigger(Parse *pParse, SrcList *pName){
   417    417     Trigger *pTrigger = 0;
   418    418     int i;
   419    419     const char *zDb;
   420    420     const char *zName;
   421    421     int nName;
   422         -  sqlite *db = pParse->db;
          422  +  sqlite3 *db = pParse->db;
   423    423   
   424    424     if( sqlite3_malloc_failed ) goto drop_trigger_cleanup;
   425    425     if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
   426    426       goto drop_trigger_cleanup;
   427    427     }
   428    428   
   429    429     assert( pName->nSrc==1 );
................................................................................
   459    459   ** Drop a trigger given a pointer to that trigger.  If nested is false,
   460    460   ** then also generate code to remove the trigger from the SQLITE_MASTER
   461    461   ** table.
   462    462   */
   463    463   void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger, int nested){
   464    464     Table   *pTable;
   465    465     Vdbe *v;
   466         -  sqlite *db = pParse->db;
          466  +  sqlite3 *db = pParse->db;
   467    467     int iDb;
   468    468   
   469    469     iDb = pTrigger->iDb;
   470    470     assert( iDb>=0 && iDb<db->nDb );
   471    471     pTable = tableOfTrigger(db, pTrigger);
   472    472     assert(pTable);
   473    473     assert( pTable->iDb==iDb || iDb==1 );

Changes to src/update.c.

     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 C code routines that are called by the parser
    13     13   ** to handle UPDATE statements.
    14     14   **
    15         -** $Id: update.c,v 1.87 2004/08/31 13:45:12 drh Exp $
           15  +** $Id: update.c,v 1.88 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Process an UPDATE statement.
    21     21   **
    22     22   **   UPDATE OR IGNORE table_wxyz SET a=b, c=d WHERE e<5 AND f NOT NULL;
................................................................................
    35     35     int addr = 0;          /* VDBE instruction address of the start of the loop */
    36     36     WhereInfo *pWInfo;     /* Information about the WHERE clause */
    37     37     Vdbe *v;               /* The virtual database engine */
    38     38     Index *pIdx;           /* For looping over indices */
    39     39     int nIdx;              /* Number of indices that need updating */
    40     40     int nIdxTotal;         /* Total number of indices */
    41     41     int iCur;              /* VDBE Cursor number of pTab */
    42         -  sqlite *db;            /* The database structure */
           42  +  sqlite3 *db;           /* The database structure */
    43     43     Index **apIdx = 0;     /* An array of indices that need updating too */
    44     44     char *aIdxUsed = 0;    /* aIdxUsed[i]==1 if the i-th index is used */
    45     45     int *aXRef = 0;        /* aXRef[i] is the index in pChanges->a[] of the
    46     46                            ** an expression for the i-th column of the table.
    47     47                            ** aXRef[i]==-1 if the i-th column is not changed. */
    48     48     int chngRecno;         /* True if the record number is being changed */
    49     49     Expr *pRecnoExpr = 0;  /* Expression defining the new record number */

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.115 2004/09/05 23:23:42 drh Exp $
           17  +** $Id: util.c,v 1.116 2004/09/06 17:24:13 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   #if SQLITE_DEBUG>2 && defined(__GLIBC__)
    24     24   #include <execinfo.h>
................................................................................
   448    448   ** zFormat and any string tokens that follow it are assumed to be
   449    449   ** encoded in UTF-8.
   450    450   **
   451    451   ** To clear the most recent error for slqite handle "db", sqlite3Error
   452    452   ** should be called with err_code set to SQLITE_OK and zFormat set
   453    453   ** to NULL.
   454    454   */
   455         -void sqlite3Error(sqlite *db, int err_code, const char *zFormat, ...){
          455  +void sqlite3Error(sqlite3 *db, int err_code, const char *zFormat, ...){
   456    456     if( db && (db->pErr || (db->pErr = sqlite3ValueNew())) ){
   457    457       db->errCode = err_code;
   458    458       if( zFormat ){
   459    459         char *z;
   460    460         va_list ap;
   461    461         va_start(ap, zFormat);
   462    462         z = sqlite3VMPrintf(zFormat, ap);
................................................................................
   778    778   **
   779    779   ** Ticket #202:  If db->magic is not a valid open value, take care not
   780    780   ** to modify the db structure at all.  It could be that db is a stale
   781    781   ** pointer.  In other words, it could be that there has been a prior
   782    782   ** call to sqlite3_close(db) and db has been deallocated.  And we do
   783    783   ** not want to write into deallocated memory.
   784    784   */
   785         -int sqlite3SafetyOn(sqlite *db){
          785  +int sqlite3SafetyOn(sqlite3 *db){
   786    786     if( db->magic==SQLITE_MAGIC_OPEN ){
   787    787       db->magic = SQLITE_MAGIC_BUSY;
   788    788       return 0;
   789    789     }else if( db->magic==SQLITE_MAGIC_BUSY || db->magic==SQLITE_MAGIC_ERROR ){
   790    790       db->magic = SQLITE_MAGIC_ERROR;
   791    791       db->flags |= SQLITE_Interrupt;
   792    792     }
................................................................................
   794    794   }
   795    795   
   796    796   /*
   797    797   ** Change the magic from SQLITE_MAGIC_BUSY to SQLITE_MAGIC_OPEN.
   798    798   ** Return an error (non-zero) if the magic was not SQLITE_MAGIC_BUSY
   799    799   ** when this routine is called.
   800    800   */
   801         -int sqlite3SafetyOff(sqlite *db){
          801  +int sqlite3SafetyOff(sqlite3 *db){
   802    802     if( db->magic==SQLITE_MAGIC_BUSY ){
   803    803       db->magic = SQLITE_MAGIC_OPEN;
   804    804       return 0;
   805    805     }else if( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ERROR ){
   806    806       db->magic = SQLITE_MAGIC_ERROR;
   807    807       db->flags |= SQLITE_Interrupt;
   808    808     }
................................................................................
   814    814   ** If we are currently in an sqlite3_exec(), return true and set
   815    815   ** sqlite.magic to SQLITE_MAGIC_ERROR.  This will cause a complete
   816    816   ** shutdown of the database.
   817    817   **
   818    818   ** This routine is used to try to detect when API routines are called
   819    819   ** at the wrong time or in the wrong sequence.
   820    820   */
   821         -int sqlite3SafetyCheck(sqlite *db){
          821  +int sqlite3SafetyCheck(sqlite3 *db){
   822    822     if( db->pVdbe!=0 ){
   823    823       db->magic = SQLITE_MAGIC_ERROR;
   824    824       return 1;
   825    825     }
   826    826     return 0;
   827    827   }
   828    828   

Changes to src/vacuum.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the VACUUM command.
    13     13   **
    14     14   ** Most of the code in this file may be omitted by defining the
    15     15   ** SQLITE_OMIT_VACUUM macro.
    16     16   **
    17         -** $Id: vacuum.c,v 1.30 2004/09/05 00:33:43 drh Exp $
           17  +** $Id: vacuum.c,v 1.31 2004/09/06 17:24:13 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   
    22     22   #if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
    23     23   /*
    24     24   ** Generate a random name of 20 character in length.
................................................................................
    87     87     }
    88     88     return;
    89     89   }
    90     90   
    91     91   /*
    92     92   ** This routine implements the OP_Vacuum opcode of the VDBE.
    93     93   */
    94         -int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
           94  +int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
    95     95     int rc = SQLITE_OK;     /* Return code from service routines */
    96     96   #if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
    97     97     const char *zFilename;  /* full pathname of the database file */
    98     98     int nFilename;          /* number of characters  in zFilename[] */
    99     99     char *zTemp = 0;        /* a temporary file in same directory as zFilename */
   100    100     int i;                  /* Loop counter */
   101    101     Btree *pMain;           /* The database being vacuumed */

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.413 2004/09/02 14:57:09 drh Exp $
           46  +** $Id: vdbe.c,v 1.414 2004/09/06 17:24:13 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include "os.h"
    50     50   #include <ctype.h>
    51     51   #include "vdbeInt.h"
    52     52   
    53     53   /*
................................................................................
   457    457   */
   458    458   int sqlite3VdbeExec(
   459    459     Vdbe *p                    /* The VDBE */
   460    460   ){
   461    461     int pc;                    /* The program counter */
   462    462     Op *pOp;                   /* Current operation */
   463    463     int rc = SQLITE_OK;        /* Value to return */
   464         -  sqlite *db = p->db;        /* The database */
          464  +  sqlite3 *db = p->db;       /* The database */
   465    465     Mem *pTos;                 /* Top entry in the operand stack */
   466    466     char zBuf[100];            /* Space to sprintf() an integer */
   467    467   #ifdef VDBE_PROFILE
   468    468     unsigned long long start;  /* CPU clock count at start of opcode */
   469    469     int origPc;                /* Program counter at start of opcode */
   470    470   #endif
   471    471   #ifndef SQLITE_OMIT_PROGRESS_CALLBACK

Changes to src/vdbe.h.

    11     11   *************************************************************************
    12     12   ** Header file for the Virtual DataBase Engine (VDBE)
    13     13   **
    14     14   ** This header defines the interface to the virtual database engine
    15     15   ** or VDBE.  The VDBE implements an abstract machine that runs a
    16     16   ** simple program to access and modify the underlying database.
    17     17   **
    18         -** $Id: vdbe.h,v 1.90 2004/08/21 17:54:45 drh Exp $
           18  +** $Id: vdbe.h,v 1.91 2004/09/06 17:24:13 drh Exp $
    19     19   */
    20     20   #ifndef _SQLITE_VDBE_H_
    21     21   #define _SQLITE_VDBE_H_
    22     22   #include <stdio.h>
    23     23   
    24     24   /*
    25     25   ** A single VDBE is an opaque structure named "Vdbe".  Only routines
................................................................................
    93     93   */
    94     94   #include "opcodes.h"
    95     95   
    96     96   /*
    97     97   ** Prototypes for the VDBE interface.  See comments on the implementation
    98     98   ** for a description of what each of these routines does.
    99     99   */
   100         -Vdbe *sqlite3VdbeCreate(sqlite*);
          100  +Vdbe *sqlite3VdbeCreate(sqlite3*);
   101    101   void sqlite3VdbeCreateCallback(Vdbe*, int*);
   102    102   int sqlite3VdbeAddOp(Vdbe*,int,int,int);
   103    103   int sqlite3VdbeOp3(Vdbe*,int,int,int,const char *zP3,int);
   104    104   int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp);
   105    105   void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
   106    106   void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
   107    107   void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N);

Changes to src/vdbeInt.h.

   291    291   ** An instance of the virtual machine.  This structure contains the complete
   292    292   ** state of the virtual machine.
   293    293   **
   294    294   ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_compile()
   295    295   ** is really a pointer to an instance of this structure.
   296    296   */
   297    297   struct Vdbe {
   298         -  sqlite *db;         /* The whole database */
          298  +  sqlite3 *db;        /* The whole database */
   299    299     Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */
   300    300     FILE *trace;        /* Write an execution trace here, if not NULL */
   301    301     int nOp;            /* Number of instructions in the program */
   302    302     int nOpAlloc;       /* Number of slots allocated for aOp[] */
   303    303     Op *aOp;            /* Space to hold the virtual machine's program */
   304    304     int nLabel;         /* Number of labels used */
   305    305     int nLabelAlloc;    /* Number of slots allocated in aLabel[] */
................................................................................
   352    352   #define VDBE_MAGIC_DEAD     0xb606c3c8    /* The VDBE has been deallocated */
   353    353   
   354    354   /*
   355    355   ** Function prototypes
   356    356   */
   357    357   void sqlite3VdbeFreeCursor(Cursor*);
   358    358   void sqlite3VdbeSorterReset(Vdbe*);
   359         -int sqlite3VdbeAggReset(sqlite *, Agg *, KeyInfo *);
          359  +int sqlite3VdbeAggReset(sqlite3*, Agg *, KeyInfo *);
   360    360   void sqlite3VdbeKeylistFree(Keylist*);
   361    361   void sqliteVdbePopStack(Vdbe*,int);
   362    362   int sqlite3VdbeCursorMoveto(Cursor*);
   363    363   #if !defined(NDEBUG) || defined(VDBE_PROFILE)
   364    364   void sqlite3VdbePrintOp(FILE*, int, Op*);
   365    365   #endif
   366    366   void sqlite3VdbePrintSql(Vdbe*);

Changes to src/vdbeapi.c.

   131    131   
   132    132   /*
   133    133   ** Execute the statement pStmt, either until a row of data is ready, the
   134    134   ** statement is completely executed or an error occurs.
   135    135   */
   136    136   int sqlite3_step(sqlite3_stmt *pStmt){
   137    137     Vdbe *p = (Vdbe*)pStmt;
   138         -  sqlite *db;
          138  +  sqlite3 *db;
   139    139     int rc;
   140    140   
   141    141     if( p==0 || p->magic!=VDBE_MAGIC_RUN ){
   142    142       return SQLITE_MISUSE;
   143    143     }
   144    144     if( p->aborted ){
   145    145       return SQLITE_ABORT;

Changes to src/vdbeaux.c.

    29     29   int sqlite3_vdbe_addop_trace = 0;
    30     30   #endif
    31     31   
    32     32   
    33     33   /*
    34     34   ** Create a new virtual database engine.
    35     35   */
    36         -Vdbe *sqlite3VdbeCreate(sqlite *db){
           36  +Vdbe *sqlite3VdbeCreate(sqlite3 *db){
    37     37     Vdbe *p;
    38     38     p = sqliteMalloc( sizeof(Vdbe) );
    39     39     if( p==0 ) return 0;
    40     40     p->db = db;
    41     41     if( db->pVdbe ){
    42     42       db->pVdbe->pPrev = p;
    43     43     }
................................................................................
   447    447   ** The interface is the same as sqlite3VdbeExec().  But instead of
   448    448   ** running the code, it invokes the callback once for each instruction.
   449    449   ** This feature is used to implement "EXPLAIN".
   450    450   */
   451    451   int sqlite3VdbeList(
   452    452     Vdbe *p                   /* The VDBE */
   453    453   ){
   454         -  sqlite *db = p->db;
          454  +  sqlite3 *db = p->db;
   455    455     int i;
   456    456     int rc = SQLITE_OK;
   457    457   
   458    458     assert( p->explain );
   459    459   
   460    460     /* Even though this opcode does not put dynamic strings onto the
   461    461     ** the stack, they may become dynamic if the user calls
................................................................................
   694    694   ** aggregates (if it was ever opened).
   695    695   **
   696    696   ** If db is not NULL, then this is being called from with an OP_AggReset
   697    697   ** opcode. Open the temp-table, if it has not already been opened and
   698    698   ** delete the contents of the table used for aggregate information, ready
   699    699   ** for the next round of aggregate processing.
   700    700   */
   701         -int sqlite3VdbeAggReset(sqlite *db, Agg *pAgg, KeyInfo *pKeyInfo){
          701  +int sqlite3VdbeAggReset(sqlite3 *db, Agg *pAgg, KeyInfo *pKeyInfo){
   702    702     int rc = 0;
   703    703     BtCursor *pCsr = pAgg->pCsr;
   704    704   
   705    705     assert( (pCsr && pAgg->nTab>0) || (!pCsr && pAgg->nTab==0)
   706    706            || sqlite3_malloc_failed );
   707    707   
   708    708     /* If pCsr is not NULL, then the table used for aggregate information
................................................................................
   921    921   
   922    922   /*
   923    923   ** A read or write transaction may or may not be active on database handle
   924    924   ** db. If a transaction is active, commit it. If there is a
   925    925   ** write-transaction spanning more than one database file, this routine
   926    926   ** takes care of the master journal trickery.
   927    927   */
   928         -static int vdbeCommit(sqlite *db){
          928  +static int vdbeCommit(sqlite3 *db){
   929    929     int i;
   930    930     int nTrans = 0;  /* Number of databases with an active write-transaction */
   931    931     int rc = SQLITE_OK;
   932    932     int needXcommit = 0;
   933    933   
   934    934     for(i=0; i<db->nDb; i++){ 
   935    935       Btree *pBt = db->aDb[i].pBt;
................................................................................
  1133   1133   ** currently active. An assertion fails if the two counts do not match.
  1134   1134   ** This is an internal self-check only - it is not an essential processing
  1135   1135   ** step.
  1136   1136   **
  1137   1137   ** This is a no-op if NDEBUG is defined.
  1138   1138   */
  1139   1139   #ifndef NDEBUG
  1140         -static void checkActiveVdbeCnt(sqlite *db){
         1140  +static void checkActiveVdbeCnt(sqlite3 *db){
  1141   1141     Vdbe *p;
  1142   1142     int cnt = 0;
  1143   1143     p = db->pVdbe;
  1144   1144     while( p ){
  1145   1145       if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){
  1146   1146         cnt++;
  1147   1147       }
................................................................................
  1162   1162   ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT.
  1163   1163   **
  1164   1164   ** Return an error code.  If the commit could not complete because of
  1165   1165   ** lock contention, return SQLITE_BUSY.  If SQLITE_BUSY is returned, it
  1166   1166   ** means the close did not happen and needs to be repeated.
  1167   1167   */
  1168   1168   int sqlite3VdbeHalt(Vdbe *p){
  1169         -  sqlite *db = p->db;
         1169  +  sqlite3 *db = p->db;
  1170   1170     int i;
  1171   1171     int (*xFunc)(Btree *pBt) = 0;  /* Function to call on each btree backend */
  1172   1172   
  1173   1173     if( p->magic!=VDBE_MAGIC_RUN ){
  1174   1174       /* Already halted.  Nothing to do. */
  1175   1175       assert( p->magic==VDBE_MAGIC_HALT );
  1176   1176       return SQLITE_OK;
................................................................................
  1318   1318    
  1319   1319   /*
  1320   1320   ** Clean up and delete a VDBE after execution.  Return an integer which is
  1321   1321   ** the result code.  Write any error message text into *pzErrMsg.
  1322   1322   */
  1323   1323   int sqlite3VdbeFinalize(Vdbe *p){
  1324   1324     int rc = SQLITE_OK;
  1325         -  sqlite *db = p->db;
         1325  +  sqlite3 *db = p->db;
  1326   1326   
  1327   1327     if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){
  1328   1328       rc = sqlite3VdbeReset(p);
  1329   1329     }else if( p->magic!=VDBE_MAGIC_INIT ){
  1330   1330       /* sqlite3Error(p->db, SQLITE_MISUSE, 0); */
  1331   1331       return SQLITE_MISUSE;
  1332   1332     }

Changes to src/where.c.

     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 module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.
    14     14   **
    15         -** $Id: where.c,v 1.112 2004/08/21 17:54:45 drh Exp $
           15  +** $Id: where.c,v 1.113 2004/09/06 17:24:13 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** The query generator uses an array of instances of this structure to
    21     21   ** help it analyze the subexpressions of the WHERE clause.  Each WHERE
    22     22   ** clause subexpression is separated from the others by an AND operator.
................................................................................
   266    266     int nEqCol,             /* Number of index columns used with == constraints */
   267    267     int *pbRev              /* Set to 1 if ORDER BY is DESC */
   268    268   ){
   269    269     int i, j;
   270    270     Index *pMatch;
   271    271     Index *pIdx;
   272    272     int sortOrder;
   273         -  sqlite *db = pParse->db;
          273  +  sqlite3 *db = pParse->db;
   274    274   
   275    275     assert( pOrderBy!=0 );
   276    276     assert( pOrderBy->nExpr>0 );
   277    277     sortOrder = pOrderBy->a[0].sortOrder;
   278    278     for(i=0; i<pOrderBy->nExpr; i++){
   279    279       Expr *p;
   280    280       if( pOrderBy->a[i].sortOrder!=sortOrder ){