/ Check-in [8af6474c]
Login

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

Overview
Comment:Change lots of internal symbols from sqliteXXX to sqlite3XXX so that the library links again. It doesn't work yet, due to changes in the btree layer calling convention. (CVS 1324)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8af6474c49263ae26216dff9465b33f76b500cf4
User & Date: danielk1977 2004-05-08 08:23:20
Context
2004-05-08
10:11
Minor change to main.c so that it will compile with GCC 2.96. (CVS 1325) check-in: 1a09a1ad user: drh tags: trunk
08:23
Change lots of internal symbols from sqliteXXX to sqlite3XXX so that the library links again. It doesn't work yet, due to changes in the btree layer calling convention. (CVS 1324) check-in: 8af6474c user: danielk1977 tags: trunk
02:03
More bug fixes in btree.c. (CVS 1323) check-in: 2d64cba3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to main.mk.

    50     50   
    51     51   # This is how we compile
    52     52   #
    53     53   TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src
    54     54   
    55     55   # Object files for the SQLite library.
    56     56   #
    57         -LIBOBJ = btree.o hash.o os.o pager.o random.o \
    58         -         util.o tclsqlite.o utf.o
           57  +# LIBOBJ = btree.o hash.o os.o pager.o random.o \
           58  +#         util.o tclsqlite.o utf.o
    59     59   
    60         -LIBOBJ_ORIG = attach.o auth.o btree.o btree_rb.o build.o copy.o date.o delete.o \
           60  +
           61  +LIBOBJ = attach.o auth.o btree.o build.o copy.o date.o delete.o \
    61     62            expr.o func.o hash.o insert.o \
    62     63            main.o opcodes.o os.o pager.o parse.o pragma.o printf.o random.o \
    63     64            select.o table.o tokenize.o trigger.o update.o util.o \
    64         -         vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o
           65  +         vacuum.o vdbe.o vdbeaux.o where.o tclsqlite.o utf.o
    65     66   
    66     67   # All of the source code files.
    67     68   #
    68     69   SRC = \
    69     70     $(TOP)/src/btree.c \
    70     71     $(TOP)/src/btree.h \
    71     72     $(TOP)/src/hash.c \
................................................................................
   116    117     $(TOP)/src/vdbeaux.c \
   117    118     $(TOP)/src/vdbeInt.h \
   118    119     $(TOP)/src/where.c
   119    120   
   120    121   # Source code to the test files.
   121    122   #
   122    123   TESTSRC = \
   123         -  $(TOP)/src/os.c \
   124         -  $(TOP)/src/pager.c \
   125         -  $(TOP)/src/test2.c \
   126         -  $(TOP)/src/test3.c \
   127         -  $(TOP)/src/test5.c \
   128         -  $(TOP)/src/md5.c
          124  +   $(TOP)/src/os.c \
          125  +   $(TOP)/src/pager.c \
          126  +   $(TOP)/src/test2.c \
          127  +   $(TOP)/src/test3.c \
          128  +   $(TOP)/src/test5.c \
          129  +   $(TOP)/src/md5.c
   129    130   
   130    131   TESTSRC_ORIG = \
   131    132     $(TOP)/src/btree.c \
   132    133     $(TOP)/src/func.c \
   133    134     $(TOP)/src/os.c \
   134    135     $(TOP)/src/pager.c \
   135    136     $(TOP)/src/test1.c \
   136    137     $(TOP)/src/test2.c \
   137    138     $(TOP)/src/test3.c \
   138    139     $(TOP)/src/test4.c \
          140  +  $(TOP)/src/test5.c \
   139    141     $(TOP)/src/vdbe.c \
   140    142     $(TOP)/src/md5.c
   141    143   
   142    144   # Header files used by all library source files.
   143    145   #
   144    146   HDR = \
   145    147      sqlite.h  \
................................................................................
   173    175   libsqlite.a:	$(LIBOBJ)
   174    176   	$(AR) libsqlite.a $(LIBOBJ)
   175    177   	$(RANLIB) libsqlite.a
   176    178   
   177    179   sqlite$(EXE):	$(TOP)/src/shell.c libsqlite.a sqlite.h
   178    180   	$(TCCX) $(READLINE_FLAGS) -o sqlite$(EXE) $(TOP)/src/shell.c \
   179    181   		libsqlite.a $(LIBREADLINE) $(THREADLIB)
          182  +
          183  +objects: $(LIBOBJ_ORIG)
   180    184   
   181    185   # This target creates a directory named "tsrc" and fills it with
   182    186   # copies of all of the C source code and header files needed to
   183    187   # build on the target system.  Some of the C source code and header
   184    188   # files are automatically generated.  This target takes care of
   185    189   # all that automatic generation.
   186    190   #
................................................................................
   213    217   	$(TCCX) -c $(TOP)/src/pager.c
   214    218   
   215    219   opcodes.o:	opcodes.c
   216    220   	$(TCCX) -c opcodes.c
   217    221   
   218    222   opcodes.c:	$(TOP)/src/vdbe.c
   219    223   	echo '/* Automatically generated file.  Do not edit */' >opcodes.c
   220         -	echo 'char *sqliteOpcodeNames[] = { "???", ' >>opcodes.c
          224  +	echo 'char *sqlite3OpcodeNames[] = { "???", ' >>opcodes.c
   221    225   	grep '^case OP_' $(TOP)/src/vdbe.c | \
   222    226   	  sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >>opcodes.c
   223    227   	echo '};' >>opcodes.c
   224    228   
   225    229   opcodes.h:	$(TOP)/src/vdbe.h
   226    230   	echo '/* Automatically generated file.  Do not edit */' >opcodes.h
   227    231   	grep '^case OP_' $(TOP)/src/vdbe.c | \
................................................................................
   230    234   
   231    235   os.o:	$(TOP)/src/os.c $(HDR)
   232    236   	$(TCCX) -c $(TOP)/src/os.c
   233    237   
   234    238   parse.o:	parse.c $(HDR)
   235    239   	$(TCCX) -c parse.c
   236    240   
   237         -utf.o:	$(TOP)/src/utf.c $(HDR)
   238         -	$(TCCX) -c $(TOP)/src/utf.c
   239         -
   240    241   parse.h:	parse.c
   241    242   
   242    243   parse.c:	$(TOP)/src/parse.y lemon
   243    244   	cp $(TOP)/src/parse.y .
   244    245   	./lemon parse.y
   245    246   
   246    247   # The config.h file will contain a single #define that tells us how
................................................................................
   265    266                    $(TOP)/src/sqlite.h.in >sqlite.h
   266    267   
   267    268   tokenize.o:	$(TOP)/src/tokenize.c $(HDR)
   268    269   	$(TCCX) -c $(TOP)/src/tokenize.c
   269    270   
   270    271   trigger.o:	$(TOP)/src/trigger.c $(HDR)
   271    272   	$(TCCX) -c $(TOP)/src/trigger.c
          273  +
          274  +utf.o:	$(TOP)/src/utf.c $(HDR)
          275  +	$(TCCX) -c $(TOP)/src/utf.c
   272    276   
   273    277   util.o:	$(TOP)/src/util.c $(HDR)
   274    278   	$(TCCX) -c $(TOP)/src/util.c
   275    279   
   276    280   vacuum.o:	$(TOP)/src/vacuum.c $(HDR)
   277    281   	$(TCCX) -c $(TOP)/src/vacuum.c
   278    282   

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.10 2004/02/12 18:46:39 drh Exp $
           14  +** $Id: attach.c,v 1.11 2004/05/08 08:23:21 danielk1977 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
    22     22   **
    23     23   ** The pFilename and pDbname arguments are the tokens that define the
    24     24   ** filename and dbname in the ATTACH statement.
    25     25   */
    26         -void sqliteAttach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){
           26  +void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey){
    27     27     Db *aNew;
    28     28     int rc, i;
    29     29     char *zFile, *zName;
    30     30     sqlite *db;
    31     31     Vdbe *v;
    32     32   
    33         -  v = sqliteGetVdbe(pParse);
    34         -  sqliteVdbeAddOp(v, OP_Halt, 0, 0);
           33  +  v = sqlite3GetVdbe(pParse);
           34  +  sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
    35     35     if( pParse->explain ) return;
    36     36     db = pParse->db;
    37     37     if( db->file_format<4 ){
    38         -    sqliteErrorMsg(pParse, "cannot attach auxiliary databases to an "
           38  +    sqlite3ErrorMsg(pParse, "cannot attach auxiliary databases to an "
    39     39          "older format master database", 0);
    40     40       pParse->rc = SQLITE_ERROR;
    41     41       return;
    42     42     }
    43     43     if( db->nDb>=MAX_ATTACHED+2 ){
    44         -    sqliteErrorMsg(pParse, "too many attached databases - max %d", 
           44  +    sqlite3ErrorMsg(pParse, "too many attached databases - max %d", 
    45     45          MAX_ATTACHED);
    46     46       pParse->rc = SQLITE_ERROR;
    47     47       return;
    48     48     }
    49     49   
    50     50     zFile = 0;
    51         -  sqliteSetNString(&zFile, pFilename->z, pFilename->n, 0);
           51  +  sqlite3SetNString(&zFile, pFilename->z, pFilename->n, 0);
    52     52     if( zFile==0 ) return;
    53         -  sqliteDequote(zFile);
           53  +  sqlite3Dequote(zFile);
    54     54   #ifndef SQLITE_OMIT_AUTHORIZATION
    55         -  if( sqliteAuthCheck(pParse, SQLITE_ATTACH, zFile, 0, 0)!=SQLITE_OK ){
           55  +  if( sqlite3AuthCheck(pParse, SQLITE_ATTACH, zFile, 0, 0)!=SQLITE_OK ){
    56     56       sqliteFree(zFile);
    57     57       return;
    58     58     }
    59     59   #endif /* SQLITE_OMIT_AUTHORIZATION */
    60     60   
    61     61     zName = 0;
    62         -  sqliteSetNString(&zName, pDbname->z, pDbname->n, 0);
           62  +  sqlite3SetNString(&zName, pDbname->z, pDbname->n, 0);
    63     63     if( zName==0 ) return;
    64         -  sqliteDequote(zName);
           64  +  sqlite3Dequote(zName);
    65     65     for(i=0; i<db->nDb; i++){
    66         -    if( db->aDb[i].zName && sqliteStrICmp(db->aDb[i].zName, zName)==0 ){
    67         -      sqliteErrorMsg(pParse, "database %z is already in use", zName);
           66  +    if( db->aDb[i].zName && sqlite3StrICmp(db->aDb[i].zName, zName)==0 ){
           67  +      sqlite3ErrorMsg(pParse, "database %z is already in use", zName);
    68     68         pParse->rc = SQLITE_ERROR;
    69     69         sqliteFree(zFile);
    70     70         return;
    71     71       }
    72     72     }
    73     73   
    74     74     if( db->aDb==db->aDbStatic ){
................................................................................
    78     78     }else{
    79     79       aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
    80     80       if( aNew==0 ) return;
    81     81     }
    82     82     db->aDb = aNew;
    83     83     aNew = &db->aDb[db->nDb++];
    84     84     memset(aNew, 0, sizeof(*aNew));
    85         -  sqliteHashInit(&aNew->tblHash, SQLITE_HASH_STRING, 0);
    86         -  sqliteHashInit(&aNew->idxHash, SQLITE_HASH_STRING, 0);
    87         -  sqliteHashInit(&aNew->trigHash, SQLITE_HASH_STRING, 0);
    88         -  sqliteHashInit(&aNew->aFKey, SQLITE_HASH_STRING, 1);
           85  +  sqlite3HashInit(&aNew->tblHash, SQLITE_HASH_STRING, 0);
           86  +  sqlite3HashInit(&aNew->idxHash, SQLITE_HASH_STRING, 0);
           87  +  sqlite3HashInit(&aNew->trigHash, SQLITE_HASH_STRING, 0);
           88  +  sqlite3HashInit(&aNew->aFKey, SQLITE_HASH_STRING, 1);
    89     89     aNew->zName = zName;
    90         -  rc = sqliteBtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt);
           90  +  rc = sqlite3BtreeFactory(db, zFile, 0, MAX_PAGES, &aNew->pBt);
    91     91     if( rc ){
    92         -    sqliteErrorMsg(pParse, "unable to open database: %s", zFile);
           92  +    sqlite3ErrorMsg(pParse, "unable to open database: %s", zFile);
    93     93     }
    94     94   #if SQLITE_HAS_CODEC
    95     95     {
    96     96       extern int sqliteCodecAttach(sqlite*, int, void*, int);
    97     97       char *zKey = 0;
    98     98       int nKey;
    99     99       if( pKey && pKey->z && pKey->n ){
   100         -      sqliteSetNString(&zKey, pKey->z, pKey->n, 0);
   101         -      sqliteDequote(zKey);
          100  +      sqlite3SetNString(&zKey, pKey->z, pKey->n, 0);
          101  +      sqlite3Dequote(zKey);
   102    102         nKey = strlen(zKey);
   103    103       }else{
   104    104         zKey = 0;
   105    105         nKey = 0;
   106    106       }
   107    107       sqliteCodecAttach(db, db->nDb-1, zKey, nKey);
   108    108     }
   109    109   #endif
   110    110     sqliteFree(zFile);
   111    111     db->flags &= ~SQLITE_Initialized;
   112    112     if( pParse->nErr ) return;
   113    113     if( rc==SQLITE_OK ){
   114         -    rc = sqliteInit(pParse->db, &pParse->zErrMsg);
          114  +    rc = sqlite3Init(pParse->db, &pParse->zErrMsg);
   115    115     }
   116    116     if( rc ){
   117    117       int i = db->nDb - 1;
   118    118       assert( i>=2 );
   119    119       if( db->aDb[i].pBt ){
   120         -      sqliteBtreeClose(db->aDb[i].pBt);
          120  +      sqlite3BtreeClose(db->aDb[i].pBt);
   121    121         db->aDb[i].pBt = 0;
   122    122       }
   123         -    sqliteResetInternalSchema(db, 0);
          123  +    sqlite3ResetInternalSchema(db, 0);
   124    124       pParse->nErr++;
   125    125       pParse->rc = SQLITE_ERROR;
   126    126     }
   127    127   }
   128    128   
   129    129   /*
   130    130   ** This routine is called by the parser to process a DETACH statement:
   131    131   **
   132    132   **    DETACH DATABASE dbname
   133    133   **
   134    134   ** The pDbname argument is the name of the database in the DETACH statement.
   135    135   */
   136         -void sqliteDetach(Parse *pParse, Token *pDbname){
          136  +void sqlite3Detach(Parse *pParse, Token *pDbname){
   137    137     int i;
   138    138     sqlite *db;
   139    139     Vdbe *v;
   140    140   
   141         -  v = sqliteGetVdbe(pParse);
   142         -  sqliteVdbeAddOp(v, OP_Halt, 0, 0);
          141  +  v = sqlite3GetVdbe(pParse);
          142  +  sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
   143    143     if( pParse->explain ) return;
   144    144     db = pParse->db;
   145    145     for(i=0; i<db->nDb; i++){
   146    146       if( db->aDb[i].pBt==0 || db->aDb[i].zName==0 ) continue;
   147    147       if( strlen(db->aDb[i].zName)!=pDbname->n ) continue;
   148         -    if( sqliteStrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;
          148  +    if( sqlite3StrNICmp(db->aDb[i].zName, pDbname->z, pDbname->n)==0 ) break;
   149    149     }
   150    150     if( i>=db->nDb ){
   151         -    sqliteErrorMsg(pParse, "no such database: %T", pDbname);
          151  +    sqlite3ErrorMsg(pParse, "no such database: %T", pDbname);
   152    152       return;
   153    153     }
   154    154     if( i<2 ){
   155         -    sqliteErrorMsg(pParse, "cannot detach database %T", pDbname);
          155  +    sqlite3ErrorMsg(pParse, "cannot detach database %T", pDbname);
   156    156       return;
   157    157     }
   158    158   #ifndef SQLITE_OMIT_AUTHORIZATION
   159         -  if( sqliteAuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){
          159  +  if( sqlite3AuthCheck(pParse,SQLITE_DETACH,db->aDb[i].zName,0,0)!=SQLITE_OK ){
   160    160       return;
   161    161     }
   162    162   #endif /* SQLITE_OMIT_AUTHORIZATION */
   163         -  sqliteBtreeClose(db->aDb[i].pBt);
          163  +  sqlite3BtreeClose(db->aDb[i].pBt);
   164    164     db->aDb[i].pBt = 0;
   165    165     sqliteFree(db->aDb[i].zName);
   166         -  sqliteResetInternalSchema(db, i);
          166  +  sqlite3ResetInternalSchema(db, i);
   167    167     db->nDb--;
   168    168     if( i<db->nDb ){
   169    169       db->aDb[i] = db->aDb[db->nDb];
   170    170       memset(&db->aDb[db->nDb], 0, sizeof(db->aDb[0]));
   171         -    sqliteResetInternalSchema(db, i);
          171  +    sqlite3ResetInternalSchema(db, i);
   172    172     }
   173    173   }
   174    174   
   175    175   /*
   176    176   ** Initialize a DbFixer structure.  This routine must be called prior
   177    177   ** to passing the structure to one of the sqliteFixAAAA() routines below.
   178    178   **
   179    179   ** The return value indicates whether or not fixation is required.  TRUE
   180    180   ** means we do need to fix the database references, FALSE means we do not.
   181    181   */
   182         -int sqliteFixInit(
          182  +int sqlite3FixInit(
   183    183     DbFixer *pFix,      /* The fixer to be initialized */
   184    184     Parse *pParse,      /* Error messages will be written here */
   185    185     int iDb,            /* This is the database that must must be used */
   186    186     const char *zType,  /* "view", "trigger", or "index" */
   187    187     const Token *pName  /* Name of the view, trigger, or index */
   188    188   ){
   189    189     sqlite *db;
................................................................................
   198    198     return 1;
   199    199   }
   200    200   
   201    201   /*
   202    202   ** The following set of routines walk through the parse tree and assign
   203    203   ** a specific database to all table references where the database name
   204    204   ** was left unspecified in the original SQL statement.  The pFix structure
   205         -** must have been initialized by a prior call to sqliteFixInit().
          205  +** must have been initialized by a prior call to sqlite3FixInit().
   206    206   **
   207    207   ** These routines are used to make sure that an index, trigger, or
   208    208   ** view in one database does not refer to objects in a different database.
   209    209   ** (Exception: indices, triggers, and views in the TEMP database are
   210    210   ** allowed to refer to anything.)  If a reference is explicitly made
   211    211   ** to an object in a different database, an error message is added to
   212    212   ** pParse->zErrMsg and these routines return non-zero.  If everything
   213    213   ** checks out, these routines return 0.
   214    214   */
   215         -int sqliteFixSrcList(
          215  +int sqlite3FixSrcList(
   216    216     DbFixer *pFix,       /* Context of the fixation */
   217    217     SrcList *pList       /* The Source list to check and modify */
   218    218   ){
   219    219     int i;
   220    220     const char *zDb;
   221    221   
   222    222     if( pList==0 ) return 0;
   223    223     zDb = pFix->zDb;
   224    224     for(i=0; i<pList->nSrc; i++){
   225    225       if( pList->a[i].zDatabase==0 ){
   226    226         pList->a[i].zDatabase = sqliteStrDup(zDb);
   227         -    }else if( sqliteStrICmp(pList->a[i].zDatabase,zDb)!=0 ){
   228         -      sqliteErrorMsg(pFix->pParse,
          227  +    }else if( sqlite3StrICmp(pList->a[i].zDatabase,zDb)!=0 ){
          228  +      sqlite3ErrorMsg(pFix->pParse,
   229    229            "%s %z cannot reference objects in database %s",
   230    230            pFix->zType, sqliteStrNDup(pFix->pName->z, pFix->pName->n),
   231    231            pList->a[i].zDatabase);
   232    232         return 1;
   233    233       }
   234         -    if( sqliteFixSelect(pFix, pList->a[i].pSelect) ) return 1;
   235         -    if( sqliteFixExpr(pFix, pList->a[i].pOn) ) return 1;
          234  +    if( sqlite3FixSelect(pFix, pList->a[i].pSelect) ) return 1;
          235  +    if( sqlite3FixExpr(pFix, pList->a[i].pOn) ) return 1;
   236    236     }
   237    237     return 0;
   238    238   }
   239         -int sqliteFixSelect(
          239  +int sqlite3FixSelect(
   240    240     DbFixer *pFix,       /* Context of the fixation */
   241    241     Select *pSelect      /* The SELECT statement to be fixed to one database */
   242    242   ){
   243    243     while( pSelect ){
   244         -    if( sqliteFixExprList(pFix, pSelect->pEList) ){
          244  +    if( sqlite3FixExprList(pFix, pSelect->pEList) ){
          245  +      return 1;
          246  +    }
          247  +    if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){
   245    248         return 1;
   246    249       }
   247         -    if( sqliteFixSrcList(pFix, pSelect->pSrc) ){
          250  +    if( sqlite3FixExpr(pFix, pSelect->pWhere) ){
   248    251         return 1;
   249    252       }
   250         -    if( sqliteFixExpr(pFix, pSelect->pWhere) ){
   251         -      return 1;
   252         -    }
   253         -    if( sqliteFixExpr(pFix, pSelect->pHaving) ){
          253  +    if( sqlite3FixExpr(pFix, pSelect->pHaving) ){
   254    254         return 1;
   255    255       }
   256    256       pSelect = pSelect->pPrior;
   257    257     }
   258    258     return 0;
   259    259   }
   260         -int sqliteFixExpr(
          260  +int sqlite3FixExpr(
   261    261     DbFixer *pFix,     /* Context of the fixation */
   262    262     Expr *pExpr        /* The expression to be fixed to one database */
   263    263   ){
   264    264     while( pExpr ){
   265         -    if( sqliteFixSelect(pFix, pExpr->pSelect) ){
          265  +    if( sqlite3FixSelect(pFix, pExpr->pSelect) ){
   266    266         return 1;
   267    267       }
   268         -    if( sqliteFixExprList(pFix, pExpr->pList) ){
          268  +    if( sqlite3FixExprList(pFix, pExpr->pList) ){
   269    269         return 1;
   270    270       }
   271         -    if( sqliteFixExpr(pFix, pExpr->pRight) ){
          271  +    if( sqlite3FixExpr(pFix, pExpr->pRight) ){
   272    272         return 1;
   273    273       }
   274    274       pExpr = pExpr->pLeft;
   275    275     }
   276    276     return 0;
   277    277   }
   278         -int sqliteFixExprList(
          278  +int sqlite3FixExprList(
   279    279     DbFixer *pFix,     /* Context of the fixation */
   280    280     ExprList *pList    /* The expression to be fixed to one database */
   281    281   ){
   282    282     int i;
   283    283     if( pList==0 ) return 0;
   284    284     for(i=0; i<pList->nExpr; i++){
   285         -    if( sqliteFixExpr(pFix, pList->a[i].pExpr) ){
          285  +    if( sqlite3FixExpr(pFix, pList->a[i].pExpr) ){
   286    286         return 1;
   287    287       }
   288    288     }
   289    289     return 0;
   290    290   }
   291         -int sqliteFixTriggerStep(
          291  +int sqlite3FixTriggerStep(
   292    292     DbFixer *pFix,     /* Context of the fixation */
   293    293     TriggerStep *pStep /* The trigger step be fixed to one database */
   294    294   ){
   295    295     while( pStep ){
   296         -    if( sqliteFixSelect(pFix, pStep->pSelect) ){
          296  +    if( sqlite3FixSelect(pFix, pStep->pSelect) ){
   297    297         return 1;
   298    298       }
   299         -    if( sqliteFixExpr(pFix, pStep->pWhere) ){
          299  +    if( sqlite3FixExpr(pFix, pStep->pWhere) ){
   300    300         return 1;
   301    301       }
   302         -    if( sqliteFixExprList(pFix, pStep->pExprList) ){
          302  +    if( sqlite3FixExprList(pFix, pStep->pExprList) ){
   303    303         return 1;
   304    304       }
   305    305       pStep = pStep->pNext;
   306    306     }
   307    307     return 0;
   308    308   }
          309  +
          310  +
          311  +

Changes to src/auth.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the sqlite_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.12 2004/02/22 18:40:57 drh Exp $
           17  +** $Id: auth.c,v 1.13 2004/05/08 08:23:21 danielk1977 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   */
................................................................................
    81     81   }
    82     82   
    83     83   /*
    84     84   ** Write an error message into pParse->zErrMsg that explains that the
    85     85   ** user-supplied authorization function returned an illegal value.
    86     86   */
    87     87   static void sqliteAuthBadReturnCode(Parse *pParse, int rc){
    88         -  sqliteErrorMsg(pParse, "illegal return value (%d) from the "
           88  +  sqlite3ErrorMsg(pParse, "illegal return value (%d) from the "
    89     89       "authorization function - should be SQLITE_OK, SQLITE_IGNORE, "
    90     90       "or SQLITE_DENY", rc);
    91     91     pParse->rc = SQLITE_MISUSE;
    92     92   }
    93     93   
    94     94   /*
    95     95   ** The pExpr should be a TK_COLUMN expression.  The table referred to
................................................................................
    96     96   ** is in pTabList or else it is the NEW or OLD table of a trigger.  
    97     97   ** Check to see if it is OK to read this particular column.
    98     98   **
    99     99   ** If the auth function returns SQLITE_IGNORE, change the TK_COLUMN 
   100    100   ** instruction into a TK_NULL.  If the auth function returns SQLITE_DENY,
   101    101   ** then generate an error.
   102    102   */
   103         -void sqliteAuthRead(
          103  +void sqlite3AuthRead(
   104    104     Parse *pParse,        /* The parser context */
   105    105     Expr *pExpr,          /* The expression to check authorization on */
   106    106     SrcList *pTabList     /* All table that pExpr might refer to */
   107    107   ){
   108    108     sqlite *db = pParse->db;
   109    109     int rc;
   110    110     Table *pTab;          /* The table being read */
................................................................................
   143    143     zDBase = db->aDb[pExpr->iDb].zName;
   144    144     rc = db->xAuth(db->pAuthArg, SQLITE_READ, pTab->zName, zCol, zDBase, 
   145    145                    pParse->zAuthContext);
   146    146     if( rc==SQLITE_IGNORE ){
   147    147       pExpr->op = TK_NULL;
   148    148     }else if( rc==SQLITE_DENY ){
   149    149       if( db->nDb>2 || pExpr->iDb!=0 ){
   150         -      sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited", 
          150  +      sqlite3ErrorMsg(pParse, "access to %s.%s.%s is prohibited", 
   151    151            zDBase, pTab->zName, zCol);
   152    152       }else{
   153         -      sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
          153  +      sqlite3ErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol);
   154    154       }
   155    155       pParse->rc = SQLITE_AUTH;
   156    156     }else if( rc!=SQLITE_OK ){
   157    157       sqliteAuthBadReturnCode(pParse, rc);
   158    158     }
   159    159   }
   160    160   
   161    161   /*
   162    162   ** Do an authorization check using the code and arguments given.  Return
   163    163   ** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY.  If SQLITE_DENY
   164    164   ** is returned, then the error count and error message in pParse are
   165    165   ** modified appropriately.
   166    166   */
   167         -int sqliteAuthCheck(
          167  +int sqlite3AuthCheck(
   168    168     Parse *pParse,
   169    169     int code,
   170    170     const char *zArg1,
   171    171     const char *zArg2,
   172    172     const char *zArg3
   173    173   ){
   174    174     sqlite *db = pParse->db;
................................................................................
   175    175     int rc;
   176    176   
   177    177     if( db->xAuth==0 ){
   178    178       return SQLITE_OK;
   179    179     }
   180    180     rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext);
   181    181     if( rc==SQLITE_DENY ){
   182         -    sqliteErrorMsg(pParse, "not authorized");
          182  +    sqlite3ErrorMsg(pParse, "not authorized");
   183    183       pParse->rc = SQLITE_AUTH;
   184    184     }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){
   185    185       rc = SQLITE_DENY;
   186    186       sqliteAuthBadReturnCode(pParse, rc);
   187    187     }
   188    188     return rc;
   189    189   }
   190    190   
   191    191   /*
   192    192   ** Push an authorization context.  After this routine is called, the
   193    193   ** zArg3 argument to authorization callbacks will be zContext until
   194    194   ** popped.  Or if pParse==0, this routine is a no-op.
   195    195   */
   196         -void sqliteAuthContextPush(
          196  +void sqlite3AuthContextPush(
   197    197     Parse *pParse,
   198    198     AuthContext *pContext, 
   199    199     const char *zContext
   200    200   ){
   201    201     pContext->pParse = pParse;
   202    202     if( pParse ){
   203    203       pContext->zAuthContext = pParse->zAuthContext;
   204    204       pParse->zAuthContext = zContext;
   205    205     }
   206    206   }
   207    207   
   208    208   /*
   209    209   ** Pop an authorization context that was previously pushed
   210         -** by sqliteAuthContextPush
          210  +** by sqlite3AuthContextPush
   211    211   */
   212         -void sqliteAuthContextPop(AuthContext *pContext){
          212  +void sqlite3AuthContextPop(AuthContext *pContext){
   213    213     if( pContext->pParse ){
   214    214       pContext->pParse->zAuthContext = pContext->zAuthContext;
   215    215       pContext->pParse = 0;
   216    216     }
   217    217   }
   218    218   
   219    219   #endif /* SQLITE_OMIT_AUTHORIZATION */
          220  +
          221  +
          222  +

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.113 2004/05/08 02:03:23 drh Exp $
           12  +** $Id: btree.c,v 1.114 2004/05/08 08:23:21 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** For a detailed discussion of BTrees, refer to
    16     16   **
    17     17   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    18     18   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    19     19   **     Publishing Company, Reading, Massachusetts.
................................................................................
  3409   3409   /*
  3410   3410   ** Append a message to the error message string.
  3411   3411   */
  3412   3412   static void checkAppendMsg(IntegrityCk *pCheck, char *zMsg1, char *zMsg2){
  3413   3413     if( pCheck->zErrMsg ){
  3414   3414       char *zOld = pCheck->zErrMsg;
  3415   3415       pCheck->zErrMsg = 0;
  3416         -    sqliteSetString(&pCheck->zErrMsg, zOld, "\n", zMsg1, zMsg2, (char*)0);
         3416  +    sqlite3SetString(&pCheck->zErrMsg, zOld, "\n", zMsg1, zMsg2, (char*)0);
  3417   3417       sqliteFree(zOld);
  3418   3418     }else{
  3419         -    sqliteSetString(&pCheck->zErrMsg, zMsg1, zMsg2, (char*)0);
         3419  +    sqlite3SetString(&pCheck->zErrMsg, zMsg1, zMsg2, (char*)0);
  3420   3420     }
  3421   3421   }
  3422   3422   
  3423   3423   /*
  3424   3424   ** Add 1 to the reference count for page iPage.  If this is the second
  3425   3425   ** reference to the page, add an error message to pCheck->zErrMsg.
  3426   3426   ** Return 1 if there are 2 ore more references to the page and 0 if
................................................................................
  3760   3760       rc = sqlite3pager_truncate(pBtTo->pPager, nPage);
  3761   3761     }
  3762   3762     if( rc ){
  3763   3763       sqlite3BtreeRollback(pBtTo);
  3764   3764     }
  3765   3765     return rc;  
  3766   3766   }
         3767  +
         3768  +int sqlite3BtreeKeyCompare(
         3769  +  BtCursor *pCur,       /* Pointer to entry to compare against */
         3770  +  const void *pKey,     /* Key to compare against entry that pCur points to */
         3771  +  int nKey,             /* Number of bytes in pKey */
         3772  +  int nIgnore,          /* Ignore this many bytes at the end of pCur */
         3773  +  int *pResult          /* Write the result here */
         3774  +){
         3775  +  void *pCellKey;
         3776  +  u64 nCellKey;
         3777  +  int rc;
         3778  +
         3779  +  sqlite3BtreeKeySize(pCur, &nCellKey);
         3780  +  nCellKey = nCellKey - nIgnore;
         3781  +  if( nCellKey<=0 ){
         3782  +    *pResult = 0;
         3783  +    return SQLITE_OK;
         3784  +  }
         3785  +
         3786  +  pCellKey = sqlite3BtreeKeyFetch(pCur);
         3787  +  if( pCellKey ){
         3788  +    *pResult = pCur->xCompare(pCur->pArg, nCellKey, pCellKey, nKey, pKey);
         3789  +    return SQLITE_OK;
         3790  +  }
         3791  +
         3792  +  pCellKey = sqliteMalloc( nCellKey );
         3793  +  if( pCellKey==0 ) return SQLITE_NOMEM;
         3794  +
         3795  +  rc = sqlite3BtreeKey(pCur, 0, nCellKey, pCellKey);
         3796  +  *pResult = pCur->xCompare(pCur->pArg, nCellKey, pCellKey, nKey, pKey);
         3797  +  sqliteFree(pCellKey);
         3798  +
         3799  +  return rc;
         3800  +}
         3801  +
         3802  +
         3803  +

Changes to src/btree.h.

     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 B-Tree file
    13     13   ** subsystem.  See comments in the source code for a detailed description
    14     14   ** of what each interface routine does.
    15     15   **
    16         -** @(#) $Id: btree.h,v 1.39 2004/05/07 23:50:57 drh Exp $
           16  +** @(#) $Id: btree.h,v 1.40 2004/05/08 08:23:23 danielk1977 Exp $
    17     17   */
    18     18   #ifndef _BTREE_H_
    19     19   #define _BTREE_H_
           20  +
           21  +/* TODO: This definition is just included so other modules compile. It
           22  +** needs to be revisited.
           23  +*/
           24  +#define SQLITE_N_BTREE_META 10
    20     25   
    21     26   /*
    22     27   ** Forward declarations of structure
    23     28   */
    24     29   typedef struct Btree Btree;
    25     30   typedef struct BtCursor BtCursor;
    26     31   
................................................................................
    39     44   int sqlite3BtreeBeginTrans(Btree*);
    40     45   int sqlite3BtreeCommit(Btree*);
    41     46   int sqlite3BtreeRollback(Btree*);
    42     47   int sqlite3BtreeBeginStmt(Btree*);
    43     48   int sqlite3BtreeCommitStmt(Btree*);
    44     49   int sqlite3BtreeRollbackStmt(Btree*);
    45     50   int sqlite3BtreeCreateTable(Btree*, int*, int flags);
           51  +
           52  +const char *sqlite3BtreeGetFilename(Btree *);
           53  +int sqlite3BtreeCopyFile(Btree *, Btree *);
    46     54   
    47     55   /* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR
    48     56   ** of the following flags:
    49     57   */
    50     58   #define BTREE_INTKEY     1      /* Table has only 64-bit integer keys */
    51     59   #define BTREE_ZERODATA   2      /* Table has keys only - no data */
    52     60   
................................................................................
    75     83   int sqlite3BtreeEof(BtCursor*);
    76     84   int sqlite3BtreePrevious(BtCursor*, int *pRes);
    77     85   int sqlite3BtreeKeySize(BtCursor*, u64 *pSize);
    78     86   int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
    79     87   void *sqlite3BtreeKeyFetch(BtCursor*);
    80     88   int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
    81     89   int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
           90  +int sqlite3BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
    82     91   
    83     92   char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot);
    84     93   struct Pager *sqlite3BtreePager(Btree*);
    85     94   
    86     95   #ifdef SQLITE_TEST
    87     96   int sqlite3BtreeCursorDump(BtCursor*, int*);
    88     97   int sqlite3BtreeFlags(BtCursor*);
    89     98   int sqlite3BtreePageDump(Btree*, int, int recursive);
    90     99   #endif
    91    100   
    92    101   
    93    102   #endif /* _BTREE_H_ */
          103  +
          104  +
          105  +

Changes to src/btree_rb.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree_rb.c,v 1.24 2004/02/29 00:11:31 drh Exp $
           12  +** $Id: btree_rb.c,v 1.25 2004/05/08 08:23:23 danielk1977 Exp $
    13     13   **
    14     14   ** This file implements an in-core database using Red-Black balanced
    15     15   ** binary trees.
    16     16   ** 
    17     17   ** It was contributed to SQLite by anonymous on 2003-Feb-04 23:24:49 UTC.
    18     18   */
    19     19   #include "btree.h"
................................................................................
   261    261    */
   262    262   static char *append_val(char * orig, char const * val){
   263    263     char *z;
   264    264     if( !orig ){
   265    265       z = sqliteStrDup( val );
   266    266     } else{
   267    267       z = 0;
   268         -    sqliteSetString(&z, orig, val, (char*)0);
          268  +    sqlite3SetString(&z, orig, val, (char*)0);
   269    269       sqliteFree( orig );
   270    270     }
   271    271     return z;
   272    272   }
   273    273   
   274    274   /*
   275    275    * Append a string representation of the entire node to orig and return it.
................................................................................
   581    581   
   582    582   /*
   583    583    * Create table n in tree pRbtree. Table n must not exist.
   584    584    */
   585    585   static void btreeCreateTable(Rbtree* pRbtree, int n)
   586    586   {
   587    587     BtRbTree *pNewTbl = sqliteMalloc(sizeof(BtRbTree));
   588         -  sqliteHashInsert(&pRbtree->tblHash, 0, n, pNewTbl);
          588  +  sqlite3HashInsert(&pRbtree->tblHash, 0, n, pNewTbl);
   589    589   }
   590    590   
   591    591   /*
   592    592    * Log a single "rollback-op" for the given Rbtree. See comments for struct
   593    593    * BtRollbackOp.
   594    594    */
   595    595   static void btreeLogRollbackOp(Rbtree* pRbtree, BtRollbackOp *pRollbackOp)
................................................................................
   614    614     int mode,
   615    615     int nPg,
   616    616     Btree **ppBtree
   617    617   ){
   618    618     Rbtree **ppRbtree = (Rbtree**)ppBtree;
   619    619     *ppRbtree = (Rbtree *)sqliteMalloc(sizeof(Rbtree));
   620    620     if( sqlite_malloc_failed ) goto open_no_mem;
   621         -  sqliteHashInit(&(*ppRbtree)->tblHash, SQLITE_HASH_INT, 0);
          621  +  sqlite3HashInit(&(*ppRbtree)->tblHash, SQLITE_HASH_INT, 0);
   622    622   
   623    623     /* Create a binary tree for the SQLITE_MASTER table at location 2 */
   624    624     btreeCreateTable(*ppRbtree, 2);
   625    625     if( sqlite_malloc_failed ) goto open_no_mem;
   626    626     (*ppRbtree)->next_idx = 3;
   627    627     (*ppRbtree)->pOps = &sqliteRbtreeOps;
   628    628     /* Set file type to 4; this is so that "attach ':memory:' as ...."  does not
................................................................................
   667    667    */
   668    668   static int memRbtreeDropTable(Rbtree* tree, int n)
   669    669   {
   670    670     BtRbTree *pTree;
   671    671     assert( tree->eTransState != TRANS_NONE );
   672    672   
   673    673     memRbtreeClearTable(tree, n);
   674         -  pTree = sqliteHashInsert(&tree->tblHash, 0, n, 0);
          674  +  pTree = sqlite3HashInsert(&tree->tblHash, 0, n, 0);
   675    675     assert(pTree);
   676    676     assert( pTree->pCursors==0 );
   677    677     sqliteFree(pTree);
   678    678   
   679    679     if( tree->eTransState != TRANS_ROLLBACK ){
   680    680       BtRollbackOp *pRollbackOp = sqliteMalloc(sizeof(BtRollbackOp));
   681    681       if( pRollbackOp==0 ) return SQLITE_NOMEM;
................................................................................
   717    717     int wrFlag,
   718    718     RbtCursor **ppCur
   719    719   ){
   720    720     RbtCursor *pCur;
   721    721     assert(tree);
   722    722     pCur = *ppCur = sqliteMalloc(sizeof(RbtCursor));
   723    723     if( sqlite_malloc_failed ) return SQLITE_NOMEM;
   724         -  pCur->pTree  = sqliteHashFind(&tree->tblHash, 0, iTable);
          724  +  pCur->pTree  = sqlite3HashFind(&tree->tblHash, 0, iTable);
   725    725     assert( pCur->pTree );
   726    726     pCur->pRbtree = tree;
   727    727     pCur->iTree  = iTable;
   728    728     pCur->pOps = &sqliteRbtreeCursorOps;
   729    729     pCur->wrFlag = wrFlag;
   730    730     pCur->pShared = pCur->pTree->pCursors;
   731    731     pCur->pTree->pCursors = pCur;
................................................................................
  1024   1024    * Empty table n of the Rbtree.
  1025   1025    */
  1026   1026   static int memRbtreeClearTable(Rbtree* tree, int n)
  1027   1027   {
  1028   1028     BtRbTree *pTree;
  1029   1029     BtRbNode *pNode;
  1030   1030   
  1031         -  pTree = sqliteHashFind(&tree->tblHash, 0, n);
         1031  +  pTree = sqlite3HashFind(&tree->tblHash, 0, n);
  1032   1032     assert(pTree);
  1033   1033   
  1034   1034     pNode = pTree->pHead;
  1035   1035     while( pNode ){
  1036   1036       if( pNode->pLeft ){
  1037   1037         pNode = pNode->pLeft;
  1038   1038       }
................................................................................
  1302   1302   {
  1303   1303     HashElem *p;
  1304   1304     memRbtreeCommit(tree);
  1305   1305     while( (p=sqliteHashFirst(&tree->tblHash))!=0 ){
  1306   1306       tree->eTransState = TRANS_ROLLBACK;
  1307   1307       memRbtreeDropTable(tree, sqliteHashKeysize(p));
  1308   1308     }
  1309         -  sqliteHashClear(&tree->tblHash);
         1309  +  sqlite3HashClear(&tree->tblHash);
  1310   1310     sqliteFree(tree);
  1311   1311     return SQLITE_OK;
  1312   1312   }
  1313   1313   
  1314   1314   /*
  1315   1315    * Execute and delete the supplied rollback-list on pRbtree.
  1316   1316    */
................................................................................
  1321   1321     int res;
  1322   1322   
  1323   1323     cur.pRbtree = pRbtree;
  1324   1324     cur.wrFlag = 1;
  1325   1325     while( pList ){
  1326   1326       switch( pList->eOp ){
  1327   1327         case ROLLBACK_INSERT:
  1328         -        cur.pTree  = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab );
         1328  +        cur.pTree  = sqlite3HashFind( &pRbtree->tblHash, 0, pList->iTab );
  1329   1329           assert(cur.pTree);
  1330   1330           cur.iTree  = pList->iTab;
  1331   1331           cur.eSkip  = SKIP_NONE;
  1332   1332           memRbtreeInsert( &cur, pList->pKey,
  1333   1333               pList->nKey, pList->pData, pList->nData );
  1334   1334           break;
  1335   1335         case ROLLBACK_DELETE:
  1336         -        cur.pTree  = sqliteHashFind( &pRbtree->tblHash, 0, pList->iTab );
         1336  +        cur.pTree  = sqlite3HashFind( &pRbtree->tblHash, 0, pList->iTab );
  1337   1337           assert(cur.pTree);
  1338   1338           cur.iTree  = pList->iTab;
  1339   1339           cur.eSkip  = SKIP_NONE;
  1340   1340           memRbtreeMoveto(&cur, pList->pKey, pList->nKey, &res);
  1341   1341           assert(res == 0);
  1342   1342           memRbtreeDelete( &cur );
  1343   1343           break;
................................................................................
  1482   1482   #ifdef SQLITE_TEST
  1483   1483       (int(*)(BtCursor*,int*)) memRbtreeCursorDump,
  1484   1484   #endif
  1485   1485   
  1486   1486   };
  1487   1487   
  1488   1488   #endif /* SQLITE_OMIT_INMEMORYDB */
         1489  +
         1490  +
         1491  +

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.176 2004/04/23 17:04:44 drh Exp $
           26  +** $Id: build.c,v 1.177 2004/05/08 08:23:23 danielk1977 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
    34     34   ** to be read from the SQLITE_MASTER and SQLITE_TEMP_MASTER tables.
    35     35   ** If it does, then read it.
    36     36   */
    37         -void sqliteBeginParse(Parse *pParse, int explainFlag){
           37  +void sqlite3BeginParse(Parse *pParse, int explainFlag){
    38     38     sqlite *db = pParse->db;
    39     39     int i;
    40     40     pParse->explain = explainFlag;
    41     41     if((db->flags & SQLITE_Initialized)==0 && db->init.busy==0 ){
    42         -    int rc = sqliteInit(db, &pParse->zErrMsg);
           42  +    int rc = sqlite3Init(db, &pParse->zErrMsg);
    43     43       if( rc!=SQLITE_OK ){
    44     44         pParse->rc = rc;
    45     45         pParse->nErr++;
    46     46       }
    47     47     }
    48     48     for(i=0; i<db->nDb; i++){
    49     49       DbClearProperty(db, i, DB_Locked);
................................................................................
    60     60   ** that statement.  Prior action routines should have already
    61     61   ** constructed VDBE code to do the work of the SQL statement.
    62     62   ** This routine just has to execute the VDBE code.
    63     63   **
    64     64   ** Note that if an error occurred, it might be the case that
    65     65   ** no VDBE code was generated.
    66     66   */
    67         -void sqliteExec(Parse *pParse){
           67  +void sqlite3Exec(Parse *pParse){
    68     68     sqlite *db = pParse->db;
    69     69     Vdbe *v = pParse->pVdbe;
    70     70   
    71         -  if( v==0 && (v = sqliteGetVdbe(pParse))!=0 ){
    72         -    sqliteVdbeAddOp(v, OP_Halt, 0, 0);
           71  +  if( v==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
           72  +    sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
    73     73     }
    74     74     if( sqlite_malloc_failed ) return;
    75     75     if( v && pParse->nErr==0 ){
    76     76       FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0;
    77         -    sqliteVdbeTrace(v, trace);
    78         -    sqliteVdbeMakeReady(v, pParse->nVar, pParse->explain);
           77  +    sqlite3VdbeTrace(v, trace);
           78  +    sqlite3VdbeMakeReady(v, pParse->nVar, pParse->explain);
    79     79       pParse->rc = pParse->nErr ? SQLITE_ERROR : SQLITE_DONE;
    80     80       pParse->colNamesSet = 0;
    81     81     }else if( pParse->rc==SQLITE_OK ){
    82     82       pParse->rc = SQLITE_ERROR;
    83     83     }
    84     84     pParse->nTab = 0;
    85     85     pParse->nMem = 0;
................................................................................
    96     96   **
    97     97   ** If zDatabase is 0, all databases are searched for the
    98     98   ** table and the first matching table is returned.  (No checking
    99     99   ** for duplicate table names is done.)  The search order is
   100    100   ** TEMP first, then MAIN, then any auxiliary databases added
   101    101   ** using the ATTACH command.
   102    102   **
   103         -** See also sqliteLocateTable().
          103  +** See also sqlite3LocateTable().
   104    104   */
   105         -Table *sqliteFindTable(sqlite *db, const char *zName, const char *zDatabase){
          105  +Table *sqlite3FindTable(sqlite *db, const char *zName, const char *zDatabase){
   106    106     Table *p = 0;
   107    107     int i;
   108    108     for(i=0; i<db->nDb; i++){
   109    109       int j = (i<2) ? i^1 : i;   /* Search TEMP before MAIN */
   110         -    if( zDatabase!=0 && sqliteStrICmp(zDatabase, db->aDb[j].zName) ) continue;
   111         -    p = sqliteHashFind(&db->aDb[j].tblHash, zName, strlen(zName)+1);
          110  +    if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue;
          111  +    p = sqlite3HashFind(&db->aDb[j].tblHash, zName, strlen(zName)+1);
   112    112       if( p ) break;
   113    113     }
   114    114     return p;
   115    115   }
   116    116   
   117    117   /*
   118    118   ** Locate the in-memory structure that describes 
   119    119   ** a particular database table given the name
   120    120   ** of that table and (optionally) the name of the database
   121    121   ** containing the table.  Return NULL if not found.
   122    122   ** Also leave an error message in pParse->zErrMsg.
   123    123   **
   124         -** The difference between this routine and sqliteFindTable()
          124  +** The difference between this routine and sqlite3FindTable()
   125    125   ** is that this routine leaves an error message in pParse->zErrMsg
   126         -** where sqliteFindTable() does not.
          126  +** where sqlite3FindTable() does not.
   127    127   */
   128         -Table *sqliteLocateTable(Parse *pParse, const char *zName, const char *zDbase){
          128  +Table *sqlite3LocateTable(Parse *pParse, const char *zName, const char *zDbase){
   129    129     Table *p;
   130    130   
   131         -  p = sqliteFindTable(pParse->db, zName, zDbase);
          131  +  p = sqlite3FindTable(pParse->db, zName, zDbase);
   132    132     if( p==0 ){
   133    133       if( zDbase ){
   134         -      sqliteErrorMsg(pParse, "no such table: %s.%s", zDbase, zName);
   135         -    }else if( sqliteFindTable(pParse->db, zName, 0)!=0 ){
   136         -      sqliteErrorMsg(pParse, "table \"%s\" is not in database \"%s\"",
          134  +      sqlite3ErrorMsg(pParse, "no such table: %s.%s", zDbase, zName);
          135  +    }else if( sqlite3FindTable(pParse->db, zName, 0)!=0 ){
          136  +      sqlite3ErrorMsg(pParse, "table \"%s\" is not in database \"%s\"",
   137    137            zName, zDbase);
   138    138       }else{
   139         -      sqliteErrorMsg(pParse, "no such table: %s", zName);
          139  +      sqlite3ErrorMsg(pParse, "no such table: %s", zName);
   140    140       }
   141    141     }
   142    142     return p;
   143    143   }
   144    144   
   145    145   /*
   146    146   ** Locate the in-memory structure that describes 
................................................................................
   150    150   **
   151    151   ** If zDatabase is 0, all databases are searched for the
   152    152   ** table and the first matching index is returned.  (No checking
   153    153   ** for duplicate index names is done.)  The search order is
   154    154   ** TEMP first, then MAIN, then any auxiliary databases added
   155    155   ** using the ATTACH command.
   156    156   */
   157         -Index *sqliteFindIndex(sqlite *db, const char *zName, const char *zDb){
          157  +Index *sqlite3FindIndex(sqlite *db, const char *zName, const char *zDb){
   158    158     Index *p = 0;
   159    159     int i;
   160    160     for(i=0; i<db->nDb; i++){
   161    161       int j = (i<2) ? i^1 : i;  /* Search TEMP before MAIN */
   162         -    if( zDb && sqliteStrICmp(zDb, db->aDb[j].zName) ) continue;
   163         -    p = sqliteHashFind(&db->aDb[j].idxHash, zName, strlen(zName)+1);
          162  +    if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zName) ) continue;
          163  +    p = sqlite3HashFind(&db->aDb[j].idxHash, zName, strlen(zName)+1);
   164    164       if( p ) break;
   165    165     }
   166    166     return p;
   167    167   }
   168    168   
   169    169   /*
   170    170   ** Remove the given index from the index hash table, and free
................................................................................
   174    174   ** it is not unlinked from the Table that it indexes.
   175    175   ** Unlinking from the Table must be done by the calling function.
   176    176   */
   177    177   static void sqliteDeleteIndex(sqlite *db, Index *p){
   178    178     Index *pOld;
   179    179   
   180    180     assert( db!=0 && p->zName!=0 );
   181         -  pOld = sqliteHashInsert(&db->aDb[p->iDb].idxHash, p->zName,
          181  +  pOld = sqlite3HashInsert(&db->aDb[p->iDb].idxHash, p->zName,
   182    182                             strlen(p->zName)+1, 0);
   183    183     if( pOld!=0 && pOld!=p ){
   184         -    sqliteHashInsert(&db->aDb[p->iDb].idxHash, pOld->zName,
          184  +    sqlite3HashInsert(&db->aDb[p->iDb].idxHash, pOld->zName,
   185    185                        strlen(pOld->zName)+1, pOld);
   186    186     }
   187    187     sqliteFree(p);
   188    188   }
   189    189   
   190    190   /*
   191    191   ** Unlink the given index from its table, then remove
   192    192   ** the index from the index hash table and free its memory
   193    193   ** structures.
   194    194   */
   195         -void sqliteUnlinkAndDeleteIndex(sqlite *db, Index *pIndex){
          195  +void sqlite3UnlinkAndDeleteIndex(sqlite *db, Index *pIndex){
   196    196     if( pIndex->pTable->pIndex==pIndex ){
   197    197       pIndex->pTable->pIndex = pIndex->pNext;
   198    198     }else{
   199    199       Index *p;
   200    200       for(p=pIndex->pTable->pIndex; p && p->pNext!=pIndex; p=p->pNext){}
   201    201       if( p && p->pNext==pIndex ){
   202    202         p->pNext = pIndex->pNext;
................................................................................
   211    211   ** before the connection closes.  It is also called during a rollback
   212    212   ** if there were schema changes during the transaction.
   213    213   **
   214    214   ** If iDb<=0 then reset the internal schema tables for all database
   215    215   ** files.  If iDb>=2 then reset the internal schema for only the
   216    216   ** single file indicated.
   217    217   */
   218         -void sqliteResetInternalSchema(sqlite *db, int iDb){
          218  +void sqlite3ResetInternalSchema(sqlite *db, int iDb){
   219    219     HashElem *pElem;
   220    220     Hash temp1;
   221    221     Hash temp2;
   222    222     int i, j;
   223    223   
   224    224     assert( iDb>=0 && iDb<db->nDb );
   225    225     db->flags &= ~SQLITE_Initialized;
   226    226     for(i=iDb; i<db->nDb; i++){
   227    227       Db *pDb = &db->aDb[i];
   228    228       temp1 = pDb->tblHash;
   229    229       temp2 = pDb->trigHash;
   230         -    sqliteHashInit(&pDb->trigHash, SQLITE_HASH_STRING, 0);
   231         -    sqliteHashClear(&pDb->aFKey);
   232         -    sqliteHashClear(&pDb->idxHash);
          230  +    sqlite3HashInit(&pDb->trigHash, SQLITE_HASH_STRING, 0);
          231  +    sqlite3HashClear(&pDb->aFKey);
          232  +    sqlite3HashClear(&pDb->idxHash);
   233    233       for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){
   234    234         Trigger *pTrigger = sqliteHashData(pElem);
   235         -      sqliteDeleteTrigger(pTrigger);
          235  +      sqlite3DeleteTrigger(pTrigger);
   236    236       }
   237         -    sqliteHashClear(&temp2);
   238         -    sqliteHashInit(&pDb->tblHash, SQLITE_HASH_STRING, 0);
          237  +    sqlite3HashClear(&temp2);
          238  +    sqlite3HashInit(&pDb->tblHash, SQLITE_HASH_STRING, 0);
   239    239       for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){
   240    240         Table *pTab = sqliteHashData(pElem);
   241         -      sqliteDeleteTable(db, pTab);
          241  +      sqlite3DeleteTable(db, pTab);
   242    242       }
   243         -    sqliteHashClear(&temp1);
          243  +    sqlite3HashClear(&temp1);
   244    244       DbClearProperty(db, i, DB_SchemaLoaded);
   245    245       if( iDb>0 ) return;
   246    246     }
   247    247     assert( iDb==0 );
   248    248     db->flags &= ~SQLITE_InternChanges;
   249    249   
   250    250     /* If one or more of the auxiliary database files has been closed,
................................................................................
   282    282   }
   283    283   
   284    284   /*
   285    285   ** This routine is called whenever a rollback occurs.  If there were
   286    286   ** schema changes during the transaction, then we have to reset the
   287    287   ** internal hash tables and reload them from disk.
   288    288   */
   289         -void sqliteRollbackInternalChanges(sqlite *db){
          289  +void sqlite3RollbackInternalChanges(sqlite *db){
   290    290     if( db->flags & SQLITE_InternChanges ){
   291         -    sqliteResetInternalSchema(db, 0);
          291  +    sqlite3ResetInternalSchema(db, 0);
   292    292     }
   293    293   }
   294    294   
   295    295   /*
   296    296   ** This routine is called when a commit occurs.
   297    297   */
   298         -void sqliteCommitInternalChanges(sqlite *db){
          298  +void sqlite3CommitInternalChanges(sqlite *db){
   299    299     db->aDb[0].schema_cookie = db->next_cookie;
   300    300     db->flags &= ~SQLITE_InternChanges;
   301    301   }
   302    302   
   303    303   /*
   304    304   ** Remove the memory data structures associated with the given
   305    305   ** Table.  No changes are made to disk by this routine.
................................................................................
   311    311   ** the table.
   312    312   **
   313    313   ** Indices associated with the table are unlinked from the "db"
   314    314   ** data structure if db!=NULL.  If db==NULL, indices attached to
   315    315   ** the table are deleted, but it is assumed they have already been
   316    316   ** unlinked.
   317    317   */
   318         -void sqliteDeleteTable(sqlite *db, Table *pTable){
          318  +void sqlite3DeleteTable(sqlite *db, Table *pTable){
   319    319     int i;
   320    320     Index *pIndex, *pNext;
   321    321     FKey *pFKey, *pNextFKey;
   322    322   
   323    323     if( pTable==0 ) return;
   324    324   
   325    325     /* Delete all indices associated with this table
................................................................................
   332    332   
   333    333     /* Delete all foreign keys associated with this table.  The keys
   334    334     ** should have already been unlinked from the db->aFKey hash table 
   335    335     */
   336    336     for(pFKey=pTable->pFKey; pFKey; pFKey=pNextFKey){
   337    337       pNextFKey = pFKey->pNextFrom;
   338    338       assert( pTable->iDb<db->nDb );
   339         -    assert( sqliteHashFind(&db->aDb[pTable->iDb].aFKey,
          339  +    assert( sqlite3HashFind(&db->aDb[pTable->iDb].aFKey,
   340    340                              pFKey->zTo, strlen(pFKey->zTo)+1)!=pFKey );
   341    341       sqliteFree(pFKey);
   342    342     }
   343    343   
   344    344     /* Delete the Table structure itself.
   345    345     */
   346    346     for(i=0; i<pTable->nCol; i++){
   347    347       sqliteFree(pTable->aCol[i].zName);
   348    348       sqliteFree(pTable->aCol[i].zDflt);
   349    349       sqliteFree(pTable->aCol[i].zType);
   350    350     }
   351    351     sqliteFree(pTable->zName);
   352    352     sqliteFree(pTable->aCol);
   353         -  sqliteSelectDelete(pTable->pSelect);
          353  +  sqlite3SelectDelete(pTable->pSelect);
   354    354     sqliteFree(pTable);
   355    355   }
   356    356   
   357    357   /*
   358    358   ** Unlink the given table from the hash tables and the delete the
   359    359   ** table structure with all its indices and foreign keys.
   360    360   */
   361    361   static void sqliteUnlinkAndDeleteTable(sqlite *db, Table *p){
   362    362     Table *pOld;
   363    363     FKey *pF1, *pF2;
   364    364     int i = p->iDb;
   365    365     assert( db!=0 );
   366         -  pOld = sqliteHashInsert(&db->aDb[i].tblHash, p->zName, strlen(p->zName)+1, 0);
          366  +  pOld = sqlite3HashInsert(&db->aDb[i].tblHash, p->zName, strlen(p->zName)+1, 0);
   367    367     assert( pOld==0 || pOld==p );
   368    368     for(pF1=p->pFKey; pF1; pF1=pF1->pNextFrom){
   369    369       int nTo = strlen(pF1->zTo) + 1;
   370         -    pF2 = sqliteHashFind(&db->aDb[i].aFKey, pF1->zTo, nTo);
          370  +    pF2 = sqlite3HashFind(&db->aDb[i].aFKey, pF1->zTo, nTo);
   371    371       if( pF2==pF1 ){
   372         -      sqliteHashInsert(&db->aDb[i].aFKey, pF1->zTo, nTo, pF1->pNextTo);
          372  +      sqlite3HashInsert(&db->aDb[i].aFKey, pF1->zTo, nTo, pF1->pNextTo);
   373    373       }else{
   374    374         while( pF2 && pF2->pNextTo!=pF1 ){ pF2=pF2->pNextTo; }
   375    375         if( pF2 ){
   376    376           pF2->pNextTo = pF1->pNextTo;
   377    377         }
   378    378       }
   379    379     }
   380         -  sqliteDeleteTable(db, p);
          380  +  sqlite3DeleteTable(db, p);
   381    381   }
   382    382   
   383    383   /*
   384    384   ** Construct the name of a user table or index from a token.
   385    385   **
   386    386   ** Space to hold the name is obtained from sqliteMalloc() and must
   387    387   ** be freed by the calling function.
   388    388   */
   389         -char *sqliteTableNameFromToken(Token *pName){
          389  +char *sqlite3TableNameFromToken(Token *pName){
   390    390     char *zName = sqliteStrNDup(pName->z, pName->n);
   391         -  sqliteDequote(zName);
          391  +  sqlite3Dequote(zName);
   392    392     return zName;
   393    393   }
   394    394   
   395    395   /*
   396    396   ** Generate code to open the appropriate master table.  The table
   397    397   ** opened will be SQLITE_MASTER for persistent tables and 
   398    398   ** SQLITE_TEMP_MASTER for temporary tables.  The table is opened
   399    399   ** on cursor 0.
   400    400   */
   401         -void sqliteOpenMasterTable(Vdbe *v, int isTemp){
   402         -  sqliteVdbeAddOp(v, OP_Integer, isTemp, 0);
   403         -  sqliteVdbeAddOp(v, OP_OpenWrite, 0, 2);
          401  +void sqlite3OpenMasterTable(Vdbe *v, int isTemp){
          402  +  sqlite3VdbeAddOp(v, OP_Integer, isTemp, 0);
          403  +  sqlite3VdbeAddOp(v, OP_OpenWrite, 0, 2);
   404    404   }
   405    405   
   406    406   /*
   407    407   ** Begin constructing a new table representation in memory.  This is
   408    408   ** the first of several action routines that get called in response
   409    409   ** to a CREATE TABLE statement.  In particular, this routine is called
   410    410   ** after seeing tokens "CREATE" and "TABLE" and the table name.  The
................................................................................
   413    413   ** file instead of in the main database file.  This is normally the case
   414    414   ** when the "TEMP" or "TEMPORARY" keyword occurs in between
   415    415   ** CREATE and TABLE.
   416    416   **
   417    417   ** The new table record is initialized and put in pParse->pNewTable.
   418    418   ** As more of the CREATE TABLE statement is parsed, additional action
   419    419   ** routines will be called to add more information to this record.
   420         -** At the end of the CREATE TABLE statement, the sqliteEndTable() routine
          420  +** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine
   421    421   ** is called to complete the construction of the new table record.
   422    422   */
   423         -void sqliteStartTable(
          423  +void sqlite3StartTable(
   424    424     Parse *pParse,   /* Parser context */
   425    425     Token *pStart,   /* The "CREATE" token */
   426    426     Token *pName,    /* Name of table or view to create */
   427    427     int isTemp,      /* True if this is a TEMP table */
   428    428     int isView       /* True if this is a VIEW */
   429    429   ){
   430    430     Table *pTable;
................................................................................
   431    431     Index *pIdx;
   432    432     char *zName;
   433    433     sqlite *db = pParse->db;
   434    434     Vdbe *v;
   435    435     int iDb;
   436    436   
   437    437     pParse->sFirstToken = *pStart;
   438         -  zName = sqliteTableNameFromToken(pName);
          438  +  zName = sqlite3TableNameFromToken(pName);
   439    439     if( zName==0 ) return;
   440    440     if( db->init.iDb==1 ) isTemp = 1;
   441    441   #ifndef SQLITE_OMIT_AUTHORIZATION
   442    442     assert( (isTemp & 1)==isTemp );
   443    443     {
   444    444       int code;
   445    445       char *zDb = isTemp ? "temp" : "main";
   446         -    if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
          446  +    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
   447    447         sqliteFree(zName);
   448    448         return;
   449    449       }
   450    450       if( isView ){
   451    451         if( isTemp ){
   452    452           code = SQLITE_CREATE_TEMP_VIEW;
   453    453         }else{
................................................................................
   456    456       }else{
   457    457         if( isTemp ){
   458    458           code = SQLITE_CREATE_TEMP_TABLE;
   459    459         }else{
   460    460           code = SQLITE_CREATE_TABLE;
   461    461         }
   462    462       }
   463         -    if( sqliteAuthCheck(pParse, code, zName, 0, zDb) ){
          463  +    if( sqlite3AuthCheck(pParse, code, zName, 0, zDb) ){
   464    464         sqliteFree(zName);
   465    465         return;
   466    466       }
   467    467     }
   468    468   #endif
   469    469    
   470    470   
   471    471     /* Before trying to create a temporary table, make sure the Btree for
   472    472     ** holding temporary tables is open.
   473    473     */
   474    474     if( isTemp && db->aDb[1].pBt==0 && !pParse->explain ){
   475         -    int rc = sqliteBtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt);
          475  +    int rc = sqlite3BtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt);
   476    476       if( rc!=SQLITE_OK ){
   477         -      sqliteErrorMsg(pParse, "unable to open a temporary database "
          477  +      sqlite3ErrorMsg(pParse, "unable to open a temporary database "
   478    478           "file for storing temporary tables");
   479    479         pParse->nErr++;
   480    480         return;
   481    481       }
   482    482       if( db->flags & SQLITE_InTrans ){
   483         -      rc = sqliteBtreeBeginTrans(db->aDb[1].pBt);
          483  +      rc = sqlite3BtreeBeginTrans(db->aDb[1].pBt);
   484    484         if( rc!=SQLITE_OK ){
   485         -        sqliteErrorMsg(pParse, "unable to get a write lock on "
          485  +        sqlite3ErrorMsg(pParse, "unable to get a write lock on "
   486    486             "the temporary database file");
   487    487           return;
   488    488         }
   489    489       }
   490    490     }
   491    491   
   492    492     /* Make sure the new table name does not collide with an existing
   493    493     ** index or table name.  Issue an error message if it does.
   494    494     **
   495    495     ** If we are re-reading the sqlite_master table because of a schema
   496    496     ** change and a new permanent table is found whose name collides with
   497    497     ** an existing temporary table, that is not an error.
   498    498     */
   499         -  pTable = sqliteFindTable(db, zName, 0);
          499  +  pTable = sqlite3FindTable(db, zName, 0);
   500    500     iDb = isTemp ? 1 : db->init.iDb;
   501    501     if( pTable!=0 && (pTable->iDb==iDb || !db->init.busy) ){
   502         -    sqliteErrorMsg(pParse, "table %T already exists", pName);
          502  +    sqlite3ErrorMsg(pParse, "table %T already exists", pName);
   503    503       sqliteFree(zName);
   504    504       return;
   505    505     }
   506         -  if( (pIdx = sqliteFindIndex(db, zName, 0))!=0 &&
          506  +  if( (pIdx = sqlite3FindIndex(db, zName, 0))!=0 &&
   507    507             (pIdx->iDb==0 || !db->init.busy) ){
   508         -    sqliteErrorMsg(pParse, "there is already an index named %s", zName);
          508  +    sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
   509    509       sqliteFree(zName);
   510    510       return;
   511    511     }
   512    512     pTable = sqliteMalloc( sizeof(Table) );
   513    513     if( pTable==0 ){
   514    514       sqliteFree(zName);
   515    515       return;
................................................................................
   516    516     }
   517    517     pTable->zName = zName;
   518    518     pTable->nCol = 0;
   519    519     pTable->aCol = 0;
   520    520     pTable->iPKey = -1;
   521    521     pTable->pIndex = 0;
   522    522     pTable->iDb = iDb;
   523         -  if( pParse->pNewTable ) sqliteDeleteTable(db, pParse->pNewTable);
          523  +  if( pParse->pNewTable ) sqlite3DeleteTable(db, pParse->pNewTable);
   524    524     pParse->pNewTable = pTable;
   525    525   
   526    526     /* Begin generating the code that will insert the table record into
   527    527     ** the SQLITE_MASTER table.  Note in particular that we must go ahead
   528    528     ** and allocate the record number for the table entry now.  Before any
   529    529     ** PRIMARY KEY or UNIQUE keywords are parsed.  Those keywords will cause
   530    530     ** indices to be created and the table record must come before the 
   531    531     ** indices.  Hence, the record number for the table must be allocated
   532    532     ** now.
   533    533     */
   534         -  if( !db->init.busy && (v = sqliteGetVdbe(pParse))!=0 ){
   535         -    sqliteBeginWriteOperation(pParse, 0, isTemp);
          534  +  if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){
          535  +    sqlite3BeginWriteOperation(pParse, 0, isTemp);
   536    536       if( !isTemp ){
   537         -      sqliteVdbeAddOp(v, OP_Integer, db->file_format, 0);
   538         -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 1);
          537  +      sqlite3VdbeAddOp(v, OP_Integer, db->file_format, 0);
          538  +      sqlite3VdbeAddOp(v, OP_SetCookie, 0, 1);
   539    539       }
   540         -    sqliteOpenMasterTable(v, isTemp);
   541         -    sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
   542         -    sqliteVdbeAddOp(v, OP_Dup, 0, 0);
   543         -    sqliteVdbeAddOp(v, OP_String, 0, 0);
   544         -    sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0);
          540  +    sqlite3OpenMasterTable(v, isTemp);
          541  +    sqlite3VdbeAddOp(v, OP_NewRecno, 0, 0);
          542  +    sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
          543  +    sqlite3VdbeAddOp(v, OP_String, 0, 0);
          544  +    sqlite3VdbeAddOp(v, OP_PutIntKey, 0, 0);
   545    545     }
   546    546   }
   547    547   
   548    548   /*
   549    549   ** Add a new column to the table currently being constructed.
   550    550   **
   551    551   ** The parser calls this routine once for each column declaration
   552         -** in a CREATE TABLE statement.  sqliteStartTable() gets called
          552  +** in a CREATE TABLE statement.  sqlite3StartTable() gets called
   553    553   ** first to get things going.  Then this routine is called for each
   554    554   ** column.
   555    555   */
   556         -void sqliteAddColumn(Parse *pParse, Token *pName){
          556  +void sqlite3AddColumn(Parse *pParse, Token *pName){
   557    557     Table *p;
   558    558     int i;
   559    559     char *z = 0;
   560    560     Column *pCol;
   561    561     if( (p = pParse->pNewTable)==0 ) return;
   562         -  sqliteSetNString(&z, pName->z, pName->n, 0);
          562  +  sqlite3SetNString(&z, pName->z, pName->n, 0);
   563    563     if( z==0 ) return;
   564         -  sqliteDequote(z);
          564  +  sqlite3Dequote(z);
   565    565     for(i=0; i<p->nCol; i++){
   566         -    if( sqliteStrICmp(z, p->aCol[i].zName)==0 ){
   567         -      sqliteErrorMsg(pParse, "duplicate column name: %s", z);
          566  +    if( sqlite3StrICmp(z, p->aCol[i].zName)==0 ){
          567  +      sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
   568    568         sqliteFree(z);
   569    569         return;
   570    570       }
   571    571     }
   572    572     if( (p->nCol & 0x7)==0 ){
   573    573       Column *aNew;
   574    574       aNew = sqliteRealloc( p->aCol, (p->nCol+8)*sizeof(p->aCol[0]));
................................................................................
   584    584   
   585    585   /*
   586    586   ** This routine is called by the parser while in the middle of
   587    587   ** parsing a CREATE TABLE statement.  A "NOT NULL" constraint has
   588    588   ** been seen on a column.  This routine sets the notNull flag on
   589    589   ** the column currently under construction.
   590    590   */
   591         -void sqliteAddNotNull(Parse *pParse, int onError){
          591  +void sqlite3AddNotNull(Parse *pParse, int onError){
   592    592     Table *p;
   593    593     int i;
   594    594     if( (p = pParse->pNewTable)==0 ) return;
   595    595     i = p->nCol-1;
   596    596     if( i>=0 ) p->aCol[i].notNull = onError;
   597    597   }
   598    598   
................................................................................
   601    601   ** parsing a CREATE TABLE statement.  The pFirst token is the first
   602    602   ** token in the sequence of tokens that describe the type of the
   603    603   ** column currently under construction.   pLast is the last token
   604    604   ** in the sequence.  Use this information to construct a string
   605    605   ** that contains the typename of the column and store that string
   606    606   ** in zType.
   607    607   */ 
   608         -void sqliteAddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
          608  +void sqlite3AddColumnType(Parse *pParse, Token *pFirst, Token *pLast){
   609    609     Table *p;
   610    610     int i, j;
   611    611     int n;
   612    612     char *z, **pz;
   613    613     Column *pCol;
   614    614     if( (p = pParse->pNewTable)==0 ) return;
   615    615     i = p->nCol-1;
   616    616     if( i<0 ) return;
   617    617     pCol = &p->aCol[i];
   618    618     pz = &pCol->zType;
   619    619     n = pLast->n + Addr(pLast->z) - Addr(pFirst->z);
   620         -  sqliteSetNString(pz, pFirst->z, n, 0);
          620  +  sqlite3SetNString(pz, pFirst->z, n, 0);
   621    621     z = *pz;
   622    622     if( z==0 ) return;
   623    623     for(i=j=0; z[i]; i++){
   624    624       int c = z[i];
   625    625       if( isspace(c) ) continue;
   626    626       z[j++] = c;
   627    627     }
   628    628     z[j] = 0;
   629    629     if( pParse->db->file_format>=4 ){
   630         -    pCol->sortOrder = sqliteCollateType(z, n);
          630  +    pCol->sortOrder = sqlite3CollateType(z, n);
   631    631     }else{
   632    632       pCol->sortOrder = SQLITE_SO_NUM;
   633    633     }
   634    634   }
   635    635   
   636    636   /*
   637    637   ** The given token is the default value for the last column added to
   638    638   ** the table currently under construction.  If "minusFlag" is true, it
   639    639   ** means the value token was preceded by a minus sign.
   640    640   **
   641    641   ** This routine is called by the parser while in the middle of
   642    642   ** parsing a CREATE TABLE statement.
   643    643   */
   644         -void sqliteAddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){
          644  +void sqlite3AddDefaultValue(Parse *pParse, Token *pVal, int minusFlag){
   645    645     Table *p;
   646    646     int i;
   647    647     char **pz;
   648    648     if( (p = pParse->pNewTable)==0 ) return;
   649    649     i = p->nCol-1;
   650    650     if( i<0 ) return;
   651    651     pz = &p->aCol[i].zDflt;
   652    652     if( minusFlag ){
   653         -    sqliteSetNString(pz, "-", 1, pVal->z, pVal->n, 0);
          653  +    sqlite3SetNString(pz, "-", 1, pVal->z, pVal->n, 0);
   654    654     }else{
   655         -    sqliteSetNString(pz, pVal->z, pVal->n, 0);
          655  +    sqlite3SetNString(pz, pVal->z, pVal->n, 0);
   656    656     }
   657         -  sqliteDequote(*pz);
          657  +  sqlite3Dequote(*pz);
   658    658   }
   659    659   
   660    660   /*
   661    661   ** Designate the PRIMARY KEY for the table.  pList is a list of names 
   662    662   ** of columns that form the primary key.  If pList is NULL, then the
   663    663   ** most recently added column of the table is the primary key.
   664    664   **
................................................................................
   673    673   ** field of the table under construction to be the index of the
   674    674   ** INTEGER PRIMARY KEY column.  Table.iPKey is set to -1 if there is
   675    675   ** no INTEGER PRIMARY KEY.
   676    676   **
   677    677   ** If the key is not an INTEGER PRIMARY KEY, then create a unique
   678    678   ** index for the key.  No index is created for INTEGER PRIMARY KEYs.
   679    679   */
   680         -void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){
          680  +void sqlite3AddPrimaryKey(Parse *pParse, IdList *pList, int onError){
   681    681     Table *pTab = pParse->pNewTable;
   682    682     char *zType = 0;
   683    683     int iCol = -1, i;
   684    684     if( pTab==0 ) goto primary_key_exit;
   685    685     if( pTab->hasPrimKey ){
   686         -    sqliteErrorMsg(pParse, 
          686  +    sqlite3ErrorMsg(pParse, 
   687    687         "table \"%s\" has more than one primary key", pTab->zName);
   688    688       goto primary_key_exit;
   689    689     }
   690    690     pTab->hasPrimKey = 1;
   691    691     if( pList==0 ){
   692    692       iCol = pTab->nCol - 1;
   693    693       pTab->aCol[iCol].isPrimKey = 1;
   694    694     }else{
   695    695       for(i=0; i<pList->nId; i++){
   696    696         for(iCol=0; iCol<pTab->nCol; iCol++){
   697         -        if( sqliteStrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ) break;
          697  +        if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ) break;
   698    698         }
   699    699         if( iCol<pTab->nCol ) pTab->aCol[iCol].isPrimKey = 1;
   700    700       }
   701    701       if( pList->nId>1 ) iCol = -1;
   702    702     }
   703    703     if( iCol>=0 && iCol<pTab->nCol ){
   704    704       zType = pTab->aCol[iCol].zType;
   705    705     }
   706    706     if( pParse->db->file_format>=1 && 
   707         -           zType && sqliteStrICmp(zType, "INTEGER")==0 ){
          707  +           zType && sqlite3StrICmp(zType, "INTEGER")==0 ){
   708    708       pTab->iPKey = iCol;
   709    709       pTab->keyConf = onError;
   710    710     }else{
   711         -    sqliteCreateIndex(pParse, 0, 0, pList, onError, 0, 0);
          711  +    sqlite3CreateIndex(pParse, 0, 0, pList, onError, 0, 0);
   712    712       pList = 0;
   713    713     }
   714    714   
   715    715   primary_key_exit:
   716         -  sqliteIdListDelete(pList);
          716  +  sqlite3IdListDelete(pList);
   717    717     return;
   718    718   }
   719    719   
   720    720   /*
   721    721   ** Return the appropriate collating type given a type name.
   722    722   **
   723    723   ** The collation type is text (SQLITE_SO_TEXT) if the type
   724    724   ** name contains the character stream "text" or "blob" or
   725    725   ** "clob".  Any other type name is collated as numeric
   726    726   ** (SQLITE_SO_NUM).
   727    727   */
   728         -int sqliteCollateType(const char *zType, int nType){
          728  +int sqlite3CollateType(const char *zType, int nType){
   729    729     int i;
   730    730     for(i=0; i<nType-3; i++){
   731    731       int c = *(zType++) | 0x60;
   732         -    if( (c=='b' || c=='c') && sqliteStrNICmp(zType, "lob", 3)==0 ){
          732  +    if( (c=='b' || c=='c') && sqlite3StrNICmp(zType, "lob", 3)==0 ){
   733    733         return SQLITE_SO_TEXT;
   734    734       }
   735         -    if( c=='c' && sqliteStrNICmp(zType, "har", 3)==0 ){
          735  +    if( c=='c' && sqlite3StrNICmp(zType, "har", 3)==0 ){
   736    736         return SQLITE_SO_TEXT;
   737    737       }
   738         -    if( c=='t' && sqliteStrNICmp(zType, "ext", 3)==0 ){
          738  +    if( c=='t' && sqlite3StrNICmp(zType, "ext", 3)==0 ){
   739    739         return SQLITE_SO_TEXT;
   740    740       }
   741    741     }
   742    742     return SQLITE_SO_NUM;
   743    743   }
   744    744   
   745    745   /*
   746    746   ** This routine is called by the parser while in the middle of
   747    747   ** parsing a CREATE TABLE statement.  A "COLLATE" clause has
   748    748   ** been seen on a column.  This routine sets the Column.sortOrder on
   749    749   ** the column currently under construction.
   750    750   */
   751         -void sqliteAddCollateType(Parse *pParse, int collType){
          751  +void sqlite3AddCollateType(Parse *pParse, int collType){
   752    752     Table *p;
   753    753     int i;
   754    754     if( (p = pParse->pNewTable)==0 ) return;
   755    755     i = p->nCol-1;
   756    756     if( i>=0 ) p->aCol[i].sortOrder = collType;
   757    757   }
   758    758   
................................................................................
   769    769   **
   770    770   ** This plan is not completely bullet-proof.  It is possible for
   771    771   ** the schema to change multiple times and for the cookie to be
   772    772   ** set back to prior value.  But schema changes are infrequent
   773    773   ** and the probability of hitting the same cookie value is only
   774    774   ** 1 chance in 2^32.  So we're safe enough.
   775    775   */
   776         -void sqliteChangeCookie(sqlite *db, Vdbe *v){
          776  +void sqlite3ChangeCookie(sqlite *db, Vdbe *v){
   777    777     if( db->next_cookie==db->aDb[0].schema_cookie ){
   778    778       unsigned char r;
   779         -    sqliteRandomness(1, &r);
          779  +    sqlite3Randomness(1, &r);
   780    780       db->next_cookie = db->aDb[0].schema_cookie + r + 1;
   781    781       db->flags |= SQLITE_InternChanges;
   782         -    sqliteVdbeAddOp(v, OP_Integer, db->next_cookie, 0);
   783         -    sqliteVdbeAddOp(v, OP_SetCookie, 0, 0);
          782  +    sqlite3VdbeAddOp(v, OP_Integer, db->next_cookie, 0);
          783  +    sqlite3VdbeAddOp(v, OP_SetCookie, 0, 0);
   784    784     }
   785    785   }
   786    786   
   787    787   /*
   788    788   ** Measure the number of characters needed to output the given
   789    789   ** identifier.  The number returned includes any quotes used
   790    790   ** but does not include the null terminator.
................................................................................
   805    805   static void identPut(char *z, int *pIdx, char *zIdent){
   806    806     int i, j, needQuote;
   807    807     i = *pIdx;
   808    808     for(j=0; zIdent[j]; j++){
   809    809       if( !isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
   810    810     }
   811    811     needQuote =  zIdent[j]!=0 || isdigit(zIdent[0])
   812         -                  || sqliteKeywordCode(zIdent, j)!=TK_ID;
          812  +                  || sqlite3KeywordCode(zIdent, j)!=TK_ID;
   813    813     if( needQuote ) z[i++] = '\'';
   814    814     for(j=0; zIdent[j]; j++){
   815    815       z[i++] = zIdent[j];
   816    816       if( zIdent[j]=='\'' ) z[i++] = '\'';
   817    817     }
   818    818     if( needQuote ) z[i++] = '\'';
   819    819     z[i] = 0;
................................................................................
   876    876   ** the sqlite_master table.  We do not want to create it again.
   877    877   **
   878    878   ** If the pSelect argument is not NULL, it means that this routine
   879    879   ** was called to create a table generated from a 
   880    880   ** "CREATE TABLE ... AS SELECT ..." statement.  The column names of
   881    881   ** the new table will match the result set of the SELECT.
   882    882   */
   883         -void sqliteEndTable(Parse *pParse, Token *pEnd, Select *pSelect){
          883  +void sqlite3EndTable(Parse *pParse, Token *pEnd, Select *pSelect){
   884    884     Table *p;
   885    885     sqlite *db = pParse->db;
   886    886   
   887    887     if( (pEnd==0 && pSelect==0) || pParse->nErr || sqlite_malloc_failed ) return;
   888    888     p = pParse->pNewTable;
   889    889     if( p==0 ) return;
   890    890   
   891    891     /* If the table is generated from a SELECT, then construct the
   892    892     ** list of columns and the text of the table.
   893    893     */
   894    894     if( pSelect ){
   895         -    Table *pSelTab = sqliteResultSetOfSelect(pParse, 0, pSelect);
          895  +    Table *pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSelect);
   896    896       if( pSelTab==0 ) return;
   897    897       assert( p->aCol==0 );
   898    898       p->nCol = pSelTab->nCol;
   899    899       p->aCol = pSelTab->aCol;
   900    900       pSelTab->nCol = 0;
   901    901       pSelTab->aCol = 0;
   902         -    sqliteDeleteTable(0, pSelTab);
          902  +    sqlite3DeleteTable(0, pSelTab);
   903    903     }
   904    904   
   905    905     /* If the db->init.busy is 1 it means we are reading the SQL off the
   906    906     ** "sqlite_master" or "sqlite_temp_master" table on the disk.
   907    907     ** So do not write to the disk again.  Extract the root page number
   908    908     ** for the table from the db->init.newTnum field.  (The page number
   909    909     ** should have been put there by the sqliteOpenCb routine.)
................................................................................
   919    919     ** If this is a TEMPORARY table, write the entry into the auxiliary
   920    920     ** file instead of into the main database file.
   921    921     */
   922    922     if( !db->init.busy ){
   923    923       int n;
   924    924       Vdbe *v;
   925    925   
   926         -    v = sqliteGetVdbe(pParse);
          926  +    v = sqlite3GetVdbe(pParse);
   927    927       if( v==0 ) return;
   928    928       if( p->pSelect==0 ){
   929    929         /* A regular table */
   930         -      sqliteVdbeOp3(v, OP_CreateTable, 0, p->iDb, (char*)&p->tnum, P3_POINTER);
          930  +      sqlite3VdbeOp3(v, OP_CreateTable, 0, p->iDb, (char*)&p->tnum, P3_POINTER);
   931    931       }else{
   932    932         /* A view */
   933         -      sqliteVdbeAddOp(v, OP_Integer, 0, 0);
          933  +      sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
   934    934       }
   935    935       p->tnum = 0;
   936         -    sqliteVdbeAddOp(v, OP_Pull, 1, 0);
   937         -    sqliteVdbeOp3(v, OP_String, 0, 0, p->pSelect==0?"table":"view", P3_STATIC);
   938         -    sqliteVdbeOp3(v, OP_String, 0, 0, p->zName, 0);
   939         -    sqliteVdbeOp3(v, OP_String, 0, 0, p->zName, 0);
   940         -    sqliteVdbeAddOp(v, OP_Dup, 4, 0);
   941         -    sqliteVdbeAddOp(v, OP_String, 0, 0);
          936  +    sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
          937  +    sqlite3VdbeOp3(v, OP_String, 0, 0, p->pSelect==0?"table":"view", P3_STATIC);
          938  +    sqlite3VdbeOp3(v, OP_String, 0, 0, p->zName, 0);
          939  +    sqlite3VdbeOp3(v, OP_String, 0, 0, p->zName, 0);
          940  +    sqlite3VdbeAddOp(v, OP_Dup, 4, 0);
          941  +    sqlite3VdbeAddOp(v, OP_String, 0, 0);
   942    942       if( pSelect ){
   943    943         char *z = createTableStmt(p);
   944    944         n = z ? strlen(z) : 0;
   945         -      sqliteVdbeChangeP3(v, -1, z, n);
          945  +      sqlite3VdbeChangeP3(v, -1, z, n);
   946    946         sqliteFree(z);
   947    947       }else{
   948    948         assert( pEnd!=0 );
   949    949         n = Addr(pEnd->z) - Addr(pParse->sFirstToken.z) + 1;
   950         -      sqliteVdbeChangeP3(v, -1, pParse->sFirstToken.z, n);
          950  +      sqlite3VdbeChangeP3(v, -1, pParse->sFirstToken.z, n);
   951    951       }
   952         -    sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);
   953         -    sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0);
          952  +    sqlite3VdbeAddOp(v, OP_MakeRecord, 5, 0);
          953  +    sqlite3VdbeAddOp(v, OP_PutIntKey, 0, 0);
   954    954       if( !p->iDb ){
   955         -      sqliteChangeCookie(db, v);
          955  +      sqlite3ChangeCookie(db, v);
   956    956       }
   957         -    sqliteVdbeAddOp(v, OP_Close, 0, 0);
          957  +    sqlite3VdbeAddOp(v, OP_Close, 0, 0);
   958    958       if( pSelect ){
   959         -      sqliteVdbeAddOp(v, OP_Integer, p->iDb, 0);
   960         -      sqliteVdbeAddOp(v, OP_OpenWrite, 1, 0);
          959  +      sqlite3VdbeAddOp(v, OP_Integer, p->iDb, 0);
          960  +      sqlite3VdbeAddOp(v, OP_OpenWrite, 1, 0);
   961    961         pParse->nTab = 2;
   962         -      sqliteSelect(pParse, pSelect, SRT_Table, 1, 0, 0, 0);
          962  +      sqlite3Select(pParse, pSelect, SRT_Table, 1, 0, 0, 0);
   963    963       }
   964         -    sqliteEndWriteOperation(pParse);
          964  +    sqlite3EndWriteOperation(pParse);
   965    965     }
   966    966   
   967    967     /* Add the table to the in-memory representation of the database.
   968    968     */
   969    969     if( pParse->explain==0 && pParse->nErr==0 ){
   970    970       Table *pOld;
   971    971       FKey *pFKey;
   972         -    pOld = sqliteHashInsert(&db->aDb[p->iDb].tblHash, 
          972  +    pOld = sqlite3HashInsert(&db->aDb[p->iDb].tblHash, 
   973    973                               p->zName, strlen(p->zName)+1, p);
   974    974       if( pOld ){
   975    975         assert( p==pOld );  /* Malloc must have failed inside HashInsert() */
   976    976         return;
   977    977       }
   978    978       for(pFKey=p->pFKey; pFKey; pFKey=pFKey->pNextFrom){
   979    979         int nTo = strlen(pFKey->zTo) + 1;
   980         -      pFKey->pNextTo = sqliteHashFind(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo);
   981         -      sqliteHashInsert(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo, pFKey);
          980  +      pFKey->pNextTo = sqlite3HashFind(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo);
          981  +      sqlite3HashInsert(&db->aDb[p->iDb].aFKey, pFKey->zTo, nTo, pFKey);
   982    982       }
   983    983       pParse->pNewTable = 0;
   984    984       db->nTable++;
   985    985       db->flags |= SQLITE_InternChanges;
   986    986     }
   987    987   }
   988    988   
   989    989   /*
   990    990   ** The parser calls this routine in order to create a new VIEW
   991    991   */
   992         -void sqliteCreateView(
          992  +void sqlite3CreateView(
   993    993     Parse *pParse,     /* The parsing context */
   994    994     Token *pBegin,     /* The CREATE token that begins the statement */
   995    995     Token *pName,      /* The token that holds the name of the view */
   996    996     Select *pSelect,   /* A SELECT statement that will become the new view */
   997    997     int isTemp         /* TRUE for a TEMPORARY view */
   998    998   ){
   999    999     Table *p;
  1000   1000     int n;
  1001   1001     const char *z;
  1002   1002     Token sEnd;
  1003   1003     DbFixer sFix;
  1004   1004   
  1005         -  sqliteStartTable(pParse, pBegin, pName, isTemp, 1);
         1005  +  sqlite3StartTable(pParse, pBegin, pName, isTemp, 1);
  1006   1006     p = pParse->pNewTable;
  1007   1007     if( p==0 || pParse->nErr ){
  1008         -    sqliteSelectDelete(pSelect);
         1008  +    sqlite3SelectDelete(pSelect);
  1009   1009       return;
  1010   1010     }
  1011         -  if( sqliteFixInit(&sFix, pParse, p->iDb, "view", pName)
  1012         -    && sqliteFixSelect(&sFix, pSelect)
         1011  +  if( sqlite3FixInit(&sFix, pParse, p->iDb, "view", pName)
         1012  +    && sqlite3FixSelect(&sFix, pSelect)
  1013   1013     ){
  1014         -    sqliteSelectDelete(pSelect);
         1014  +    sqlite3SelectDelete(pSelect);
  1015   1015       return;
  1016   1016     }
  1017   1017   
  1018   1018     /* Make a copy of the entire SELECT statement that defines the view.
  1019   1019     ** This will force all the Expr.token.z values to be dynamically
  1020   1020     ** allocated rather than point to the input string - which means that
  1021   1021     ** they will persist after the current sqlite_exec() call returns.
  1022   1022     */
  1023         -  p->pSelect = sqliteSelectDup(pSelect);
  1024         -  sqliteSelectDelete(pSelect);
         1023  +  p->pSelect = sqlite3SelectDup(pSelect);
         1024  +  sqlite3SelectDelete(pSelect);
  1025   1025     if( !pParse->db->init.busy ){
  1026         -    sqliteViewGetColumnNames(pParse, p);
         1026  +    sqlite3ViewGetColumnNames(pParse, p);
  1027   1027     }
  1028   1028   
  1029   1029     /* Locate the end of the CREATE VIEW statement.  Make sEnd point to
  1030   1030     ** the end.
  1031   1031     */
  1032   1032     sEnd = pParse->sLastToken;
  1033   1033     if( sEnd.z[0]!=0 && sEnd.z[0]!=';' ){
................................................................................
  1036   1036     sEnd.n = 0;
  1037   1037     n = ((int)sEnd.z) - (int)pBegin->z;
  1038   1038     z = pBegin->z;
  1039   1039     while( n>0 && (z[n-1]==';' || isspace(z[n-1])) ){ n--; }
  1040   1040     sEnd.z = &z[n-1];
  1041   1041     sEnd.n = 1;
  1042   1042   
  1043         -  /* Use sqliteEndTable() to add the view to the SQLITE_MASTER table */
  1044         -  sqliteEndTable(pParse, &sEnd, 0);
         1043  +  /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */
         1044  +  sqlite3EndTable(pParse, &sEnd, 0);
  1045   1045     return;
  1046   1046   }
  1047   1047   
  1048   1048   /*
  1049   1049   ** The Table structure pTable is really a VIEW.  Fill in the names of
  1050   1050   ** the columns of the view in the pTable structure.  Return the number
  1051   1051   ** of errors.  If an error is seen leave an error message in pParse->zErrMsg.
  1052   1052   */
  1053         -int sqliteViewGetColumnNames(Parse *pParse, Table *pTable){
         1053  +int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
  1054   1054     ExprList *pEList;
  1055   1055     Select *pSel;
  1056   1056     Table *pSelTab;
  1057   1057     int nErr = 0;
  1058   1058   
  1059   1059     assert( pTable );
  1060   1060   
................................................................................
  1070   1070     **     CREATE VIEW one AS SELECT * FROM two;
  1071   1071     **     CREATE VIEW two AS SELECT * FROM one;
  1072   1072     **
  1073   1073     ** Actually, this error is caught previously and so the following test
  1074   1074     ** should always fail.  But we will leave it in place just to be safe.
  1075   1075     */
  1076   1076     if( pTable->nCol<0 ){
  1077         -    sqliteErrorMsg(pParse, "view %s is circularly defined", pTable->zName);
         1077  +    sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable->zName);
  1078   1078       return 1;
  1079   1079     }
  1080   1080   
  1081   1081     /* If we get this far, it means we need to compute the table names.
  1082   1082     */
  1083   1083     assert( pTable->pSelect ); /* If nCol==0, then pTable must be a VIEW */
  1084   1084     pSel = pTable->pSelect;
  1085   1085   
  1086         -  /* Note that the call to sqliteResultSetOfSelect() will expand any
         1086  +  /* Note that the call to sqlite3ResultSetOfSelect() will expand any
  1087   1087     ** "*" elements in this list.  But we will need to restore the list
  1088   1088     ** back to its original configuration afterwards, so we save a copy of
  1089   1089     ** the original in pEList.
  1090   1090     */
  1091   1091     pEList = pSel->pEList;
  1092         -  pSel->pEList = sqliteExprListDup(pEList);
         1092  +  pSel->pEList = sqlite3ExprListDup(pEList);
  1093   1093     if( pSel->pEList==0 ){
  1094   1094       pSel->pEList = pEList;
  1095   1095       return 1;  /* Malloc failed */
  1096   1096     }
  1097   1097     pTable->nCol = -1;
  1098         -  pSelTab = sqliteResultSetOfSelect(pParse, 0, pSel);
         1098  +  pSelTab = sqlite3ResultSetOfSelect(pParse, 0, pSel);
  1099   1099     if( pSelTab ){
  1100   1100       assert( pTable->aCol==0 );
  1101   1101       pTable->nCol = pSelTab->nCol;
  1102   1102       pTable->aCol = pSelTab->aCol;
  1103   1103       pSelTab->nCol = 0;
  1104   1104       pSelTab->aCol = 0;
  1105         -    sqliteDeleteTable(0, pSelTab);
         1105  +    sqlite3DeleteTable(0, pSelTab);
  1106   1106       DbSetProperty(pParse->db, pTable->iDb, DB_UnresetViews);
  1107   1107     }else{
  1108   1108       pTable->nCol = 0;
  1109   1109       nErr++;
  1110   1110     }
  1111         -  sqliteSelectUnbind(pSel);
  1112         -  sqliteExprListDelete(pSel->pEList);
         1111  +  sqlite3SelectUnbind(pSel);
         1112  +  sqlite3ExprListDelete(pSel->pEList);
  1113   1113     pSel->pEList = pEList;
  1114   1114     return nErr;  
  1115   1115   }
  1116   1116   
  1117   1117   /*
  1118   1118   ** Clear the column names from the VIEW pTable.
  1119   1119   **
................................................................................
  1151   1151     DbClearProperty(db, idx, DB_UnresetViews);
  1152   1152   }
  1153   1153   
  1154   1154   /*
  1155   1155   ** Given a token, look up a table with that name.  If not found, leave
  1156   1156   ** an error for the parser to find and return NULL.
  1157   1157   */
  1158         -Table *sqliteTableFromToken(Parse *pParse, Token *pTok){
         1158  +Table *sqlite3TableFromToken(Parse *pParse, Token *pTok){
  1159   1159     char *zName;
  1160   1160     Table *pTab;
  1161         -  zName = sqliteTableNameFromToken(pTok);
         1161  +  zName = sqlite3TableNameFromToken(pTok);
  1162   1162     if( zName==0 ) return 0;
  1163         -  pTab = sqliteFindTable(pParse->db, zName, 0);
         1163  +  pTab = sqlite3FindTable(pParse->db, zName, 0);
  1164   1164     sqliteFree(zName);
  1165   1165     if( pTab==0 ){
  1166         -    sqliteErrorMsg(pParse, "no such table: %T", pTok);
         1166  +    sqlite3ErrorMsg(pParse, "no such table: %T", pTok);
  1167   1167     }
  1168   1168     return pTab;
  1169   1169   }
  1170   1170   
  1171   1171   /*
  1172   1172   ** This routine is called to do the work of a DROP TABLE statement.
  1173   1173   ** pName is the name of the table to be dropped.
  1174   1174   */
  1175         -void sqliteDropTable(Parse *pParse, Token *pName, int isView){
         1175  +void sqlite3DropTable(Parse *pParse, Token *pName, int isView){
  1176   1176     Table *pTable;
  1177   1177     Vdbe *v;
  1178   1178     int base;
  1179   1179     sqlite *db = pParse->db;
  1180   1180     int iDb;
  1181   1181   
  1182   1182     if( pParse->nErr || sqlite_malloc_failed ) return;
  1183         -  pTable = sqliteTableFromToken(pParse, pName);
         1183  +  pTable = sqlite3TableFromToken(pParse, pName);
  1184   1184     if( pTable==0 ) return;
  1185   1185     iDb = pTable->iDb;
  1186   1186     assert( iDb>=0 && iDb<db->nDb );
  1187   1187   #ifndef SQLITE_OMIT_AUTHORIZATION
  1188   1188     {
  1189   1189       int code;
  1190   1190       const char *zTab = SCHEMA_TABLE(pTable->iDb);
  1191   1191       const char *zDb = db->aDb[pTable->iDb].zName;
  1192         -    if( sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){
         1192  +    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){
  1193   1193         return;
  1194   1194       }
  1195   1195       if( isView ){
  1196   1196         if( iDb==1 ){
  1197   1197           code = SQLITE_DROP_TEMP_VIEW;
  1198   1198         }else{
  1199   1199           code = SQLITE_DROP_VIEW;
................................................................................
  1201   1201       }else{
  1202   1202         if( iDb==1 ){
  1203   1203           code = SQLITE_DROP_TEMP_TABLE;
  1204   1204         }else{
  1205   1205           code = SQLITE_DROP_TABLE;
  1206   1206         }
  1207   1207       }
  1208         -    if( sqliteAuthCheck(pParse, code, pTable->zName, 0, zDb) ){
         1208  +    if( sqlite3AuthCheck(pParse, code, pTable->zName, 0, zDb) ){
  1209   1209         return;
  1210   1210       }
  1211         -    if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0, zDb) ){
         1211  +    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTable->zName, 0, zDb) ){
  1212   1212         return;
  1213   1213       }
  1214   1214     }
  1215   1215   #endif
  1216   1216     if( pTable->readOnly ){
  1217         -    sqliteErrorMsg(pParse, "table %s may not be dropped", pTable->zName);
         1217  +    sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTable->zName);
  1218   1218       pParse->nErr++;
  1219   1219       return;
  1220   1220     }
  1221   1221     if( isView && pTable->pSelect==0 ){
  1222         -    sqliteErrorMsg(pParse, "use DROP TABLE to delete table %s", pTable->zName);
         1222  +    sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTable->zName);
  1223   1223       return;
  1224   1224     }
  1225   1225     if( !isView && pTable->pSelect ){
  1226         -    sqliteErrorMsg(pParse, "use DROP VIEW to delete view %s", pTable->zName);
         1226  +    sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTable->zName);
  1227   1227       return;
  1228   1228     }
  1229   1229   
  1230   1230     /* Generate code to remove the table from the master table
  1231   1231     ** on disk.
  1232   1232     */
  1233         -  v = sqliteGetVdbe(pParse);
         1233  +  v = sqlite3GetVdbe(pParse);
  1234   1234     if( v ){
  1235   1235       static VdbeOpList dropTable[] = {
  1236   1236         { OP_Rewind,     0, ADDR(8),  0},
  1237   1237         { OP_String,     0, 0,        0}, /* 1 */
  1238   1238         { OP_MemStore,   1, 1,        0},
  1239   1239         { OP_MemLoad,    1, 0,        0}, /* 3 */
  1240   1240         { OP_Column,     0, 2,        0},
  1241   1241         { OP_Ne,         0, ADDR(7),  0},
  1242   1242         { OP_Delete,     0, 0,        0},
  1243   1243         { OP_Next,       0, ADDR(3),  0}, /* 7 */
  1244   1244       };
  1245   1245       Index *pIdx;
  1246   1246       Trigger *pTrigger;
  1247         -    sqliteBeginWriteOperation(pParse, 0, pTable->iDb);
         1247  +    sqlite3BeginWriteOperation(pParse, 0, pTable->iDb);
  1248   1248   
  1249   1249       /* Drop all triggers associated with the table being dropped */
  1250   1250       pTrigger = pTable->pTrigger;
  1251   1251       while( pTrigger ){
  1252   1252         assert( pTrigger->iDb==pTable->iDb || pTrigger->iDb==1 );
  1253         -      sqliteDropTriggerPtr(pParse, pTrigger, 1);
         1253  +      sqlite3DropTriggerPtr(pParse, pTrigger, 1);
  1254   1254         if( pParse->explain ){
  1255   1255           pTrigger = pTrigger->pNext;
  1256   1256         }else{
  1257   1257           pTrigger = pTable->pTrigger;
  1258   1258         }
  1259   1259       }
  1260   1260   
  1261   1261       /* Drop all SQLITE_MASTER entries that refer to the table */
  1262         -    sqliteOpenMasterTable(v, pTable->iDb);
  1263         -    base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable);
  1264         -    sqliteVdbeChangeP3(v, base+1, pTable->zName, 0);
         1262  +    sqlite3OpenMasterTable(v, pTable->iDb);
         1263  +    base = sqlite3VdbeAddOpList(v, ArraySize(dropTable), dropTable);
         1264  +    sqlite3VdbeChangeP3(v, base+1, pTable->zName, 0);
  1265   1265   
  1266   1266       /* Drop all SQLITE_TEMP_MASTER entries that refer to the table */
  1267   1267       if( pTable->iDb!=1 ){
  1268         -      sqliteOpenMasterTable(v, 1);
  1269         -      base = sqliteVdbeAddOpList(v, ArraySize(dropTable), dropTable);
  1270         -      sqliteVdbeChangeP3(v, base+1, pTable->zName, 0);
         1268  +      sqlite3OpenMasterTable(v, 1);
         1269  +      base = sqlite3VdbeAddOpList(v, ArraySize(dropTable), dropTable);
         1270  +      sqlite3VdbeChangeP3(v, base+1, pTable->zName, 0);
  1271   1271       }
  1272   1272   
  1273   1273       if( pTable->iDb==0 ){
  1274         -      sqliteChangeCookie(db, v);
         1274  +      sqlite3ChangeCookie(db, v);
  1275   1275       }
  1276         -    sqliteVdbeAddOp(v, OP_Close, 0, 0);
         1276  +    sqlite3VdbeAddOp(v, OP_Close, 0, 0);
  1277   1277       if( !isView ){
  1278         -      sqliteVdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->iDb);
         1278  +      sqlite3VdbeAddOp(v, OP_Destroy, pTable->tnum, pTable->iDb);
  1279   1279         for(pIdx=pTable->pIndex; pIdx; pIdx=pIdx->pNext){
  1280         -        sqliteVdbeAddOp(v, OP_Destroy, pIdx->tnum, pIdx->iDb);
         1280  +        sqlite3VdbeAddOp(v, OP_Destroy, pIdx->tnum, pIdx->iDb);
  1281   1281         }
  1282   1282       }
  1283         -    sqliteEndWriteOperation(pParse);
         1283  +    sqlite3EndWriteOperation(pParse);
  1284   1284     }
  1285   1285   
  1286   1286     /* Delete the in-memory description of the table.
  1287   1287     **
  1288   1288     ** Exception: if the SQL statement began with the EXPLAIN keyword,
  1289   1289     ** then no changes should be made.
  1290   1290     */
................................................................................
  1299   1299   ** This routine constructs a P3 string suitable for an OP_MakeIdxKey
  1300   1300   ** opcode and adds that P3 string to the most recently inserted instruction
  1301   1301   ** in the virtual machine.  The P3 string consists of a single character
  1302   1302   ** for each column in the index pIdx of table pTab.  If the column uses
  1303   1303   ** a numeric sort order, then the P3 string character corresponding to
  1304   1304   ** that column is 'n'.  If the column uses a text sort order, then the
  1305   1305   ** P3 string is 't'.  See the OP_MakeIdxKey opcode documentation for
  1306         -** additional information.  See also the sqliteAddKeyType() routine.
         1306  +** additional information.  See also the sqlite3AddKeyType() routine.
  1307   1307   */
  1308         -void sqliteAddIdxKeyType(Vdbe *v, Index *pIdx){
         1308  +void sqlite3AddIdxKeyType(Vdbe *v, Index *pIdx){
  1309   1309     char *zType;
  1310   1310     Table *pTab;
  1311   1311     int i, n;
  1312   1312     assert( pIdx!=0 && pIdx->pTable!=0 );
  1313   1313     pTab = pIdx->pTable;
  1314   1314     n = pIdx->nColumn;
  1315   1315     zType = sqliteMallocRaw( n+1 );
................................................................................
  1320   1320       if( (pTab->aCol[iCol].sortOrder & SQLITE_SO_TYPEMASK)==SQLITE_SO_TEXT ){
  1321   1321         zType[i] = 't';
  1322   1322       }else{
  1323   1323         zType[i] = 'n';
  1324   1324       }
  1325   1325     }
  1326   1326     zType[n] = 0;
  1327         -  sqliteVdbeChangeP3(v, -1, zType, n);
         1327  +  sqlite3VdbeChangeP3(v, -1, zType, n);
  1328   1328     sqliteFree(zType);
  1329   1329   }
  1330   1330   
  1331   1331   /*
  1332   1332   ** This routine is called to create a new foreign key on the table
  1333   1333   ** currently under construction.  pFromCol determines which columns
  1334   1334   ** in the current table point to the foreign key.  If pFromCol==0 then
................................................................................
  1337   1337   ** pTo table that the foreign key points to.  flags contains all
  1338   1338   ** information about the conflict resolution algorithms specified
  1339   1339   ** in the ON DELETE, ON UPDATE and ON INSERT clauses.
  1340   1340   **
  1341   1341   ** An FKey structure is created and added to the table currently
  1342   1342   ** under construction in the pParse->pNewTable field.  The new FKey
  1343   1343   ** is not linked into db->aFKey at this point - that does not happen
  1344         -** until sqliteEndTable().
         1344  +** until sqlite3EndTable().
  1345   1345   **
  1346   1346   ** The foreign key is set for IMMEDIATE processing.  A subsequent call
  1347         -** to sqliteDeferForeignKey() might change this to DEFERRED.
         1347  +** to sqlite3DeferForeignKey() might change this to DEFERRED.
  1348   1348   */
  1349         -void sqliteCreateForeignKey(
         1349  +void sqlite3CreateForeignKey(
  1350   1350     Parse *pParse,       /* Parsing context */
  1351   1351     IdList *pFromCol,    /* Columns in this table that point to other table */
  1352   1352     Token *pTo,          /* Name of the other table */
  1353   1353     IdList *pToCol,      /* Columns in the other table */
  1354   1354     int flags            /* Conflict resolution algorithms. */
  1355   1355   ){
  1356   1356     Table *p = pParse->pNewTable;
................................................................................
  1362   1362   
  1363   1363     assert( pTo!=0 );
  1364   1364     if( p==0 || pParse->nErr ) goto fk_end;
  1365   1365     if( pFromCol==0 ){
  1366   1366       int iCol = p->nCol-1;
  1367   1367       if( iCol<0 ) goto fk_end;
  1368   1368       if( pToCol && pToCol->nId!=1 ){
  1369         -      sqliteErrorMsg(pParse, "foreign key on %s"
         1369  +      sqlite3ErrorMsg(pParse, "foreign key on %s"
  1370   1370            " should reference only one column of table %T",
  1371   1371            p->aCol[iCol].zName, pTo);
  1372   1372         goto fk_end;
  1373   1373       }
  1374   1374       nCol = 1;
  1375   1375     }else if( pToCol && pToCol->nId!=pFromCol->nId ){
  1376         -    sqliteErrorMsg(pParse,
         1376  +    sqlite3ErrorMsg(pParse,
  1377   1377           "number of columns in foreign key does not match the number of "
  1378   1378           "columns in the referenced table");
  1379   1379       goto fk_end;
  1380   1380     }else{
  1381   1381       nCol = pFromCol->nId;
  1382   1382     }
  1383   1383     nByte = sizeof(*pFKey) + nCol*sizeof(pFKey->aCol[0]) + pTo->n + 1;
................................................................................
  1401   1401     pFKey->nCol = nCol;
  1402   1402     if( pFromCol==0 ){
  1403   1403       pFKey->aCol[0].iFrom = p->nCol-1;
  1404   1404     }else{
  1405   1405       for(i=0; i<nCol; i++){
  1406   1406         int j;
  1407   1407         for(j=0; j<p->nCol; j++){
  1408         -        if( sqliteStrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){
         1408  +        if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){
  1409   1409             pFKey->aCol[i].iFrom = j;
  1410   1410             break;
  1411   1411           }
  1412   1412         }
  1413   1413         if( j>=p->nCol ){
  1414         -        sqliteErrorMsg(pParse, 
         1414  +        sqlite3ErrorMsg(pParse, 
  1415   1415             "unknown column \"%s\" in foreign key definition", 
  1416   1416             pFromCol->a[i].zName);
  1417   1417           goto fk_end;
  1418   1418         }
  1419   1419       }
  1420   1420     }
  1421   1421     if( pToCol ){
................................................................................
  1435   1435     /* Link the foreign key to the table as the last step.
  1436   1436     */
  1437   1437     p->pFKey = pFKey;
  1438   1438     pFKey = 0;
  1439   1439   
  1440   1440   fk_end:
  1441   1441     sqliteFree(pFKey);
  1442         -  sqliteIdListDelete(pFromCol);
  1443         -  sqliteIdListDelete(pToCol);
         1442  +  sqlite3IdListDelete(pFromCol);
         1443  +  sqlite3IdListDelete(pToCol);
  1444   1444   }
  1445   1445   
  1446   1446   /*
  1447   1447   ** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED
  1448   1448   ** clause is seen as part of a foreign key definition.  The isDeferred
  1449   1449   ** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.
  1450   1450   ** The behavior of the most recently created foreign key is adjusted
  1451   1451   ** accordingly.
  1452   1452   */
  1453         -void sqliteDeferForeignKey(Parse *pParse, int isDeferred){
         1453  +void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){
  1454   1454     Table *pTab;
  1455   1455     FKey *pFKey;
  1456   1456     if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
  1457   1457     pFKey->isDeferred = isDeferred;
  1458   1458   }
  1459   1459   
  1460   1460   /*
................................................................................
  1465   1465   ** as the table to be indexed.  pParse->pNewTable is a table that is
  1466   1466   ** currently being constructed by a CREATE TABLE statement.
  1467   1467   **
  1468   1468   ** pList is a list of columns to be indexed.  pList will be NULL if this
  1469   1469   ** is a primary key or unique-constraint on the most recent column added
  1470   1470   ** to the table currently under construction.  
  1471   1471   */
  1472         -void sqliteCreateIndex(
         1472  +void sqlite3CreateIndex(
  1473   1473     Parse *pParse,   /* All information about this parse */
  1474   1474     Token *pName,    /* Name of the index.  May be NULL */
  1475   1475     SrcList *pTable, /* Name of the table to index.  Use pParse->pNewTable if 0 */
  1476   1476     IdList *pList,   /* A list of columns to be indexed */
  1477   1477     int onError,     /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
  1478   1478     Token *pStart,   /* The CREATE token that begins a CREATE TABLE statement */
  1479   1479     Token *pEnd      /* The ")" that closes the CREATE INDEX statement */
................................................................................
  1485   1485     Token nullId;    /* Fake token for an empty ID list */
  1486   1486     DbFixer sFix;    /* For assigning database names to pTable */
  1487   1487     int isTemp;      /* True for a temporary index */
  1488   1488     sqlite *db = pParse->db;
  1489   1489   
  1490   1490     if( pParse->nErr || sqlite_malloc_failed ) goto exit_create_index;
  1491   1491     if( db->init.busy 
  1492         -     && sqliteFixInit(&sFix, pParse, db->init.iDb, "index", pName)
  1493         -     && sqliteFixSrcList(&sFix, pTable)
         1492  +     && sqlite3FixInit(&sFix, pParse, db->init.iDb, "index", pName)
         1493  +     && sqlite3FixSrcList(&sFix, pTable)
  1494   1494     ){
  1495   1495       goto exit_create_index;
  1496   1496     }
  1497   1497   
  1498   1498     /*
  1499   1499     ** Find the table that is to be indexed.  Return early if not found.
  1500   1500     */
  1501   1501     if( pTable!=0 ){
  1502   1502       assert( pName!=0 );
  1503   1503       assert( pTable->nSrc==1 );
  1504         -    pTab =  sqliteSrcListLookup(pParse, pTable);
         1504  +    pTab =  sqlite3SrcListLookup(pParse, pTable);
  1505   1505     }else{
  1506   1506       assert( pName==0 );
  1507   1507       pTab =  pParse->pNewTable;
  1508   1508     }
  1509   1509     if( pTab==0 || pParse->nErr ) goto exit_create_index;
  1510   1510     if( pTab->readOnly ){
  1511         -    sqliteErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
         1511  +    sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
  1512   1512       goto exit_create_index;
  1513   1513     }
  1514   1514     if( pTab->iDb>=2 && db->init.busy==0 ){
  1515         -    sqliteErrorMsg(pParse, "table %s may not have indices added", pTab->zName);
         1515  +    sqlite3ErrorMsg(pParse, "table %s may not have indices added", pTab->zName);
  1516   1516       goto exit_create_index;
  1517   1517     }
  1518   1518     if( pTab->pSelect ){
  1519         -    sqliteErrorMsg(pParse, "views may not be indexed");
         1519  +    sqlite3ErrorMsg(pParse, "views may not be indexed");
  1520   1520       goto exit_create_index;
  1521   1521     }
  1522   1522     isTemp = pTab->iDb==1;
  1523   1523   
  1524   1524     /*
  1525   1525     ** Find the name of the index.  Make sure there is not already another
  1526   1526     ** index or table with the same name.  
................................................................................
  1535   1535     ** own name.
  1536   1536     */
  1537   1537     if( pName && !db->init.busy ){
  1538   1538       Index *pISameName;    /* Another index with the same name */
  1539   1539       Table *pTSameName;    /* A table with same name as the index */
  1540   1540       zName = sqliteStrNDup(pName->z, pName->n);
  1541   1541       if( zName==0 ) goto exit_create_index;
  1542         -    if( (pISameName = sqliteFindIndex(db, zName, 0))!=0 ){
  1543         -      sqliteErrorMsg(pParse, "index %s already exists", zName);
         1542  +    if( (pISameName = sqlite3FindIndex(db, zName, 0))!=0 ){
         1543  +      sqlite3ErrorMsg(pParse, "index %s already exists", zName);
  1544   1544         goto exit_create_index;
  1545   1545       }
  1546         -    if( (pTSameName = sqliteFindTable(db, zName, 0))!=0 ){
  1547         -      sqliteErrorMsg(pParse, "there is already a table named %s", zName);
         1546  +    if( (pTSameName = sqlite3FindTable(db, zName, 0))!=0 ){
         1547  +      sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);
  1548   1548         goto exit_create_index;
  1549   1549       }
  1550   1550     }else if( pName==0 ){
  1551   1551       char zBuf[30];
  1552   1552       int n;
  1553   1553       Index *pLoop;
  1554   1554       for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
  1555   1555       sprintf(zBuf,"%d)",n);
  1556   1556       zName = 0;
  1557         -    sqliteSetString(&zName, "(", pTab->zName, " autoindex ", zBuf, (char*)0);
         1557  +    sqlite3SetString(&zName, "(", pTab->zName, " autoindex ", zBuf, (char*)0);
  1558   1558       if( zName==0 ) goto exit_create_index;
  1559   1559     }else{
  1560   1560       zName = sqliteStrNDup(pName->z, pName->n);
  1561   1561     }
  1562   1562   
  1563   1563     /* Check for authorization to create an index.
  1564   1564     */
  1565   1565   #ifndef SQLITE_OMIT_AUTHORIZATION
  1566   1566     {
  1567   1567       const char *zDb = db->aDb[pTab->iDb].zName;
  1568   1568   
  1569   1569       assert( pTab->iDb==db->init.iDb || isTemp );
  1570         -    if( sqliteAuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
         1570  +    if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
  1571   1571         goto exit_create_index;
  1572   1572       }
  1573   1573       i = SQLITE_CREATE_INDEX;
  1574   1574       if( isTemp ) i = SQLITE_CREATE_TEMP_INDEX;
  1575         -    if( sqliteAuthCheck(pParse, i, zName, pTab->zName, zDb) ){
         1575  +    if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){
  1576   1576         goto exit_create_index;
  1577   1577       }
  1578   1578     }
  1579   1579   #endif
  1580   1580   
  1581   1581     /* If pList==0, it means this routine was called to make a primary
  1582   1582     ** key out of the last column added to the table under construction.
  1583   1583     ** So create a fake list to simulate this.
  1584   1584     */
  1585   1585     if( pList==0 ){
  1586   1586       nullId.z = pTab->aCol[pTab->nCol-1].zName;
  1587   1587       nullId.n = strlen(nullId.z);
  1588         -    pList = sqliteIdListAppend(0, &nullId);
         1588  +    pList = sqlite3IdListAppend(0, &nullId);
  1589   1589       if( pList==0 ) goto exit_create_index;
  1590   1590     }
  1591   1591   
  1592   1592     /* 
  1593   1593     ** Allocate the index structure. 
  1594   1594     */
  1595   1595     pIndex = sqliteMalloc( sizeof(Index) + strlen(zName) + 1 +
................................................................................
  1606   1606   
  1607   1607     /* Scan the names of the columns of the table to be indexed and
  1608   1608     ** load the column indices into the Index structure.  Report an error
  1609   1609     ** if any column is not found.
  1610   1610     */
  1611   1611     for(i=0; i<pList->nId; i++){
  1612   1612       for(j=0; j<pTab->nCol; j++){
  1613         -      if( sqliteStrICmp(pList->a[i].zName, pTab->aCol[j].zName)==0 ) break;
         1613  +      if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[j].zName)==0 ) break;
  1614   1614       }
  1615   1615       if( j>=pTab->nCol ){
  1616         -      sqliteErrorMsg(pParse, "table %s has no column named %s",
         1616  +      sqlite3ErrorMsg(pParse, "table %s has no column named %s",
  1617   1617           pTab->zName, pList->a[i].zName);
  1618   1618         sqliteFree(pIndex);
  1619   1619         goto exit_create_index;
  1620   1620       }
  1621   1621       pIndex->aiColumn[i] = j;
  1622   1622     }
  1623   1623   
  1624   1624     /* Link the new Index structure to its table and to the other
  1625   1625     ** in-memory database structures. 
  1626   1626     */
  1627   1627     if( !pParse->explain ){
  1628   1628       Index *p;
  1629         -    p = sqliteHashInsert(&db->aDb[pIndex->iDb].idxHash, 
         1629  +    p = sqlite3HashInsert(&db->aDb[pIndex->iDb].idxHash, 
  1630   1630                            pIndex->zName, strlen(pIndex->zName)+1, pIndex);
  1631   1631       if( p ){
  1632   1632         assert( p==pIndex );  /* Malloc must have failed */
  1633   1633         sqliteFree(pIndex);
  1634   1634         goto exit_create_index;
  1635   1635       }
  1636   1636       db->flags |= SQLITE_InternChanges;
................................................................................
  1680   1680     else if( db->init.busy==0 ){
  1681   1681       int n;
  1682   1682       Vdbe *v;
  1683   1683       int lbl1, lbl2;
  1684   1684       int i;
  1685   1685       int addr;
  1686   1686   
  1687         -    v = sqliteGetVdbe(pParse);
         1687  +    v = sqlite3GetVdbe(pParse);
  1688   1688       if( v==0 ) goto exit_create_index;
  1689   1689       if( pTable!=0 ){
  1690         -      sqliteBeginWriteOperation(pParse, 0, isTemp);
  1691         -      sqliteOpenMasterTable(v, isTemp);
         1690  +      sqlite3BeginWriteOperation(pParse, 0, isTemp);
         1691  +      sqlite3OpenMasterTable(v, isTemp);
  1692   1692       }
  1693         -    sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
  1694         -    sqliteVdbeOp3(v, OP_String, 0, 0, "index", P3_STATIC);
  1695         -    sqliteVdbeOp3(v, OP_String, 0, 0, pIndex->zName, 0);
  1696         -    sqliteVdbeOp3(v, OP_String, 0, 0, pTab->zName, 0);
  1697         -    sqliteVdbeOp3(v, OP_CreateIndex, 0, isTemp,(char*)&pIndex->tnum,P3_POINTER);
         1693  +    sqlite3VdbeAddOp(v, OP_NewRecno, 0, 0);
         1694  +    sqlite3VdbeOp3(v, OP_String, 0, 0, "index", P3_STATIC);
         1695  +    sqlite3VdbeOp3(v, OP_String, 0, 0, pIndex->zName, 0);
         1696  +    sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->zName, 0);
         1697  +    sqlite3VdbeOp3(v, OP_CreateIndex, 0, isTemp,(char*)&pIndex->tnum,P3_POINTER);
  1698   1698       pIndex->tnum = 0;
  1699   1699       if( pTable ){
  1700         -      sqliteVdbeCode(v,
         1700  +      sqlite3VdbeCode(v,
  1701   1701             OP_Dup,       0,      0,
  1702   1702             OP_Integer,   isTemp, 0,
  1703   1703             OP_OpenWrite, 1,      0,
  1704   1704         0);
  1705   1705       }
  1706         -    addr = sqliteVdbeAddOp(v, OP_String, 0, 0);
         1706  +    addr = sqlite3VdbeAddOp(v, OP_String, 0, 0);
  1707   1707       if( pStart && pEnd ){
  1708   1708         n = Addr(pEnd->z) - Addr(pStart->z) + 1;
  1709         -      sqliteVdbeChangeP3(v, addr, pStart->z, n);
         1709  +      sqlite3VdbeChangeP3(v, addr, pStart->z, n);
  1710   1710       }
  1711         -    sqliteVdbeAddOp(v, OP_MakeRecord, 5, 0);
  1712         -    sqliteVdbeAddOp(v, OP_PutIntKey, 0, 0);
         1711  +    sqlite3VdbeAddOp(v, OP_MakeRecord, 5, 0);
         1712  +    sqlite3VdbeAddOp(v, OP_PutIntKey, 0, 0);
  1713   1713       if( pTable ){
  1714         -      sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
  1715         -      sqliteVdbeOp3(v, OP_OpenRead, 2, pTab->tnum, pTab->zName, 0);
  1716         -      lbl2 = sqliteVdbeMakeLabel(v);
  1717         -      sqliteVdbeAddOp(v, OP_Rewind, 2, lbl2);
  1718         -      lbl1 = sqliteVdbeAddOp(v, OP_Recno, 2, 0);
         1714  +      sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);
         1715  +      sqlite3VdbeOp3(v, OP_OpenRead, 2, pTab->tnum, pTab->zName, 0);
         1716  +      lbl2 = sqlite3VdbeMakeLabel(v);
         1717  +      sqlite3VdbeAddOp(v, OP_Rewind, 2, lbl2);
         1718  +      lbl1 = sqlite3VdbeAddOp(v, OP_Recno, 2, 0);
  1719   1719         for(i=0; i<pIndex->nColumn; i++){
  1720   1720           int iCol = pIndex->aiColumn[i];
  1721   1721           if( pTab->iPKey==iCol ){
  1722         -          sqliteVdbeAddOp(v, OP_Dup, i, 0);
         1722  +          sqlite3VdbeAddOp(v, OP_Dup, i, 0);
  1723   1723           }else{
  1724         -          sqliteVdbeAddOp(v, OP_Column, 2, iCol);
         1724  +          sqlite3VdbeAddOp(v, OP_Column, 2, iCol);
  1725   1725           }
  1726   1726         }
  1727         -      sqliteVdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0);
  1728         -      if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIndex);
  1729         -      sqliteVdbeOp3(v, OP_IdxPut, 1, pIndex->onError!=OE_None,
         1727  +      sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIndex->nColumn, 0);
         1728  +      if( db->file_format>=4 ) sqlite3AddIdxKeyType(v, pIndex);
         1729  +      sqlite3VdbeOp3(v, OP_IdxPut, 1, pIndex->onError!=OE_None,
  1730   1730                         "indexed columns are not unique", P3_STATIC);
  1731         -      sqliteVdbeAddOp(v, OP_Next, 2, lbl1);
  1732         -      sqliteVdbeResolveLabel(v, lbl2);
  1733         -      sqliteVdbeAddOp(v, OP_Close, 2, 0);
  1734         -      sqliteVdbeAddOp(v, OP_Close, 1, 0);
         1731  +      sqlite3VdbeAddOp(v, OP_Next, 2, lbl1);
         1732  +      sqlite3VdbeResolveLabel(v, lbl2);
         1733  +      sqlite3VdbeAddOp(v, OP_Close, 2, 0);
         1734  +      sqlite3VdbeAddOp(v, OP_Close, 1, 0);
  1735   1735       }
  1736   1736       if( pTable!=0 ){
  1737   1737         if( !isTemp ){
  1738         -        sqliteChangeCookie(db, v);
         1738  +        sqlite3ChangeCookie(db, v);
  1739   1739         }
  1740         -      sqliteVdbeAddOp(v, OP_Close, 0, 0);
  1741         -      sqliteEndWriteOperation(pParse);
         1740  +      sqlite3VdbeAddOp(v, OP_Close, 0, 0);
         1741  +      sqlite3EndWriteOperation(pParse);
  1742   1742       }
  1743   1743     }
  1744   1744   
  1745   1745     /* Clean up before exiting */
  1746   1746   exit_create_index:
  1747         -  sqliteIdListDelete(pList);
  1748         -  sqliteSrcListDelete(pTable);
         1747  +  sqlite3IdListDelete(pList);
         1748  +  sqlite3SrcListDelete(pTable);
  1749   1749     sqliteFree(zName);
  1750   1750     return;
  1751   1751   }
  1752   1752   
  1753   1753   /*
  1754   1754   ** This routine will drop an existing named index.  This routine
  1755   1755   ** implements the DROP INDEX statement.
  1756   1756   */
  1757         -void sqliteDropIndex(Parse *pParse, SrcList *pName){
         1757  +void sqlite3DropIndex(Parse *pParse, SrcList *pName){
  1758   1758     Index *pIndex;
  1759   1759     Vdbe *v;
  1760   1760     sqlite *db = pParse->db;
  1761   1761   
  1762   1762     if( pParse->nErr || sqlite_malloc_failed ) return;
  1763   1763     assert( pName->nSrc==1 );
  1764         -  pIndex = sqliteFindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);
         1764  +  pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);
  1765   1765     if( pIndex==0 ){
  1766         -    sqliteErrorMsg(pParse, "no such index: %S", pName, 0);
         1766  +    sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0);
  1767   1767       goto exit_drop_index;
  1768   1768     }
  1769   1769     if( pIndex->autoIndex ){
  1770         -    sqliteErrorMsg(pParse, "index associated with UNIQUE "
         1770  +    sqlite3ErrorMsg(pParse, "index associated with UNIQUE "
  1771   1771         "or PRIMARY KEY constraint cannot be dropped", 0);
  1772   1772       goto exit_drop_index;
  1773   1773     }
  1774   1774     if( pIndex->iDb>1 ){
  1775         -    sqliteErrorMsg(pParse, "cannot alter schema of attached "
         1775  +    sqlite3ErrorMsg(pParse, "cannot alter schema of attached "
  1776   1776          "databases", 0);
  1777   1777       goto exit_drop_index;
  1778   1778     }
  1779   1779   #ifndef SQLITE_OMIT_AUTHORIZATION
  1780   1780     {
  1781   1781       int code = SQLITE_DROP_INDEX;
  1782   1782       Table *pTab = pIndex->pTable;
  1783   1783       const char *zDb = db->aDb[pIndex->iDb].zName;
  1784   1784       const char *zTab = SCHEMA_TABLE(pIndex->iDb);
  1785         -    if( sqliteAuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
         1785  +    if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
  1786   1786         goto exit_drop_index;
  1787   1787       }
  1788   1788       if( pIndex->iDb ) code = SQLITE_DROP_TEMP_INDEX;
  1789         -    if( sqliteAuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
         1789  +    if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
  1790   1790         goto exit_drop_index;
  1791   1791       }
  1792   1792     }
  1793   1793   #endif
  1794   1794   
  1795   1795     /* Generate code to remove the index and from the master table */
  1796         -  v = sqliteGetVdbe(pParse);
         1796  +  v = sqlite3GetVdbe(pParse);
  1797   1797     if( v ){
  1798   1798       static VdbeOpList dropIndex[] = {
  1799   1799         { OP_Rewind,     0, ADDR(9), 0}, 
  1800   1800         { OP_String,     0, 0,       0}, /* 1 */
  1801   1801         { OP_MemStore,   1, 1,       0},
  1802   1802         { OP_MemLoad,    1, 0,       0}, /* 3 */
  1803   1803         { OP_Column,     0, 1,       0},
................................................................................
  1804   1804         { OP_Eq,         0, ADDR(8), 0},
  1805   1805         { OP_Next,       0, ADDR(3), 0},
  1806   1806         { OP_Goto,       0, ADDR(9), 0},
  1807   1807         { OP_Delete,     0, 0,       0}, /* 8 */
  1808   1808       };
  1809   1809       int base;
  1810   1810   
  1811         -    sqliteBeginWriteOperation(pParse, 0, pIndex->iDb);
  1812         -    sqliteOpenMasterTable(v, pIndex->iDb);
  1813         -    base = sqliteVdbeAddOpList(v, ArraySize(dropIndex), dropIndex);
  1814         -    sqliteVdbeChangeP3(v, base+1, pIndex->zName, 0);
         1811  +    sqlite3BeginWriteOperation(pParse, 0, pIndex->iDb);
         1812  +    sqlite3OpenMasterTable(v, pIndex->iDb);
         1813  +    base = sqlite3VdbeAddOpList(v, ArraySize(dropIndex), dropIndex);
         1814  +    sqlite3VdbeChangeP3(v, base+1, pIndex->zName, 0);
  1815   1815       if( pIndex->iDb==0 ){
  1816         -      sqliteChangeCookie(db, v);
         1816  +      sqlite3ChangeCookie(db, v);
  1817   1817       }
  1818         -    sqliteVdbeAddOp(v, OP_Close, 0, 0);
  1819         -    sqliteVdbeAddOp(v, OP_Destroy, pIndex->tnum, pIndex->iDb);
  1820         -    sqliteEndWriteOperation(pParse);
         1818  +    sqlite3VdbeAddOp(v, OP_Close, 0, 0);
         1819  +    sqlite3VdbeAddOp(v, OP_Destroy, pIndex->tnum, pIndex->iDb);
         1820  +    sqlite3EndWriteOperation(pParse);
  1821   1821     }
  1822   1822   
  1823   1823     /* Delete the in-memory description of this index.
  1824   1824     */
  1825   1825     if( !pParse->explain ){
  1826         -    sqliteUnlinkAndDeleteIndex(db, pIndex);
         1826  +    sqlite3UnlinkAndDeleteIndex(db, pIndex);
  1827   1827       db->flags |= SQLITE_InternChanges;
  1828   1828     }
  1829   1829   
  1830   1830   exit_drop_index:
  1831         -  sqliteSrcListDelete(pName);
         1831  +  sqlite3SrcListDelete(pName);
  1832   1832   }
  1833   1833   
  1834   1834   /*
  1835   1835   ** Append a new element to the given IdList.  Create a new IdList if
  1836   1836   ** need be.
  1837   1837   **
  1838   1838   ** A new IdList is returned, or NULL if malloc() fails.
  1839   1839   */
  1840         -IdList *sqliteIdListAppend(IdList *pList, Token *pToken){
         1840  +IdList *sqlite3IdListAppend(IdList *pList, Token *pToken){
  1841   1841     if( pList==0 ){
  1842   1842       pList = sqliteMalloc( sizeof(IdList) );
  1843   1843       if( pList==0 ) return 0;
  1844   1844       pList->nAlloc = 0;
  1845   1845     }
  1846   1846     if( pList->nId>=pList->nAlloc ){
  1847   1847       struct IdList_item *a;
  1848   1848       pList->nAlloc = pList->nAlloc*2 + 5;
  1849   1849       a = sqliteRealloc(pList->a, pList->nAlloc*sizeof(pList->a[0]) );
  1850   1850       if( a==0 ){
  1851         -      sqliteIdListDelete(pList);
         1851  +      sqlite3IdListDelete(pList);
  1852   1852         return 0;
  1853   1853       }
  1854   1854       pList->a = a;
  1855   1855     }
  1856   1856     memset(&pList->a[pList->nId], 0, sizeof(pList->a[0]));
  1857   1857     if( pToken ){
  1858   1858       char **pz = &pList->a[pList->nId].zName;
  1859         -    sqliteSetNString(pz, pToken->z, pToken->n, 0);
         1859  +    sqlite3SetNString(pz, pToken->z, pToken->n, 0);
  1860   1860       if( *pz==0 ){
  1861         -      sqliteIdListDelete(pList);
         1861  +      sqlite3IdListDelete(pList);
  1862   1862         return 0;
  1863   1863       }else{
  1864         -      sqliteDequote(*pz);
         1864  +      sqlite3Dequote(*pz);
  1865   1865       }
  1866   1866     }
  1867   1867     pList->nId++;
  1868   1868     return pList;
  1869   1869   }
  1870   1870   
  1871   1871   /*
................................................................................
  1880   1880   ** The SrcList.a[].zName field is filled with the table name which might
  1881   1881   ** come from pTable (if pDatabase is NULL) or from pDatabase.  
  1882   1882   ** SrcList.a[].zDatabase is filled with the database name from pTable,
  1883   1883   ** or with NULL if no database is specified.
  1884   1884   **
  1885   1885   ** In other words, if call like this:
  1886   1886   **
  1887         -**         sqliteSrcListAppend(A,B,0);
         1887  +**         sqlite3SrcListAppend(A,B,0);
  1888   1888   **
  1889   1889   ** Then B is a table name and the database name is unspecified.  If called
  1890   1890   ** like this:
  1891   1891   **
  1892         -**         sqliteSrcListAppend(A,B,C);
         1892  +**         sqlite3SrcListAppend(A,B,C);
  1893   1893   **
  1894   1894   ** Then C is the table name and B is the database name.
  1895   1895   */
  1896         -SrcList *sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){
         1896  +SrcList *sqlite3SrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){
  1897   1897     if( pList==0 ){
  1898   1898       pList = sqliteMalloc( sizeof(SrcList) );
  1899   1899       if( pList==0 ) return 0;
  1900   1900       pList->nAlloc = 1;
  1901   1901     }
  1902   1902     if( pList->nSrc>=pList->nAlloc ){
  1903   1903       SrcList *pNew;
  1904   1904       pList->nAlloc *= 2;
  1905   1905       pNew = sqliteRealloc(pList,
  1906   1906                  sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) );
  1907   1907       if( pNew==0 ){
  1908         -      sqliteSrcListDelete(pList);
         1908  +      sqlite3SrcListDelete(pList);
  1909   1909         return 0;
  1910   1910       }
  1911   1911       pList = pNew;
  1912   1912     }
  1913   1913     memset(&pList->a[pList->nSrc], 0, sizeof(pList->a[0]));
  1914   1914     if( pDatabase && pDatabase->z==0 ){
  1915   1915       pDatabase = 0;
................................................................................
  1917   1917     if( pDatabase && pTable ){
  1918   1918       Token *pTemp = pDatabase;
  1919   1919       pDatabase = pTable;
  1920   1920       pTable = pTemp;
  1921   1921     }
  1922   1922     if( pTable ){
  1923   1923       char **pz = &pList->a[pList->nSrc].zName;
  1924         -    sqliteSetNString(pz, pTable->z, pTable->n, 0);
         1924  +    sqlite3SetNString(pz, pTable->z, pTable->n, 0);
  1925   1925       if( *pz==0 ){
  1926         -      sqliteSrcListDelete(pList);
         1926  +      sqlite3SrcListDelete(pList);
  1927   1927         return 0;
  1928   1928       }else{
  1929         -      sqliteDequote(*pz);
         1929  +      sqlite3Dequote(*pz);
  1930   1930       }
  1931   1931     }
  1932   1932     if( pDatabase ){
  1933   1933       char **pz = &pList->a[pList->nSrc].zDatabase;
  1934         -    sqliteSetNString(pz, pDatabase->z, pDatabase->n, 0);
         1934  +    sqlite3SetNString(pz, pDatabase->z, pDatabase->n, 0);
  1935   1935       if( *pz==0 ){
  1936         -      sqliteSrcListDelete(pList);
         1936  +      sqlite3SrcListDelete(pList);
  1937   1937         return 0;
  1938   1938       }else{
  1939         -      sqliteDequote(*pz);
         1939  +      sqlite3Dequote(*pz);
  1940   1940       }
  1941   1941     }
  1942   1942     pList->a[pList->nSrc].iCursor = -1;
  1943   1943     pList->nSrc++;
  1944   1944     return pList;
  1945   1945   }
  1946   1946   
  1947   1947   /*
  1948   1948   ** Assign cursors to all tables in a SrcList
  1949   1949   */
  1950         -void sqliteSrcListAssignCursors(Parse *pParse, SrcList *pList){
         1950  +void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){
  1951   1951     int i;
  1952   1952     for(i=0; i<pList->nSrc; i++){
  1953   1953       if( pList->a[i].iCursor<0 ){
  1954   1954         pList->a[i].iCursor = pParse->nTab++;
  1955   1955       }
  1956   1956     }
  1957   1957   }
  1958   1958   
  1959   1959   /*
  1960   1960   ** Add an alias to the last identifier on the given identifier list.
  1961   1961   */
  1962         -void sqliteSrcListAddAlias(SrcList *pList, Token *pToken){
         1962  +void sqlite3SrcListAddAlias(SrcList *pList, Token *pToken){
  1963   1963     if( pList && pList->nSrc>0 ){
  1964   1964       int i = pList->nSrc - 1;
  1965         -    sqliteSetNString(&pList->a[i].zAlias, pToken->z, pToken->n, 0);
  1966         -    sqliteDequote(pList->a[i].zAlias);
         1965  +    sqlite3SetNString(&pList->a[i].zAlias, pToken->z, pToken->n, 0);
         1966  +    sqlite3Dequote(pList->a[i].zAlias);
  1967   1967     }
  1968   1968   }
  1969   1969   
  1970   1970   /*
  1971   1971   ** Delete an IdList.
  1972   1972   */
  1973         -void sqliteIdListDelete(IdList *pList){
         1973  +void sqlite3IdListDelete(IdList *pList){
  1974   1974     int i;
  1975   1975     if( pList==0 ) return;
  1976   1976     for(i=0; i<pList->nId; i++){
  1977   1977       sqliteFree(pList->a[i].zName);
  1978   1978     }
  1979   1979     sqliteFree(pList->a);
  1980   1980     sqliteFree(pList);
  1981   1981   }
  1982   1982   
  1983   1983   /*
  1984   1984   ** Return the index in pList of the identifier named zId.  Return -1
  1985   1985   ** if not found.
  1986   1986   */
  1987         -int sqliteIdListIndex(IdList *pList, const char *zName){
         1987  +int sqlite3IdListIndex(IdList *pList, const char *zName){
  1988   1988     int i;
  1989   1989     if( pList==0 ) return -1;
  1990   1990     for(i=0; i<pList->nId; i++){
  1991         -    if( sqliteStrICmp(pList->a[i].zName, zName)==0 ) return i;
         1991  +    if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;
  1992   1992     }
  1993   1993     return -1;
  1994   1994   }
  1995   1995   
  1996   1996   /*
  1997   1997   ** Delete an entire SrcList including all its substructure.
  1998   1998   */
  1999         -void sqliteSrcListDelete(SrcList *pList){
         1999  +void sqlite3SrcListDelete(SrcList *pList){
  2000   2000     int i;
  2001   2001     if( pList==0 ) return;
  2002   2002     for(i=0; i<pList->nSrc; i++){
  2003   2003       sqliteFree(pList->a[i].zDatabase);
  2004   2004       sqliteFree(pList->a[i].zName);
  2005   2005       sqliteFree(pList->a[i].zAlias);
  2006   2006       if( pList->a[i].pTab && pList->a[i].pTab->isTransient ){
  2007         -      sqliteDeleteTable(0, pList->a[i].pTab);
         2007  +      sqlite3DeleteTable(0, pList->a[i].pTab);
  2008   2008       }
  2009         -    sqliteSelectDelete(pList->a[i].pSelect);
  2010         -    sqliteExprDelete(pList->a[i].pOn);
  2011         -    sqliteIdListDelete(pList->a[i].pUsing);
         2009  +    sqlite3SelectDelete(pList->a[i].pSelect);
         2010  +    sqlite3ExprDelete(pList->a[i].pOn);
         2011  +    sqlite3IdListDelete(pList->a[i].pUsing);
  2012   2012     }
  2013   2013     sqliteFree(pList);
  2014   2014   }
  2015   2015   
  2016   2016   /*
  2017   2017   ** Begin a transaction
  2018   2018   */
  2019         -void sqliteBeginTransaction(Parse *pParse, int onError){
         2019  +void sqlite3BeginTransaction(Parse *pParse, int onError){
  2020   2020     sqlite *db;
  2021   2021   
  2022   2022     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2023   2023     if( pParse->nErr || sqlite_malloc_failed ) return;
  2024         -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ) return;
         2024  +  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ) return;
  2025   2025     if( db->flags & SQLITE_InTrans ){
  2026         -    sqliteErrorMsg(pParse, "cannot start a transaction within a transaction");
         2026  +    sqlite3ErrorMsg(pParse, "cannot start a transaction within a transaction");
  2027   2027       return;
  2028   2028     }
  2029         -  sqliteBeginWriteOperation(pParse, 0, 0);
         2029  +  sqlite3BeginWriteOperation(pParse, 0, 0);
  2030   2030     if( !pParse->explain ){
  2031   2031       db->flags |= SQLITE_InTrans;
  2032   2032       db->onError = onError;
  2033   2033     }
  2034   2034   }
  2035   2035   
  2036   2036   /*
  2037   2037   ** Commit a transaction
  2038   2038   */
  2039         -void sqliteCommitTransaction(Parse *pParse){
         2039  +void sqlite3CommitTransaction(Parse *pParse){
  2040   2040     sqlite *db;
  2041   2041   
  2042   2042     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2043   2043     if( pParse->nErr || sqlite_malloc_failed ) return;
  2044         -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ) return;
         2044  +  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "COMMIT", 0, 0) ) return;
  2045   2045     if( (db->flags & SQLITE_InTrans)==0 ){
  2046         -    sqliteErrorMsg(pParse, "cannot commit - no transaction is active");
         2046  +    sqlite3ErrorMsg(pParse, "cannot commit - no transaction is active");
  2047   2047       return;
  2048   2048     }
  2049   2049     if( !pParse->explain ){
  2050   2050       db->flags &= ~SQLITE_InTrans;
  2051   2051     }
  2052         -  sqliteEndWriteOperation(pParse);
         2052  +  sqlite3EndWriteOperation(pParse);
  2053   2053     if( !pParse->explain ){
  2054   2054       db->onError = OE_Default;
  2055   2055     }
  2056   2056   }
  2057   2057   
  2058   2058   /*
  2059   2059   ** Rollback a transaction
  2060   2060   */
  2061         -void sqliteRollbackTransaction(Parse *pParse){
         2061  +void sqlite3RollbackTransaction(Parse *pParse){
  2062   2062     sqlite *db;
  2063   2063     Vdbe *v;
  2064   2064   
  2065   2065     if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
  2066   2066     if( pParse->nErr || sqlite_malloc_failed ) return;
  2067         -  if( sqliteAuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ) return;
         2067  +  if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "ROLLBACK", 0, 0) ) return;
  2068   2068     if( (db->flags & SQLITE_InTrans)==0 ){
  2069         -    sqliteErrorMsg(pParse, "cannot rollback - no transaction is active");
         2069  +    sqlite3ErrorMsg(pParse, "cannot rollback - no transaction is active");
  2070   2070       return; 
  2071   2071     }
  2072         -  v = sqliteGetVdbe(pParse);
         2072  +  v = sqlite3GetVdbe(pParse);
  2073   2073     if( v ){
  2074         -    sqliteVdbeAddOp(v, OP_Rollback, 0, 0);
         2074  +    sqlite3VdbeAddOp(v, OP_Rollback, 0, 0);
  2075   2075     }
  2076   2076     if( !pParse->explain ){
  2077   2077       db->flags &= ~SQLITE_InTrans;
  2078   2078       db->onError = OE_Default;
  2079   2079     }
  2080   2080   }
  2081   2081   
  2082   2082   /*
  2083   2083   ** Generate VDBE code that will verify the schema cookie for all
  2084   2084   ** named database files.
  2085   2085   */
  2086         -void sqliteCodeVerifySchema(Parse *pParse, int iDb){
         2086  +void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  2087   2087     sqlite *db = pParse->db;
  2088         -  Vdbe *v = sqliteGetVdbe(pParse);
         2088  +  Vdbe *v = sqlite3GetVdbe(pParse);
  2089   2089     assert( iDb>=0 && iDb<db->nDb );
  2090   2090     assert( db->aDb[iDb].pBt!=0 );
  2091   2091     if( iDb!=1 && !DbHasProperty(db, iDb, DB_Cookie) ){
  2092         -    sqliteVdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie);
         2092  +    sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie);
  2093   2093       DbSetProperty(db, iDb, DB_Cookie);
  2094   2094     }
  2095   2095   }
  2096   2096   
  2097   2097   /*
  2098   2098   ** Generate VDBE code that prepares for doing an operation that
  2099   2099   ** might change the database.
................................................................................
  2108   2108   ** necessary to undo a write and the checkpoint should not be set.
  2109   2109   **
  2110   2110   ** Only database iDb and the temp database are made writable by this call.
  2111   2111   ** If iDb==0, then the main and temp databases are made writable.   If
  2112   2112   ** iDb==1 then only the temp database is made writable.  If iDb>1 then the
  2113   2113   ** specified auxiliary database and the temp database are made writable.
  2114   2114   */
  2115         -void sqliteBeginWriteOperation(Parse *pParse, int setCheckpoint, int iDb){
         2115  +void sqlite3BeginWriteOperation(Parse *pParse, int setCheckpoint, int iDb){
  2116   2116     Vdbe *v;
  2117   2117     sqlite *db = pParse->db;
  2118   2118     if( DbHasProperty(db, iDb, DB_Locked) ) return;
  2119         -  v = sqliteGetVdbe(pParse);
         2119  +  v = sqlite3GetVdbe(pParse);
  2120   2120     if( v==0 ) return;
  2121   2121     if( !db->aDb[iDb].inTrans ){
  2122         -    sqliteVdbeAddOp(v, OP_Transaction, iDb, 0);
         2122  +    sqlite3VdbeAddOp(v, OP_Transaction, iDb, 0);
  2123   2123       DbSetProperty(db, iDb, DB_Locked);
  2124         -    sqliteCodeVerifySchema(pParse, iDb);
         2124  +    sqlite3CodeVerifySchema(pParse, iDb);
  2125   2125       if( iDb!=1 ){
  2126         -      sqliteBeginWriteOperation(pParse, setCheckpoint, 1);
         2126  +      sqlite3BeginWriteOperation(pParse, setCheckpoint, 1);
  2127   2127       }
  2128   2128     }else if( setCheckpoint ){
  2129         -    sqliteVdbeAddOp(v, OP_Checkpoint, iDb, 0);
         2129  +    sqlite3VdbeAddOp(v, OP_Checkpoint, iDb, 0);
  2130   2130       DbSetProperty(db, iDb, DB_Locked);
  2131   2131     }
  2132   2132   }
  2133   2133   
  2134   2134   /*
  2135   2135   ** Generate code that concludes an operation that may have changed
  2136   2136   ** the database.  If a statement transaction was started, then emit
  2137   2137   ** an OP_Commit that will cause the changes to be committed to disk.
  2138   2138   **
  2139   2139   ** Note that checkpoints are automatically committed at the end of
  2140   2140   ** a statement.  Note also that there can be multiple calls to 
  2141         -** sqliteBeginWriteOperation() but there should only be a single
  2142         -** call to sqliteEndWriteOperation() at the conclusion of the statement.
         2141  +** sqlite3BeginWriteOperation() but there should only be a single
         2142  +** call to sqlite3EndWriteOperation() at the conclusion of the statement.
  2143   2143   */
  2144         -void sqliteEndWriteOperation(Parse *pParse){
         2144  +void sqlite3EndWriteOperation(Parse *pParse){
  2145   2145     Vdbe *v;
  2146   2146     sqlite *db = pParse->db;
  2147   2147     if( pParse->trigStack ) return; /* if this is in a trigger */
  2148         -  v = sqliteGetVdbe(pParse);
         2148  +  v = sqlite3GetVdbe(pParse);
  2149   2149     if( v==0 ) return;
  2150   2150     if( db->flags & SQLITE_InTrans ){
  2151   2151       /* A BEGIN has executed.  Do not commit until we see an explicit
  2152   2152       ** COMMIT statement. */
  2153   2153     }else{
  2154         -    sqliteVdbeAddOp(v, OP_Commit, 0, 0);
         2154  +    sqlite3VdbeAddOp(v, OP_Commit, 0, 0);
  2155   2155     }
  2156   2156   }
         2157  +
         2158  +
         2159  +

Changes to src/copy.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 COPY command.
    13     13   **
    14         -** $Id: copy.c,v 1.9 2004/02/25 13:47:31 drh Exp $
           14  +** $Id: copy.c,v 1.10 2004/05/08 08:23:24 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   
    18     18   /*
    19     19   ** The COPY command is for compatibility with PostgreSQL and specificially
    20     20   ** for the ability to read the output of pg_dump.  The format is as
    21     21   ** follows:
................................................................................
    22     22   **
    23     23   **    COPY table FROM file [USING DELIMITERS string]
    24     24   **
    25     25   ** "table" is an existing table name.  We will read lines of code from
    26     26   ** file to fill this table with data.  File might be "stdin".  The optional
    27     27   ** delimiter string identifies the field separators.  The default is a tab.
    28     28   */
    29         -void sqliteCopy(
           29  +void sqlite3Copy(
    30     30     Parse *pParse,       /* The parser context */
    31     31     SrcList *pTableName, /* The name of the table into which we will insert */
    32     32     Token *pFilename,    /* The file from which to obtain information */
    33     33     Token *pDelimiter,   /* Use this as the field delimiter */
    34     34     int onError          /* What to do if a constraint fails */
    35     35   ){
    36     36     Table *pTab;
................................................................................
    40     40     char *zFile = 0;
    41     41     const char *zDb;
    42     42     sqlite *db = pParse->db;
    43     43   
    44     44   
    45     45     if( sqlite_malloc_failed  ) goto copy_cleanup;
    46     46     assert( pTableName->nSrc==1 );
    47         -  pTab = sqliteSrcListLookup(pParse, pTableName);
    48         -  if( pTab==0 || sqliteIsReadOnly(pParse, pTab, 0) ) goto copy_cleanup;
           47  +  pTab = sqlite3SrcListLookup(pParse, pTableName);
           48  +  if( pTab==0 || sqlite3IsReadOnly(pParse, pTab, 0) ) goto copy_cleanup;
    49     49     zFile = sqliteStrNDup(pFilename->z, pFilename->n);
    50         -  sqliteDequote(zFile);
           50  +  sqlite3Dequote(zFile);
    51     51     assert( pTab->iDb<db->nDb );
    52     52     zDb = db->aDb[pTab->iDb].zName;
    53         -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb)
    54         -      || sqliteAuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile, zDb) ){
           53  +  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb)
           54  +      || sqlite3AuthCheck(pParse, SQLITE_COPY, pTab->zName, zFile, zDb) ){
    55     55       goto copy_cleanup;
    56     56     }
    57         -  v = sqliteGetVdbe(pParse);
           57  +  v = sqlite3GetVdbe(pParse);
    58     58     if( v ){
    59         -    sqliteBeginWriteOperation(pParse, 1, pTab->iDb);
    60         -    addr = sqliteVdbeOp3(v, OP_FileOpen, 0, 0, pFilename->z, pFilename->n);
    61         -    sqliteVdbeDequoteP3(v, addr);
    62         -    sqliteOpenTableAndIndices(pParse, pTab, 0);
           59  +    sqlite3BeginWriteOperation(pParse, 1, pTab->iDb);
           60  +    addr = sqlite3VdbeOp3(v, OP_FileOpen, 0, 0, pFilename->z, pFilename->n);
           61  +    sqlite3VdbeDequoteP3(v, addr);
           62  +    sqlite3OpenTableAndIndices(pParse, pTab, 0);
    63     63       if( db->flags & SQLITE_CountRows ){
    64         -      sqliteVdbeAddOp(v, OP_Integer, 0, 0);  /* Initialize the row count */
           64  +      sqlite3VdbeAddOp(v, OP_Integer, 0, 0);  /* Initialize the row count */
    65     65       }
    66         -    end = sqliteVdbeMakeLabel(v);
    67         -    addr = sqliteVdbeAddOp(v, OP_FileRead, pTab->nCol, end);
           66  +    end = sqlite3VdbeMakeLabel(v);
           67  +    addr = sqlite3VdbeAddOp(v, OP_FileRead, pTab->nCol, end);
    68     68       if( pDelimiter ){
    69         -      sqliteVdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n);
    70         -      sqliteVdbeDequoteP3(v, addr);
           69  +      sqlite3VdbeChangeP3(v, addr, pDelimiter->z, pDelimiter->n);
           70  +      sqlite3VdbeDequoteP3(v, addr);
    71     71       }else{
    72         -      sqliteVdbeChangeP3(v, addr, "\t", 1);
           72  +      sqlite3VdbeChangeP3(v, addr, "\t", 1);
    73     73       }
    74     74       if( pTab->iPKey>=0 ){
    75         -      sqliteVdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0);
    76         -      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
           75  +      sqlite3VdbeAddOp(v, OP_FileColumn, pTab->iPKey, 0);
           76  +      sqlite3VdbeAddOp(v, OP_MustBeInt, 0, 0);
    77     77       }else{
    78         -      sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
           78  +      sqlite3VdbeAddOp(v, OP_NewRecno, 0, 0);
    79     79       }
    80     80       for(i=0; i<pTab->nCol; i++){
    81     81         if( i==pTab->iPKey ){
    82     82           /* The integer primary key column is filled with NULL since its
    83     83           ** value is always pulled from the record number */
    84         -        sqliteVdbeAddOp(v, OP_String, 0, 0);
           84  +        sqlite3VdbeAddOp(v, OP_String, 0, 0);
    85     85         }else{
    86         -        sqliteVdbeAddOp(v, OP_FileColumn, i, 0);
           86  +        sqlite3VdbeAddOp(v, OP_FileColumn, i, 0);
    87     87         }
    88     88       }
    89         -    sqliteGenerateConstraintChecks(pParse, pTab, 0, 0, pTab->iPKey>=0, 
           89  +    sqlite3GenerateConstraintChecks(pParse, pTab, 0, 0, pTab->iPKey>=0, 
    90     90                                      0, onError, addr);
    91         -    sqliteCompleteInsertion(pParse, pTab, 0, 0, 0, 0, -1);
           91  +    sqlite3CompleteInsertion(pParse, pTab, 0, 0, 0, 0, -1);
    92     92       if( (db->flags & SQLITE_CountRows)!=0 ){
    93         -      sqliteVdbeAddOp(v, OP_AddImm, 1, 0);  /* Increment row count */
           93  +      sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);  /* Increment row count */
    94     94       }
    95         -    sqliteVdbeAddOp(v, OP_Goto, 0, addr);
    96         -    sqliteVdbeResolveLabel(v, end);
    97         -    sqliteVdbeAddOp(v, OP_Noop, 0, 0);
    98         -    sqliteEndWriteOperation(pParse);
           95  +    sqlite3VdbeAddOp(v, OP_Goto, 0, addr);
           96  +    sqlite3VdbeResolveLabel(v, end);
           97  +    sqlite3VdbeAddOp(v, OP_Noop, 0, 0);
           98  +    sqlite3EndWriteOperation(pParse);
    99     99       if( db->flags & SQLITE_CountRows ){
   100         -      sqliteVdbeAddOp(v, OP_ColumnName, 0, 1);
   101         -      sqliteVdbeChangeP3(v, -1, "rows inserted", P3_STATIC);
   102         -      sqliteVdbeAddOp(v, OP_Callback, 1, 0);
          100  +      sqlite3VdbeAddOp(v, OP_ColumnName, 0, 1);
          101  +      sqlite3VdbeChangeP3(v, -1, "rows inserted", P3_STATIC);
          102  +      sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
   103    103       }
   104    104     }
   105    105     
   106    106   copy_cleanup:
   107         -  sqliteSrcListDelete(pTableName);
          107  +  sqlite3SrcListDelete(pTableName);
   108    108     sqliteFree(zFile);
   109    109     return;
   110    110   }
          111  +
          112  +
          113  +

Changes to src/date.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    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         -** sqliteRegisterDateTimeFunctions() found at the bottom of the file.
           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.16 2004/02/29 01:08:18 drh Exp $
           19  +** $Id: date.c,v 1.17 2004/05/08 08:23:24 danielk1977 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.
................................................................................
   122    122   
   123    123   /*
   124    124   ** Read text from z[] and convert into a floating point number.  Return
   125    125   ** the number of digits converted.
   126    126   */
   127    127   static int getValue(const char *z, double *pR){
   128    128     const char *zEnd;
   129         -  *pR = sqliteAtoF(z, &zEnd);
          129  +  *pR = sqlite3AtoF(z, &zEnd);
   130    130     return zEnd - z;
   131    131   }
   132    132   
   133    133   /*
   134    134   ** Parse a timezone extension on the end of a date-time.
   135    135   ** The extension is of the form:
   136    136   **
................................................................................
   309    309   */
   310    310   static int parseDateOrTime(const char *zDate, DateTime *p){
   311    311     memset(p, 0, sizeof(*p));
   312    312     if( parseYyyyMmDd(zDate,p)==0 ){
   313    313       return 0;
   314    314     }else if( parseHhMmSs(zDate, p)==0 ){
   315    315       return 0;
   316         -  }else if( sqliteStrICmp(zDate,"now")==0){
          316  +  }else if( sqlite3StrICmp(zDate,"now")==0){
   317    317       double r;
   318         -    if( sqliteOsCurrentTime(&r)==0 ){
          318  +    if( sqlite3OsCurrentTime(&r)==0 ){
   319    319         p->rJD = r;
   320    320         p->validJD = 1;
   321    321         return 0;
   322    322       }
   323    323       return 1;
   324         -  }else if( sqliteIsNumber(zDate) ){
   325         -    p->rJD = sqliteAtoF(zDate, 0);
          324  +  }else if( sqlite3IsNumber(zDate) ){
          325  +    p->rJD = sqlite3AtoF(zDate, 0);
   326    326       p->validJD = 1;
   327    327       return 0;
   328    328     }
   329    329     return 1;
   330    330   }
   331    331   
   332    332   /*
................................................................................
   411    411       int s = x.s + 0.5;
   412    412       x.s = s;
   413    413     }
   414    414     x.tz = 0;
   415    415     x.validJD = 0;
   416    416     computeJD(&x);
   417    417     t = (x.rJD-2440587.5)*86400.0 + 0.5;
   418         -  sqliteOsEnterMutex();
          418  +  sqlite3OsEnterMutex();
   419    419     pTm = localtime(&t);
   420    420     y.Y = pTm->tm_year + 1900;
   421    421     y.M = pTm->tm_mon + 1;
   422    422     y.D = pTm->tm_mday;
   423    423     y.h = pTm->tm_hour;
   424    424     y.m = pTm->tm_min;
   425    425     y.s = pTm->tm_sec;
   426         -  sqliteOsLeaveMutex();
          426  +  sqlite3OsLeaveMutex();
   427    427     y.validYMD = 1;
   428    428     y.validHMS = 1;
   429    429     y.validJD = 0;
   430    430     y.validTZ = 0;
   431    431     computeJD(&y);
   432    432     return y.rJD - x.rJD;
   433    433   }
................................................................................
   842    842   #endif /* !defined(SQLITE_OMIT_DATETIME_FUNCS) */
   843    843   
   844    844   /*
   845    845   ** This function registered all of the above C functions as SQL
   846    846   ** functions.  This should be the only routine in this file with
   847    847   ** external linkage.
   848    848   */
   849         -void sqliteRegisterDateTimeFunctions(sqlite *db){
          849  +void sqlite3RegisterDateTimeFunctions(sqlite *db){
   850    850     static struct {
   851    851        char *zName;
   852    852        int nArg;
   853    853        int dataType;
   854    854        void (*xFunc)(sqlite_func*,int,const char**);
   855    855     } aFuncs[] = {
   856    856   #ifndef SQLITE_OMIT_DATETIME_FUNCS
................................................................................
   867    867       sqlite_create_function(db, aFuncs[i].zName,
   868    868              aFuncs[i].nArg, aFuncs[i].xFunc, 0);
   869    869       if( aFuncs[i].xFunc ){
   870    870         sqlite_function_type(db, aFuncs[i].zName, aFuncs[i].dataType);
   871    871       }
   872    872     }
   873    873   }
          874  +
          875  +
          876  +

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.61 2004/02/24 01:05:32 drh Exp $
           15  +** $Id: delete.c,v 1.62 2004/05/08 08:23:24 danielk1977 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.
    23     23   */
    24         -Table *sqliteSrcListLookup(Parse *pParse, SrcList *pSrc){
           24  +Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
    25     25     Table *pTab = 0;
    26     26     int i;
    27     27     for(i=0; i<pSrc->nSrc; i++){
    28     28       const char *zTab = pSrc->a[i].zName;
    29     29       const char *zDb = pSrc->a[i].zDatabase;
    30         -    pTab = sqliteLocateTable(pParse, zTab, zDb);
           30  +    pTab = sqlite3LocateTable(pParse, zTab, zDb);
    31     31       pSrc->a[i].pTab = pTab;
    32     32     }
    33     33     return pTab;
    34     34   }
    35     35   
    36     36   /*
    37     37   ** Check to make sure the given table is writable.  If it is not
    38     38   ** writable, generate an error message and return 1.  If it is
    39     39   ** writable return 0;
    40     40   */
    41         -int sqliteIsReadOnly(Parse *pParse, Table *pTab, int viewOk){
           41  +int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){
    42     42     if( pTab->readOnly ){
    43         -    sqliteErrorMsg(pParse, "table %s may not be modified", pTab->zName);
           43  +    sqlite3ErrorMsg(pParse, "table %s may not be modified", pTab->zName);
    44     44       return 1;
    45     45     }
    46     46     if( !viewOk && pTab->pSelect ){
    47         -    sqliteErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName);
           47  +    sqlite3ErrorMsg(pParse, "cannot modify %s because it is a view",pTab->zName);
    48     48       return 1;
    49     49     }
    50     50     return 0;
    51     51   }
    52     52   
    53     53   /*
    54     54   ** Process a DELETE FROM statement.
    55     55   */
    56         -void sqliteDeleteFrom(
           56  +void sqlite3DeleteFrom(
    57     57     Parse *pParse,         /* The parser context */
    58     58     SrcList *pTabList,     /* The table from which we should delete things */
    59     59     Expr *pWhere           /* The WHERE clause.  May be null */
    60     60   ){
    61     61     Vdbe *v;               /* The virtual database engine */
    62     62     Table *pTab;           /* The table from which records will be deleted */
    63     63     const char *zDb;       /* Name of database holding pTab */
................................................................................
    84     84     assert( pTabList->nSrc==1 );
    85     85   
    86     86     /* Locate the table which we want to delete.  This table has to be
    87     87     ** put in an SrcList structure because some of the subroutines we
    88     88     ** will be calling are designed to work with multiple tables and expect
    89     89     ** an SrcList* parameter instead of just a Table* parameter.
    90     90     */
    91         -  pTab = sqliteSrcListLookup(pParse, pTabList);
           91  +  pTab = sqlite3SrcListLookup(pParse, pTabList);
    92     92     if( pTab==0 )  goto delete_from_cleanup;
    93         -  before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, 
           93  +  before_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger, 
    94     94                            TK_DELETE, TK_BEFORE, TK_ROW, 0);
    95         -  after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, 
           95  +  after_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger, 
    96     96                            TK_DELETE, TK_AFTER, TK_ROW, 0);
    97     97     row_triggers_exist = before_triggers || after_triggers;
    98     98     isView = pTab->pSelect!=0;
    99         -  if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){
           99  +  if( sqlite3IsReadOnly(pParse, pTab, before_triggers) ){
   100    100       goto delete_from_cleanup;
   101    101     }
   102    102     assert( pTab->iDb<db->nDb );
   103    103     zDb = db->aDb[pTab->iDb].zName;
   104         -  if( sqliteAuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
          104  +  if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
   105    105       goto delete_from_cleanup;
   106    106     }
   107    107   
   108    108     /* If pTab is really a view, make sure it has been initialized.
   109    109     */
   110         -  if( isView && sqliteViewGetColumnNames(pParse, pTab) ){
          110  +  if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){
   111    111       goto delete_from_cleanup;
   112    112     }
   113    113   
   114    114     /* Allocate a cursor used to store the old.* data for a trigger.
   115    115     */
   116    116     if( row_triggers_exist ){ 
   117    117       oldIdx = pParse->nTab++;
................................................................................
   118    118     }
   119    119   
   120    120     /* Resolve the column names in all the expressions.
   121    121     */
   122    122     assert( pTabList->nSrc==1 );
   123    123     iCur = pTabList->a[0].iCursor = pParse->nTab++;
   124    124     if( pWhere ){
   125         -    if( sqliteExprResolveIds(pParse, pTabList, 0, pWhere) ){
          125  +    if( sqlite3ExprResolveIds(pParse, pTabList, 0, pWhere) ){
   126    126         goto delete_from_cleanup;
   127    127       }
   128         -    if( sqliteExprCheck(pParse, pWhere, 0, 0) ){
          128  +    if( sqlite3ExprCheck(pParse, pWhere, 0, 0) ){
   129    129         goto delete_from_cleanup;
   130    130       }
   131    131     }
   132    132   
   133    133     /* Start the view context
   134    134     */
   135    135     if( isView ){
   136         -    sqliteAuthContextPush(pParse, &sContext, pTab->zName);
          136  +    sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
   137    137     }
   138    138   
   139    139     /* Begin generating code.
   140    140     */
   141         -  v = sqliteGetVdbe(pParse);
          141  +  v = sqlite3GetVdbe(pParse);
   142    142     if( v==0 ){
   143    143       goto delete_from_cleanup;
   144    144     }
   145         -  sqliteBeginWriteOperation(pParse, row_triggers_exist, pTab->iDb);
          145  +  sqlite3BeginWriteOperation(pParse, row_triggers_exist, pTab->iDb);
   146    146   
   147    147     /* If we are trying to delete from a view, construct that view into
   148    148     ** a temporary table.
   149    149     */
   150    150     if( isView ){
   151         -    Select *pView = sqliteSelectDup(pTab->pSelect);
   152         -    sqliteSelect(pParse, pView, SRT_TempTable, iCur, 0, 0, 0);
   153         -    sqliteSelectDelete(pView);
          151  +    Select *pView = sqlite3SelectDup(pTab->pSelect);
          152  +    sqlite3Select(pParse, pView, SRT_TempTable, iCur, 0, 0, 0);
          153  +    sqlite3SelectDelete(pView);
   154    154     }
   155    155   
   156    156     /* Initialize the counter of the number of rows deleted, if
   157    157     ** we are counting rows.
   158    158     */
   159    159     if( db->flags & SQLITE_CountRows ){
   160         -    sqliteVdbeAddOp(v, OP_Integer, 0, 0);
          160  +    sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
   161    161     }
   162    162   
   163    163     /* Special case: A DELETE without a WHERE clause deletes everything.
   164    164     ** It is easier just to erase the whole table.  Note, however, that
   165    165     ** this means that the row change count will be incorrect.
   166    166     */
   167    167     if( pWhere==0 && !row_triggers_exist ){
   168    168       if( db->flags & SQLITE_CountRows ){
   169    169         /* If counting rows deleted, just count the total number of
   170    170         ** entries in the table. */
   171         -      int endOfLoop = sqliteVdbeMakeLabel(v);
          171  +      int endOfLoop = sqlite3VdbeMakeLabel(v);
   172    172         int addr;
   173    173         if( !isView ){
   174         -        sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
   175         -        sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
          174  +        sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);
          175  +        sqlite3VdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
   176    176         }
   177         -      sqliteVdbeAddOp(v, OP_Rewind, iCur, sqliteVdbeCurrentAddr(v)+2);
   178         -      addr = sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
   179         -      sqliteVdbeAddOp(v, OP_Next, iCur, addr);
   180         -      sqliteVdbeResolveLabel(v, endOfLoop);
   181         -      sqliteVdbeAddOp(v, OP_Close, iCur, 0);
          177  +      sqlite3VdbeAddOp(v, OP_Rewind, iCur, sqlite3VdbeCurrentAddr(v)+2);
          178  +      addr = sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);
          179  +      sqlite3VdbeAddOp(v, OP_Next, iCur, addr);
          180  +      sqlite3VdbeResolveLabel(v, endOfLoop);
          181  +      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   182    182       }
   183    183       if( !isView ){
   184         -      sqliteVdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb);
          184  +      sqlite3VdbeAddOp(v, OP_Clear, pTab->tnum, pTab->iDb);
   185    185         for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
   186         -        sqliteVdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb);
          186  +        sqlite3VdbeAddOp(v, OP_Clear, pIdx->tnum, pIdx->iDb);
   187    187         }
   188    188       }
   189    189     }
   190    190   
   191    191     /* The usual case: There is a WHERE clause so we have to scan through
   192    192     ** the table and pick which records to delete.
   193    193     */
   194    194     else{
   195    195       /* Begin the database scan
   196    196       */
   197         -    pWInfo = sqliteWhereBegin(pParse, pTabList, pWhere, 1, 0);
          197  +    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 1, 0);
   198    198       if( pWInfo==0 ) goto delete_from_cleanup;
   199    199   
   200    200       /* Remember the key of every item to be deleted.
   201    201       */
   202         -    sqliteVdbeAddOp(v, OP_ListWrite, 0, 0);
          202  +    sqlite3VdbeAddOp(v, OP_ListWrite, 0, 0);
   203    203       if( db->flags & SQLITE_CountRows ){
   204         -      sqliteVdbeAddOp(v, OP_AddImm, 1, 0);
          204  +      sqlite3VdbeAddOp(v, OP_AddImm, 1, 0);
   205    205       }
   206    206   
   207    207       /* End the database scan loop.
   208    208       */
   209         -    sqliteWhereEnd(pWInfo);
          209  +    sqlite3WhereEnd(pWInfo);
   210    210   
   211    211       /* Open the pseudo-table used to store OLD if there are triggers.
   212    212       */
   213    213       if( row_triggers_exist ){
   214         -      sqliteVdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);
          214  +      sqlite3VdbeAddOp(v, OP_OpenPseudo, oldIdx, 0);
   215    215       }
   216    216   
   217    217       /* Delete every item whose key was written to the list during the
   218    218       ** database scan.  We have to delete items after the scan is complete
   219    219       ** because deleting an item can change the scan order.
   220    220       */
   221         -    sqliteVdbeAddOp(v, OP_ListRewind, 0, 0);
   222         -    end = sqliteVdbeMakeLabel(v);
          221  +    sqlite3VdbeAddOp(v, OP_ListRewind, 0, 0);
          222  +    end = sqlite3VdbeMakeLabel(v);
   223    223   
   224    224       /* This is the beginning of the delete loop when there are
   225    225       ** row triggers.
   226    226       */
   227    227       if( row_triggers_exist ){
   228         -      addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
   229         -      sqliteVdbeAddOp(v, OP_Dup, 0, 0);
          228  +      addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, end);
          229  +      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
   230    230         if( !isView ){
   231         -        sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
   232         -        sqliteVdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
          231  +        sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);
          232  +        sqlite3VdbeAddOp(v, OP_OpenRead, iCur, pTab->tnum);
   233    233         }
   234         -      sqliteVdbeAddOp(v, OP_MoveTo, iCur, 0);
          234  +      sqlite3VdbeAddOp(v, OP_MoveTo, iCur, 0);
   235    235   
   236         -      sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
   237         -      sqliteVdbeAddOp(v, OP_RowData, iCur, 0);
   238         -      sqliteVdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
          236  +      sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);
          237  +      sqlite3VdbeAddOp(v, OP_RowData, iCur, 0);
          238  +      sqlite3VdbeAddOp(v, OP_PutIntKey, oldIdx, 0);
   239    239         if( !isView ){
   240         -        sqliteVdbeAddOp(v, OP_Close, iCur, 0);
          240  +        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   241    241         }
   242    242   
   243         -      sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, 
          243  +      sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_BEFORE, pTab, -1, 
   244    244             oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
   245    245   	  addr);
   246    246       }
   247    247   
   248    248       if( !isView ){
   249    249         /* Open cursors for the table we are deleting from and all its
   250    250         ** indices.  If there are row triggers, this happens inside the
   251    251         ** OP_ListRead loop because the cursor have to all be closed
   252    252         ** before the trigger fires.  If there are no row triggers, the
   253    253         ** cursors are opened only once on the outside the loop.
   254    254         */
   255    255         pParse->nTab = iCur + 1;
   256         -      sqliteOpenTableAndIndices(pParse, pTab, iCur);
          256  +      sqlite3OpenTableAndIndices(pParse, pTab, iCur);
   257    257   
   258    258         /* This is the beginning of the delete loop when there are no
   259    259         ** row triggers */
   260    260         if( !row_triggers_exist ){ 
   261         -        addr = sqliteVdbeAddOp(v, OP_ListRead, 0, end);
          261  +        addr = sqlite3VdbeAddOp(v, OP_ListRead, 0, end);
   262    262         }
   263    263   
   264    264         /* Delete the row */
   265         -      sqliteGenerateRowDelete(db, v, pTab, iCur, pParse->trigStack==0);
          265  +      sqlite3GenerateRowDelete(db, v, pTab, iCur, pParse->trigStack==0);
   266    266       }
   267    267   
   268    268       /* If there are row triggers, close all cursors then invoke
   269    269       ** the AFTER triggers
   270    270       */
   271    271       if( row_triggers_exist ){
   272    272         if( !isView ){
   273    273           for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
   274         -          sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
          274  +          sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
   275    275           }
   276         -        sqliteVdbeAddOp(v, OP_Close, iCur, 0);
          276  +        sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   277    277         }
   278         -      sqliteCodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, 
          278  +      sqlite3CodeRowTrigger(pParse, TK_DELETE, 0, TK_AFTER, pTab, -1, 
   279    279             oldIdx, (pParse->trigStack)?pParse->trigStack->orconf:OE_Default,
   280    280   	  addr);
   281    281       }
   282    282   
   283    283       /* End of the delete loop */
   284         -    sqliteVdbeAddOp(v, OP_Goto, 0, addr);
   285         -    sqliteVdbeResolveLabel(v, end);
   286         -    sqliteVdbeAddOp(v, OP_ListReset, 0, 0);
          284  +    sqlite3VdbeAddOp(v, OP_Goto, 0, addr);
          285  +    sqlite3VdbeResolveLabel(v, end);
          286  +    sqlite3VdbeAddOp(v, OP_ListReset, 0, 0);
   287    287   
   288    288       /* Close the cursors after the loop if there are no row triggers */
   289    289       if( !row_triggers_exist ){
   290    290         for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
   291         -        sqliteVdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
          291  +        sqlite3VdbeAddOp(v, OP_Close, iCur + i, pIdx->tnum);
   292    292         }
   293         -      sqliteVdbeAddOp(v, OP_Close, iCur, 0);
          293  +      sqlite3VdbeAddOp(v, OP_Close, iCur, 0);
   294    294         pParse->nTab = iCur;
   295    295       }
   296    296     }
   297         -  sqliteVdbeAddOp(v, OP_SetCounts, 0, 0);
   298         -  sqliteEndWriteOperation(pParse);
          297  +  sqlite3VdbeAddOp(v, OP_SetCounts, 0, 0);
          298  +  sqlite3EndWriteOperation(pParse);
   299    299   
   300    300     /*
   301    301     ** Return the number of rows that were deleted.
   302    302     */
   303    303     if( db->flags & SQLITE_CountRows ){
   304         -    sqliteVdbeAddOp(v, OP_ColumnName, 0, 1);
   305         -    sqliteVdbeChangeP3(v, -1, "rows deleted", P3_STATIC);
   306         -    sqliteVdbeAddOp(v, OP_Callback, 1, 0);
          304  +    sqlite3VdbeAddOp(v, OP_ColumnName, 0, 1);
          305  +    sqlite3VdbeChangeP3(v, -1, "rows deleted", P3_STATIC);
          306  +    sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
   307    307     }
   308    308   
   309    309   delete_from_cleanup:
   310         -  sqliteAuthContextPop(&sContext);
   311         -  sqliteSrcListDelete(pTabList);
   312         -  sqliteExprDelete(pWhere);
          310  +  sqlite3AuthContextPop(&sContext);
          311  +  sqlite3SrcListDelete(pTabList);
          312  +  sqlite3ExprDelete(pWhere);
   313    313     return;
   314    314   }
   315    315   
   316    316   /*
   317    317   ** This routine generates VDBE code that causes a single row of a
   318    318   ** single table to be deleted.
   319    319   **
................................................................................
   329    329   **   3.  The record number of the row to be deleted must be on the top
   330    330   **       of the stack.
   331    331   **
   332    332   ** This routine pops the top of the stack to remove the record number
   333    333   ** and then generates code to remove both the table record and all index
   334    334   ** entries that point to that record.
   335    335   */
   336         -void sqliteGenerateRowDelete(
          336  +void sqlite3GenerateRowDelete(
   337    337     sqlite *db,        /* The database containing the index */
   338    338     Vdbe *v,           /* Generate code into this VDBE */
   339    339     Table *pTab,       /* Table containing the row to be deleted */
   340    340     int iCur,          /* Cursor number for the table */
   341    341     int count          /* Increment the row change counter */
   342    342   ){
   343    343     int addr;
   344         -  addr = sqliteVdbeAddOp(v, OP_NotExists, iCur, 0);
   345         -  sqliteGenerateRowIndexDelete(db, v, pTab, iCur, 0);
   346         -  sqliteVdbeAddOp(v, OP_Delete, iCur,
          344  +  addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0);
          345  +  sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, 0);
          346  +  sqlite3VdbeAddOp(v, OP_Delete, iCur,
   347    347       (count?OPFLAG_NCHANGE:0) | OPFLAG_CSCHANGE);
   348         -  sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));
          348  +  sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
   349    349   }
   350    350   
   351    351   /*
   352    352   ** This routine generates VDBE code that causes the deletion of all
   353    353   ** index entries associated with a single row of a single table.
   354    354   **
   355    355   ** The VDBE must be in a particular state when this routine is called.
................................................................................
   360    360   **
   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         -void sqliteGenerateRowIndexDelete(
          367  +void sqlite3GenerateRowIndexDelete(
   368    368     sqlite *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;
   376    376   
   377    377     for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){
   378    378       int j;
   379    379       if( aIdxUsed!=0 && aIdxUsed[i-1]==0 ) continue;
   380         -    sqliteVdbeAddOp(v, OP_Recno, iCur, 0);
          380  +    sqlite3VdbeAddOp(v, OP_Recno, iCur, 0);
   381    381       for(j=0; j<pIdx->nColumn; j++){
   382    382         int idx = pIdx->aiColumn[j];
   383    383         if( idx==pTab->iPKey ){
   384         -        sqliteVdbeAddOp(v, OP_Dup, j, 0);
          384  +        sqlite3VdbeAddOp(v, OP_Dup, j, 0);
   385    385         }else{
   386         -        sqliteVdbeAddOp(v, OP_Column, iCur, idx);
          386  +        sqlite3VdbeAddOp(v, OP_Column, iCur, idx);
   387    387         }
   388    388       }
   389         -    sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
   390         -    if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx);
   391         -    sqliteVdbeAddOp(v, OP_IdxDelete, iCur+i, 0);
          389  +    sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
          390  +    if( db->file_format>=4 ) sqlite3AddIdxKeyType(v, pIdx);
          391  +    sqlite3VdbeAddOp(v, OP_IdxDelete, iCur+i, 0);
   392    392     }
   393    393   }
          394  +
          395  +
          396  +

Changes to src/encode.c.

    11     11   *************************************************************************
    12     12   ** This file contains helper routines used to translate binary data into
    13     13   ** a null-terminated string (suitable for use in SQLite) and back again.
    14     14   ** These are convenience routines for use by people who want to store binary
    15     15   ** data in an SQLite database.  The code in this file is not used by any other
    16     16   ** part of the SQLite library.
    17     17   **
    18         -** $Id: encode.c,v 1.12 2004/03/17 18:44:46 drh Exp $
           18  +** $Id: encode.c,v 1.13 2004/05/08 08:23:24 danielk1977 Exp $
    19     19   */
    20     20   #include <string.h>
    21     21   #include <assert.h>
    22     22   
    23     23   /*
    24     24   ** How This Encoder Works
    25     25   **
................................................................................
   248    248     }
   249    249     fprintf(stderr,"Finished.  Total encoding: %d->%d bytes\n",
   250    250             nByteIn, nByteOut);
   251    251     fprintf(stderr,"Avg size increase: %.3f%%\n",
   252    252       (nByteOut-nByteIn)*100.0/(double)nByteIn);
   253    253   }
   254    254   #endif /* ENCODER_TEST */
          255  +
          256  +
          257  +

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.114 2004/04/23 17:04:45 drh Exp $
           15  +** $Id: expr.c,v 1.115 2004/05/08 08:23:24 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Construct a new expression node and return a pointer to it.  Memory
    22     22   ** for this node is obtained from sqliteMalloc().  The calling function
    23     23   ** is responsible for making sure the node eventually gets freed.
    24     24   */
    25         -Expr *sqliteExpr(int op, Expr *pLeft, Expr *pRight, Token *pToken){
           25  +Expr *sqlite3Expr(int op, Expr *pLeft, Expr *pRight, Token *pToken){
    26     26     Expr *pNew;
    27     27     pNew = sqliteMalloc( sizeof(Expr) );
    28     28     if( pNew==0 ){
    29     29       /* When malloc fails, we leak memory from pLeft and pRight */
    30     30       return 0;
    31     31     }
    32     32     pNew->op = op;
................................................................................
    37     37       pNew->token = *pToken;
    38     38       pNew->span = *pToken;
    39     39     }else{
    40     40       assert( pNew->token.dyn==0 );
    41     41       assert( pNew->token.z==0 );
    42     42       assert( pNew->token.n==0 );
    43     43       if( pLeft && pRight ){
    44         -      sqliteExprSpan(pNew, &pLeft->span, &pRight->span);
           44  +      sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span);
    45     45       }else{
    46     46         pNew->span = pNew->token;
    47     47       }
    48     48     }
    49     49     return pNew;
    50     50   }
    51     51   
    52     52   /*
    53     53   ** Set the Expr.span field of the given expression to span all
    54     54   ** text between the two given tokens.
    55     55   */
    56         -void sqliteExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){
           56  +void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){
    57     57     assert( pRight!=0 );
    58     58     assert( pLeft!=0 );
    59     59     /* Note: pExpr might be NULL due to a prior malloc failure */
    60     60     if( pExpr && pRight->z && pLeft->z ){
    61     61       if( pLeft->dyn==0 && pRight->dyn==0 ){
    62     62         pExpr->span.z = pLeft->z;
    63     63         pExpr->span.n = pRight->n + Addr(pRight->z) - Addr(pLeft->z);
................................................................................
    67     67     }
    68     68   }
    69     69   
    70     70   /*
    71     71   ** Construct a new expression node for a function with multiple
    72     72   ** arguments.
    73     73   */
    74         -Expr *sqliteExprFunction(ExprList *pList, Token *pToken){
           74  +Expr *sqlite3ExprFunction(ExprList *pList, Token *pToken){
    75     75     Expr *pNew;
    76     76     pNew = sqliteMalloc( sizeof(Expr) );
    77     77     if( pNew==0 ){
    78         -    /* sqliteExprListDelete(pList); // Leak pList when malloc fails */
           78  +    /* sqlite3ExprListDelete(pList); // Leak pList when malloc fails */
    79     79       return 0;
    80     80     }
    81     81     pNew->op = TK_FUNCTION;
    82     82     pNew->pList = pList;
    83     83     if( pToken ){
    84     84       assert( pToken->dyn==0 );
    85     85       pNew->token = *pToken;
................................................................................
    89     89     pNew->span = pNew->token;
    90     90     return pNew;
    91     91   }
    92     92   
    93     93   /*
    94     94   ** Recursively delete an expression tree.
    95     95   */
    96         -void sqliteExprDelete(Expr *p){
           96  +void sqlite3ExprDelete(Expr *p){
    97     97     if( p==0 ) return;
    98     98     if( p->span.dyn ) sqliteFree((char*)p->span.z);
    99     99     if( p->token.dyn ) sqliteFree((char*)p->token.z);
   100         -  sqliteExprDelete(p->pLeft);
   101         -  sqliteExprDelete(p->pRight);
   102         -  sqliteExprListDelete(p->pList);
   103         -  sqliteSelectDelete(p->pSelect);
          100  +  sqlite3ExprDelete(p->pLeft);
          101  +  sqlite3ExprDelete(p->pRight);
          102  +  sqlite3ExprListDelete(p->pList);
          103  +  sqlite3SelectDelete(p->pSelect);
   104    104     sqliteFree(p);
   105    105   }
   106    106   
   107    107   
   108    108   /*
   109    109   ** The following group of routines make deep copies of expressions,
   110    110   ** expression lists, ID lists, and select statements.  The copies can
   111    111   ** be deleted (by being passed to their respective ...Delete() routines)
   112    112   ** without effecting the originals.
   113    113   **
   114         -** The expression list, ID, and source lists return by sqliteExprListDup(),
   115         -** sqliteIdListDup(), and sqliteSrcListDup() can not be further expanded 
          114  +** The expression list, ID, and source lists return by sqlite3ExprListDup(),
          115  +** sqlite3IdListDup(), and sqlite3SrcListDup() can not be further expanded 
   116    116   ** by subsequent calls to sqlite*ListAppend() routines.
   117    117   **
   118    118   ** Any tables that the SrcList might point to are not duplicated.
   119    119   */
   120         -Expr *sqliteExprDup(Expr *p){
          120  +Expr *sqlite3ExprDup(Expr *p){
   121    121     Expr *pNew;
   122    122     if( p==0 ) return 0;
   123    123     pNew = sqliteMallocRaw( sizeof(*p) );
   124    124     if( pNew==0 ) return 0;
   125    125     memcpy(pNew, p, sizeof(*pNew));
   126    126     if( p->token.z!=0 ){
   127    127       pNew->token.z = sqliteStrDup(p->token.z);
   128    128       pNew->token.dyn = 1;
   129    129     }else{
   130    130       assert( pNew->token.z==0 );
   131    131     }
   132    132     pNew->span.z = 0;
   133         -  pNew->pLeft = sqliteExprDup(p->pLeft);
   134         -  pNew->pRight = sqliteExprDup(p->pRight);
   135         -  pNew->pList = sqliteExprListDup(p->pList);
   136         -  pNew->pSelect = sqliteSelectDup(p->pSelect);
          133  +  pNew->pLeft = sqlite3ExprDup(p->pLeft);
          134  +  pNew->pRight = sqlite3ExprDup(p->pRight);
          135  +  pNew->pList = sqlite3ExprListDup(p->pList);
          136  +  pNew->pSelect = sqlite3SelectDup(p->pSelect);
   137    137     return pNew;
   138    138   }
   139         -void sqliteTokenCopy(Token *pTo, Token *pFrom){
          139  +void sqlite3TokenCopy(Token *pTo, Token *pFrom){
   140    140     if( pTo->dyn ) sqliteFree((char*)pTo->z);
   141    141     if( pFrom->z ){
   142    142       pTo->n = pFrom->n;
   143    143       pTo->z = sqliteStrNDup(pFrom->z, pFrom->n);
   144    144       pTo->dyn = 1;
   145    145     }else{
   146    146       pTo->z = 0;
   147    147     }
   148    148   }
   149         -ExprList *sqliteExprListDup(ExprList *p){
          149  +ExprList *sqlite3ExprListDup(ExprList *p){
   150    150     ExprList *pNew;
   151    151     struct ExprList_item *pItem;
   152    152     int i;
   153    153     if( p==0 ) return 0;
   154    154     pNew = sqliteMalloc( sizeof(*pNew) );
   155    155     if( pNew==0 ) return 0;
   156    156     pNew->nExpr = pNew->nAlloc = p->nExpr;
   157    157     pNew->a = pItem = sqliteMalloc( p->nExpr*sizeof(p->a[0]) );
   158    158     if( pItem==0 ) return 0;  /* Leaks memory after a malloc failure */
   159    159     for(i=0; i<p->nExpr; i++, pItem++){
   160    160       Expr *pNewExpr, *pOldExpr;
   161         -    pItem->pExpr = pNewExpr = sqliteExprDup(pOldExpr = p->a[i].pExpr);
          161  +    pItem->pExpr = pNewExpr = sqlite3ExprDup(pOldExpr = p->a[i].pExpr);
   162    162       if( pOldExpr->span.z!=0 && pNewExpr ){
   163    163         /* Always make a copy of the span for top-level expressions in the
   164    164         ** expression list.  The logic in SELECT processing that determines
   165    165         ** the names of columns in the result set needs this information */
   166         -      sqliteTokenCopy(&pNewExpr->span, &pOldExpr->span);
          166  +      sqlite3TokenCopy(&pNewExpr->span, &pOldExpr->span);
   167    167       }
   168    168       assert( pNewExpr==0 || pNewExpr->span.z!=0 
   169    169               || pOldExpr->span.z==0 || sqlite_malloc_failed );
   170    170       pItem->zName = sqliteStrDup(p->a[i].zName);
   171    171       pItem->sortOrder = p->a[i].sortOrder;
   172    172       pItem->isAgg = p->a[i].isAgg;
   173    173       pItem->done = 0;
   174    174     }
   175    175     return pNew;
   176    176   }
   177         -SrcList *sqliteSrcListDup(SrcList *p){
          177  +SrcList *sqlite3SrcListDup(SrcList *p){
   178    178     SrcList *pNew;
   179    179     int i;
   180    180     int nByte;
   181    181     if( p==0 ) return 0;
   182    182     nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);
   183    183     pNew = sqliteMallocRaw( nByte );
   184    184     if( pNew==0 ) return 0;
................................................................................
   188    188       struct SrcList_item *pOldItem = &p->a[i];
   189    189       pNewItem->zDatabase = sqliteStrDup(pOldItem->zDatabase);
   190    190       pNewItem->zName = sqliteStrDup(pOldItem->zName);
   191    191       pNewItem->zAlias = sqliteStrDup(pOldItem->zAlias);
   192    192       pNewItem->jointype = pOldItem->jointype;
   193    193       pNewItem->iCursor = pOldItem->iCursor;
   194    194       pNewItem->pTab = 0;
   195         -    pNewItem->pSelect = sqliteSelectDup(pOldItem->pSelect);
   196         -    pNewItem->pOn = sqliteExprDup(pOldItem->pOn);
   197         -    pNewItem->pUsing = sqliteIdListDup(pOldItem->pUsing);
          195  +    pNewItem->pSelect = sqlite3SelectDup(pOldItem->pSelect);
          196  +    pNewItem->pOn = sqlite3ExprDup(pOldItem->pOn);
          197  +    pNewItem->pUsing = sqlite3IdListDup(pOldItem->pUsing);
   198    198     }
   199    199     return pNew;
   200    200   }
   201         -IdList *sqliteIdListDup(IdList *p){
          201  +IdList *sqlite3IdListDup(IdList *p){
   202    202     IdList *pNew;
   203    203     int i;
   204    204     if( p==0 ) return 0;
   205    205     pNew = sqliteMallocRaw( sizeof(*pNew) );
   206    206     if( pNew==0 ) return 0;
   207    207     pNew->nId = pNew->nAlloc = p->nId;
   208    208     pNew->a = sqliteMallocRaw( p->nId*sizeof(p->a[0]) );
................................................................................
   211    211       struct IdList_item *pNewItem = &pNew->a[i];
   212    212       struct IdList_item *pOldItem = &p->a[i];
   213    213       pNewItem->zName = sqliteStrDup(pOldItem->zName);
   214    214       pNewItem->idx = pOldItem->idx;
   215    215     }
   216    216     return pNew;
   217    217   }
   218         -Select *sqliteSelectDup(Select *p){
          218  +Select *sqlite3SelectDup(Select *p){
   219    219     Select *pNew;
   220    220     if( p==0 ) return 0;
   221    221     pNew = sqliteMallocRaw( sizeof(*p) );
   222    222     if( pNew==0 ) return 0;
   223    223     pNew->isDistinct = p->isDistinct;
   224         -  pNew->pEList = sqliteExprListDup(p->pEList);
   225         -  pNew->pSrc = sqliteSrcListDup(p->pSrc);
   226         -  pNew->pWhere = sqliteExprDup(p->pWhere);
   227         -  pNew->pGroupBy = sqliteExprListDup(p->pGroupBy);
   228         -  pNew->pHaving = sqliteExprDup(p->pHaving);
   229         -  pNew->pOrderBy = sqliteExprListDup(p->pOrderBy);
          224  +  pNew->pEList = sqlite3ExprListDup(p->pEList);
          225  +  pNew->pSrc = sqlite3SrcListDup(p->pSrc);
          226  +  pNew->pWhere = sqlite3ExprDup(p->pWhere);
          227  +  pNew->pGroupBy = sqlite3ExprListDup(p->pGroupBy);
          228  +  pNew->pHaving = sqlite3ExprDup(p->pHaving);
          229  +  pNew->pOrderBy = sqlite3ExprListDup(p->pOrderBy);
   230    230     pNew->op = p->op;
   231         -  pNew->pPrior = sqliteSelectDup(p->pPrior);
          231  +  pNew->pPrior = sqlite3SelectDup(p->pPrior);
   232    232     pNew->nLimit = p->nLimit;
   233    233     pNew->nOffset = p->nOffset;
   234    234     pNew->zSelect = 0;
   235    235     pNew->iLimit = -1;
   236    236     pNew->iOffset = -1;
   237    237     return pNew;
   238    238   }
   239    239   
   240    240   
   241    241   /*
   242    242   ** Add a new element to the end of an expression list.  If pList is
   243    243   ** initially NULL, then create a new expression list.
   244    244   */
   245         -ExprList *sqliteExprListAppend(ExprList *pList, Expr *pExpr, Token *pName){
          245  +ExprList *sqlite3ExprListAppend(ExprList *pList, Expr *pExpr, Token *pName){
   246    246     if( pList==0 ){
   247    247       pList = sqliteMalloc( sizeof(ExprList) );
   248    248       if( pList==0 ){
   249         -      /* sqliteExprDelete(pExpr); // Leak memory if malloc fails */
          249  +      /* sqlite3ExprDelete(pExpr); // Leak memory if malloc fails */
   250    250         return 0;
   251    251       }
   252    252       assert( pList->nAlloc==0 );
   253    253     }
   254    254     if( pList->nAlloc<=pList->nExpr ){
   255    255       pList->nAlloc = pList->nAlloc*2 + 4;
   256    256       pList->a = sqliteRealloc(pList->a, pList->nAlloc*sizeof(pList->a[0]));
   257    257       if( pList->a==0 ){
   258         -      /* sqliteExprDelete(pExpr); // Leak memory if malloc fails */
          258  +      /* sqlite3ExprDelete(pExpr); // Leak memory if malloc fails */
   259    259         pList->nExpr = pList->nAlloc = 0;
   260    260         return pList;
   261    261       }
   262    262     }
   263    263     assert( pList->a!=0 );
   264    264     if( pExpr || pName ){
   265    265       struct ExprList_item *pItem = &pList->a[pList->nExpr++];
   266    266       memset(pItem, 0, sizeof(*pItem));
   267    267       pItem->pExpr = pExpr;
   268    268       if( pName ){
   269         -      sqliteSetNString(&pItem->zName, pName->z, pName->n, 0);
   270         -      sqliteDequote(pItem->zName);
          269  +      sqlite3SetNString(&pItem->zName, pName->z, pName->n, 0);
          270  +      sqlite3Dequote(pItem->zName);
   271    271       }
   272    272     }
   273    273     return pList;
   274    274   }
   275    275   
   276    276   /*
   277    277   ** Delete an entire expression list.
   278    278   */
   279         -void sqliteExprListDelete(ExprList *pList){
          279  +void sqlite3ExprListDelete(ExprList *pList){
   280    280     int i;
   281    281     if( pList==0 ) return;
   282    282     assert( pList->a!=0 || (pList->nExpr==0 && pList->nAlloc==0) );
   283    283     assert( pList->nExpr<=pList->nAlloc );
   284    284     for(i=0; i<pList->nExpr; i++){
   285         -    sqliteExprDelete(pList->a[i].pExpr);
          285  +    sqlite3ExprDelete(pList->a[i].pExpr);
   286    286       sqliteFree(pList->a[i].zName);
   287    287     }
   288    288     sqliteFree(pList->a);
   289    289     sqliteFree(pList);
   290    290   }
   291    291   
   292    292   /*
................................................................................
   293    293   ** Walk an expression tree.  Return 1 if the expression is constant
   294    294   ** and 0 if it involves variables.
   295    295   **
   296    296   ** For the purposes of this function, a double-quoted string (ex: "abc")
   297    297   ** is considered a variable but a single-quoted string (ex: 'abc') is
   298    298   ** a constant.
   299    299   */
   300         -int sqliteExprIsConstant(Expr *p){
          300  +int sqlite3ExprIsConstant(Expr *p){
   301    301     switch( p->op ){
   302    302       case TK_ID:
   303    303       case TK_COLUMN:
   304    304       case TK_DOT:
   305    305       case TK_FUNCTION:
   306    306         return 0;
   307    307       case TK_NULL:
   308    308       case TK_STRING:
   309    309       case TK_INTEGER:
   310    310       case TK_FLOAT:
   311    311       case TK_VARIABLE:
   312    312         return 1;
   313    313       default: {
   314         -      if( p->pLeft && !sqliteExprIsConstant(p->pLeft) ) return 0;
   315         -      if( p->pRight && !sqliteExprIsConstant(p->pRight) ) return 0;
          314  +      if( p->pLeft && !sqlite3ExprIsConstant(p->pLeft) ) return 0;
          315  +      if( p->pRight && !sqlite3ExprIsConstant(p->pRight) ) return 0;
   316    316         if( p->pList ){
   317    317           int i;
   318    318           for(i=0; i<p->pList->nExpr; i++){
   319         -          if( !sqliteExprIsConstant(p->pList->a[i].pExpr) ) return 0;
          319  +          if( !sqlite3ExprIsConstant(p->pList->a[i].pExpr) ) return 0;
   320    320           }
   321    321         }
   322    322         return p->pLeft!=0 || p->pRight!=0 || (p->pList && p->pList->nExpr>0);
   323    323       }
   324    324     }
   325    325     return 0;
   326    326   }
................................................................................
   327    327   
   328    328   /*
   329    329   ** If the given expression codes a constant integer that is small enough
   330    330   ** to fit in a 32-bit integer, return 1 and put the value of the integer
   331    331   ** in *pValue.  If the expression is not an integer or if it is too big
   332    332   ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged.
   333    333   */
   334         -int sqliteExprIsInteger(Expr *p, int *pValue){
          334  +int sqlite3ExprIsInteger(Expr *p, int *pValue){
   335    335     switch( p->op ){
   336    336       case TK_INTEGER: {
   337         -      if( sqliteFitsIn32Bits(p->token.z) ){
          337  +      if( sqlite3FitsIn32Bits(p->token.z) ){
   338    338           *pValue = atoi(p->token.z);
   339    339           return 1;
   340    340         }
   341    341         break;
   342    342       }
   343    343       case TK_STRING: {
   344    344         const char *z = p->token.z;
   345    345         int n = p->token.n;
   346    346         if( n>0 && z[0]=='-' ){ z++; n--; }
   347    347         while( n>0 && *z && isdigit(*z) ){ z++; n--; }
   348         -      if( n==0 && sqliteFitsIn32Bits(p->token.z) ){
          348  +      if( n==0 && sqlite3FitsIn32Bits(p->token.z) ){
   349    349           *pValue = atoi(p->token.z);
   350    350           return 1;
   351    351         }
   352    352         break;
   353    353       }
   354    354       case TK_UPLUS: {
   355         -      return sqliteExprIsInteger(p->pLeft, pValue);
          355  +      return sqlite3ExprIsInteger(p->pLeft, pValue);
   356    356       }
   357    357       case TK_UMINUS: {
   358    358         int v;
   359         -      if( sqliteExprIsInteger(p->pLeft, &v) ){
          359  +      if( sqlite3ExprIsInteger(p->pLeft, &v) ){
   360    360           *pValue = -v;
   361    361           return 1;
   362    362         }
   363    363         break;
   364    364       }
   365    365       default: break;
   366    366     }
   367    367     return 0;
   368    368   }
   369    369   
   370    370   /*
   371    371   ** Return TRUE if the given string is a row-id column name.
   372    372   */
   373         -int sqliteIsRowid(const char *z){
   374         -  if( sqliteStrICmp(z, "_ROWID_")==0 ) return 1;
   375         -  if( sqliteStrICmp(z, "ROWID")==0 ) return 1;
   376         -  if( sqliteStrICmp(z, "OID")==0 ) return 1;
          373  +int sqlite3IsRowid(const char *z){
          374  +  if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1;
          375  +  if( sqlite3StrICmp(z, "ROWID")==0 ) return 1;
          376  +  if( sqlite3StrICmp(z, "OID")==0 ) return 1;
   377    377     return 0;
   378    378   }
   379    379   
   380    380   /*
   381    381   ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up
   382    382   ** that name in the set of source tables in pSrcList and make the pExpr 
   383    383   ** expression node refer back to that source column.  The following changes
................................................................................
   419    419     int cnt = 0;         /* Number of matching column names */
   420    420     int cntTab = 0;      /* Number of matching table names */
   421    421     sqlite *db = pParse->db;  /* The database */
   422    422   
   423    423     assert( pColumnToken && pColumnToken->z ); /* The Z in X.Y.Z cannot be NULL */
   424    424     if( pDbToken && pDbToken->z ){
   425    425       zDb = sqliteStrNDup(pDbToken->z, pDbToken->n);
   426         -    sqliteDequote(zDb);
          426  +    sqlite3Dequote(zDb);
   427    427     }else{
   428    428       zDb = 0;
   429    429     }
   430    430     if( pTableToken && pTableToken->z ){
   431    431       zTab = sqliteStrNDup(pTableToken->z, pTableToken->n);
   432         -    sqliteDequote(zTab);
          432  +    sqlite3Dequote(zTab);
   433    433     }else{
   434    434       assert( zDb==0 );
   435    435       zTab = 0;
   436    436     }
   437    437     zCol = sqliteStrNDup(pColumnToken->z, pColumnToken->n);
   438         -  sqliteDequote(zCol);
          438  +  sqlite3Dequote(zCol);
   439    439     if( sqlite_malloc_failed ){
   440    440       return 1;  /* Leak memory (zDb and zTab) if malloc fails */
   441    441     }
   442    442     assert( zTab==0 || pEList==0 );
   443    443   
   444    444     pExpr->iTable = -1;
   445    445     for(i=0; i<pSrcList->nSrc; i++){
................................................................................
   448    448       Column *pCol;
   449    449   
   450    450       if( pTab==0 ) continue;
   451    451       assert( pTab->nCol>0 );
   452    452       if( zTab ){
   453    453         if( pItem->zAlias ){
   454    454           char *zTabName = pItem->zAlias;
   455         -        if( sqliteStrICmp(zTabName, zTab)!=0 ) continue;
          455  +        if( sqlite3StrICmp(zTabName, zTab)!=0 ) continue;
   456    456         }else{
   457    457           char *zTabName = pTab->zName;
   458         -        if( zTabName==0 || sqliteStrICmp(zTabName, zTab)!=0 ) continue;
   459         -        if( zDb!=0 && sqliteStrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){
          458  +        if( zTabName==0 || sqlite3StrICmp(zTabName, zTab)!=0 ) continue;
          459  +        if( zDb!=0 && sqlite3StrICmp(db->aDb[pTab->iDb].zName, zDb)!=0 ){
   460    460             continue;
   461    461           }
   462    462         }
   463    463       }
   464    464       if( 0==(cntTab++) ){
   465    465         pExpr->iTable = pItem->iCursor;
   466    466         pExpr->iDb = pTab->iDb;
   467    467       }
   468    468       for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
   469         -      if( sqliteStrICmp(pCol->zName, zCol)==0 ){
          469  +      if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
   470    470           cnt++;
   471    471           pExpr->iTable = pItem->iCursor;
   472    472           pExpr->iDb = pTab->iDb;
   473    473           /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
   474    474           pExpr->iColumn = j==pTab->iPKey ? -1 : j;
   475    475           pExpr->dataType = pCol->sortOrder & SQLITE_SO_TYPEMASK;
   476    476           break;
................................................................................
   480    480   
   481    481     /* If we have not already resolved the name, then maybe 
   482    482     ** it is a new.* or old.* trigger argument reference
   483    483     */
   484    484     if( zDb==0 && zTab!=0 && cnt==0 && pParse->trigStack!=0 ){
   485    485       TriggerStack *pTriggerStack = pParse->trigStack;
   486    486       Table *pTab = 0;
   487         -    if( pTriggerStack->newIdx != -1 && sqliteStrICmp("new", zTab) == 0 ){
          487  +    if( pTriggerStack->newIdx != -1 && sqlite3StrICmp("new", zTab) == 0 ){
   488    488         pExpr->iTable = pTriggerStack->newIdx;
   489    489         assert( pTriggerStack->pTab );
   490    490         pTab = pTriggerStack->pTab;
   491         -    }else if( pTriggerStack->oldIdx != -1 && sqliteStrICmp("old", zTab) == 0 ){
          491  +    }else if( pTriggerStack->oldIdx != -1 && sqlite3StrICmp("old", zTab) == 0 ){
   492    492         pExpr->iTable = pTriggerStack->oldIdx;
   493    493         assert( pTriggerStack->pTab );
   494    494         pTab = pTriggerStack->pTab;
   495    495       }
   496    496   
   497    497       if( pTab ){ 
   498    498         int j;
   499    499         Column *pCol = pTab->aCol;
   500    500         
   501    501         pExpr->iDb = pTab->iDb;
   502    502         cntTab++;
   503    503         for(j=0; j < pTab->nCol; j++, pCol++) {
   504         -        if( sqliteStrICmp(pCol->zName, zCol)==0 ){
          504  +        if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
   505    505             cnt++;
   506    506             pExpr->iColumn = j==pTab->iPKey ? -1 : j;
   507    507             pExpr->dataType = pCol->sortOrder & SQLITE_SO_TYPEMASK;
   508    508             break;
   509    509           }
   510    510         }
   511    511       }
   512    512     }
   513    513   
   514    514     /*
   515    515     ** Perhaps the name is a reference to the ROWID
   516    516     */
   517         -  if( cnt==0 && cntTab==1 && sqliteIsRowid(zCol) ){
          517  +  if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
   518    518       cnt = 1;
   519    519       pExpr->iColumn = -1;
   520    520       pExpr->dataType = SQLITE_SO_NUM;
   521    521     }
   522    522   
   523    523     /*
   524    524     ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
................................................................................
   531    531     ** forms the result set entry ("a+b" in the example) and return immediately.
   532    532     ** Note that the expression in the result set should have already been
   533    533     ** resolved by the time the WHERE clause is resolved.
   534    534     */
   535    535     if( cnt==0 && pEList!=0 ){
   536    536       for(j=0; j<pEList->nExpr; j++){
   537    537         char *zAs = pEList->a[j].zName;
   538         -      if( zAs!=0 && sqliteStrICmp(zAs, zCol)==0 ){
          538  +      if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
   539    539           assert( pExpr->pLeft==0 && pExpr->pRight==0 );
   540    540           pExpr->op = TK_AS;
   541    541           pExpr->iColumn = j;
   542         -        pExpr->pLeft = sqliteExprDup(pEList->a[j].pExpr);
          542  +        pExpr->pLeft = sqlite3ExprDup(pEList->a[j].pExpr);
   543    543           sqliteFree(zCol);
   544    544           assert( zTab==0 && zDb==0 );
   545    545           return 0;
   546    546         }
   547    547       } 
   548    548     }
   549    549   
................................................................................
   564    564     ** more matches.  Either way, we have an error.
   565    565     */
   566    566     if( cnt!=1 ){
   567    567       char *z = 0;
   568    568       char *zErr;
   569    569       zErr = cnt==0 ? "no such column: %s" : "ambiguous column name: %s";
   570    570       if( zDb ){
   571         -      sqliteSetString(&z, zDb, ".", zTab, ".", zCol, 0);
          571  +      sqlite3SetString(&z, zDb, ".", zTab, ".", zCol, 0);
   572    572       }else if( zTab ){
   573         -      sqliteSetString(&z, zTab, ".", zCol, 0);
          573  +      sqlite3SetString(&z, zTab, ".", zCol, 0);
   574    574       }else{
   575    575         z = sqliteStrDup(zCol);
   576    576       }
   577         -    sqliteErrorMsg(pParse, zErr, z);
          577  +    sqlite3ErrorMsg(pParse, zErr, z);
   578    578       sqliteFree(z);
   579    579     }
   580    580   
   581    581     /* Clean up and return
   582    582     */
   583    583     sqliteFree(zDb);
   584    584     sqliteFree(zTab);
   585    585     sqliteFree(zCol);
   586         -  sqliteExprDelete(pExpr->pLeft);
          586  +  sqlite3ExprDelete(pExpr->pLeft);
   587    587     pExpr->pLeft = 0;
   588         -  sqliteExprDelete(pExpr->pRight);
          588  +  sqlite3ExprDelete(pExpr->pRight);
   589    589     pExpr->pRight = 0;
   590    590     pExpr->op = TK_COLUMN;
   591         -  sqliteAuthRead(pParse, pExpr, pSrcList);
          591  +  sqlite3AuthRead(pParse, pExpr, pSrcList);
   592    592     return cnt!=1;
   593    593   }
   594    594   
   595    595   /*
   596    596   ** This routine walks an expression tree and resolves references to
   597    597   ** table columns.  Nodes of the form ID.ID or ID resolve into an
   598    598   ** index to the table in the table list and a column offset.  The 
................................................................................
   619    619   ** This routine also looks for scalar SELECTs that are part of an expression.
   620    620   ** If it finds any, it generates code to write the value of that select
   621    621   ** into a memory cell.
   622    622   **
   623    623   ** Unknown columns or tables provoke an error.  The function returns
   624    624   ** the number of errors seen and leaves an error message on pParse->zErrMsg.
   625    625   */
   626         -int sqliteExprResolveIds(
          626  +int sqlite3ExprResolveIds(
   627    627     Parse *pParse,     /* The parser context */
   628    628     SrcList *pSrcList, /* List of tables used to resolve column names */
   629    629     ExprList *pEList,  /* List of expressions used to resolve "AS" */
   630    630     Expr *pExpr        /* The expression to be analyzed. */
   631    631   ){
   632    632     int i;
   633    633   
................................................................................
   676    676         if( lookupName(pParse, pDb, pTable, pColumn, pSrcList, 0, pExpr) ){
   677    677           return 1;
   678    678         }
   679    679         break;
   680    680       }
   681    681   
   682    682       case TK_IN: {
   683         -      Vdbe *v = sqliteGetVdbe(pParse);
          683  +      Vdbe *v = sqlite3GetVdbe(pParse);
   684    684         if( v==0 ) return 1;
   685         -      if( sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){
          685  +      if( sqlite3ExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){
   686    686           return 1;
   687    687         }
   688    688         if( pExpr->pSelect ){
   689    689           /* Case 1:     expr IN (SELECT ...)
   690    690           **
   691    691           ** Generate code to write the results of the select into a temporary
   692    692           ** table.  The cursor number of the temporary table has already
   693         -        ** been put in iTable by sqliteExprResolveInSelect().
          693  +        ** been put in iTable by sqlite3ExprResolveInSelect().
   694    694           */
   695    695           pExpr->iTable = pParse->nTab++;
   696         -        sqliteVdbeAddOp(v, OP_OpenTemp, pExpr->iTable, 1);
   697         -        sqliteSelect(pParse, pExpr->pSelect, SRT_Set, pExpr->iTable, 0,0,0);
          696  +        sqlite3VdbeAddOp(v, OP_OpenTemp, pExpr->iTable, 1);
          697  +        sqlite3Select(pParse, pExpr->pSelect, SRT_Set, pExpr->iTable, 0,0,0);
   698    698         }else if( pExpr->pList ){
   699    699           /* Case 2:     expr IN (exprlist)
   700    700           **
   701    701           ** Create a set to put the exprlist values in.  The Set id is stored
   702    702           ** in iTable.
   703    703           */
   704    704           int i, iSet;
   705    705           for(i=0; i<pExpr->pList->nExpr; i++){
   706    706             Expr *pE2 = pExpr->pList->a[i].pExpr;
   707         -          if( !sqliteExprIsConstant(pE2) ){
   708         -            sqliteErrorMsg(pParse,
          707  +          if( !sqlite3ExprIsConstant(pE2) ){
          708  +            sqlite3ErrorMsg(pParse,
   709    709                 "right-hand side of IN operator must be constant");
   710    710               return 1;
   711    711             }
   712         -          if( sqliteExprCheck(pParse, pE2, 0, 0) ){
          712  +          if( sqlite3ExprCheck(pParse, pE2, 0, 0) ){
   713    713               return 1;
   714    714             }
   715    715           }
   716    716           iSet = pExpr->iTable = pParse->nSet++;
   717    717           for(i=0; i<pExpr->pList->nExpr; i++){
   718    718             Expr *pE2 = pExpr->pList->a[i].pExpr;
   719    719             switch( pE2->op ){
   720    720               case TK_FLOAT:
   721    721               case TK_INTEGER:
   722    722               case TK_STRING: {
   723    723                 int addr;
   724    724                 assert( pE2->token.z );
   725         -              addr = sqliteVdbeOp3(v, OP_SetInsert, iSet, 0,
          725  +              addr = sqlite3VdbeOp3(v, OP_SetInsert, iSet, 0,
   726    726                                     pE2->token.z, pE2->token.n);
   727         -              sqliteVdbeDequoteP3(v, addr);
          727  +              sqlite3VdbeDequoteP3(v, addr);
   728    728                 break;
   729    729               }
   730    730               default: {
   731         -              sqliteExprCode(pParse, pE2);
   732         -              sqliteVdbeAddOp(v, OP_SetInsert, iSet, 0);
          731  +              sqlite3ExprCode(pParse, pE2);
          732  +              sqlite3VdbeAddOp(v, OP_SetInsert, iSet, 0);
   733    733                 break;
   734    734               }
   735    735             }
   736    736           }
   737    737         }
   738    738         break;
   739    739       }
................................................................................
   740    740   
   741    741       case TK_SELECT: {
   742    742         /* This has to be a scalar SELECT.  Generate code to put the
   743    743         ** value of this select in a memory cell and record the number
   744    744         ** of the memory cell in iColumn.
   745    745         */
   746    746         pExpr->iColumn = pParse->nMem++;
   747         -      if( sqliteSelect(pParse, pExpr->pSelect, SRT_Mem, pExpr->iColumn,0,0,0) ){
          747  +      if( sqlite3Select(pParse, pExpr->pSelect, SRT_Mem, pExpr->iColumn,0,0,0) ){
   748    748           return 1;
   749    749         }
   750    750         break;
   751    751       }
   752    752   
   753    753       /* For all else, just recursively walk the tree */
   754    754       default: {
   755    755         if( pExpr->pLeft
   756         -      && sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){
          756  +      && sqlite3ExprResolveIds(pParse, pSrcList, pEList, pExpr->pLeft) ){
   757    757           return 1;
   758    758         }
   759    759         if( pExpr->pRight 
   760         -      && sqliteExprResolveIds(pParse, pSrcList, pEList, pExpr->pRight) ){
          760  +      && sqlite3ExprResolveIds(pParse, pSrcList, pEList, pExpr->pRight) ){
   761    761           return 1;
   762    762         }
   763    763         if( pExpr->pList ){
   764    764           int i;
   765    765           ExprList *pList = pExpr->pList;
   766    766           for(i=0; i<pList->nExpr; i++){
   767    767             Expr *pArg = pList->a[i].pExpr;
   768         -          if( sqliteExprResolveIds(pParse, pSrcList, pEList, pArg) ){
          768  +          if( sqlite3ExprResolveIds(pParse, pSrcList, pEList, pArg) ){
   769    769               return 1;
   770    770             }
   771    771           }
   772    772         }
   773    773       }
   774    774     }
   775    775     return 0;
................................................................................
   813    813   ** function names are recognized and all functions have the correct
   814    814   ** number of arguments.  Leave an error message in pParse->zErrMsg
   815    815   ** if anything is amiss.  Return the number of errors.
   816    816   **
   817    817   ** if pIsAgg is not null and this expression is an aggregate function
   818    818   ** (like count(*) or max(value)) then write a 1 into *pIsAgg.
   819    819   */
   820         -int sqliteExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){
          820  +int sqlite3ExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){
   821    821     int nErr = 0;
   822    822     if( pExpr==0 ) return 0;
   823    823     switch( pExpr->op ){
   824    824       case TK_GLOB:
   825    825       case TK_LIKE:
   826    826       case TK_FUNCTION: {
   827    827         int n = pExpr->pList ? pExpr->pList->nExpr : 0;  /* Number of arguments */
................................................................................
   830    830         int is_agg = 0;             /* True if is an aggregate function */
   831    831         int i;
   832    832         int nId;                    /* Number of characters in function name */
   833    833         const char *zId;            /* The function name. */
   834    834         FuncDef *pDef;
   835    835   
   836    836         getFunctionName(pExpr, &zId, &nId);
   837         -      pDef = sqliteFindFunction(pParse->db, zId, nId, n, 0);
          837  +      pDef = sqlite3FindFunction(pParse->db, zId, nId, n, 0);
   838    838         if( pDef==0 ){
   839         -        pDef = sqliteFindFunction(pParse->db, zId, nId, -1, 0);
          839  +        pDef = sqlite3FindFunction(pParse->db, zId, nId, -1, 0);
   840    840           if( pDef==0 ){
   841    841             no_such_func = 1;
   842    842           }else{
   843    843             wrong_num_args = 1;
   844    844           }
   845    845         }else{
   846    846           is_agg = pDef->xFunc==0;
   847    847         }
   848    848         if( is_agg && !allowAgg ){
   849         -        sqliteErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId);
          849  +        sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId);
   850    850           nErr++;
   851    851           is_agg = 0;
   852    852         }else if( no_such_func ){
   853         -        sqliteErrorMsg(pParse, "no such function: %.*s", nId, zId);
          853  +        sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
   854    854           nErr++;
   855    855         }else if( wrong_num_args ){
   856         -        sqliteErrorMsg(pParse,"wrong number of arguments to function %.*s()",
          856  +        sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
   857    857                nId, zId);
   858    858           nErr++;
   859    859         }
   860    860         if( is_agg ){
   861    861           pExpr->op = TK_AGG_FUNCTION;
   862    862           if( pIsAgg ) *pIsAgg = 1;
   863    863         }
   864    864         for(i=0; nErr==0 && i<n; i++){
   865         -        nErr = sqliteExprCheck(pParse, pExpr->pList->a[i].pExpr,
          865  +        nErr = sqlite3ExprCheck(pParse, pExpr->pList->a[i].pExpr,
   866    866                                  allowAgg && !is_agg, pIsAgg);
   867    867         }
   868    868         if( pDef==0 ){
   869    869           /* Already reported an error */
   870    870         }else if( pDef->dataType>=0 ){
   871    871           if( pDef->dataType<n ){
   872    872             pExpr->dataType = 
   873         -             sqliteExprType(pExpr->pList->a[pDef->dataType].pExpr);
          873  +             sqlite3ExprType(pExpr->pList->a[pDef->dataType].pExpr);
   874    874           }else{
   875    875             pExpr->dataType = SQLITE_SO_NUM;
   876    876           }
   877    877         }else if( pDef->dataType==SQLITE_ARGS ){
   878    878           pDef->dataType = SQLITE_SO_TEXT;
   879    879           for(i=0; i<n; i++){
   880         -          if( sqliteExprType(pExpr->pList->a[i].pExpr)==SQLITE_SO_NUM ){
          880  +          if( sqlite3ExprType(pExpr->pList->a[i].pExpr)==SQLITE_SO_NUM ){
   881    881               pExpr->dataType = SQLITE_SO_NUM;
   882    882               break;
   883    883             }
   884    884           }
   885    885         }else if( pDef->dataType==SQLITE_NUMERIC ){
   886    886           pExpr->dataType = SQLITE_SO_NUM;
   887    887         }else{
   888    888           pExpr->dataType = SQLITE_SO_TEXT;
   889    889         }
   890    890       }
   891    891       default: {
   892    892         if( pExpr->pLeft ){
   893         -        nErr = sqliteExprCheck(pParse, pExpr->pLeft, allowAgg, pIsAgg);
          893  +        nErr = sqlite3ExprCheck(pParse, pExpr->pLeft, allowAgg, pIsAgg);
   894    894         }
   895    895         if( nErr==0 && pExpr->pRight ){
   896         -        nErr = sqliteExprCheck(pParse, pExpr->pRight, allowAgg, pIsAgg);
          896  +        nErr = sqlite3ExprCheck(pParse, pExpr->pRight, allowAgg, pIsAgg);
   897    897         }
   898    898         if( nErr==0 && pExpr->pList ){
   899    899           int n = pExpr->pList->nExpr;
   900    900           int i;
   901    901           for(i=0; nErr==0 && i<n; i++){
   902    902             Expr *pE2 = pExpr->pList->a[i].pExpr;
   903         -          nErr = sqliteExprCheck(pParse, pE2, allowAgg, pIsAgg);
          903  +          nErr = sqlite3ExprCheck(pParse, pE2, allowAgg, pIsAgg);
   904    904           }
   905    905         }
   906    906         break;
   907    907       }
   908    908     }
   909    909     return nErr;
   910    910   }
   911    911   
   912    912   /*
   913    913   ** Return either SQLITE_SO_NUM or SQLITE_SO_TEXT to indicate whether the
   914    914   ** given expression should sort as numeric values or as text.
   915    915   **
   916         -** The sqliteExprResolveIds() and sqliteExprCheck() routines must have
          916  +** The sqlite3ExprResolveIds() and sqlite3ExprCheck() routines must have
   917    917   ** both been called on the expression before it is passed to this routine.
   918    918   */
   919         -int sqliteExprType(Expr *p){
          919  +int sqlite3ExprType(Expr *p){
   920    920     if( p==0 ) return SQLITE_SO_NUM;
   921    921     while( p ) switch( p->op ){
   922    922       case TK_PLUS:
   923    923       case TK_MINUS:
   924    924       case TK_STAR:
   925    925       case TK_SLASH:
   926    926       case TK_AND:
................................................................................
   952    952   
   953    953       case TK_LT:
   954    954       case TK_LE:
   955    955       case TK_GT:
   956    956       case TK_GE:
   957    957       case TK_NE:
   958    958       case TK_EQ:
   959         -      if( sqliteExprType(p->pLeft)==SQLITE_SO_NUM ){
          959  +      if( sqlite3ExprType(p->pLeft)==SQLITE_SO_NUM ){
   960    960           return SQLITE_SO_NUM;
   961    961         }
   962    962         p = p->pRight;
   963    963         break;
   964    964   
   965    965       case TK_AS:
   966    966         p = p->pLeft;
................................................................................
   975    975         assert( p->pSelect );
   976    976         assert( p->pSelect->pEList );
   977    977         assert( p->pSelect->pEList->nExpr>0 );
   978    978         p = p->pSelect->pEList->a[0].pExpr;
   979    979         break;
   980    980   
   981    981       case TK_CASE: {
   982         -      if( p->pRight && sqliteExprType(p->pRight)==SQLITE_SO_NUM ){
          982  +      if( p->pRight && sqlite3ExprType(p->pRight)==SQLITE_SO_NUM ){
   983    983           return SQLITE_SO_NUM;
   984    984         }
   985    985         if( p->pList ){
   986    986           int i;
   987    987           ExprList *pList = p->pList;
   988    988           for(i=1; i<pList->nExpr; i+=2){
   989         -          if( sqliteExprType(pList->a[i].pExpr)==SQLITE_SO_NUM ){
          989  +          if( sqlite3ExprType(pList->a[i].pExpr)==SQLITE_SO_NUM ){
   990    990               return SQLITE_SO_NUM;
   991    991             }
   992    992           }
   993    993         }
   994    994         return SQLITE_SO_TEXT;
   995    995       }
   996    996   
................................................................................
  1001   1001     return SQLITE_SO_NUM;
  1002   1002   }
  1003   1003   
  1004   1004   /*
  1005   1005   ** Generate code into the current Vdbe to evaluate the given
  1006   1006   ** expression and leave the result on the top of stack.
  1007   1007   */
  1008         -void sqliteExprCode(Parse *pParse, Expr *pExpr){
         1008  +void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
  1009   1009     Vdbe *v = pParse->pVdbe;
  1010   1010     int op;
  1011   1011     if( v==0 || pExpr==0 ) return;
  1012   1012     switch( pExpr->op ){
  1013   1013       case TK_PLUS:     op = OP_Add;      break;
  1014   1014       case TK_MINUS:    op = OP_Subtract; break;
  1015   1015       case TK_STAR:     op = OP_Multiply; break;
................................................................................
  1033   1033       case TK_RSHIFT:   op = OP_ShiftRight; break;
  1034   1034       case TK_REM:      op = OP_Remainder;  break;
  1035   1035       default: break;
  1036   1036     }
  1037   1037     switch( pExpr->op ){
  1038   1038       case TK_COLUMN: {
  1039   1039         if( pParse->useAgg ){
  1040         -        sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg);
         1040  +        sqlite3VdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg);
  1041   1041         }else if( pExpr->iColumn>=0 ){
  1042         -        sqliteVdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn);
         1042  +        sqlite3VdbeAddOp(v, OP_Column, pExpr->iTable, pExpr->iColumn);
  1043   1043         }else{
  1044         -        sqliteVdbeAddOp(v, OP_Recno, pExpr->iTable, 0);
         1044  +        sqlite3VdbeAddOp(v, OP_Recno, pExpr->iTable, 0);
  1045   1045         }
  1046   1046         break;
  1047   1047       }
  1048   1048       case TK_STRING:
  1049   1049       case TK_FLOAT:
  1050   1050       case TK_INTEGER: {
  1051         -      if( pExpr->op==TK_INTEGER && sqliteFitsIn32Bits(pExpr->token.z) ){
  1052         -        sqliteVdbeAddOp(v, OP_Integer, atoi(pExpr->token.z), 0);
         1051  +      if( pExpr->op==TK_INTEGER && sqlite3FitsIn32Bits(pExpr->token.z) ){
         1052  +        sqlite3VdbeAddOp(v, OP_Integer, atoi(pExpr->token.z), 0);
  1053   1053         }else{
  1054         -        sqliteVdbeAddOp(v, OP_String, 0, 0);
         1054  +        sqlite3VdbeAddOp(v, OP_String, 0, 0);
  1055   1055         }
  1056   1056         assert( pExpr->token.z );
  1057         -      sqliteVdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
  1058         -      sqliteVdbeDequoteP3(v, -1);
         1057  +      sqlite3VdbeChangeP3(v, -1, pExpr->token.z, pExpr->token.n);
         1058  +      sqlite3VdbeDequoteP3(v, -1);
  1059   1059         break;
  1060   1060       }
  1061   1061       case TK_NULL: {
  1062         -      sqliteVdbeAddOp(v, OP_String, 0, 0);
         1062  +      sqlite3VdbeAddOp(v, OP_String, 0, 0);
  1063   1063         break;
  1064   1064       }
  1065   1065       case TK_VARIABLE: {
  1066         -      sqliteVdbeAddOp(v, OP_Variable, pExpr->iTable, 0);
         1066  +      sqlite3VdbeAddOp(v, OP_Variable, pExpr->iTable, 0);
  1067   1067         break;
  1068   1068       }
  1069   1069       case TK_LT:
  1070   1070       case TK_LE:
  1071   1071       case TK_GT:
  1072   1072       case TK_GE:
  1073   1073       case TK_NE:
  1074   1074       case TK_EQ: {
  1075         -      if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==SQLITE_SO_TEXT ){
         1075  +      if( pParse->db->file_format>=4 && sqlite3ExprType(pExpr)==SQLITE_SO_TEXT ){
  1076   1076           op += 6;  /* Convert numeric opcodes to text opcodes */
  1077   1077         }
  1078   1078         /* Fall through into the next case */
  1079   1079       }
  1080   1080       case TK_AND:
  1081   1081       case TK_OR:
  1082   1082       case TK_PLUS:
  1083   1083       case TK_STAR:
  1084   1084       case TK_MINUS:
  1085   1085       case TK_REM:
  1086   1086       case TK_BITAND:
  1087   1087       case TK_BITOR:
  1088   1088       case TK_SLASH: {
  1089         -      sqliteExprCode(pParse, pExpr->pLeft);
  1090         -      sqliteExprCode(pParse, pExpr->pRight);
  1091         -      sqliteVdbeAddOp(v, op, 0, 0);
         1089  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1090  +      sqlite3ExprCode(pParse, pExpr->pRight);
         1091  +      sqlite3VdbeAddOp(v, op, 0, 0);
  1092   1092         break;
  1093   1093       }
  1094   1094       case TK_LSHIFT:
  1095   1095       case TK_RSHIFT: {
  1096         -      sqliteExprCode(pParse, pExpr->pRight);
  1097         -      sqliteExprCode(pParse, pExpr->pLeft);
  1098         -      sqliteVdbeAddOp(v, op, 0, 0);
         1096  +      sqlite3ExprCode(pParse, pExpr->pRight);
         1097  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1098  +      sqlite3VdbeAddOp(v, op, 0, 0);
  1099   1099         break;
  1100   1100       }
  1101   1101       case TK_CONCAT: {
  1102         -      sqliteExprCode(pParse, pExpr->pLeft);
  1103         -      sqliteExprCode(pParse, pExpr->pRight);
  1104         -      sqliteVdbeAddOp(v, OP_Concat, 2, 0);
         1102  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1103  +      sqlite3ExprCode(pParse, pExpr->pRight);
         1104  +      sqlite3VdbeAddOp(v, OP_Concat, 2, 0);
  1105   1105         break;
  1106   1106       }
  1107   1107       case TK_UMINUS: {
  1108   1108         assert( pExpr->pLeft );
  1109   1109         if( pExpr->pLeft->op==TK_FLOAT || pExpr->pLeft->op==TK_INTEGER ){
  1110   1110           Token *p = &pExpr->pLeft->token;
  1111   1111           char *z = sqliteMalloc( p->n + 2 );
  1112   1112           sprintf(z, "-%.*s", p->n, p->z);
  1113         -        if( pExpr->pLeft->op==TK_INTEGER && sqliteFitsIn32Bits(z) ){
  1114         -          sqliteVdbeAddOp(v, OP_Integer, atoi(z), 0);
         1113  +        if( pExpr->pLeft->op==TK_INTEGER && sqlite3FitsIn32Bits(z) ){
         1114  +          sqlite3VdbeAddOp(v, OP_Integer, atoi(z), 0);
  1115   1115           }else{
  1116         -          sqliteVdbeAddOp(v, OP_String, 0, 0);
         1116  +          sqlite3VdbeAddOp(v, OP_String, 0, 0);
  1117   1117           }
  1118         -        sqliteVdbeChangeP3(v, -1, z, p->n+1);
         1118  +        sqlite3VdbeChangeP3(v, -1, z, p->n+1);
  1119   1119           sqliteFree(z);
  1120   1120           break;
  1121   1121         }
  1122   1122         /* Fall through into TK_NOT */
  1123   1123       }
  1124   1124       case TK_BITNOT:
  1125   1125       case TK_NOT: {
  1126         -      sqliteExprCode(pParse, pExpr->pLeft);
  1127         -      sqliteVdbeAddOp(v, op, 0, 0);
         1126  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1127  +      sqlite3VdbeAddOp(v, op, 0, 0);
  1128   1128         break;
  1129   1129       }
  1130   1130       case TK_ISNULL:
  1131   1131       case TK_NOTNULL: {
  1132   1132         int dest;
  1133         -      sqliteVdbeAddOp(v, OP_Integer, 1, 0);
  1134         -      sqliteExprCode(pParse, pExpr->pLeft);
  1135         -      dest = sqliteVdbeCurrentAddr(v) + 2;
  1136         -      sqliteVdbeAddOp(v, op, 1, dest);
  1137         -      sqliteVdbeAddOp(v, OP_AddImm, -1, 0);
         1133  +      sqlite3VdbeAddOp(v, OP_Integer, 1, 0);
         1134  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1135  +      dest = sqlite3VdbeCurrentAddr(v) + 2;
         1136  +      sqlite3VdbeAddOp(v, op, 1, dest);
         1137  +      sqlite3VdbeAddOp(v, OP_AddImm, -1, 0);
  1138   1138         break;
  1139   1139       }
  1140   1140       case TK_AGG_FUNCTION: {
  1141         -      sqliteVdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg);
         1141  +      sqlite3VdbeAddOp(v, OP_AggGet, 0, pExpr->iAgg);
  1142   1142         break;
  1143   1143       }
  1144   1144       case TK_GLOB:
  1145   1145       case TK_LIKE:
  1146   1146       case TK_FUNCTION: {
  1147   1147         ExprList *pList = pExpr->pList;
  1148   1148         int nExpr = pList ? pList->nExpr : 0;
  1149   1149         FuncDef *pDef;
  1150   1150         int nId;
  1151   1151         const char *zId;
  1152   1152         getFunctionName(pExpr, &zId, &nId);
  1153         -      pDef = sqliteFindFunction(pParse->db, zId, nId, nExpr, 0);
         1153  +      pDef = sqlite3FindFunction(pParse->db, zId, nId, nExpr, 0);
  1154   1154         assert( pDef!=0 );
  1155         -      nExpr = sqliteExprCodeExprList(pParse, pList, pDef->includeTypes);
  1156         -      sqliteVdbeOp3(v, OP_Function, nExpr, 0, (char*)pDef, P3_POINTER);
         1155  +      nExpr = sqlite3ExprCodeExprList(pParse, pList, pDef->includeTypes);
         1156  +      sqlite3VdbeOp3(v, OP_Function, nExpr, 0, (char*)pDef, P3_POINTER);
  1157   1157         break;
  1158   1158       }
  1159   1159       case TK_SELECT: {
  1160         -      sqliteVdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0);
         1160  +      sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0);
  1161   1161         break;
  1162   1162       }
  1163   1163       case TK_IN: {
  1164   1164         int addr;
  1165         -      sqliteVdbeAddOp(v, OP_Integer, 1, 0);
  1166         -      sqliteExprCode(pParse, pExpr->pLeft);
  1167         -      addr = sqliteVdbeCurrentAddr(v);
  1168         -      sqliteVdbeAddOp(v, OP_NotNull, -1, addr+4);
  1169         -      sqliteVdbeAddOp(v, OP_Pop, 2, 0);
  1170         -      sqliteVdbeAddOp(v, OP_String, 0, 0);
  1171         -      sqliteVdbeAddOp(v, OP_Goto, 0, addr+6);
         1165  +      sqlite3VdbeAddOp(v, OP_Integer, 1, 0);
         1166  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1167  +      addr = sqlite3VdbeCurrentAddr(v);
         1168  +      sqlite3VdbeAddOp(v, OP_NotNull, -1, addr+4);
         1169  +      sqlite3VdbeAddOp(v, OP_Pop, 2, 0);
         1170  +      sqlite3VdbeAddOp(v, OP_String, 0, 0);
         1171  +      sqlite3VdbeAddOp(v, OP_Goto, 0, addr+6);
  1172   1172         if( pExpr->pSelect ){
  1173         -        sqliteVdbeAddOp(v, OP_Found, pExpr->iTable, addr+6);
         1173  +        sqlite3VdbeAddOp(v, OP_Found, pExpr->iTable, addr+6);
  1174   1174         }else{
  1175         -        sqliteVdbeAddOp(v, OP_SetFound, pExpr->iTable, addr+6);
         1175  +        sqlite3VdbeAddOp(v, OP_SetFound, pExpr->iTable, addr+6);
  1176   1176         }
  1177         -      sqliteVdbeAddOp(v, OP_AddImm, -1, 0);
         1177  +      sqlite3VdbeAddOp(v, OP_AddImm, -1, 0);
  1178   1178         break;
  1179   1179       }
  1180   1180       case TK_BETWEEN: {
  1181         -      sqliteExprCode(pParse, pExpr->pLeft);
  1182         -      sqliteVdbeAddOp(v, OP_Dup, 0, 0);
  1183         -      sqliteExprCode(pParse, pExpr->pList->a[0].pExpr);
  1184         -      sqliteVdbeAddOp(v, OP_Ge, 0, 0);
  1185         -      sqliteVdbeAddOp(v, OP_Pull, 1, 0);
  1186         -      sqliteExprCode(pParse, pExpr->pList->a[1].pExpr);
  1187         -      sqliteVdbeAddOp(v, OP_Le, 0, 0);
  1188         -      sqliteVdbeAddOp(v, OP_And, 0, 0);
         1181  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1182  +      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
         1183  +      sqlite3ExprCode(pParse, pExpr->pList->a[0].pExpr);
         1184  +      sqlite3VdbeAddOp(v, OP_Ge, 0, 0);
         1185  +      sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
         1186  +      sqlite3ExprCode(pParse, pExpr->pList->a[1].pExpr);
         1187  +      sqlite3VdbeAddOp(v, OP_Le, 0, 0);
         1188  +      sqlite3VdbeAddOp(v, OP_And, 0, 0);
  1189   1189         break;
  1190   1190       }
  1191   1191       case TK_UPLUS:
  1192   1192       case TK_AS: {
  1193         -      sqliteExprCode(pParse, pExpr->pLeft);
         1193  +      sqlite3ExprCode(pParse, pExpr->pLeft);
  1194   1194         break;
  1195   1195       }
  1196   1196       case TK_CASE: {
  1197   1197         int expr_end_label;
  1198   1198         int jumpInst;
  1199   1199         int addr;
  1200   1200         int nExpr;
  1201   1201         int i;
  1202   1202   
  1203   1203         assert(pExpr->pList);
  1204   1204         assert((pExpr->pList->nExpr % 2) == 0);
  1205   1205         assert(pExpr->pList->nExpr > 0);
  1206   1206         nExpr = pExpr->pList->nExpr;
  1207         -      expr_end_label = sqliteVdbeMakeLabel(v);
         1207  +      expr_end_label = sqlite3VdbeMakeLabel(v);
  1208   1208         if( pExpr->pLeft ){
  1209         -        sqliteExprCode(pParse, pExpr->pLeft);
         1209  +        sqlite3ExprCode(pParse, pExpr->pLeft);
  1210   1210         }
  1211   1211         for(i=0; i<nExpr; i=i+2){
  1212         -        sqliteExprCode(pParse, pExpr->pList->a[i].pExpr);
         1212  +        sqlite3ExprCode(pParse, pExpr->pList->a[i].pExpr);
  1213   1213           if( pExpr->pLeft ){
  1214         -          sqliteVdbeAddOp(v, OP_Dup, 1, 1);
  1215         -          jumpInst = sqliteVdbeAddOp(v, OP_Ne, 1, 0);
  1216         -          sqliteVdbeAddOp(v, OP_Pop, 1, 0);
         1214  +          sqlite3VdbeAddOp(v, OP_Dup, 1, 1);
         1215  +          jumpInst = sqlite3VdbeAddOp(v, OP_Ne, 1, 0);
         1216  +          sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
  1217   1217           }else{
  1218         -          jumpInst = sqliteVdbeAddOp(v, OP_IfNot, 1, 0);
         1218  +          jumpInst = sqlite3VdbeAddOp(v, OP_IfNot, 1, 0);
  1219   1219           }
  1220         -        sqliteExprCode(pParse, pExpr->pList->a[i+1].pExpr);
  1221         -        sqliteVdbeAddOp(v, OP_Goto, 0, expr_end_label);
  1222         -        addr = sqliteVdbeCurrentAddr(v);
  1223         -        sqliteVdbeChangeP2(v, jumpInst, addr);
         1220  +        sqlite3ExprCode(pParse, pExpr->pList->a[i+1].pExpr);
         1221  +        sqlite3VdbeAddOp(v, OP_Goto, 0, expr_end_label);
         1222  +        addr = sqlite3VdbeCurrentAddr(v);
         1223  +        sqlite3VdbeChangeP2(v, jumpInst, addr);
  1224   1224         }
  1225   1225         if( pExpr->pLeft ){
  1226         -        sqliteVdbeAddOp(v, OP_Pop, 1, 0);
         1226  +        sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
  1227   1227         }
  1228   1228         if( pExpr->pRight ){
  1229         -        sqliteExprCode(pParse, pExpr->pRight);
         1229  +        sqlite3ExprCode(pParse, pExpr->pRight);
  1230   1230         }else{
  1231         -        sqliteVdbeAddOp(v, OP_String, 0, 0);
         1231  +        sqlite3VdbeAddOp(v, OP_String, 0, 0);
  1232   1232         }
  1233         -      sqliteVdbeResolveLabel(v, expr_end_label);
         1233  +      sqlite3VdbeResolveLabel(v, expr_end_label);
  1234   1234         break;
  1235   1235       }
  1236   1236       case TK_RAISE: {
  1237   1237         if( !pParse->trigStack ){
  1238         -        sqliteErrorMsg(pParse,
         1238  +        sqlite3ErrorMsg(pParse,
  1239   1239                          "RAISE() may only be used within a trigger-program");
  1240   1240           pParse->nErr++;
  1241   1241   	return;
  1242   1242         }
  1243   1243         if( pExpr->iColumn == OE_Rollback ||
  1244   1244   	  pExpr->iColumn == OE_Abort ||
  1245   1245   	  pExpr->iColumn == OE_Fail ){
  1246         -	  sqliteVdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->iColumn,
         1246  +	  sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, pExpr->iColumn,
  1247   1247                              pExpr->token.z, pExpr->token.n);
  1248         -	  sqliteVdbeDequoteP3(v, -1);
         1248  +	  sqlite3VdbeDequoteP3(v, -1);
  1249   1249         } else {
  1250   1250   	  assert( pExpr->iColumn == OE_Ignore );
  1251         -	  sqliteVdbeOp3(v, OP_Goto, 0, pParse->trigStack->ignoreJump,
         1251  +	  sqlite3VdbeOp3(v, OP_Goto, 0, pParse->trigStack->ignoreJump,
  1252   1252                              "(IGNORE jump)", 0);
  1253   1253         }
  1254   1254       }
  1255   1255       break;
  1256   1256     }
  1257   1257   }
  1258   1258   
................................................................................
  1260   1260   ** Generate code that pushes the value of every element of the given
  1261   1261   ** expression list onto the stack.  If the includeTypes flag is true,
  1262   1262   ** then also push a string that is the datatype of each element onto
  1263   1263   ** the stack after the value.
  1264   1264   **
  1265   1265   ** Return the number of elements pushed onto the stack.
  1266   1266   */
  1267         -int sqliteExprCodeExprList(
         1267  +int sqlite3ExprCodeExprList(
  1268   1268     Parse *pParse,     /* Parsing context */
  1269   1269     ExprList *pList,   /* The expression list to be coded */
  1270   1270     int includeTypes   /* TRUE to put datatypes on the stack too */
  1271   1271   ){
  1272   1272     struct ExprList_item *pItem;
  1273   1273     int i, n;
  1274   1274     Vdbe *v;
  1275   1275     if( pList==0 ) return 0;
  1276         -  v = sqliteGetVdbe(pParse);
         1276  +  v = sqlite3GetVdbe(pParse);
  1277   1277     n = pList->nExpr;
  1278   1278     for(pItem=pList->a, i=0; i<n; i++, pItem++){
  1279         -    sqliteExprCode(pParse, pItem->pExpr);
         1279  +    sqlite3ExprCode(pParse, pItem->pExpr);
  1280   1280       if( includeTypes ){
  1281         -      sqliteVdbeOp3(v, OP_String, 0, 0, 
  1282         -         sqliteExprType(pItem->pExpr)==SQLITE_SO_NUM ? "numeric" : "text",
         1281  +      sqlite3VdbeOp3(v, OP_String, 0, 0, 
         1282  +         sqlite3ExprType(pItem->pExpr)==SQLITE_SO_NUM ? "numeric" : "text",
  1283   1283            P3_STATIC);
  1284   1284       }
  1285   1285     }
  1286   1286     return includeTypes ? n*2 : n;
  1287   1287   }
  1288   1288   
  1289   1289   /*
................................................................................
  1290   1290   ** Generate code for a boolean expression such that a jump is made
  1291   1291   ** to the label "dest" if the expression is true but execution
  1292   1292   ** continues straight thru if the expression is false.
  1293   1293   **
  1294   1294   ** If the expression evaluates to NULL (neither true nor false), then
  1295   1295   ** take the jump if the jumpIfNull flag is true.
  1296   1296   */
  1297         -void sqliteExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
         1297  +void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
  1298   1298     Vdbe *v = pParse->pVdbe;
  1299   1299     int op = 0;
  1300   1300     if( v==0 || pExpr==0 ) return;
  1301   1301     switch( pExpr->op ){
  1302   1302       case TK_LT:       op = OP_Lt;       break;
  1303   1303       case TK_LE:       op = OP_Le;       break;
  1304   1304       case TK_GT:       op = OP_Gt;       break;
................................................................................
  1307   1307       case TK_EQ:       op = OP_Eq;       break;
  1308   1308       case TK_ISNULL:   op = OP_IsNull;   break;
  1309   1309       case TK_NOTNULL:  op = OP_NotNull;  break;
  1310   1310       default:  break;
  1311   1311     }
  1312   1312     switch( pExpr->op ){
  1313   1313       case TK_AND: {
  1314         -      int d2 = sqliteVdbeMakeLabel(v);
  1315         -      sqliteExprIfFalse(pParse, pExpr->pLeft, d2, !jumpIfNull);
  1316         -      sqliteExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
  1317         -      sqliteVdbeResolveLabel(v, d2);
         1314  +      int d2 = sqlite3VdbeMakeLabel(v);
         1315  +      sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2, !jumpIfNull);
         1316  +      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
         1317  +      sqlite3VdbeResolveLabel(v, d2);
  1318   1318         break;
  1319   1319       }
  1320   1320       case TK_OR: {
  1321         -      sqliteExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
  1322         -      sqliteExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
         1321  +      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
         1322  +      sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
  1323   1323         break;
  1324   1324       }
  1325   1325       case TK_NOT: {
  1326         -      sqliteExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
         1326  +      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
  1327   1327         break;
  1328   1328       }
  1329   1329       case TK_LT:
  1330   1330       case TK_LE:
  1331   1331       case TK_GT:
  1332   1332       case TK_GE:
  1333   1333       case TK_NE:
  1334   1334       case TK_EQ: {
  1335         -      sqliteExprCode(pParse, pExpr->pLeft);
  1336         -      sqliteExprCode(pParse, pExpr->pRight);
  1337         -      if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==SQLITE_SO_TEXT ){
         1335  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1336  +      sqlite3ExprCode(pParse, pExpr->pRight);
         1337  +      if( pParse->db->file_format>=4 && sqlite3ExprType(pExpr)==SQLITE_SO_TEXT ){
  1338   1338           op += 6;  /* Convert numeric opcodes to text opcodes */
  1339   1339         }
  1340         -      sqliteVdbeAddOp(v, op, jumpIfNull, dest);
         1340  +      sqlite3VdbeAddOp(v, op, jumpIfNull, dest);
  1341   1341         break;
  1342   1342       }
  1343   1343       case TK_ISNULL:
  1344   1344       case TK_NOTNULL: {
  1345         -      sqliteExprCode(pParse, pExpr->pLeft);
  1346         -      sqliteVdbeAddOp(v, op, 1, dest);
         1345  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1346  +      sqlite3VdbeAddOp(v, op, 1, dest);
  1347   1347         break;
  1348   1348       }
  1349   1349       case TK_IN: {
  1350   1350         int addr;
  1351         -      sqliteExprCode(pParse, pExpr->pLeft);
  1352         -      addr = sqliteVdbeCurrentAddr(v);
  1353         -      sqliteVdbeAddOp(v, OP_NotNull, -1, addr+3);
  1354         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
  1355         -      sqliteVdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4);
         1351  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1352  +      addr = sqlite3VdbeCurrentAddr(v);
         1353  +      sqlite3VdbeAddOp(v, OP_NotNull, -1, addr+3);
         1354  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
         1355  +      sqlite3VdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4);
  1356   1356         if( pExpr->pSelect ){
  1357         -        sqliteVdbeAddOp(v, OP_Found, pExpr->iTable, dest);
         1357  +        sqlite3VdbeAddOp(v, OP_Found, pExpr->iTable, dest);
  1358   1358         }else{
  1359         -        sqliteVdbeAddOp(v, OP_SetFound, pExpr->iTable, dest);
         1359  +        sqlite3VdbeAddOp(v, OP_SetFound, pExpr->iTable, dest);
  1360   1360         }
  1361   1361         break;
  1362   1362       }
  1363   1363       case TK_BETWEEN: {
  1364   1364         int addr;
  1365         -      sqliteExprCode(pParse, pExpr->pLeft);
  1366         -      sqliteVdbeAddOp(v, OP_Dup, 0, 0);
  1367         -      sqliteExprCode(pParse, pExpr->pList->a[0].pExpr);
  1368         -      addr = sqliteVdbeAddOp(v, OP_Lt, !jumpIfNull, 0);
  1369         -      sqliteExprCode(pParse, pExpr->pList->a[1].pExpr);
  1370         -      sqliteVdbeAddOp(v, OP_Le, jumpIfNull, dest);
  1371         -      sqliteVdbeAddOp(v, OP_Integer, 0, 0);
  1372         -      sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));
  1373         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
         1365  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1366  +      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
         1367  +      sqlite3ExprCode(pParse, pExpr->pList->a[0].pExpr);
         1368  +      addr = sqlite3VdbeAddOp(v, OP_Lt, !jumpIfNull, 0);
         1369  +      sqlite3ExprCode(pParse, pExpr->pList->a[1].pExpr);
         1370  +      sqlite3VdbeAddOp(v, OP_Le, jumpIfNull, dest);
         1371  +      sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
         1372  +      sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
         1373  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
  1374   1374         break;
  1375   1375       }
  1376   1376       default: {
  1377         -      sqliteExprCode(pParse, pExpr);
  1378         -      sqliteVdbeAddOp(v, OP_If, jumpIfNull, dest);
         1377  +      sqlite3ExprCode(pParse, pExpr);
         1378  +      sqlite3VdbeAddOp(v, OP_If, jumpIfNull, dest);
  1379   1379         break;
  1380   1380       }
  1381   1381     }
  1382   1382   }
  1383   1383   
  1384   1384   /*
  1385   1385   ** Generate code for a boolean expression such that a jump is made
  1386   1386   ** to the label "dest" if the expression is false but execution
  1387   1387   ** continues straight thru if the expression is true.
  1388   1388   **
  1389   1389   ** If the expression evaluates to NULL (neither true nor false) then
  1390   1390   ** jump if jumpIfNull is true or fall through if jumpIfNull is false.
  1391   1391   */
  1392         -void sqliteExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
         1392  +void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
  1393   1393     Vdbe *v = pParse->pVdbe;
  1394   1394     int op = 0;
  1395   1395     if( v==0 || pExpr==0 ) return;
  1396   1396     switch( pExpr->op ){
  1397   1397       case TK_LT:       op = OP_Ge;       break;
  1398   1398       case TK_LE:       op = OP_Gt;       break;
  1399   1399       case TK_GT:       op = OP_Le;       break;
................................................................................
  1402   1402       case TK_EQ:       op = OP_Ne;       break;
  1403   1403       case TK_ISNULL:   op = OP_NotNull;  break;
  1404   1404       case TK_NOTNULL:  op = OP_IsNull;   break;
  1405   1405       default:  break;
  1406   1406     }
  1407   1407     switch( pExpr->op ){
  1408   1408       case TK_AND: {
  1409         -      sqliteExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
  1410         -      sqliteExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
         1409  +      sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull);
         1410  +      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
  1411   1411         break;
  1412   1412       }
  1413   1413       case TK_OR: {
  1414         -      int d2 = sqliteVdbeMakeLabel(v);
  1415         -      sqliteExprIfTrue(pParse, pExpr->pLeft, d2, !jumpIfNull);
  1416         -      sqliteExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
  1417         -      sqliteVdbeResolveLabel(v, d2);
         1414  +      int d2 = sqlite3VdbeMakeLabel(v);
         1415  +      sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, !jumpIfNull);
         1416  +      sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
         1417  +      sqlite3VdbeResolveLabel(v, d2);
  1418   1418         break;
  1419   1419       }
  1420   1420       case TK_NOT: {
  1421         -      sqliteExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
         1421  +      sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull);
  1422   1422         break;
  1423   1423       }
  1424   1424       case TK_LT:
  1425   1425       case TK_LE:
  1426   1426       case TK_GT:
  1427   1427       case TK_GE:
  1428   1428       case TK_NE:
  1429   1429       case TK_EQ: {
  1430         -      if( pParse->db->file_format>=4 && sqliteExprType(pExpr)==SQLITE_SO_TEXT ){
         1430  +      if( pParse->db->file_format>=4 && sqlite3ExprType(pExpr)==SQLITE_SO_TEXT ){
  1431   1431           /* Convert numeric comparison opcodes into text comparison opcodes.
  1432   1432           ** This step depends on the fact that the text comparision opcodes are
  1433   1433           ** always 6 greater than their corresponding numeric comparison
  1434   1434           ** opcodes.
  1435   1435           */
  1436   1436           assert( OP_Eq+6 == OP_StrEq );
  1437   1437           op += 6;
  1438   1438         }
  1439         -      sqliteExprCode(pParse, pExpr->pLeft);
  1440         -      sqliteExprCode(pParse, pExpr->pRight);
  1441         -      sqliteVdbeAddOp(v, op, jumpIfNull, dest);
         1439  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1440  +      sqlite3ExprCode(pParse, pExpr->pRight);
         1441  +      sqlite3VdbeAddOp(v, op, jumpIfNull, dest);
  1442   1442         break;
  1443   1443       }
  1444   1444       case TK_ISNULL:
  1445   1445       case TK_NOTNULL: {
  1446         -      sqliteExprCode(pParse, pExpr->pLeft);
  1447         -      sqliteVdbeAddOp(v, op, 1, dest);
         1446  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1447  +      sqlite3VdbeAddOp(v, op, 1, dest);
  1448   1448         break;
  1449   1449       }
  1450   1450       case TK_IN: {
  1451   1451         int addr;
  1452         -      sqliteExprCode(pParse, pExpr->pLeft);
  1453         -      addr = sqliteVdbeCurrentAddr(v);
  1454         -      sqliteVdbeAddOp(v, OP_NotNull, -1, addr+3);
  1455         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
  1456         -      sqliteVdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4);
         1452  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1453  +      addr = sqlite3VdbeCurrentAddr(v);
         1454  +      sqlite3VdbeAddOp(v, OP_NotNull, -1, addr+3);
         1455  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
         1456  +      sqlite3VdbeAddOp(v, OP_Goto, 0, jumpIfNull ? dest : addr+4);
  1457   1457         if( pExpr->pSelect ){
  1458         -        sqliteVdbeAddOp(v, OP_NotFound, pExpr->iTable, dest);
         1458  +        sqlite3VdbeAddOp(v, OP_NotFound, pExpr->iTable, dest);
  1459   1459         }else{
  1460         -        sqliteVdbeAddOp(v, OP_SetNotFound, pExpr->iTable, dest);
         1460  +        sqlite3VdbeAddOp(v, OP_SetNotFound, pExpr->iTable, dest);
  1461   1461         }
  1462   1462         break;
  1463   1463       }
  1464   1464       case TK_BETWEEN: {
  1465   1465         int addr;
  1466         -      sqliteExprCode(pParse, pExpr->pLeft);
  1467         -      sqliteVdbeAddOp(v, OP_Dup, 0, 0);
  1468         -      sqliteExprCode(pParse, pExpr->pList->a[0].pExpr);
  1469         -      addr = sqliteVdbeCurrentAddr(v);
  1470         -      sqliteVdbeAddOp(v, OP_Ge, !jumpIfNull, addr+3);
  1471         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
  1472         -      sqliteVdbeAddOp(v, OP_Goto, 0, dest);
  1473         -      sqliteExprCode(pParse, pExpr->pList->a[1].pExpr);
  1474         -      sqliteVdbeAddOp(v, OP_Gt, jumpIfNull, dest);
         1466  +      sqlite3ExprCode(pParse, pExpr->pLeft);
         1467  +      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
         1468  +      sqlite3ExprCode(pParse, pExpr->pList->a[0].pExpr);
         1469  +      addr = sqlite3VdbeCurrentAddr(v);
         1470  +      sqlite3VdbeAddOp(v, OP_Ge, !jumpIfNull, addr+3);
         1471  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
         1472  +      sqlite3VdbeAddOp(v, OP_Goto, 0, dest);
         1473  +      sqlite3ExprCode(pParse, pExpr->pList->a[1].pExpr);
         1474  +      sqlite3VdbeAddOp(v, OP_Gt, jumpIfNull, dest);
  1475   1475         break;
  1476   1476       }
  1477   1477       default: {
  1478         -      sqliteExprCode(pParse, pExpr);
  1479         -      sqliteVdbeAddOp(v, OP_IfNot, jumpIfNull, dest);
         1478  +      sqlite3ExprCode(pParse, pExpr);
         1479  +      sqlite3VdbeAddOp(v, OP_IfNot, jumpIfNull, dest);
  1480   1480         break;
  1481   1481       }
  1482   1482     }
  1483   1483   }
  1484   1484   
  1485   1485   /*
  1486   1486   ** Do a deep comparison of two expression trees.  Return TRUE (non-zero)
  1487   1487   ** if they are identical and return FALSE if they differ in any way.
  1488   1488   */
  1489         -int sqliteExprCompare(Expr *pA, Expr *pB){
         1489  +int sqlite3ExprCompare(Expr *pA, Expr *pB){
  1490   1490     int i;
  1491   1491     if( pA==0 ){
  1492   1492       return pB==0;
  1493   1493     }else if( pB==0 ){
  1494   1494       return 0;
  1495   1495     }
  1496   1496     if( pA->op!=pB->op ) return 0;
  1497         -  if( !sqliteExprCompare(pA->pLeft, pB->pLeft) ) return 0;
  1498         -  if( !sqliteExprCompare(pA->pRight, pB->pRight) ) return 0;
         1497  +  if( !sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 0;
         1498  +  if( !sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 0;
  1499   1499     if( pA->pList ){
  1500   1500       if( pB->pList==0 ) return 0;
  1501   1501       if( pA->pList->nExpr!=pB->pList->nExpr ) return 0;
  1502   1502       for(i=0; i<pA->pList->nExpr; i++){
  1503         -      if( !sqliteExprCompare(pA->pList->a[i].pExpr, pB->pList->a[i].pExpr) ){
         1503  +      if( !sqlite3ExprCompare(pA->pList->a[i].pExpr, pB->pList->a[i].pExpr) ){
  1504   1504           return 0;
  1505   1505         }
  1506   1506       }
  1507   1507     }else if( pB->pList ){
  1508   1508       return 0;
  1509   1509     }
  1510   1510     if( pA->pSelect || pB->pSelect ) return 0;
  1511   1511     if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 0;
  1512   1512     if( pA->token.z ){
  1513   1513       if( pB->token.z==0 ) return 0;
  1514   1514       if( pB->token.n!=pA->token.n ) return 0;
  1515         -    if( sqliteStrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
         1515  +    if( sqlite3StrNICmp(pA->token.z, pB->token.z, pB->token.n)!=0 ) return 0;
  1516   1516     }
  1517   1517     return 1;
  1518   1518   }
  1519   1519   
  1520   1520   /*
  1521   1521   ** Add a new element to the pParse->aAgg[] array and return its index.
  1522   1522   */
................................................................................
  1535   1535   
  1536   1536   /*
  1537   1537   ** Analyze the given expression looking for aggregate functions and
  1538   1538   ** for variables that need to be added to the pParse->aAgg[] array.
  1539   1539   ** Make additional entries to the pParse->aAgg[] array as necessary.
  1540   1540   **
  1541   1541   ** This routine should only be called after the expression has been
  1542         -** analyzed by sqliteExprResolveIds() and sqliteExprCheck().
         1542  +** analyzed by sqlite3ExprResolveIds() and sqlite3ExprCheck().
  1543   1543   **
  1544   1544   ** If errors are seen, leave an error message in zErrMsg and return
  1545   1545   ** the number of errors.
  1546   1546   */
  1547         -int sqliteExprAnalyzeAggregates(Parse *pParse, Expr *pExpr){
         1547  +int sqlite3ExprAnalyzeAggregates(Parse *pParse, Expr *pExpr){
  1548   1548     int i;
  1549   1549     AggExpr *aAgg;
  1550   1550     int nErr = 0;
  1551   1551   
  1552   1552     if( pExpr==0 ) return 0;
  1553   1553     switch( pExpr->op ){
  1554   1554       case TK_COLUMN: {
................................................................................
  1569   1569         pExpr->iAgg = i;
  1570   1570         break;
  1571   1571       }
  1572   1572       case TK_AGG_FUNCTION: {
  1573   1573         aAgg = pParse->aAgg;
  1574   1574         for(i=0; i<pParse->nAgg; i++){
  1575   1575           if( !aAgg[i].isAgg ) continue;
  1576         -        if( sqliteExprCompare(aAgg[i].pExpr, pExpr) ){
         1576  +        if( sqlite3ExprCompare(aAgg[i].pExpr, pExpr) ){
  1577   1577             break;
  1578   1578           }
  1579   1579         }
  1580   1580         if( i>=pParse->nAgg ){
  1581   1581           i = appendAggInfo(pParse);
  1582   1582           if( i<0 ) return 1;
  1583   1583           pParse->aAgg[i].isAgg = 1;
  1584   1584           pParse->aAgg[i].pExpr = pExpr;
  1585         -        pParse->aAgg[i].pFunc = sqliteFindFunction(pParse->db,
         1585  +        pParse->aAgg[i].pFunc = sqlite3FindFunction(pParse->db,
  1586   1586                pExpr->token.z, pExpr->token.n,
  1587   1587                pExpr->pList ? pExpr->pList->nExpr : 0, 0);
  1588   1588         }
  1589   1589         pExpr->iAgg = i;
  1590   1590         break;
  1591   1591       }
  1592   1592       default: {
  1593   1593         if( pExpr->pLeft ){
  1594         -        nErr = sqliteExprAnalyzeAggregates(pParse, pExpr->pLeft);
         1594  +        nErr = sqlite3ExprAnalyzeAggregates(pParse, pExpr->pLeft);
  1595   1595         }
  1596   1596         if( nErr==0 && pExpr->pRight ){
  1597         -        nErr = sqliteExprAnalyzeAggregates(pParse, pExpr->pRight);
         1597  +        nErr = sqlite3ExprAnalyzeAggregates(pParse, pExpr->pRight);
  1598   1598         }
  1599   1599         if( nErr==0 && pExpr->pList ){
  1600   1600           int n = pExpr->pList->nExpr;
  1601   1601           int i;
  1602   1602           for(i=0; nErr==0 && i<n; i++){
  1603         -          nErr = sqliteExprAnalyzeAggregates(pParse, pExpr->pList->a[i].pExpr);
         1603  +          nErr = sqlite3ExprAnalyzeAggregates(pParse, pExpr->pList->a[i].pExpr);
  1604   1604           }
  1605   1605         }
  1606   1606         break;
  1607   1607       }
  1608   1608     }
  1609   1609     return nErr;
  1610   1610   }
................................................................................
  1620   1620   ** and the nArg parameter is -1, then only a function that accepts
  1621   1621   ** any number of arguments will be returned.
  1622   1622   **
  1623   1623   ** If createFlag is false and nArg is -1, then the first valid
  1624   1624   ** function found is returned.  A function is valid if either xFunc
  1625   1625   ** or xStep is non-zero.
  1626   1626   */
  1627         -FuncDef *sqliteFindFunction(
         1627  +FuncDef *sqlite3FindFunction(
  1628   1628     sqlite *db,        /* An open database */
  1629   1629     const char *zName, /* Name of the function.  Not null-terminated */
  1630   1630     int nName,         /* Number of characters in the name */
  1631   1631     int nArg,          /* Number of arguments.  -1 means any number */
  1632   1632     int createFlag     /* Create new entry if true and does not otherwise exist */
  1633   1633   ){
  1634   1634     FuncDef *pFirst, *p, *pMaybe;
  1635         -  pFirst = p = (FuncDef*)sqliteHashFind(&db->aFunc, zName, nName);
         1635  +  pFirst = p = (FuncDef*)sqlite3HashFind(&db->aFunc, zName, nName);
  1636   1636     if( p && !createFlag && nArg<0 ){
  1637   1637       while( p && p->xFunc==0 && p->xStep==0 ){ p = p->pNext; }
  1638   1638       return p;
  1639   1639     }
  1640   1640     pMaybe = 0;
  1641   1641     while( p && p->nArg!=nArg ){
  1642   1642       if( p->nArg<0 && !createFlag && (p->xFunc || p->xStep) ) pMaybe = p;
................................................................................
  1649   1649       assert( createFlag==0 );
  1650   1650       return pMaybe;
  1651   1651     }
  1652   1652     if( p==0 && createFlag && (p = sqliteMalloc(sizeof(*p)))!=0 ){
  1653   1653       p->nArg = nArg;
  1654   1654       p->pNext = pFirst;
  1655   1655       p->dataType = pFirst ? pFirst->dataType : SQLITE_NUMERIC;
  1656         -    sqliteHashInsert(&db->aFunc, zName, nName, (void*)p);
         1656  +    sqlite3HashInsert(&db->aFunc, zName, nName, (void*)p);
  1657   1657     }
  1658   1658     return p;
  1659   1659   }
         1660  +
         1661  +
         1662  +

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.43 2004/02/25 22:51:06 rdc Exp $
           19  +** $Id: func.c,v 1.44 2004/05/08 08:23:25 danielk1977 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 "os.h"
................................................................................
    35     35     int mask;    /* 0 for min() or 0xffffffff for max() */
    36     36   
    37     37     if( argc==0 ) return;
    38     38     mask = (int)sqlite_user_data(context);
    39     39     zBest = argv[0];
    40     40     if( zBest==0 ) return;
    41     41     if( argv[1][0]=='n' ){
    42         -    xCompare = sqliteCompare;
           42  +    xCompare = sqlite3Compare;
    43     43     }else{
    44     44       xCompare = strcmp;
    45     45     }
    46     46     for(i=2; i<argc; i+=2){
    47     47       if( argv[i]==0 ) return;
    48     48       if( (xCompare(argv[i], zBest)^mask)<0 ){
    49     49         zBest = argv[i];
................................................................................
   144    144     double r;
   145    145     char zBuf[100];
   146    146     assert( argc==1 || argc==2 );
   147    147     if( argv[0]==0 || (argc==2 && argv[1]==0) ) return;
   148    148     n = argc==2 ? atoi(argv[1]) : 0;
   149    149     if( n>30 ) n = 30;
   150    150     if( n<0 ) n = 0;
   151         -  r = sqliteAtoF(argv[0], 0);
          151  +  r = sqlite3AtoF(argv[0], 0);
   152    152     sprintf(zBuf,"%.*f",n,r);
   153    153     sqlite_set_result_string(context, zBuf, -1);
   154    154   }
   155    155   
   156    156   /*
   157    157   ** Implementation of the upper() and lower() SQL functions.
   158    158   */
................................................................................
   193    193   }
   194    194   
   195    195   /*
   196    196   ** Implementation of random().  Return a random integer.  
   197    197   */
   198    198   static void randomFunc(sqlite_func *context, int argc, const char **argv){
   199    199     int r;
   200         -  sqliteRandomness(sizeof(r), &r);
          200  +  sqlite3Randomness(sizeof(r), &r);
   201    201     sqlite_set_result_int(context, r);
   202    202   }
   203    203   
   204    204   /*
   205    205   ** Implementation of the last_insert_rowid() SQL function.  The return
   206    206   ** value is the same as the sqlite_last_insert_rowid() API function.
   207    207   */
................................................................................
   237    237   **       A LIKE B
   238    238   **
   239    239   ** is implemented as like(A,B).
   240    240   */
   241    241   static void likeFunc(sqlite_func *context, int arg, const char **argv){
   242    242     if( argv[0]==0 || argv[1]==0 ) return;
   243    243     sqlite_set_result_int(context, 
   244         -    sqliteLikeCompare((const unsigned char*)argv[0],
          244  +    sqlite3LikeCompare((const unsigned char*)argv[0],
   245    245                         (const unsigned char*)argv[1]));
   246    246   }
   247    247   
   248    248   /*
   249    249   ** Implementation of the glob() SQL function.  This function implements
   250    250   ** the build-in GLOB operator.  The first argument to the function is the
   251    251   ** string and the second argument is the pattern.  So, the SQL statements:
................................................................................
   253    253   **       A GLOB B
   254    254   **
   255    255   ** is implemented as glob(A,B).
   256    256   */
   257    257   static void globFunc(sqlite_func *context, int arg, const char **argv){
   258    258     if( argv[0]==0 || argv[1]==0 ) return;
   259    259     sqlite_set_result_int(context,
   260         -    sqliteGlobCompare((const unsigned char*)argv[0],
          260  +    sqlite3GlobCompare((const unsigned char*)argv[0],
   261    261                         (const unsigned char*)argv[1]));
   262    262   }
   263    263   
   264    264   /*
   265    265   ** Implementation of the NULLIF(x,y) function.  The result is the first
   266    266   ** argument if the arguments are different.  The result is NULL if the
   267    267   ** arguments are equal to each other.
   268    268   */
   269    269   static void nullifFunc(sqlite_func *context, int argc, const char **argv){
   270         -  if( argv[0]!=0 && sqliteCompare(argv[0],argv[1])!=0 ){
          270  +  if( argv[0]!=0 && sqlite3Compare(argv[0],argv[1])!=0 ){
   271    271       sqlite_set_result_string(context, argv[0], -1);
   272    272     }
   273    273   }
   274    274   
   275    275   /*
   276    276   ** Implementation of the VERSION(*) function.  The result is the version
   277    277   ** of the SQLite library that is running.
................................................................................
   291    291   ** "NULL".  Otherwise, the argument is enclosed in single quotes with
   292    292   ** single-quote escapes.
   293    293   */
   294    294   static void quoteFunc(sqlite_func *context, int argc, const char **argv){
   295    295     if( argc<1 ) return;
   296    296     if( argv[0]==0 ){
   297    297       sqlite_set_result_string(context, "NULL", 4);
   298         -  }else if( sqliteIsNumber(argv[0]) ){
          298  +  }else if( sqlite3IsNumber(argv[0]) ){
   299    299       sqlite_set_result_string(context, argv[0], -1);
   300    300     }else{
   301    301       int i,j,n;
   302    302       char *z;
   303    303       for(i=n=0; argv[0][i]; i++){ if( argv[0][i]=='\'' ) n++; }
   304    304       z = sqliteMalloc( i+n+3 );
   305    305       if( z==0 ) return;
................................................................................
   382    382       if( iMax<iMin ) iMax = iMin;
   383    383       if( iMax>=sizeof(zBuf) ) iMax = sizeof(zBuf)-1;
   384    384     }else{
   385    385       iMax = 50;
   386    386     }
   387    387     n = iMin;
   388    388     if( iMax>iMin ){
   389         -    sqliteRandomness(sizeof(r), &r);
          389  +    sqlite3Randomness(sizeof(r), &r);
   390    390       r &= 0x7fffffff;
   391    391       n += r%(iMax + 1 - iMin);
   392    392     }
   393    393     assert( n<sizeof(zBuf) );
   394         -  sqliteRandomness(n, zBuf);
          394  +  sqlite3Randomness(n, zBuf);
   395    395     for(i=0; i<n; i++){
   396    396       zBuf[i] = zSrc[zBuf[i]%(sizeof(zSrc)-1)];
   397    397     }
   398    398     zBuf[n] = 0;
   399    399     sqlite_set_result_string(context, zBuf, n);
   400    400   }
   401    401   #endif
................................................................................
   414    414   ** Routines used to compute the sum or average.
   415    415   */
   416    416   static void sumStep(sqlite_func *context, int argc, const char **argv){
   417    417     SumCtx *p;
   418    418     if( argc<1 ) return;
   419    419     p = sqlite_aggregate_context(context, sizeof(*p));
   420    420     if( p && argv[0] ){
   421         -    p->sum += sqliteAtoF(argv[0], 0);
          421  +    p->sum += sqlite3AtoF(argv[0], 0);
   422    422       p->cnt++;
   423    423     }
   424    424   }
   425    425   static void sumFinalize(sqlite_func *context){
   426    426     SumCtx *p;
   427    427     p = sqlite_aggregate_context(context, sizeof(*p));
   428    428     sqlite_set_result_double(context, p ? p->sum : 0.0);
................................................................................
   452    452   */
   453    453   static void stdDevStep(sqlite_func *context, int argc, const char **argv){
   454    454     StdDevCtx *p;
   455    455     double x;
   456    456     if( argc<1 ) return;
   457    457     p = sqlite_aggregate_context(context, sizeof(*p));
   458    458     if( p && argv[0] ){
   459         -    x = sqliteAtoF(argv[0], 0);
          459  +    x = sqlite3AtoF(argv[0], 0);
   460    460       p->sum += x;
   461    461       p->sum2 += x*x;
   462    462       p->cnt++;
   463    463     }
   464    464   }
   465    465   static void stdDevFinalize(sqlite_func *context){
   466    466     double rN = sqlite_aggregate_count(context);
................................................................................
   514    514   static void minmaxStep(sqlite_func *context, int argc, const char **argv){
   515    515     MinMaxCtx *p;
   516    516     int (*xCompare)(const char*, const char*);
   517    517     int mask;    /* 0 for min() or 0xffffffff for max() */
   518    518   
   519    519     assert( argc==2 );
   520    520     if( argv[1][0]=='n' ){
   521         -    xCompare = sqliteCompare;
          521  +    xCompare = sqlite3Compare;
   522    522     }else{
   523    523       xCompare = strcmp;
   524    524     }
   525    525     mask = (int)sqlite_user_data(context);
   526    526     p = sqlite_aggregate_context(context, sizeof(*p));
   527    527     if( p==0 || argc<1 || argv[0]==0 ) return;
   528    528     if( p->z==0 || (xCompare(argv[0],p->z)^mask)<0 ){
................................................................................
   554    554   }
   555    555   
   556    556   /*
   557    557   ** This function registered all of the above C functions as SQL
   558    558   ** functions.  This should be the only routine in this file with
   559    559   ** external linkage.
   560    560   */
   561         -void sqliteRegisterBuiltinFunctions(sqlite *db){
          561  +void sqlite3RegisterBuiltinFunctions(sqlite *db){
   562    562     static struct {
   563    563        char *zName;
   564    564        signed char nArg;
   565    565        signed char dataType;
   566    566        u8 argType;               /* 0: none.  1: db  2: (-1) */
   567    567        void (*xFunc)(sqlite_func*,int,const char**);
   568    568     } aFuncs[] = {
................................................................................
   632    632       void *pArg = aAggs[i].argType==2 ? (void*)(-1) : db;
   633    633       sqlite_create_aggregate(db, aAggs[i].zName,
   634    634              aAggs[i].nArg, aAggs[i].xStep, aAggs[i].xFinalize, pArg);
   635    635       sqlite_function_type(db, aAggs[i].zName, aAggs[i].dataType);
   636    636     }
   637    637     for(i=0; i<sizeof(azTypeFuncs)/sizeof(azTypeFuncs[0]); i++){
   638    638       int n = strlen(azTypeFuncs[i]);
   639         -    FuncDef *p = sqliteHashFind(&db->aFunc, azTypeFuncs[i], n);
          639  +    FuncDef *p = sqlite3HashFind(&db->aFunc, azTypeFuncs[i], n);
   640    640       while( p ){
   641    641         p->includeTypes = 1;
   642    642         p = p->pNext;
   643    643       }
   644    644     }
   645         -  sqliteRegisterDateTimeFunctions(db);
          645  +  sqlite3RegisterDateTimeFunctions(db);
   646    646   }
          647  +
          648  +
          649  +

Changes to src/hash.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 is the implementation of generic hash-tables
    13     13   ** used in SQLite.
    14     14   **
    15         -** $Id: hash.c,v 1.11 2004/01/08 02:17:33 drh Exp $
           15  +** $Id: hash.c,v 1.12 2004/05/08 08:23:25 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <assert.h>
    19     19   
    20     20   /* Turn bulk memory into a hash table object by initializing the
    21     21   ** fields of the Hash structure.
    22     22   **
................................................................................
    25     25   ** SQLITE_HASH_BINARY, or SQLITE_HASH_STRING.  The value of keyClass 
    26     26   ** determines what kind of key the hash table will use.  "copyKey" is
    27     27   ** true if the hash table should make its own private copy of keys and
    28     28   ** false if it should just use the supplied pointer.  CopyKey only makes
    29     29   ** sense for SQLITE_HASH_STRING and SQLITE_HASH_BINARY and is ignored
    30     30   ** for other key classes.
    31     31   */
    32         -void sqliteHashInit(Hash *new, int keyClass, int copyKey){
           32  +void sqlite3HashInit(Hash *new, int keyClass, int copyKey){
    33     33     assert( new!=0 );
    34     34     assert( keyClass>=SQLITE_HASH_INT && keyClass<=SQLITE_HASH_BINARY );
    35     35     new->keyClass = keyClass;
    36     36     new->copyKey = copyKey &&
    37     37                   (keyClass==SQLITE_HASH_STRING || keyClass==SQLITE_HASH_BINARY);
    38     38     new->first = 0;
    39     39     new->count = 0;
................................................................................
    41     41     new->ht = 0;
    42     42   }
    43     43   
    44     44   /* Remove all entries from a hash table.  Reclaim all memory.
    45     45   ** Call this routine to delete a hash table or to reset a hash table
    46     46   ** to the empty state.
    47     47   */
    48         -void sqliteHashClear(Hash *pH){
           48  +void sqlite3HashClear(Hash *pH){
    49     49     HashElem *elem;         /* For looping over all elements of the table */
    50     50   
    51     51     assert( pH!=0 );
    52     52     elem = pH->first;
    53     53     pH->first = 0;
    54     54     if( pH->ht ) sqliteFree(pH->ht);
    55     55     pH->ht = 0;
................................................................................
    90     90   }
    91     91   #endif
    92     92   
    93     93   /*
    94     94   ** Hash and comparison functions when the mode is SQLITE_HASH_STRING
    95     95   */
    96     96   static int strHash(const void *pKey, int nKey){
    97         -  return sqliteHashNoCase((const char*)pKey, nKey); 
           97  +  return sqlite3HashNoCase((const char*)pKey, nKey); 
    98     98   }
    99     99   static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){
   100    100     if( n1!=n2 ) return n2-n1;
   101         -  return sqliteStrNICmp((const char*)pKey1,(const char*)pKey2,n1);
          101  +  return sqlite3StrNICmp((const char*)pKey1,(const char*)pKey2,n1);
   102    102   }
   103    103   
   104    104   /*
   105    105   ** Hash and comparison functions when the mode is SQLITE_HASH_BINARY
   106    106   */
   107    107   static int binHash(const void *pKey, int nKey){
   108    108     int h = 0;
................................................................................
   254    254     pH->count--;
   255    255   }
   256    256   
   257    257   /* Attempt to locate an element of the hash table pH with a key
   258    258   ** that matches pKey,nKey.  Return the data for this element if it is
   259    259   ** found, or NULL if there is no match.
   260    260   */
   261         -void *sqliteHashFind(const Hash *pH, const void *pKey, int nKey){
          261  +void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){
   262    262     int h;             /* A hash on key */
   263    263     HashElem *elem;    /* The element that matches key */
   264    264     int (*xHash)(const void*,int);  /* The hash function */
   265    265   
   266    266     if( pH==0 || pH->ht==0 ) return 0;
   267    267     xHash = hashFunction(pH->keyClass);
   268    268     assert( xHash!=0 );
................................................................................
   283    283   ** new data replaces the old data and the old data is returned.
   284    284   ** The key is not copied in this instance.  If a malloc fails, then
   285    285   ** the new data is returned and the hash table is unchanged.
   286    286   **
   287    287   ** If the "data" parameter to this function is NULL, then the
   288    288   ** element corresponding to "key" is removed from the hash table.
   289    289   */
   290         -void *sqliteHashInsert(Hash *pH, const void *pKey, int nKey, void *data){
          290  +void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){
   291    291     int hraw;             /* Raw hash value of the key */
   292    292     int h;                /* the hash of the key modulo hash table size */
   293    293     HashElem *elem;       /* Used to loop thru the element list */
   294    294     HashElem *new_elem;   /* New element added to the pH */
   295    295     int (*xHash)(const void*,int);  /* The hash function */
   296    296   
   297    297     assert( pH!=0 );
................................................................................
   350    350       pH->first = new_elem;
   351    351     }
   352    352     pH->ht[h].count++;
   353    353     pH->ht[h].chain = new_elem;
   354    354     new_elem->data = data;
   355    355     return 0;
   356    356   }
          357  +
          358  +
          359  +

Changes to src/hash.h.

     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 is the header file for the generic hash-table implemenation
    13     13   ** used in SQLite.
    14     14   **
    15         -** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $
           15  +** $Id: hash.h,v 1.7 2004/05/08 08:23:25 danielk1977 Exp $
    16     16   */
    17     17   #ifndef _SQLITE_HASH_H_
    18     18   #define _SQLITE_HASH_H_
    19     19   
    20     20   /* Forward declarations of structures. */
    21     21   typedef struct Hash Hash;
    22     22   typedef struct HashElem HashElem;
................................................................................
    74     74   /* #define SQLITE_HASH_POINTER   2 // NOT USED */
    75     75   #define SQLITE_HASH_STRING    3
    76     76   #define SQLITE_HASH_BINARY    4
    77     77   
    78     78   /*
    79     79   ** Access routines.  To delete, insert a NULL pointer.
    80     80   */
    81         -void sqliteHashInit(Hash*, int keytype, int copyKey);
    82         -void *sqliteHashInsert(Hash*, const void *pKey, int nKey, void *pData);
    83         -void *sqliteHashFind(const Hash*, const void *pKey, int nKey);
    84         -void sqliteHashClear(Hash*);
           81  +void sqlite3HashInit(Hash*, int keytype, int copyKey);
           82  +void *sqlite3HashInsert(Hash*, const void *pKey, int nKey, void *pData);
           83  +void *sqlite3HashFind(const Hash*, const void *pKey, int nKey);
           84  +void sqlite3HashClear(Hash*);
    85     85   
    86     86   /*
    87     87   ** Macros for looping over all elements of a hash table.  The idiom is
    88     88   ** like this:
    89     89   **
    90     90   **   Hash h;
    91     91   **   HashElem *p;
................................................................................
   103    103   
   104    104   /*
   105    105   ** Number of entries in a hash table
   106    106   */
   107    107   #define sqliteHashCount(H)  ((H)->count)
   108    108   
   109    109   #endif /* _SQLITE_HASH_H_ */
          110  +
          111  +
          112  +

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.94 2004/02/24 01:05:33 drh Exp $
           15  +** $Id: insert.c,v 1.95 2004/05/08 08:23:25 danielk1977 Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** This routine is call to handle SQL of the following forms:
    21     21   **
    22     22   **    insert into TABLE (IDLIST) values(EXPRLIST)
................................................................................
    79     79   **         goto A
    80     80   **      D: open write cursor to <table> and its indices
    81     81   **         loop over the intermediate table
    82     82   **           transfer values form intermediate table into <table>
    83     83   **         end the loop
    84     84   **         cleanup
    85     85   */
    86         -void sqliteInsert(
           86  +void sqlite3Insert(
    87     87     Parse *pParse,        /* Parser context */
    88     88     SrcList *pTabList,    /* Name of table into which we are inserting */
    89     89     ExprList *pList,      /* List of values to be inserted */
    90     90     Select *pSelect,      /* A SELECT statement to use as the data source */
    91     91     IdList *pColumn,      /* Column names corresponding to IDLIST. */
    92     92     int onError           /* How to handle constraint errors */
    93     93   ){
................................................................................
   120    120     db = pParse->db;
   121    121   
   122    122     /* Locate the table into which we will be inserting new information.
   123    123     */
   124    124     assert( pTabList->nSrc==1 );
   125    125     zTab = pTabList->a[0].zName;
   126    126     if( zTab==0 ) goto insert_cleanup;
   127         -  pTab = sqliteSrcListLookup(pParse, pTabList);
          127  +  pTab = sqlite3SrcListLookup(pParse, pTabList);
   128    128     if( pTab==0 ){
   129    129       goto insert_cleanup;
   130    130     }
   131    131     assert( pTab->iDb<db->nDb );
   132    132     zDb = db->aDb[pTab->iDb].zName;
   133         -  if( sqliteAuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){
          133  +  if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){
   134    134       goto insert_cleanup;
   135    135     }
   136    136   
   137    137     /* Ensure that:
   138    138     *  (a) the table is not read-only, 
   139    139     *  (b) that if it is a view then ON INSERT triggers exist
   140    140     */
   141         -  before_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT, 
          141  +  before_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger, TK_INSERT, 
   142    142                                          TK_BEFORE, TK_ROW, 0);
   143         -  after_triggers = sqliteTriggersExist(pParse, pTab->pTrigger, TK_INSERT,
          143  +  after_triggers = sqlite3TriggersExist(pParse, pTab->pTrigger, TK_INSERT,
   144    144                                          TK_AFTER, TK_ROW, 0);
   145    145     row_triggers_exist = before_triggers || after_triggers;
   146    146     isView = pTab->pSelect!=0;
   147         -  if( sqliteIsReadOnly(pParse, pTab, before_triggers) ){
          147  +  if( sqlite3IsReadOnly(pParse, pTab, before_triggers) ){
   148    148       goto insert_cleanup;
   149    149     }
   150    150     if( pTab==0 ) goto insert_cleanup;
   151    151   
   152    152     /* If pTab is really a view, make sure it has been initialized.
   153    153     */
   154         -  if( isView && sqliteViewGetColumnNames(pParse, pTab) ){
          154  +  if( isView && sqlite3ViewGetColumnNames(pParse, pTab) ){
   155    155       goto insert_cleanup;
   156    156     }
   157    157   
   158    158     /* Allocate a VDBE
   159    159     */
   160         -  v = sqliteGetVdbe(pParse);
          160  +  v = sqlite3GetVdbe(pParse);
   161    161     if( v==0 ) goto insert_cleanup;
   162         -  sqliteBeginWriteOperation(pParse, pSelect || row_triggers_exist, pTab->iDb);
          162  +  sqlite3BeginWriteOperation(pParse, pSelect || row_triggers_exist, pTab->iDb);
   163    163   
   164    164     /* if there are row triggers, allocate a temp table for new.* references. */
   165    165     if( row_triggers_exist ){
   166    166       newIdx = pParse->nTab++;
   167    167     }
   168    168   
   169    169     /* Figure out how many columns of data are supplied.  If the data
................................................................................
   174    174     ** subroutine is also coded here.  That subroutine stores the SELECT
   175    175     ** results in a temporary table. (Template 3.)
   176    176     */
   177    177     if( pSelect ){
   178    178       /* Data is coming from a SELECT.  Generate code to implement that SELECT
   179    179       */
   180    180       int rc, iInitCode;
   181         -    iInitCode = sqliteVdbeAddOp(v, OP_Goto, 0, 0);
   182         -    iSelectLoop = sqliteVdbeCurrentAddr(v);
   183         -    iInsertBlock = sqliteVdbeMakeLabel(v);
   184         -    rc = sqliteSelect(pParse, pSelect, SRT_Subroutine, iInsertBlock, 0,0,0);
          181  +    iInitCode = sqlite3VdbeAddOp(v, OP_Goto, 0, 0);
          182  +    iSelectLoop = sqlite3VdbeCurrentAddr(v);
          183  +    iInsertBlock = sqlite3VdbeMakeLabel(v);
          184  +    rc = sqlite3Select(pParse, pSelect, SRT_Subroutine, iInsertBlock, 0,0,0);
   185    185       if( rc || pParse->nErr || sqlite_malloc_failed ) goto insert_cleanup;
   186         -    iCleanup = sqliteVdbeMakeLabel(v);
   187         -    sqliteVdbeAddOp(v, OP_Goto, 0, iCleanup);
          186  +    iCleanup = sqlite3VdbeMakeLabel(v);
          187  +    sqlite3VdbeAddOp(v, OP_Goto, 0, iCleanup);
   188    188       assert( pSelect->pEList );
   189    189       nColumn = pSelect->pEList->nExpr;
   190    190   
   191    191       /* Set useTempTable to TRUE if the result of the SELECT statement
   192    192       ** should be written into a temporary table.  Set to FALSE if each
   193    193       ** row of the SELECT can be written directly into the result table.
   194    194       **
................................................................................
   195    195       ** A temp table must be used if the table being updated is also one
   196    196       ** of the tables being read by the SELECT statement.  Also use a 
   197    197       ** temp table in the case of row triggers.
   198    198       */
   199    199       if( row_triggers_exist ){
   200    200         useTempTable = 1;
   201    201       }else{
   202         -      int addr = sqliteVdbeFindOp(v, OP_OpenRead, pTab->tnum);
          202  +      int addr = sqlite3VdbeFindOp(v, OP_OpenRead, pTab->tnum);
   203    203         useTempTable = 0;
   204    204         if( addr>0 ){
   205         -        VdbeOp *pOp = sqliteVdbeGetOp(v, addr-2);
          205  +        VdbeOp *pOp = sqlite3VdbeGetOp(v, addr-2);
   206    206           if( pOp->opcode==OP_Integer && pOp->p1==pTab->iDb ){
   207    207             useTempTable = 1;
   208    208           }
   209    209         }
   210    210       }
   211    211   
   212    212       if( useTempTable ){
   213    213         /* Generate the subroutine that SELECT calls to process each row of
   214    214         ** the result.  Store the result in a temporary table
   215    215         */
   216    216         srcTab = pParse->nTab++;
   217         -      sqliteVdbeResolveLabel(v, iInsertBlock);
   218         -      sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0);
   219         -      sqliteVdbeAddOp(v, OP_NewRecno, srcTab, 0);
   220         -      sqliteVdbeAddOp(v, OP_Pull, 1, 0);
   221         -      sqliteVdbeAddOp(v, OP_PutIntKey, srcTab, 0);
   222         -      sqliteVdbeAddOp(v, OP_Return, 0, 0);
          217  +      sqlite3VdbeResolveLabel(v, iInsertBlock);
          218  +      sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
          219  +      sqlite3VdbeAddOp(v, OP_NewRecno, srcTab, 0);
          220  +      sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
          221  +      sqlite3VdbeAddOp(v, OP_PutIntKey, srcTab, 0);
          222  +      sqlite3VdbeAddOp(v, OP_Return, 0, 0);
   223    223   
   224    224         /* The following code runs first because the GOTO at the very top
   225    225         ** of the program jumps to it.  Create the temporary table, then jump
   226    226         ** back up and execute the SELECT code above.
   227    227         */
   228         -      sqliteVdbeChangeP2(v, iInitCode, sqliteVdbeCurrentAddr(v));
   229         -      sqliteVdbeAddOp(v, OP_OpenTemp, srcTab, 0);
   230         -      sqliteVdbeAddOp(v, OP_Goto, 0, iSelectLoop);
   231         -      sqliteVdbeResolveLabel(v, iCleanup);
          228  +      sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v));
          229  +      sqlite3VdbeAddOp(v, OP_OpenTemp, srcTab, 0);
          230  +      sqlite3VdbeAddOp(v, OP_Goto, 0, iSelectLoop);
          231  +      sqlite3VdbeResolveLabel(v, iCleanup);
   232    232       }else{
   233         -      sqliteVdbeChangeP2(v, iInitCode, sqliteVdbeCurrentAddr(v));
          233  +      sqlite3VdbeChangeP2(v, iInitCode, sqlite3VdbeCurrentAddr(v));
   234    234       }
   235    235     }else{
   236    236       /* This is the case if the data for the INSERT is coming from a VALUES
   237    237       ** clause
   238    238       */
   239    239       SrcList dummy;
   240    240       assert( pList!=0 );
   241    241       srcTab = -1;
   242    242       useTempTable = 0;
   243    243       assert( pList );
   244    244       nColumn = pList->nExpr;
   245    245       dummy.nSrc = 0;
   246    246       for(i=0; i<nColumn; i++){
   247         -      if( sqliteExprResolveIds(pParse, &dummy, 0, pList->a[i].pExpr) ){
          247  +      if( sqlite3ExprResolveIds(pParse, &dummy, 0, pList->a[i].pExpr) ){
   248    248           goto insert_cleanup;
   249    249         }
   250         -      if( sqliteExprCheck(pParse, pList->a[i].pExpr, 0, 0) ){
          250  +      if( sqlite3ExprCheck(pParse, pList->a[i].pExpr, 0, 0) ){
   251    251           goto insert_cleanup;
   252    252         }
   253    253       }
   254    254     }
   255    255   
   256    256     /* Make sure the number of columns in the source data matches the number
   257    257     ** of columns to be inserted into the table.
   258    258     */
   259    259     if( pColumn==0 && nColumn!=pTab->nCol ){
   260         -    sqliteErrorMsg(pParse, 
          260  +    sqlite3ErrorMsg(pParse, 
   261    261          "table %S has %d columns but %d values were supplied",
   262    262          pTabList, 0, pTab->nCol, nColumn);
   263    263       goto insert_cleanup;
   264    264     }
   265    265     if( pColumn!=0 && nColumn!=pColumn->nId ){
   266         -    sqliteErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);
          266  +    sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);
   267    267       goto insert_cleanup;
   268    268     }
   269    269   
   270    270     /* If the INSERT statement included an IDLIST term, then make sure
   271    271     ** all elements of the IDLIST really are columns of the table and 
   272    272     ** remember the column indices.
   273    273     **
................................................................................
   280    280     */
   281    281     if( pColumn ){
   282    282       for(i=0; i<pColumn->nId; i++){
   283    283         pColumn->a[i].idx = -1;
   284    284       }
   285    285       for(i=0; i<pColumn->nId; i++){
   286    286         for(j=0; j<pTab->nCol; j++){
   287         -        if( sqliteStrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
          287  +        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){
   288    288             pColumn->a[i].idx = j;
   289    289             if( j==pTab->iPKey ){
   290    290               keyColumn = i;
   291    291             }
   292    292             break;
   293    293           }
   294    294         }
   295    295         if( j>=pTab->nCol ){
   296         -        if( sqliteIsRowid(pColumn->a[i].zName) ){
          296  +        if( sqlite3IsRowid(pColumn->a[i].zName) ){
   297    297             keyColumn = i;
   298    298           }else{
   299         -          sqliteErrorMsg(pParse, "table %S has no column named %s",
          299  +          sqlite3ErrorMsg(pParse, "table %S has no column named %s",
   300    300                 pTabList, 0, pColumn->a[i].zName);
   301    301             pParse->nErr++;
   302    302             goto insert_cleanup;
   303    303           }
   304    304         }
   305    305       }
   306    306     }
................................................................................
   312    312     if( pColumn==0 ){
   313    313       keyColumn = pTab->iPKey;
   314    314     }
   315    315   
   316    316     /* Open the temp table for FOR EACH ROW triggers
   317    317     */
   318    318     if( row_triggers_exist ){
   319         -    sqliteVdbeAddOp(v, OP_OpenPseudo, newIdx, 0);
          319  +    sqlite3VdbeAddOp(v, OP_OpenPseudo, newIdx, 0);
   320    320     }
   321    321       
   322    322     /* Initialize the count of rows to be inserted
   323    323     */
   324    324     if( db->flags & SQLITE_CountRows ){
   325    325       iCntMem = pParse->nMem++;
   326         -    sqliteVdbeAddOp(v, OP_Integer, 0, 0);
   327         -    sqliteVdbeAddOp(v, OP_MemStore, iCntMem, 1);
          326  +    sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
          327  +    sqlite3VdbeAddOp(v, OP_MemStore, iCntMem, 1);
   328    328     }
   329    329   
   330    330     /* Open tables and indices if there are no row triggers */
   331    331     if( !row_triggers_exist ){
   332    332       base = pParse->nTab;
   333         -    idx = sqliteOpenTableAndIndices(pParse, pTab, base);
          333  +    idx = sqlite3OpenTableAndIndices(pParse, pTab, base);
   334    334       pParse->nTab += idx;
   335    335     }
   336    336   
   337    337     /* If the data source is a temporary table, then we have to create
   338    338     ** a loop because there might be multiple rows of data.  If the data
   339    339     ** source is a subroutine call from the SELECT statement, then we need
   340    340     ** to launch the SELECT statement processing.
   341    341     */
   342    342     if( useTempTable ){
   343         -    iBreak = sqliteVdbeMakeLabel(v);
   344         -    sqliteVdbeAddOp(v, OP_Rewind, srcTab, iBreak);
   345         -    iCont = sqliteVdbeCurrentAddr(v);
          343  +    iBreak = sqlite3VdbeMakeLabel(v);
          344  +    sqlite3VdbeAddOp(v, OP_Rewind, srcTab, iBreak);
          345  +    iCont = sqlite3VdbeCurrentAddr(v);
   346    346     }else if( pSelect ){
   347         -    sqliteVdbeAddOp(v, OP_Goto, 0, iSelectLoop);
   348         -    sqliteVdbeResolveLabel(v, iInsertBlock);
          347  +    sqlite3VdbeAddOp(v, OP_Goto, 0, iSelectLoop);
          348  +    sqlite3VdbeResolveLabel(v, iInsertBlock);
   349    349     }
   350    350   
   351    351     /* Run the BEFORE and INSTEAD OF triggers, if there are any
   352    352     */
   353         -  endOfLoop = sqliteVdbeMakeLabel(v);
          353  +  endOfLoop = sqlite3VdbeMakeLabel(v);
   354    354     if( before_triggers ){
   355    355   
   356    356       /* build the NEW.* reference row.  Note that if there is an INTEGER
   357    357       ** PRIMARY KEY into which a NULL is being inserted, that NULL will be
   358    358       ** translated into a unique ID for the row.  But on a BEFORE trigger,
   359    359       ** we do not know what the unique ID will be (because the insert has
   360    360       ** not happened yet) so we substitute a rowid of -1
   361    361       */
   362    362       if( keyColumn<0 ){
   363         -      sqliteVdbeAddOp(v, OP_Integer, -1, 0);
          363  +      sqlite3VdbeAddOp(v, OP_Integer, -1, 0);
   364    364       }else if( useTempTable ){
   365         -      sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn);
          365  +      sqlite3VdbeAddOp(v, OP_Column, srcTab, keyColumn);
   366    366       }else if( pSelect ){
   367         -      sqliteVdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1);
          367  +      sqlite3VdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1);
   368    368       }else{
   369         -      sqliteExprCode(pParse, pList->a[keyColumn].pExpr);
   370         -      sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3);
   371         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
   372         -      sqliteVdbeAddOp(v, OP_Integer, -1, 0);
   373         -      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
          369  +      sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr);
          370  +      sqlite3VdbeAddOp(v, OP_NotNull, -1, sqlite3VdbeCurrentAddr(v)+3);
          371  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
          372  +      sqlite3VdbeAddOp(v, OP_Integer, -1, 0);
          373  +      sqlite3VdbeAddOp(v, OP_MustBeInt, 0, 0);
   374    374       }
   375    375   
   376    376       /* Create the new column data
   377    377       */
   378    378       for(i=0; i<pTab->nCol; i++){
   379    379         if( pColumn==0 ){
   380    380           j = i;
   381    381         }else{
   382    382           for(j=0; j<pColumn->nId; j++){
   383    383             if( pColumn->a[j].idx==i ) break;
   384    384           }
   385    385         }
   386    386         if( pColumn && j>=pColumn->nId ){
   387         -        sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
          387  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
   388    388         }else if( useTempTable ){
   389         -        sqliteVdbeAddOp(v, OP_Column, srcTab, j); 
          389  +        sqlite3VdbeAddOp(v, OP_Column, srcTab, j); 
   390    390         }else if( pSelect ){
   391         -        sqliteVdbeAddOp(v, OP_Dup, nColumn-j-1, 1);
          391  +        sqlite3VdbeAddOp(v, OP_Dup, nColumn-j-1, 1);
   392    392         }else{
   393         -        sqliteExprCode(pParse, pList->a[j].pExpr);
          393  +        sqlite3ExprCode(pParse, pList->a[j].pExpr);
   394    394         }
   395    395       }
   396         -    sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
   397         -    sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0);
          396  +    sqlite3VdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
          397  +    sqlite3VdbeAddOp(v, OP_PutIntKey, newIdx, 0);
   398    398   
   399    399       /* Fire BEFORE or INSTEAD OF triggers */
   400         -    if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab, 
          400  +    if( sqlite3CodeRowTrigger(pParse, TK_INSERT, 0, TK_BEFORE, pTab, 
   401    401           newIdx, -1, onError, endOfLoop) ){
   402    402         goto insert_cleanup;
   403    403       }
   404    404     }
   405    405   
   406    406     /* If any triggers exists, the opening of tables and indices is deferred
   407    407     ** until now.
   408    408     */
   409    409     if( row_triggers_exist && !isView ){
   410    410       base = pParse->nTab;
   411         -    idx = sqliteOpenTableAndIndices(pParse, pTab, base);
          411  +    idx = sqlite3OpenTableAndIndices(pParse, pTab, base);
   412    412       pParse->nTab += idx;
   413    413     }
   414    414   
   415    415     /* Push the record number for the new entry onto the stack.  The
   416    416     ** record number is a randomly generate integer created by NewRecno
   417    417     ** except when the table has an INTEGER PRIMARY KEY column, in which
   418    418     ** case the record number is the same as that column. 
   419    419     */
   420    420     if( !isView ){
   421    421       if( keyColumn>=0 ){
   422    422         if( useTempTable ){
   423         -        sqliteVdbeAddOp(v, OP_Column, srcTab, keyColumn);
          423  +        sqlite3VdbeAddOp(v, OP_Column, srcTab, keyColumn);
   424    424         }else if( pSelect ){
   425         -        sqliteVdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1);
          425  +        sqlite3VdbeAddOp(v, OP_Dup, nColumn - keyColumn - 1, 1);
   426    426         }else{
   427         -        sqliteExprCode(pParse, pList->a[keyColumn].pExpr);
          427  +        sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr);
   428    428         }
   429    429         /* If the PRIMARY KEY expression is NULL, then use OP_NewRecno
   430    430         ** to generate a unique primary key value.
   431    431         */
   432         -      sqliteVdbeAddOp(v, OP_NotNull, -1, sqliteVdbeCurrentAddr(v)+3);
   433         -      sqliteVdbeAddOp(v, OP_Pop, 1, 0);
   434         -      sqliteVdbeAddOp(v, OP_NewRecno, base, 0);
   435         -      sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
          432  +      sqlite3VdbeAddOp(v, OP_NotNull, -1, sqlite3VdbeCurrentAddr(v)+3);
          433  +      sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
          434  +      sqlite3VdbeAddOp(v, OP_NewRecno, base, 0);
          435  +      sqlite3VdbeAddOp(v, OP_MustBeInt, 0, 0);
   436    436       }else{
   437         -      sqliteVdbeAddOp(v, OP_NewRecno, base, 0);
          437  +      sqlite3VdbeAddOp(v, OP_NewRecno, base, 0);
   438    438       }
   439    439   
   440    440       /* Push onto the stack, data for all columns of the new entry, beginning
   441    441       ** with the first column.
   442    442       */
   443    443       for(i=0; i<pTab->nCol; i++){
   444    444         if( i==pTab->iPKey ){
   445    445           /* The value of the INTEGER PRIMARY KEY column is always a NULL.
   446    446           ** Whenever this column is read, the record number will be substituted
   447    447           ** in its place.  So will fill this column with a NULL to avoid
   448    448           ** taking up data space with information that will never be used. */
   449         -        sqliteVdbeAddOp(v, OP_String, 0, 0);
          449  +        sqlite3VdbeAddOp(v, OP_String, 0, 0);
   450    450           continue;
   451    451         }
   452    452         if( pColumn==0 ){
   453    453           j = i;
   454    454         }else{
   455    455           for(j=0; j<pColumn->nId; j++){
   456    456             if( pColumn->a[j].idx==i ) break;
   457    457           }
   458    458         }
   459    459         if( pColumn && j>=pColumn->nId ){
   460         -        sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
          460  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
   461    461         }else if( useTempTable ){
   462         -        sqliteVdbeAddOp(v, OP_Column, srcTab, j); 
          462  +        sqlite3VdbeAddOp(v, OP_Column, srcTab, j); 
   463    463         }else if( pSelect ){
   464         -        sqliteVdbeAddOp(v, OP_Dup, i+nColumn-j, 1);
          464  +        sqlite3VdbeAddOp(v, OP_Dup, i+nColumn-j, 1);
   465    465         }else{
   466         -        sqliteExprCode(pParse, pList->a[j].pExpr);
          466  +        sqlite3ExprCode(pParse, pList->a[j].pExpr);
   467    467         }
   468    468       }
   469    469   
   470    470       /* Generate code to check constraints and generate index keys and
   471    471       ** do the insertion.
   472    472       */
   473         -    sqliteGenerateConstraintChecks(pParse, pTab, base, 0, keyColumn>=0,
          473  +    sqlite3GenerateConstraintChecks(pParse, pTab, base, 0, keyColumn>=0,
   474    474                                      0, onError, endOfLoop);
   475         -    sqliteCompleteInsertion(pParse, pTab, base, 0,0,0,
          475  +    sqlite3CompleteInsertion(pParse, pTab, base, 0,0,0,
   476    476                               after_triggers ? newIdx : -1);
   477    477     }
   478    478   
   479    479     /* Update the count of rows that are inserted
   480    480     */
   481    481     if( (db->flags & SQLITE_CountRows)!=0 ){
   482         -    sqliteVdbeAddOp(v, OP_MemIncr, iCntMem, 0);
          482  +    sqlite3VdbeAddOp(v, OP_MemIncr, iCntMem, 0);
   483    483     }
   484    484   
   485    485     if( row_triggers_exist ){
   486    486       /* Close all tables opened */
   487    487       if( !isView ){
   488         -      sqliteVdbeAddOp(v, OP_Close, base, 0);
          488  +      sqlite3VdbeAddOp(v, OP_Close, base, 0);
   489    489         for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){
   490         -        sqliteVdbeAddOp(v, OP_Close, idx+base, 0);
          490  +        sqlite3VdbeAddOp(v, OP_Close, idx+base, 0);
   491    491         }
   492    492       }
   493    493   
   494    494       /* Code AFTER triggers */
   495         -    if( sqliteCodeRowTrigger(pParse, TK_INSERT, 0, TK_AFTER, pTab, newIdx, -1, 
          495  +    if( sqlite3CodeRowTrigger(pParse, TK_INSERT, 0, TK_AFTER, pTab, newIdx, -1, 
   496    496             onError, endOfLoop) ){
   497    497         goto insert_cleanup;
   498    498       }
   499    499     }
   500    500   
   501    501     /* The bottom of the loop, if the data source is a SELECT statement
   502    502     */
   503         -  sqliteVdbeResolveLabel(v, endOfLoop);
          503  +  sqlite3VdbeResolveLabel(v, endOfLoop);
   504    504     if( useTempTable ){
   505         -    sqliteVdbeAddOp(v, OP_Next, srcTab, iCont);
   506         -    sqliteVdbeResolveLabel(v, iBreak);
   507         -    sqliteVdbeAddOp(v, OP_Close, srcTab, 0);
          505  +    sqlite3VdbeAddOp(v, OP_Next, srcTab, iCont);
          506  +    sqlite3VdbeResolveLabel(v, iBreak);
          507  +    sqlite3VdbeAddOp(v, OP_Close, srcTab, 0);
   508    508     }else if( pSelect ){
   509         -    sqliteVdbeAddOp(v, OP_Pop, nColumn, 0);
   510         -    sqliteVdbeAddOp(v, OP_Return, 0, 0);
   511         -    sqliteVdbeResolveLabel(v, iCleanup);
          509  +    sqlite3VdbeAddOp(v, OP_Pop, nColumn, 0);
          510  +    sqlite3VdbeAddOp(v, OP_Return, 0, 0);
          511  +    sqlite3VdbeResolveLabel(v, iCleanup);
   512    512     }
   513    513   
   514    514     if( !row_triggers_exist ){
   515    515       /* Close all tables opened */
   516         -    sqliteVdbeAddOp(v, OP_Close, base, 0);
          516  +    sqlite3VdbeAddOp(v, OP_Close, base, 0);
   517    517       for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){
   518         -      sqliteVdbeAddOp(v, OP_Close, idx+base, 0);
          518  +      sqlite3VdbeAddOp(v, OP_Close, idx+base, 0);
   519    519       }
   520    520     }
   521    521   
   522         -  sqliteVdbeAddOp(v, OP_SetCounts, 0, 0);
   523         -  sqliteEndWriteOperation(pParse);
          522  +  sqlite3VdbeAddOp(v, OP_SetCounts, 0, 0);
          523  +  sqlite3EndWriteOperation(pParse);
   524    524   
   525    525     /*
   526    526     ** Return the number of rows inserted.
   527    527     */
   528    528     if( db->flags & SQLITE_CountRows ){
   529         -    sqliteVdbeOp3(v, OP_ColumnName, 0, 1, "rows inserted", P3_STATIC);
   530         -    sqliteVdbeAddOp(v, OP_MemLoad, iCntMem, 0);
   531         -    sqliteVdbeAddOp(v, OP_Callback, 1, 0);
          529  +    sqlite3VdbeOp3(v, OP_ColumnName, 0, 1, "rows inserted", P3_STATIC);
          530  +    sqlite3VdbeAddOp(v, OP_MemLoad, iCntMem, 0);
          531  +    sqlite3VdbeAddOp(v, OP_Callback, 1, 0);
   532    532     }
   533    533   
   534    534   insert_cleanup:
   535         -  sqliteSrcListDelete(pTabList);
   536         -  if( pList ) sqliteExprListDelete(pList);
   537         -  if( pSelect ) sqliteSelectDelete(pSelect);
   538         -  sqliteIdListDelete(pColumn);
          535  +  sqlite3SrcListDelete(pTabList);
          536  +  if( pList ) sqlite3ExprListDelete(pList);
          537  +  if( pSelect ) sqlite3SelectDelete(pSelect);
          538  +  sqlite3IdListDelete(pColumn);
   539    539   }
   540    540   
   541    541   /*
   542    542   ** Generate code to do a constraint check prior to an INSERT or an UPDATE.
   543    543   **
   544    544   ** When this routine is called, the stack contains (from bottom to top)
   545    545   ** the following values:
................................................................................
   613    613   **
   614    614   ** If the isUpdate flag is true, it means that the "base" cursor is
   615    615   ** initially pointing to an entry that is being updated.  The isUpdate
   616    616   ** flag causes extra code to be generated so that the "base" cursor
   617    617   ** is still pointing at the same entry after the routine returns.
   618    618   ** Without the isUpdate flag, the "base" cursor might be moved.
   619    619   */
   620         -void sqliteGenerateConstraintChecks(
          620  +void sqlite3GenerateConstraintChecks(
   621    621     Parse *pParse,      /* The parser context */
   622    622     Table *pTab,        /* the table into which we are inserting */
   623    623     int base,           /* Index of a read/write cursor pointing at pTab */
   624    624     char *aIdxUsed,     /* Which indices are used.  NULL means all are used */
   625    625     int recnoChng,      /* True if the record number will change */
   626    626     int isUpdate,       /* True for UPDATE, False for INSERT */
   627    627     int overrideError,  /* Override onError to this if not OE_Default */
................................................................................
   636    636     int iCur;
   637    637     Index *pIdx;
   638    638     int seenReplace = 0;
   639    639     int jumpInst1, jumpInst2;
   640    640     int contAddr;
   641    641     int hasTwoRecnos = (isUpdate && recnoChng);
   642    642   
   643         -  v = sqliteGetVdbe(pParse);
          643  +  v = sqlite3GetVdbe(pParse);
   644    644     assert( v!=0 );
   645    645     assert( pTab->pSelect==0 );  /* This table is not a VIEW */
   646    646     nCol = pTab->nCol;
   647    647   
   648    648     /* Test all NOT NULL constraints.
   649    649     */
   650    650     for(i=0; i<nCol; i++){
................................................................................
   659    659         onError = pParse->db->onError;
   660    660       }else if( onError==OE_Default ){
   661    661         onError = OE_Abort;
   662    662       }
   663    663       if( onError==OE_Replace && pTab->aCol[i].zDflt==0 ){
   664    664         onError = OE_Abort;
   665    665       }
   666         -    sqliteVdbeAddOp(v, OP_Dup, nCol-1-i, 1);
   667         -    addr = sqliteVdbeAddOp(v, OP_NotNull, 1, 0);
          666  +    sqlite3VdbeAddOp(v, OP_Dup, nCol-1-i, 1);
          667  +    addr = sqlite3VdbeAddOp(v, OP_NotNull, 1, 0);
   668    668       switch( onError ){
   669    669         case OE_Rollback:
   670    670         case OE_Abort:
   671    671         case OE_Fail: {
   672    672           char *zMsg = 0;
   673         -        sqliteVdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
   674         -        sqliteSetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName,
          673  +        sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError);
          674  +        sqlite3SetString(&zMsg, pTab->zName, ".", pTab->aCol[i].zName,
   675    675                           " may not be NULL", (char*)0);
   676         -        sqliteVdbeChangeP3(v, -1, zMsg, P3_DYNAMIC);
          676  +        sqlite3VdbeChangeP3(v, -1, zMsg, P3_DYNAMIC);
   677    677           break;
   678    678         }
   679    679         case OE_Ignore: {
   680         -        sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
   681         -        sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
          680  +        sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
          681  +        sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
   682    682           break;
   683    683         }
   684    684         case OE_Replace: {
   685         -        sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
   686         -        sqliteVdbeAddOp(v, OP_Push, nCol-i, 0);
          685  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zDflt, P3_STATIC);
          686  +        sqlite3VdbeAddOp(v, OP_Push, nCol-i, 0);
   687    687           break;
   688    688         }
   689    689         default: assert(0);
   690    690       }
   691         -    sqliteVdbeChangeP2(v, addr, sqliteVdbeCurrentAddr(v));
          691  +    sqlite3VdbeChangeP2(v, addr, sqlite3VdbeCurrentAddr(v));
   692    692     }
   693    693   
   694    694     /* Test all CHECK constraints
   695    695     */
   696    696     /**** TBD ****/
   697    697   
   698    698     /* If we have an INTEGER PRIMARY KEY, make sure the primary key
................................................................................
   706    706       }else if( pParse->db->onError!=OE_Default ){
   707    707         onError = pParse->db->onError;
   708    708       }else if( onError==OE_Default ){
   709    709         onError = OE_Abort;
   710    710       }
   711    711       
   712    712       if( isUpdate ){
   713         -      sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1);
   714         -      sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1);
   715         -      jumpInst1 = sqliteVdbeAddOp(v, OP_Eq, 0, 0);
          713  +      sqlite3VdbeAddOp(v, OP_Dup, nCol+1, 1);
          714  +      sqlite3VdbeAddOp(v, OP_Dup, nCol+1, 1);
          715  +      jumpInst1 = sqlite3VdbeAddOp(v, OP_Eq, 0, 0);
   716    716       }
   717         -    sqliteVdbeAddOp(v, OP_Dup, nCol, 1);
   718         -    jumpInst2 = sqliteVdbeAddOp(v, OP_NotExists, base, 0);
          717  +    sqlite3VdbeAddOp(v, OP_Dup, nCol, 1);
          718  +    jumpInst2 = sqlite3VdbeAddOp(v, OP_NotExists, base, 0);
   719    719       switch( onError ){
   720    720         default: {
   721    721           onError = OE_Abort;
   722    722           /* Fall thru into the next case */
   723    723         }
   724    724         case OE_Rollback:
   725    725         case OE_Abort:
   726    726         case OE_Fail: {
   727         -        sqliteVdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError,
          727  +        sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError,
   728    728                            "PRIMARY KEY must be unique", P3_STATIC);
   729    729           break;
   730    730         }
   731    731         case OE_Replace: {
   732         -        sqliteGenerateRowIndexDelete(pParse->db, v, pTab, base, 0);
          732  +        sqlite3GenerateRowIndexDelete(pParse->db, v, pTab, base, 0);
   733    733           if( isUpdate ){
   734         -          sqliteVdbeAddOp(v, OP_Dup, nCol+hasTwoRecnos, 1);
   735         -          sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
          734  +          sqlite3VdbeAddOp(v, OP_Dup, nCol+hasTwoRecnos, 1);
          735  +          sqlite3VdbeAddOp(v, OP_MoveTo, base, 0);
   736    736           }
   737    737           seenReplace = 1;
   738    738           break;
   739    739         }
   740    740         case OE_Ignore: {
   741    741           assert( seenReplace==0 );
   742         -        sqliteVdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
   743         -        sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
          742  +        sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRecnos, 0);
          743  +        sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
   744    744           break;
   745    745         }
   746    746       }
   747         -    contAddr = sqliteVdbeCurrentAddr(v);
   748         -    sqliteVdbeChangeP2(v, jumpInst2, contAddr);
          747  +    contAddr = sqlite3VdbeCurrentAddr(v);
          748  +    sqlite3VdbeChangeP2(v, jumpInst2, contAddr);
   749    749       if( isUpdate ){
   750         -      sqliteVdbeChangeP2(v, jumpInst1, contAddr);
   751         -      sqliteVdbeAddOp(v, OP_Dup, nCol+1, 1);
   752         -      sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
          750  +      sqlite3VdbeChangeP2(v, jumpInst1, contAddr);
          751  +      sqlite3VdbeAddOp(v, OP_Dup, nCol+1, 1);
          752  +      sqlite3VdbeAddOp(v, OP_MoveTo, base, 0);
   753    753       }
   754    754     }
   755    755   
   756    756     /* Test all UNIQUE constraints by creating entries for each UNIQUE
   757    757     ** index and making sure that duplicate entries do not already exist.
   758    758     ** Add the new records to the indices as we go.
   759    759     */
   760    760     extra = -1;
   761    761     for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){
   762    762       if( aIdxUsed && aIdxUsed[iCur]==0 ) continue;  /* Skip unused indices */
   763    763       extra++;
   764    764   
   765    765       /* Create a key for accessing the index entry */
   766         -    sqliteVdbeAddOp(v, OP_Dup, nCol+extra, 1);
          766  +    sqlite3VdbeAddOp(v, OP_Dup, nCol+extra, 1);
   767    767       for(i=0; i<pIdx->nColumn; i++){
   768    768         int idx = pIdx->aiColumn[i];
   769    769         if( idx==pTab->iPKey ){
   770         -        sqliteVdbeAddOp(v, OP_Dup, i+extra+nCol+1, 1);
          770  +        sqlite3VdbeAddOp(v, OP_Dup, i+extra+nCol+1, 1);
   771    771         }else{
   772         -        sqliteVdbeAddOp(v, OP_Dup, i+extra+nCol-idx, 1);
          772  +        sqlite3VdbeAddOp(v, OP_Dup, i+extra+nCol-idx, 1);
   773    773         }
   774    774       }
   775         -    jumpInst1 = sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
   776         -    if( pParse->db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx);
          775  +    jumpInst1 = sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
          776  +    if( pParse->db->file_format>=4 ) sqlite3AddIdxKeyType(v, pIdx);
   777    777   
   778    778       /* Find out what action to take in case there is an indexing conflict */
   779    779       onError = pIdx->onError;
   780    780       if( onError==OE_None ) continue;  /* pIdx is not a UNIQUE index */
   781    781       if( overrideError!=OE_Default ){
   782    782         onError = overrideError;
   783    783       }else if( pParse->db->onError!=OE_Default ){
................................................................................
   788    788       if( seenReplace ){
   789    789         if( onError==OE_Ignore ) onError = OE_Replace;
   790    790         else if( onError==OE_Fail ) onError = OE_Abort;
   791    791       }
   792    792       
   793    793   
   794    794       /* Check to see if the new index entry will be unique */
   795         -    sqliteVdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1);
   796         -    jumpInst2 = sqliteVdbeAddOp(v, OP_IsUnique, base+iCur+1, 0);
          795  +    sqlite3VdbeAddOp(v, OP_Dup, extra+nCol+1+hasTwoRecnos, 1);
          796  +    jumpInst2 = sqlite3VdbeAddOp(v, OP_IsUnique, base+iCur+1, 0);
   797    797   
   798    798       /* Generate code that executes if the new index entry is not unique */
   799    799       switch( onError ){
   800    800         case OE_Rollback:
   801    801         case OE_Abort:
   802    802         case OE_Fail: {
   803    803           int j, n1, n2;
................................................................................
   818    818             }else{
   819    819               strcpy(&zErrMsg[n1], zCol);
   820    820               n1 += n2;
   821    821             }
   822    822           }
   823    823           strcpy(&zErrMsg[n1], 
   824    824               pIdx->nColumn>1 ? " are not unique" : " is not unique");
   825         -        sqliteVdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, zErrMsg, 0);
          825  +        sqlite3VdbeOp3(v, OP_Halt, SQLITE_CONSTRAINT, onError, zErrMsg, 0);
   826    826           break;
   827    827         }
   828    828         case OE_Ignore: {
   829    829           assert( seenReplace==0 );
   830         -        sqliteVdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0);
   831         -        sqliteVdbeAddOp(v, OP_Goto, 0, ignoreDest);
          830  +        sqlite3VdbeAddOp(v, OP_Pop, nCol+extra+3+hasTwoRecnos, 0);
          831  +        sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest);
   832    832           break;
   833    833         }
   834    834         case OE_Replace: {
   835         -        sqliteGenerateRowDelete(pParse->db, v, pTab, base, 0);
          835  +        sqlite3GenerateRowDelete(pParse->db, v, pTab, base, 0);
   836    836           if( isUpdate ){
   837         -          sqliteVdbeAddOp(v, OP_Dup, nCol+extra+1+hasTwoRecnos, 1);
   838         -          sqliteVdbeAddOp(v, OP_MoveTo, base, 0);
          837  +          sqlite3VdbeAddOp(v, OP_Dup, nCol+extra+1+hasTwoRecnos, 1);
          838  +          sqlite3VdbeAddOp(v, OP_MoveTo, base, 0);
   839    839           }
   840    840           seenReplace = 1;
   841    841           break;
   842    842         }
   843    843         default: assert(0);
   844    844       }
   845         -    contAddr = sqliteVdbeCurrentAddr(v);
          845  +    contAddr = sqlite3VdbeCurrentAddr(v);
   846    846   #if NULL_DISTINCT_FOR_UNIQUE
   847         -    sqliteVdbeChangeP2(v, jumpInst1, contAddr);
          847  +    sqlite3VdbeChangeP2(v, jumpInst1, contAddr);
   848    848   #endif
   849         -    sqliteVdbeChangeP2(v, jumpInst2, contAddr);
          849  +    sqlite3VdbeChangeP2(v, jumpInst2, contAddr);
   850    850     }
   851    851   }
   852    852   
   853    853   /*
   854    854   ** This routine generates code to finish the INSERT or UPDATE operation
   855         -** that was started by a prior call to sqliteGenerateConstraintChecks.
          855  +** that was started by a prior call to sqlite3GenerateConstraintChecks.
   856    856   ** The stack must contain keys for all active indices followed by data
   857    857   ** and the recno for the new entry.  This routine creates the new
   858    858   ** entries in all indices and in the main table.
   859    859   **
   860    860   ** The arguments to this routine should be the same as the first six
   861         -** arguments to sqliteGenerateConstraintChecks.
          861  +** arguments to sqlite3GenerateConstraintChecks.
   862    862   */
   863         -void sqliteCompleteInsertion(
          863  +void sqlite3CompleteInsertion(
   864    864     Parse *pParse,      /* The parser context */
   865    865     Table *pTab,        /* the table into which we are inserting */
   866    866     int base,           /* Index of a read/write cursor pointing at pTab */
   867    867     char *aIdxUsed,     /* Which indices are used.  NULL means all are used */
   868    868     int recnoChng,      /* True if the record number will change */
   869    869     int isUpdate,       /* True for UPDATE, False for INSERT */
   870    870     int newIdx          /* Index of NEW table for triggers.  -1 if none */
   871    871   ){
   872    872     int i;
   873    873     Vdbe *v;
   874    874     int nIdx;
   875    875     Index *pIdx;
   876    876   
   877         -  v = sqliteGetVdbe(pParse);
          877  +  v = sqlite3GetVdbe(pParse);
   878    878     assert( v!=0 );
   879    879     assert( pTab->pSelect==0 );  /* This table is not a VIEW */
   880    880     for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){}
   881    881     for(i=nIdx-1; i>=0; i--){
   882    882       if( aIdxUsed && aIdxUsed[i]==0 ) continue;
   883         -    sqliteVdbeAddOp(v, OP_IdxPut, base+i+1, 0);
          883  +    sqlite3VdbeAddOp(v, OP_IdxPut, base+i+1, 0);
   884    884     }
   885         -  sqliteVdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
          885  +  sqlite3VdbeAddOp(v, OP_MakeRecord, pTab->nCol, 0);
   886    886     if( newIdx>=0 ){
   887         -    sqliteVdbeAddOp(v, OP_Dup, 1, 0);
   888         -    sqliteVdbeAddOp(v, OP_Dup, 1, 0);
   889         -    sqliteVdbeAddOp(v, OP_PutIntKey, newIdx, 0);
          887  +    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);
          888  +    sqlite3VdbeAddOp(v, OP_Dup, 1, 0);
          889  +    sqlite3VdbeAddOp(v, OP_PutIntKey, newIdx, 0);
   890    890     }
   891         -  sqliteVdbeAddOp(v, OP_PutIntKey, base,
          891  +  sqlite3VdbeAddOp(v, OP_PutIntKey, base,
   892    892       (pParse->trigStack?0:OPFLAG_NCHANGE) |
   893    893       (isUpdate?0:OPFLAG_LASTROWID) | OPFLAG_CSCHANGE);
   894    894     if( isUpdate && recnoChng ){
   895         -    sqliteVdbeAddOp(v, OP_Pop, 1, 0);
          895  +    sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
   896    896     }
   897    897   }
   898    898   
   899    899   /*
   900    900   ** Generate code that will open write cursors for a table and for all
   901    901   ** indices of that table.  The "base" parameter is the cursor number used
   902    902   ** for the table.  Indices are opened on subsequent cursors.
   903    903   **
   904    904   ** Return the total number of cursors opened.  This is always at least
   905    905   ** 1 (for the main table) plus more for each cursor.
   906    906   */
   907         -int sqliteOpenTableAndIndices(Parse *pParse, Table *pTab, int base){
          907  +int sqlite3OpenTableAndIndices(Parse *pParse, Table *pTab, int base){
   908    908     int i;
   909    909     Index *pIdx;
   910         -  Vdbe *v = sqliteGetVdbe(pParse);
          910  +  Vdbe *v = sqlite3GetVdbe(pParse);
   911    911     assert( v!=0 );
   912         -  sqliteVdbeAddOp(v, OP_Integer, pTab->iDb, 0);
   913         -  sqliteVdbeOp3(v, OP_OpenWrite, base, pTab->tnum, pTab->zName, P3_STATIC);
          912  +  sqlite3VdbeAddOp(v, OP_Integer, pTab->iDb, 0);
          913  +  sqlite3VdbeOp3(v, OP_OpenWrite, base, pTab->tnum, pTab->zName, P3_STATIC);
   914    914     for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
   915         -    sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
   916         -    sqliteVdbeOp3(v, OP_OpenWrite, i+base, pIdx->tnum, pIdx->zName, P3_STATIC);
          915  +    sqlite3VdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
          916  +    sqlite3VdbeOp3(v, OP_OpenWrite, i+base, pIdx->tnum, pIdx->zName, P3_STATIC);
   917    917     }
   918    918     return i;
   919    919   }
          920  +
          921  +
          922  +

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.164 2004/04/23 17:04:45 drh Exp $
           17  +** $Id: main.c,v 1.165 2004/05/08 08:23:26 danielk1977 Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** A pointer to this structure is used to communicate information
    25         -** from sqliteInit into the sqliteInitCallback.
           25  +** from sqlite3Init into the sqlite3InitCallback.
    26     26   */
    27     27   typedef struct {
    28     28     sqlite *db;         /* The database being initialized */
    29     29     char **pzErrMsg;    /* Error message stored here */
    30     30   } InitData;
    31     31   
    32     32   /*
    33     33   ** Fill the InitData structure with an error message that indicates
    34     34   ** that the database is corrupt.
    35     35   */
    36     36   static void corruptSchema(InitData *pData, const char *zExtra){
    37         -  sqliteSetString(pData->pzErrMsg, "malformed database schema",
           37  +  sqlite3SetString(pData->pzErrMsg, "malformed database schema",
    38     38        zExtra!=0 && zExtra[0]!=0 ? " - " : (char*)0, zExtra, (char*)0);
    39     39   }
    40     40   
    41     41   /*
    42     42   ** This is the callback routine for the code that initializes the
    43         -** database.  See sqliteInit() below for additional information.
           43  +** database.  See sqlite3Init() below for additional information.
    44     44   **
    45     45   ** Each callback contains the following information:
    46     46   **
    47     47   **     argv[0] = "file-format" or "schema-cookie" or "table" or "index"
    48     48   **     argv[1] = table or index name or meta statement type.
    49     49   **     argv[2] = root page number for table or index.  NULL for meta.
    50     50   **     argv[3] = SQL text for a CREATE TABLE or CREATE INDEX statement.
    51     51   **     argv[4] = "1" for temporary files, "0" for main database, "2" or more
    52     52   **               for auxiliary database files.
    53     53   **
    54     54   */
    55     55   static
    56         -int sqliteInitCallback(void *pInit, int argc, char **argv, char **azColName){
           56  +int sqlite3InitCallback(void *pInit, int argc, char **argv, char **azColName){
    57     57     InitData *pData = (InitData*)pInit;
    58     58     int nErr = 0;
    59     59   
    60     60     assert( argc==5 );
    61     61     if( argv==0 ) return 0;   /* Might happen if EMPTY_RESULT_CALLBACKS are on */
    62     62     if( argv[0]==0 ){
    63     63       corruptSchema(pData, 0);
................................................................................
    96     96           ** to do here is record the root page number for that index.
    97     97           */
    98     98           int iDb;
    99     99           Index *pIndex;
   100    100   
   101    101           iDb = atoi(argv[4]);
   102    102           assert( iDb>=0 && iDb<db->nDb );
   103         -        pIndex = sqliteFindIndex(db, argv[1], db->aDb[iDb].zName);
          103  +        pIndex = sqlite3FindIndex(db, argv[1], db->aDb[iDb].zName);
   104    104           if( pIndex==0 || pIndex->tnum!=0 ){
   105    105             /* This can occur if there exists an index on a TEMP table which
   106    106             ** has the same name as another index on a permanent index.  Since
   107    107             ** the permanent table is hidden by the TEMP table, we can also
   108    108             ** safely ignore the index on the permanent table.
   109    109             */
   110    110             /* Do Nothing */;
................................................................................
   139    139   int upgrade_3_callback(void *pInit, int argc, char **argv, char **NotUsed){
   140    140     InitData *pData = (InitData*)pInit;
   141    141     int rc;
   142    142     Table *pTab;
   143    143     Trigger *pTrig;
   144    144     char *zErr = 0;
   145    145   
   146         -  pTab = sqliteFindTable(pData->db, argv[0], 0);
          146  +  pTab = sqlite3FindTable(pData->db, argv[0], 0);
   147    147     assert( pTab!=0 );
   148         -  assert( sqliteStrICmp(pTab->zName, argv[0])==0 );
          148  +  assert( sqlite3StrICmp(pTab->zName, argv[0])==0 );
   149    149     if( pTab ){
   150    150       pTrig = pTab->pTrigger;
   151    151       pTab->pTrigger = 0;  /* Disable all triggers before rebuilding the table */
   152    152     }
   153    153     rc = sqlite_exec_printf(pData->db,
   154    154       "CREATE TEMP TABLE sqlite_x AS SELECT * FROM '%q'; "
   155    155       "DELETE FROM '%q'; "
................................................................................
   162    162     }
   163    163   
   164    164     /* If an error occurred in the SQL above, then the transaction will
   165    165     ** rollback which will delete the internal symbol tables.  This will
   166    166     ** cause the structure that pTab points to be deleted.  In case that
   167    167     ** happened, we need to refetch pTab.
   168    168     */
   169         -  pTab = sqliteFindTable(pData->db, argv[0], 0);
          169  +  pTab = sqlite3FindTable(pData->db, argv[0], 0);
   170    170     if( pTab ){
   171         -    assert( sqliteStrICmp(pTab->zName, argv[0])==0 );
          171  +    assert( sqlite3StrICmp(pTab->zName, argv[0])==0 );
   172    172       pTab->pTrigger = pTrig;  /* Re-enable triggers */
   173    173     }
   174    174     return rc!=SQLITE_OK;
   175    175   }
   176    176   
   177    177   
   178    178   
................................................................................
   180    180   ** Attempt to read the database schema and initialize internal
   181    181   ** data structures for a single database file.  The index of the
   182    182   ** database file is given by iDb.  iDb==0 is used for the main
   183    183   ** database.  iDb==1 should never be used.  iDb>=2 is used for
   184    184   ** auxiliary databases.  Return one of the SQLITE_ error codes to
   185    185   ** indicate success or failure.
   186    186   */
   187         -static int sqliteInitOne(sqlite *db, int iDb, char **pzErrMsg){
          187  +static int sqlite3InitOne(sqlite *db, int iDb, char **pzErrMsg){
   188    188     int rc;
   189    189     BtCursor *curMain;
   190    190     int size;
   191    191     Table *pTab;
   192    192     char *azArg[6];
   193    193     char zDbNum[30];
   194    194     int meta[SQLITE_N_BTREE_META];
................................................................................
   244    244        "WHERE type='index'";
   245    245   
   246    246   
   247    247     assert( iDb>=0 && iDb!=1 && iDb<db->nDb );
   248    248   
   249    249     /* Construct the schema tables: sqlite_master and sqlite_temp_master
   250    250     */
   251         -  sqliteSafetyOff(db);
          251  +  sqlite3SafetyOff(db);
   252    252     azArg[0] = "table";
   253    253     azArg[1] = MASTER_NAME;
   254    254     azArg[2] = "2";
   255    255     azArg[3] = master_schema;
   256    256     sprintf(zDbNum, "%d", iDb);
   257    257     azArg[4] = zDbNum;
   258    258     azArg[5] = 0;
   259    259     initData.db = db;
   260    260     initData.pzErrMsg = pzErrMsg;
   261         -  sqliteInitCallback(&initData, 5, azArg, 0);
   262         -  pTab = sqliteFindTable(db, MASTER_NAME, "main");
          261  +  sqlite3InitCallback(&initData, 5, azArg, 0);
          262  +  pTab = sqlite3FindTable(db, MASTER_NAME, "main");
   263    263     if( pTab ){
   264    264       pTab->readOnly = 1;
   265    265     }
   266    266     if( iDb==0 ){
   267    267       azArg[1] = TEMP_MASTER_NAME;
   268    268       azArg[3] = temp_master_schema;
   269    269       azArg[4] = "1";
   270         -    sqliteInitCallback(&initData, 5, azArg, 0);
   271         -    pTab = sqliteFindTable(db, TEMP_MASTER_NAME, "temp");
          270  +    sqlite3InitCallback(&initData, 5, azArg, 0);
          271  +    pTab = sqlite3FindTable(db, TEMP_MASTER_NAME, "temp");
   272    272       if( pTab ){
   273    273         pTab->readOnly = 1;
   274    274       }
   275    275     }
   276         -  sqliteSafetyOn(db);
          276  +  sqlite3SafetyOn(db);
   277    277   
   278    278     /* Create a cursor to hold the database open
   279    279     */
   280    280     if( db->aDb[iDb].pBt==0 ) return SQLITE_OK;
   281         -  rc = sqliteBtreeCursor(db->aDb[iDb].pBt, 2, 0, &curMain);
          281  +  rc = sqlite3BtreeCursor(db->aDb[iDb].pBt, 2, 0, 0, 0, &curMain);
   282    282     if( rc ){
   283         -    sqliteSetString(pzErrMsg, sqlite_error_string(rc), (char*)0);
          283  +    sqlite3SetString(pzErrMsg, sqlite_error_string(rc), (char*)0);
   284    284       return rc;
   285    285     }
   286    286   
   287    287     /* Get the database meta information
   288    288     */
   289         -  rc = sqliteBtreeGetMeta(db->aDb[iDb].pBt, meta);
          289  +  {
          290  +    int ii;
          291  +    for(ii=0; rc==SQLITE_OK && ii<SQLITE_N_BTREE_META; ii++){
          292  +      rc = sqlite3BtreeGetMeta(db->aDb[iDb].pBt, ii+1, &meta[ii]);
          293  +    }
          294  +  }
   290    295     if( rc ){
   291         -    sqliteSetString(pzErrMsg, sqlite_error_string(rc), (char*)0);
   292         -    sqliteBtreeCloseCursor(curMain);
          296  +    sqlite3SetString(pzErrMsg, sqlite_error_string(rc), (char*)0);
          297  +    sqlite3BtreeCloseCursor(curMain);
   293    298       return rc;
   294    299     }
   295    300     db->aDb[iDb].schema_cookie = meta[1];
   296    301     if( iDb==0 ){
   297    302       db->next_cookie = meta[1];
   298    303       db->file_format = meta[2];
   299    304       size = meta[3];
................................................................................
   312    317       **  file_format==4    Version 2.7.0. Add support for separate numeric and
   313    318       **                    text datatypes.
   314    319       */
   315    320       if( db->file_format==0 ){
   316    321         /* This happens if the database was initially empty */
   317    322         db->file_format = 4;
   318    323       }else if( db->file_format>4 ){
   319         -      sqliteBtreeCloseCursor(curMain);
   320         -      sqliteSetString(pzErrMsg, "unsupported file format", (char*)0);
          324  +      sqlite3BtreeCloseCursor(curMain);
          325  +      sqlite3SetString(pzErrMsg, "unsupported file format", (char*)0);
   321    326         return SQLITE_ERROR;
   322    327       }
   323    328     }else if( db->file_format!=meta[2] || db->file_format<4 ){
   324    329       assert( db->file_format>=4 );
   325    330       if( meta[2]==0 ){
   326         -      sqliteSetString(pzErrMsg, "cannot attach empty database: ",
          331  +      sqlite3SetString(pzErrMsg, "cannot attach empty database: ",
   327    332            db->aDb[iDb].zName, (char*)0);
   328    333       }else{
   329         -      sqliteSetString(pzErrMsg, "incompatible file format in auxiliary "
          334  +      sqlite3SetString(pzErrMsg, "incompatible file format in auxiliary "
   330    335            "database: ", db->aDb[iDb].zName, (char*)0);
   331    336       }
   332         -    sqliteBtreeClose(db->aDb[iDb].pBt);
          337  +    sqlite3BtreeClose(db->aDb[iDb].pBt);
   333    338       db->aDb[iDb].pBt = 0;
   334    339       return SQLITE_FORMAT;
   335    340     }
   336         -  sqliteBtreeSetCacheSize(db->aDb[iDb].pBt, db->cache_size);
   337         -  sqliteBtreeSetSafetyLevel(db->aDb[iDb].pBt, meta[4]==0 ? 2 : meta[4]);
          341  +  sqlite3BtreeSetCacheSize(db->aDb[iDb].pBt, db->cache_size);
          342  +  sqlite3BtreeSetSafetyLevel(db->aDb[iDb].pBt, meta[4]==0 ? 2 : meta[4]);
   338    343   
   339    344     /* Read the schema information out of the schema tables
   340    345     */
   341    346     assert( db->init.busy );
   342         -  sqliteSafetyOff(db);
          347  +  sqlite3SafetyOff(db);
   343    348     if( iDb==0 ){
   344    349       rc = sqlite_exec(db, 
   345    350           db->file_format>=2 ? init_script : older_init_script,
   346         -        sqliteInitCallback, &initData, 0);
          351  +        sqlite3InitCallback, &initData, 0);
   347    352     }else{
   348    353       char *zSql = 0;
   349         -    sqliteSetString(&zSql, 
          354  +    sqlite3SetString(&zSql, 
   350    355          "SELECT type, name, rootpage, sql, ", zDbNum, " FROM \"",
   351    356          db->aDb[iDb].zName, "\".sqlite_master", (char*)0);
   352         -    rc = sqlite_exec(db, zSql, sqliteInitCallback, &initData, 0);
          357  +    rc = sqlite_exec(db, zSql, sqlite3InitCallback, &initData, 0);
   353    358       sqliteFree(zSql);
   354    359     }
   355         -  sqliteSafetyOn(db);
   356         -  sqliteBtreeCloseCursor(curMain);
          360  +  sqlite3SafetyOn(db);
          361  +  sqlite3BtreeCloseCursor(curMain);
   357    362     if( sqlite_malloc_failed ){
   358         -    sqliteSetString(pzErrMsg, "out of memory", (char*)0);
          363  +    sqlite3SetString(pzErrMsg, "out of memory", (char*)0);
   359    364       rc = SQLITE_NOMEM;
   360         -    sqliteResetInternalSchema(db, 0);
          365  +    sqlite3ResetInternalSchema(db, 0);
   361    366     }
   362    367     if( rc==SQLITE_OK ){
   363    368       DbSetProperty(db, iDb, DB_SchemaLoaded);
   364    369       if( iDb==0 ){
   365    370         DbSetProperty(db, 1, DB_SchemaLoaded);
   366    371       }
   367    372     }else{
   368         -    sqliteResetInternalSchema(db, iDb);
          373  +    sqlite3ResetInternalSchema(db, iDb);
   369    374     }
   370    375     return rc;
   371    376   }
   372    377   
   373    378   /*
   374    379   ** Initialize all database files - the main database file, the file
   375    380   ** used to store temporary tables, and any additional database files
................................................................................
   379    384   ** After the database is initialized, the SQLITE_Initialized
   380    385   ** bit is set in the flags field of the sqlite structure.  An
   381    386   ** attempt is made to initialize the database as soon as it
   382    387   ** is opened.  If that fails (perhaps because another process
   383    388   ** has the sqlite_master table locked) than another attempt
   384    389   ** is made the first time the database is accessed.
   385    390   */
   386         -int sqliteInit(sqlite *db, char **pzErrMsg){
          391  +int sqlite3Init(sqlite *db, char **pzErrMsg){
   387    392     int i, rc;
   388    393     
   389    394     if( db->init.busy ) return SQLITE_OK;
   390    395     assert( (db->flags & SQLITE_Initialized)==0 );
   391    396     rc = SQLITE_OK;
   392    397     db->init.busy = 1;
   393    398     for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
   394    399       if( DbHasProperty(db, i, DB_SchemaLoaded) ) continue;
   395    400       assert( i!=1 );  /* Should have been initialized together with 0 */
   396         -    rc = sqliteInitOne(db, i, pzErrMsg);
          401  +    rc = sqlite3InitOne(db, i, pzErrMsg);
   397    402       if( rc ){
   398         -      sqliteResetInternalSchema(db, i);
          403  +      sqlite3ResetInternalSchema(db, i);
   399    404       }
   400    405     }
   401    406     db->init.busy = 0;
   402    407     if( rc==SQLITE_OK ){
   403    408       db->flags |= SQLITE_Initialized;
   404         -    sqliteCommitInternalChanges(db);
          409  +    sqlite3CommitInternalChanges(db);
   405    410     }
   406    411   
   407    412     /* If the database is in formats 1 or 2, then upgrade it to
   408    413     ** version 3.  This will reconstruct all indices.  If the
   409    414     ** upgrade fails for any reason (ex: out of disk space, database
   410    415     ** is read only, interrupt received, etc.) then fail the init.
   411    416     */
................................................................................
   420    425       db->file_format = 3;
   421    426       rc = sqlite_exec(db,
   422    427         "BEGIN; SELECT name FROM sqlite_master WHERE type='table';",
   423    428         upgrade_3_callback,
   424    429         &initData,
   425    430         &zErr);
   426    431       if( rc==SQLITE_OK ){
   427         -      sqliteBtreeGetMeta(db->aDb[0].pBt, meta);
          432  +      int ii;
          433  +      for(ii=0; rc==SQLITE_OK && ii<SQLITE_N_BTREE_META; ii++){
          434  +        rc = sqlite3BtreeGetMeta(db->aDb[0].pBt, ii+1, &meta[ii]);
          435  +      }
   428    436         meta[2] = 4;
   429         -      sqliteBtreeUpdateMeta(db->aDb[0].pBt, meta);
          437  +      for(ii=0; rc==SQLITE_OK && ii<SQLITE_N_BTREE_META; ii++){
          438  +        rc = sqlite3BtreeUpdateMeta(db->aDb[0].pBt, ii+1, meta[ii]);
          439  +      }
   430    440         sqlite_exec(db, "COMMIT", 0, 0, 0);
   431    441       }
   432    442       if( rc!=SQLITE_OK ){
   433         -      sqliteSetString(pzErrMsg, 
          443  +      sqlite3SetString(pzErrMsg, 
   434    444           "unable to upgrade database to the version 2.6 format",
   435    445           zErr ? ": " : 0, zErr, (char*)0);
   436    446       }
   437    447       sqlite_freemem(zErr);
   438    448     }
   439    449   
   440    450     if( rc!=SQLITE_OK ){
................................................................................
   478    488     if( db==0 ) goto no_mem_on_open;
   479    489     db->onError = OE_Default;
   480    490     db->priorNewRowid = 0;
   481    491     db->magic = SQLITE_MAGIC_BUSY;
   482    492     db->nDb = 2;
   483    493     db->aDb = db->aDbStatic;
   484    494     /* db->flags |= SQLITE_ShortColNames; */
   485         -  sqliteHashInit(&db->aFunc, SQLITE_HASH_STRING, 1);
          495  +  sqlite3HashInit(&db->aFunc, SQLITE_HASH_STRING, 1);
   486    496     for(i=0; i<db->nDb; i++){
   487         -    sqliteHashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0);
   488         -    sqliteHashInit(&db->aDb[i].idxHash, SQLITE_HASH_STRING, 0);
   489         -    sqliteHashInit(&db->aDb[i].trigHash, SQLITE_HASH_STRING, 0);
   490         -    sqliteHashInit(&db->aDb[i].aFKey, SQLITE_HASH_STRING, 1);
          497  +    sqlite3HashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0);
          498  +    sqlite3HashInit(&db->aDb[i].idxHash, SQLITE_HASH_STRING, 0);
          499  +    sqlite3HashInit(&db->aDb[i].trigHash, SQLITE_HASH_STRING, 0);
          500  +    sqlite3HashInit(&db->aDb[i].aFKey, SQLITE_HASH_STRING, 1);
   491    501     }
   492    502     
   493    503     /* Open the backend database driver */
   494    504     if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){
   495    505       db->temp_store = 2;
   496    506     }
   497         -  rc = sqliteBtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);
          507  +  rc = sqlite3BtreeFactory(db, zFilename, 0, MAX_PAGES, &db->aDb[0].pBt);
   498    508     if( rc!=SQLITE_OK ){
   499    509       switch( rc ){
   500    510         default: {
   501         -        sqliteSetString(pzErrMsg, "unable to open database: ",
          511  +        sqlite3SetString(pzErrMsg, "unable to open database: ",
   502    512              zFilename, (char*)0);
   503    513         }
   504    514       }
   505    515       sqliteFree(db);
   506         -    sqliteStrRealloc(pzErrMsg);
          516  +    sqlite3StrRealloc(pzErrMsg);
   507    517       return 0;
   508    518     }
   509    519     db->aDb[0].zName = "main";
   510    520     db->aDb[1].zName = "temp";
   511    521   
   512    522     /* Attempt to read the schema */
   513         -  sqliteRegisterBuiltinFunctions(db);
   514         -  rc = sqliteInit(db, pzErrMsg);
          523  +  sqlite3RegisterBuiltinFunctions(db);
          524  +  rc = sqlite3Init(db, pzErrMsg);
   515    525     db->magic = SQLITE_MAGIC_OPEN;
   516    526     if( sqlite_malloc_failed ){
   517    527       sqlite_close(db);
   518    528       goto no_mem_on_open;
   519    529     }else if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
   520    530       sqlite_close(db);
   521         -    sqliteStrRealloc(pzErrMsg);
          531  +    sqlite3StrRealloc(pzErrMsg);
   522    532       return 0;
   523    533     }else if( pzErrMsg ){
   524    534       sqliteFree(*pzErrMsg);
   525    535       *pzErrMsg = 0;
   526    536     }
   527    537   
   528    538     /* Return a pointer to the newly opened database structure */
   529    539     return db;
   530    540   
   531    541   no_mem_on_open:
   532         -  sqliteSetString(pzErrMsg, "out of memory", (char*)0);
   533         -  sqliteStrRealloc(pzErrMsg);
          542  +  sqlite3SetString(pzErrMsg, "out of memory", (char*)0);
          543  +  sqlite3StrRealloc(pzErrMsg);
   534    544     return 0;
   535    545   }
   536    546   
   537    547   /*
   538    548   ** Return the ROWID of the most recent insert
   539    549   */
   540    550   int sqlite_last_insert_rowid(sqlite *db){
................................................................................
   561    571   /*
   562    572   ** Close an existing SQLite database
   563    573   */
   564    574   void sqlite_close(sqlite *db){
   565    575     HashElem *i;
   566    576     int j;
   567    577     db->want_to_close = 1;
   568         -  if( sqliteSafetyCheck(db) || sqliteSafetyOn(db) ){
          578  +  if( sqlite3SafetyCheck(db) || sqlite3SafetyOn(db) ){
   569    579       /* printf("DID NOT CLOSE\n"); fflush(stdout); */
   570    580       return;
   571    581     }
   572    582     db->magic = SQLITE_MAGIC_CLOSED;
   573    583     for(j=0; j<db->nDb; j++){
   574    584       struct Db *pDb = &db->aDb[j];
   575    585       if( pDb->pBt ){
   576         -      sqliteBtreeClose(pDb->pBt);
          586  +      sqlite3BtreeClose(pDb->pBt);
   577    587         pDb->pBt = 0;
   578    588       }
   579    589     }
   580         -  sqliteResetInternalSchema(db, 0);
          590  +  sqlite3ResetInternalSchema(db, 0);
   581    591     assert( db->nDb<=2 );
   582    592     assert( db->aDb==db->aDbStatic );
   583    593     for(i=sqliteHashFirst(&db->aFunc); i; i=sqliteHashNext(i)){
   584    594       FuncDef *pFunc, *pNext;
   585    595       for(pFunc = (FuncDef*)sqliteHashData(i); pFunc; pFunc=pNext){
   586    596         pNext = pFunc->pNext;
   587    597         sqliteFree(pFunc);
   588    598       }
   589    599     }
   590         -  sqliteHashClear(&db->aFunc);
          600  +  sqlite3HashClear(&db->aFunc);
   591    601     sqliteFree(db);
   592    602   }
   593    603   
   594    604   /*
   595    605   ** Rollback all database files.
   596    606   */
   597         -void sqliteRollbackAll(sqlite *db){
          607  +void sqlite3RollbackAll(sqlite *db){
   598    608     int i;
   599    609     for(i=0; i<db->nDb; i++){
   600    610       if( db->aDb[i].pBt ){
   601         -      sqliteBtreeRollback(db->aDb[i].pBt);
          611  +      sqlite3BtreeRollback(db->aDb[i].pBt);
   602    612         db->aDb[i].inTrans = 0;
   603    613       }
   604    614     }
   605         -  sqliteResetInternalSchema(db, 0);
   606         -  /* sqliteRollbackInternalChanges(db); */
          615  +  sqlite3ResetInternalSchema(db, 0);
          616  +  /* sqlite3RollbackInternalChanges(db); */
   607    617   }
   608    618   
   609    619   /*
   610    620   ** Execute SQL code.  Return one of the SQLITE_ success/failure
   611    621   ** codes.  Also write an error message into memory obtained from
   612    622   ** malloc() and make *pzErrMsg point to that message.
   613    623   **
................................................................................
   690    700     const char **pzTail,        /* OUT: Next statement after the first */
   691    701     sqlite_vm **ppVm,           /* OUT: The virtual machine */
   692    702     char **pzErrMsg             /* OUT: Write error messages here */
   693    703   ){
   694    704     Parse sParse;
   695    705   
   696    706     if( pzErrMsg ) *pzErrMsg = 0;
   697         -  if( sqliteSafetyOn(db) ) goto exec_misuse;
          707  +  if( sqlite3SafetyOn(db) ) goto exec_misuse;
   698    708     if( !db->init.busy ){
   699    709       if( (db->flags & SQLITE_Initialized)==0 ){
   700    710         int rc, cnt = 1;
   701         -      while( (rc = sqliteInit(db, pzErrMsg))==SQLITE_BUSY
          711  +      while( (rc = sqlite3Init(db, pzErrMsg))==SQLITE_BUSY
   702    712            && db->xBusyCallback
   703    713            && db->xBusyCallback(db->pBusyArg, "", cnt++)!=0 ){}
   704    714         if( rc!=SQLITE_OK ){
   705         -        sqliteStrRealloc(pzErrMsg);
   706         -        sqliteSafetyOff(db);
          715  +        sqlite3StrRealloc(pzErrMsg);
          716  +        sqlite3SafetyOff(db);
   707    717           return rc;
   708    718         }
   709    719         if( pzErrMsg ){
   710    720           sqliteFree(*pzErrMsg);
   711    721           *pzErrMsg = 0;
   712    722         }
   713    723       }
   714    724       if( db->file_format<3 ){
   715         -      sqliteSafetyOff(db);
   716         -      sqliteSetString(pzErrMsg, "obsolete database file format", (char*)0);
          725  +      sqlite3SafetyOff(db);
          726  +      sqlite3SetString(pzErrMsg, "obsolete database file format", (char*)0);
   717    727         return SQLITE_ERROR;
   718    728       }
   719    729     }
   720    730     assert( (db->flags & SQLITE_Initialized)!=0 || db->init.busy );
   721    731     if( db->pVdbe==0 ){ db->nChange = 0; }
   722    732     memset(&sParse, 0, sizeof(sParse));
   723    733     sParse.db = db;
   724         -  sqliteRunParser(&sParse, zSql, pzErrMsg);
          734  +  sqlite3RunParser(&sParse, zSql, pzErrMsg);
   725    735     if( db->xTrace && !db->init.busy ){
   726    736       /* Trace only the statment that was compiled.
   727    737       ** Make a copy of that part of the SQL string since zSQL is const
   728    738       ** and we must pass a zero terminated string to the trace function
   729    739       ** The copy is unnecessary if the tail pointer is pointing at the
   730    740       ** beginnig or end of the SQL string.
   731    741       */
................................................................................
   742    752           db->xTrace(db->pTraceArg, zSql); 
   743    753         }
   744    754       }else{
   745    755         db->xTrace(db->pTraceArg, zSql); 
   746    756       }
   747    757     }
   748    758     if( sqlite_malloc_failed ){
   749         -    sqliteSetString(pzErrMsg, "out of memory", (char*)0);
          759  +    sqlite3SetString(pzErrMsg, "out of memory", (char*)0);
   750    760       sParse.rc = SQLITE_NOMEM;
   751         -    sqliteRollbackAll(db);
   752         -    sqliteResetInternalSchema(db, 0);
          761  +    sqlite3RollbackAll(db);
          762  +    sqlite3ResetInternalSchema(db, 0);
   753    763       db->flags &= ~SQLITE_InTrans;
   754    764     }
   755    765     if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
   756    766     if( sParse.rc!=SQLITE_OK && pzErrMsg && *pzErrMsg==0 ){
   757         -    sqliteSetString(pzErrMsg, sqlite_error_string(sParse.rc), (char*)0);
          767  +    sqlite3SetString(pzErrMsg, sqlite_error_string(sParse.rc), (char*)0);
   758    768     }
   759         -  sqliteStrRealloc(pzErrMsg);
          769  +  sqlite3StrRealloc(pzErrMsg);
   760    770     if( sParse.rc==SQLITE_SCHEMA ){
   761         -    sqliteResetInternalSchema(db, 0);
          771  +    sqlite3ResetInternalSchema(db, 0);
   762    772     }
   763    773     assert( ppVm );
   764    774     *ppVm = (sqlite_vm*)sParse.pVdbe;
   765    775     if( pzTail ) *pzTail = sParse.zTail;
   766         -  if( sqliteSafetyOff(db) ) goto exec_misuse;
          776  +  if( sqlite3SafetyOff(db) ) goto exec_misuse;
   767    777     return sParse.rc;
   768    778   
   769    779   exec_misuse:
   770    780     if( pzErrMsg ){
   771    781       *pzErrMsg = 0;
   772         -    sqliteSetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), (char*)0);
   773         -    sqliteStrRealloc(pzErrMsg);
          782  +    sqlite3SetString(pzErrMsg, sqlite_error_string(SQLITE_MISUSE), (char*)0);
          783  +    sqlite3StrRealloc(pzErrMsg);
   774    784     }
   775    785     return SQLITE_MISUSE;
   776    786   }
   777    787   
   778    788   
   779    789   /*
   780    790   ** The following routine destroys a virtual machine that is created by
................................................................................
   787    797   ** should use sqlite_freemem() to delete the message when it has finished
   788    798   ** with it.
   789    799   */
   790    800   int sqlite_finalize(
   791    801     sqlite_vm *pVm,            /* The virtual machine to be destroyed */
   792    802     char **pzErrMsg            /* OUT: Write error messages here */
   793    803   ){
   794         -  int rc = sqliteVdbeFinalize((Vdbe*)pVm, pzErrMsg);
   795         -  sqliteStrRealloc(pzErrMsg);
          804  +  int rc = sqlite3VdbeFinalize((Vdbe*)pVm, pzErrMsg);
          805  +  sqlite3StrRealloc(pzErrMsg);
   796    806     return rc;
   797    807   }
   798    808   
   799    809   /*
   800    810   ** Terminate the current execution of a virtual machine then
   801    811   ** reset the virtual machine back to its starting state so that it
   802    812   ** can be reused.  Any error message resulting from the prior execution
................................................................................
   803    813   ** is written into *pzErrMsg.  A success code from the prior execution
   804    814   ** is returned.
   805    815   */
   806    816   int sqlite_reset(
   807    817     sqlite_vm *pVm,            /* The virtual machine to be destroyed */
   808    818     char **pzErrMsg            /* OUT: Write error messages here */
   809    819   ){
   810         -  int rc = sqliteVdbeReset((Vdbe*)pVm, pzErrMsg);
   811         -  sqliteVdbeMakeReady((Vdbe*)pVm, -1, 0);
   812         -  sqliteStrRealloc(pzErrMsg);
          820  +  int rc = sqlite3VdbeReset((Vdbe*)pVm, pzErrMsg);
          821  +  sqlite3VdbeMakeReady((Vdbe*)pVm, -1, 0);
          822  +  sqlite3StrRealloc(pzErrMsg);
   813    823     return rc;
   814    824   }
   815    825   
   816    826   /*
   817    827   ** Return a static string that describes the kind of error specified in the
   818    828   ** argument.
   819    829   */
................................................................................
   879    889       delay = delays[NDELAY-1];
   880    890       prior = totals[NDELAY-1] + delay*(count-NDELAY-1);
   881    891     }
   882    892     if( prior + delay > timeout ){
   883    893       delay = timeout - prior;
   884    894       if( delay<=0 ) return 0;
   885    895     }
   886         -  sqliteOsSleep(delay);
          896  +  sqlite3OsSleep(delay);
   887    897     return 1;
   888    898   #else
   889    899     int timeout = (int)Timeout;
   890    900     if( (count+1)*1000 > timeout ){
   891    901       return 0;
   892    902     }
   893         -  sqliteOsSleep(1000);
          903  +  sqlite3OsSleep(1000);
   894    904     return 1;
   895    905   #endif
   896    906   }
   897    907   
   898    908   /*
   899    909   ** This routine sets the busy callback for an Sqlite database to the
   900    910   ** given callback function with the given argument.
................................................................................
   956    966   ** Windows systems should call this routine to free memory that
   957    967   ** is returned in the in the errmsg parameter of sqlite_open() when
   958    968   ** SQLite is a DLL.  For some reason, it does not work to call free()
   959    969   ** directly.
   960    970   **
   961    971   ** Note that we need to call free() not sqliteFree() here, since every
   962    972   ** string that is exported from SQLite should have already passed through
   963         -** sqliteStrRealloc().
          973  +** sqlite3StrRealloc().
   964    974   */
   965    975   void sqlite_freemem(void *p){ free(p); }
   966    976   
   967    977   /*
   968    978   ** Windows systems need functions to call to return the sqlite_version
   969    979   ** and sqlite_encoding strings since they are unable to access constants
   970    980   ** within DLLs.
................................................................................
   991   1001     const char *zName,   /* Name of the function to add */
   992   1002     int nArg,            /* Number of arguments */
   993   1003     void (*xFunc)(sqlite_func*,int,const char**),  /* The implementation */
   994   1004     void *pUserData      /* User data */
   995   1005   ){
   996   1006     FuncDef *p;
   997   1007     int nName;
   998         -  if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1;
         1008  +  if( db==0 || zName==0 || sqlite3SafetyCheck(db) ) return 1;
   999   1009     if( nArg<-1 || nArg>127 ) return 1;
  1000   1010     nName = strlen(zName);
  1001   1011     if( nName>255 ) return 1;
  1002         -  p = sqliteFindFunction(db, zName, nName, nArg, 1);
         1012  +  p = sqlite3FindFunction(db, zName, nName, nArg, 1);
  1003   1013     if( p==0 ) return 1;
  1004   1014     p->xFunc = xFunc;
  1005   1015     p->xStep = 0;
  1006   1016     p->xFinalize = 0;
  1007   1017     p->pUserData = pUserData;
  1008   1018     return 0;
  1009   1019   }
................................................................................
  1013   1023     int nArg,            /* Number of arguments */
  1014   1024     void (*xStep)(sqlite_func*,int,const char**), /* The step function */
  1015   1025     void (*xFinalize)(sqlite_func*),              /* The finalizer */
  1016   1026     void *pUserData      /* User data */
  1017   1027   ){
  1018   1028     FuncDef *p;
  1019   1029     int nName;
  1020         -  if( db==0 || zName==0 || sqliteSafetyCheck(db) ) return 1;
         1030  +  if( db==0 || zName==0 || sqlite3SafetyCheck(db) ) return 1;
  1021   1031     if( nArg<-1 || nArg>127 ) return 1;
  1022   1032     nName = strlen(zName);
  1023   1033     if( nName>255 ) return 1;
  1024         -  p = sqliteFindFunction(db, zName, nName, nArg, 1);
         1034  +  p = sqlite3FindFunction(db, zName, nName, nArg, 1);
  1025   1035     if( p==0 ) return 1;
  1026   1036     p->xFunc = 0;
  1027   1037     p->xStep = xStep;
  1028   1038     p->xFinalize = xFinalize;
  1029   1039     p->pUserData = pUserData;
  1030   1040     return 0;
  1031   1041   }
................................................................................
  1032   1042   
  1033   1043   /*
  1034   1044   ** Change the datatype for all functions with a given name.  See the
  1035   1045   ** header comment for the prototype of this function in sqlite.h for
  1036   1046   ** additional information.
  1037   1047   */
  1038   1048   int sqlite_function_type(sqlite *db, const char *zName, int dataType){
  1039         -  FuncDef *p = (FuncDef*)sqliteHashFind(&db->aFunc, zName, strlen(zName));
         1049  +  FuncDef *p = (FuncDef*)sqlite3HashFind(&db->aFunc, zName, strlen(zName));
  1040   1050     while( p ){
  1041   1051       p->dataType = dataType; 
  1042   1052       p = p->pNext;
  1043   1053     }
  1044   1054     return SQLITE_OK;
  1045   1055   }
  1046   1056   
................................................................................
  1098   1108   **           1                2              memory
  1099   1109   **           1                0              file
  1100   1110   **           2                1              file
  1101   1111   **           2                2              memory
  1102   1112   **           2                0              memory
  1103   1113   **           3               any             memory
  1104   1114   */
  1105         -int sqliteBtreeFactory(
         1115  +int sqlite3BtreeFactory(
  1106   1116     const sqlite *db,	    /* Main database when opening aux otherwise 0 */
  1107   1117     const char *zFilename,    /* Name of the file containing the BTree database */
  1108   1118     int omitJournal,          /* if TRUE then do not journal this file */
  1109   1119     int nCache,               /* How many pages in the page cache */
  1110         -  Btree **ppBtree){         /* Pointer to new Btree object written here */
  1111         -
         1120  +  Btree **ppBtree           /* Pointer to new Btree object written here */
         1121  +){
  1112   1122     assert( ppBtree != 0);
  1113         -
  1114         -#ifndef SQLITE_OMIT_INMEMORYDB
  1115         -  if( zFilename==0 ){
  1116         -    if (TEMP_STORE == 0) {
  1117         -      /* Always use file based temporary DB */
  1118         -      return sqliteBtreeOpen(0, omitJournal, nCache, ppBtree);
  1119         -    } else if (TEMP_STORE == 1 || TEMP_STORE == 2) {
  1120         -      /* Switch depending on compile-time and/or runtime settings. */
  1121         -      int location = db->temp_store==0 ? TEMP_STORE : db->temp_store;
  1122         -
  1123         -      if (location == 1) {
  1124         -        return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree);
  1125         -      } else {
  1126         -        return sqliteRbtreeOpen(0, 0, 0, ppBtree);
  1127         -      }
  1128         -    } else {
  1129         -      /* Always use in-core DB */
  1130         -      return sqliteRbtreeOpen(0, 0, 0, ppBtree);
  1131         -    }
  1132         -  }else if( zFilename[0]==':' && strcmp(zFilename,":memory:")==0 ){
  1133         -    return sqliteRbtreeOpen(0, 0, 0, ppBtree);
  1134         -  }else
  1135         -#endif
  1136         -  {
  1137         -    return sqliteBtreeOpen(zFilename, omitJournal, nCache, ppBtree);
         1123  +  int btree_flags = 0;
         1124  +  
         1125  +  if( omitJournal ){
         1126  +    btree_flags |= BTREE_OMIT_JOURNAL;
         1127  +  }
         1128  +  if( !zFilename ){
         1129  +    btree_flags |= BTREE_MEMORY;
         1130  +  }
         1131  +
         1132  +  return sqlite3BtreeOpen(zFilename, ppBtree, nCache, btree_flags);
         1133  +}
         1134  +
         1135  +#if 0
         1136  +
         1137  +/*
         1138  +** sqlite3_open
         1139  +**
         1140  +*/
         1141  +int sqlite3_open(const char *filename, sqlite3 **pDb, const char **options){
         1142  +  *pDb = sqlite_open(filename, 0, &errmsg);
         1143  +  return (*pDb?SQLITE_OK:SQLITE_ERROR);
         1144  +}
         1145  +int sqlite3_open16(const void *filename, sqlite3 **pDb, const char **options){
         1146  +  int rc;
         1147  +  char * filename8;
         1148  +
         1149  +  filename8 = sqlite3utf16to8(filename, -1);
         1150  +  if( !filename8 ){
         1151  +    return SQLITE_NOMEM;
         1152  +  }
         1153  +
         1154  +  rc = sqlite3_open(filename8, pDb, options);
         1155  +  sqliteFree(filename8);
         1156  +
         1157  +  return rc;
         1158  +}
         1159  +
         1160  +/*
         1161  +** sqlite3_close
         1162  +**
         1163  +*/
         1164  +int sqlite3_close(sqlite3 *db){
         1165  +  return sqlite_close(db);
         1166  +}
         1167  +
         1168  +/*
         1169  +** sqlite3_errmsg
         1170  +**
         1171  +** TODO: !
         1172  +*/
         1173  +const char *sqlite3_errmsg(sqlite3 *db){
         1174  +  assert(!"TODO");
         1175  +}
         1176  +const void *sqlite3_errmsg16(sqlite3 *db){
         1177  +  assert(!"TODO");
         1178  +}
         1179  +
         1180  +/*
         1181  +** sqlite3_errcode
         1182  +**
         1183  +** TODO: !
         1184  +*/
         1185  +int sqlite3_errcode(sqlite3 *db){
         1186  +  assert(!"TODO");
         1187  +}
         1188  +
         1189  +struct sqlite_stmt {
         1190  +};
         1191  +
         1192  +/*
         1193  +** sqlite3_prepare
         1194  +**
         1195  +** TODO: error message handling
         1196  +*/
         1197  +int sqlite3_prepare(
         1198  +  sqlite3 *db, 
         1199  +  const char *zSql, 
         1200  +  sqlite3_stmt **ppStmt, 
         1201  +  const char** pzTail
         1202  +){
         1203  +  int rc;
         1204  +  rc = sqlite_compile(db, zSql, pzTail, ppStmt, 0); 
         1205  +  return rc;
         1206  +}
         1207  +int sqlite3_prepare16(
         1208  +  sqlite3 *db, 
         1209  +  const void *zSql, 
         1210  +  sqlite3_stmt **ppStmt, 
         1211  +  const void **pzTail
         1212  +){
         1213  +  int rc;
         1214  +  char *sql8;
         1215  +
         1216  +  sql8 = sqlite3utf16to8(zSql, -1);
         1217  +  if( !sql8 ){
         1218  +    return SQLITE_NOMEM;
         1219  +  }
         1220  +
         1221  +  /* TODO: Have to set *pzTail to point into the original UTF-16 string
         1222  +  ** somehow.
         1223  +  */
         1224  +  rc = sqlite3_prepare(db, sql8, ppStmt, 0);
         1225  +  sqliteFree(filename8);
         1226  +
         1227  +  return rc;
         1228  +}
         1229  +
         1230  +/*
         1231  +** sqlite3_finalize
         1232  +*/
         1233  +int sqlite3_finalize(sqlite3_stmt *stmt){
         1234  +  return sqlite_finalize(stmt, 0);
         1235  +}
         1236  +
         1237  +/*
         1238  +** sqlite3_reset
         1239  +*/
         1240  +int sqlite3_reset(sqlite3_stmt*){
         1241  +  return sqlite_reset(stmt, 0);
         1242  +}
         1243  +
         1244  +/*
         1245  +** sqlite3_step
         1246  +*/
         1247  +int sqlite3_step(sqlite3_stmt *pStmt){
         1248  +  return sqlite_step(pStmt);
         1249  +}
         1250  +
         1251  +/*
         1252  +** sqlite3_bind_text
         1253  +*/
         1254  +int sqlite3_bind_text(
         1255  +  sqlite3_stmt *pStmt, 
         1256  +  int i, 
         1257  +  const char *zVal, 
         1258  +  int n, 
         1259  +  int eCopy
         1260  +){
         1261  +  return sqlite_bind(pStmt, i, zVal, n, eCopy);
         1262  +}
         1263  +
         1264  +int sqlite3_bind_text16(
         1265  +  sqlite3_stmt *pStmt, 
         1266  +  int i, 
         1267  +  void *zVal, 
         1268  +  int n, 
         1269  +  int eCopy
         1270  +){
         1271  +  int rc;
         1272  +  char * zVal8;
         1273  +
         1274  +  /* convert the first n bytes of the UTF-16 string to UTF-8 */
         1275  +  zVal8 = sqlite3utf16to8(zVal, n);
         1276  +  if( !zVal8 ){
         1277  +    return SQLITE_NOMEM;
  1138   1278     }
         1279  +
         1280  +  /* Pass -1 as the length of the UTF-8 string. It is guaranteed to be
         1281  +  ** NULL-terminated by sqlite3utf16to8().
         1282  +  */
         1283  +  rc = sqlite3_bind_text(pStmt, i, zVal8, -1, eCopy);
         1284  +  sqliteFree(filename8);
         1285  +
         1286  +  return rc;
         1287  +}
         1288  +
         1289  +/*
         1290  +** sqlite3_bind_null
         1291  +*/
         1292  +int sqlite3_bind_null(sqlite3_stmt*, int iParm){
         1293  +  return sqlite_bind(pStmt, i, 0, 0, 0);
         1294  +}
         1295  +
         1296  +
         1297  +int sqlite3_bind_int32(sqlite3_stmt*, int iParm, int iValue){
         1298  +  assert(!"TODO");
         1299  +}
         1300  +int sqlite3_bind_int64(sqlite3_stmt*, int iParm, long long int iValue){
         1301  +  assert(!"TODO");
         1302  +}
         1303  +int sqlite3_bind_double(sqlite3_stmt*, int iParm, double iValue){
         1304  +  assert(!"TODO");
         1305  +}
         1306  +int sqlite3_bind_blob(sqlite3_stmt*, int i, const void*, int n, int eCopy){
         1307  +  assert(!"TODO");
         1308  +}
         1309  +
         1310  +
         1311  +int sqlite3_column_count(sqlite3_stmt*){
         1312  +}
         1313  +
         1314  +int sqlite3_column_type(sqlite3_stmt*,int){
         1315  +}
         1316  +
         1317  +const char *sqlite3_column_decltype(sqlite3_stmt*,int){
         1318  +}
         1319  +
         1320  +const void *sqlite3_column_decltype16(sqlite3_stmt*,int){
         1321  +}
         1322  +
         1323  +const char *sqlite3_column_name(sqlite3_stmt*,int){
         1324  +}
         1325  +
         1326  +const void *sqlite3_column_name16(sqlite3_stmt*,int){
         1327  +}
         1328  +
         1329  +const unsigned char *sqlite3_column_data(sqlite3_stmt*,int){
         1330  +}
         1331  +
         1332  +const void *sqlite3_column_data16(sqlite3_stmt*,int){
         1333  +}
         1334  +
         1335  +int sqlite3_column_bytes(sqlite3_stmt*,int){
         1336  +}
         1337  +
         1338  +long long int sqlite3_column_int(sqlite3_stmt*,int){
         1339  +}
         1340  +
         1341  +double sqlite3_column_float(sqlite3_stmt*,int){
  1139   1342   }
         1343  +
         1344  +#endif
         1345  +
         1346  +
         1347  +

Changes to src/md5.c.

   348    348   */
   349    349   int Md5_Init(Tcl_Interp *interp){
   350    350     Tcl_CreateCommand(interp, "md5", (Tcl_CmdProc*)md5_cmd, 0, 0);
   351    351     Tcl_CreateCommand(interp, "md5file", (Tcl_CmdProc*)md5file_cmd, 0, 0);
   352    352     return TCL_OK;
   353    353   }
   354    354   
   355         -#if 0
   356    355   /*
   357    356   ** During testing, the special md5sum() aggregate function is available.
   358    357   ** inside SQLite.  The following routines implement that function.
   359    358   */
   360    359   static void md5step(sqlite_func *context, int argc, const char **argv){
   361    360     MD5Context *p;
   362    361     int i;
................................................................................
   380    379     MD5Final(digest,p);
   381    380     DigestToBase16(digest, zBuf);
   382    381     sqlite_set_result_string(context, zBuf, strlen(zBuf));
   383    382   }
   384    383   void Md5_Register(sqlite *db){
   385    384     sqlite_create_aggregate(db, "md5sum", -1, md5step, md5finalize, 0);
   386    385   }
   387         -#endif
          386  +
          387  +
          388  +

Changes to src/os.c.

   261    261   
   262    262   /*
   263    263   ** Release a lockInfo structure previously allocated by findLockInfo().
   264    264   */
   265    265   static void releaseLockInfo(struct lockInfo *pLock){
   266    266     pLock->nRef--;
   267    267     if( pLock->nRef==0 ){
   268         -    sqliteHashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0);
          268  +    sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0);
   269    269       sqliteFree(pLock);
   270    270     }
   271    271   }
   272    272   
   273    273   /*
   274    274   ** Release a openCnt structure previously allocated by findLockInfo().
   275    275   */
   276    276   static void releaseOpenCnt(struct openCnt *pOpen){
   277    277     pOpen->nRef--;
   278    278     if( pOpen->nRef==0 ){
   279         -    sqliteHashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0);
          279  +    sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0);
   280    280       sqliteFree(pOpen->aPending);
   281    281       sqliteFree(pOpen);
   282    282     }
   283    283   }
   284    284   
   285    285   /*
   286    286   ** Given a file descriptor, locate lockInfo and openCnt structures that
................................................................................
   305    305     memset(&key1, 0, sizeof(key1));
   306    306     key1.dev = statbuf.st_dev;
   307    307     key1.ino = statbuf.st_ino;
   308    308     key1.pid = getpid();
   309    309     memset(&key2, 0, sizeof(key2));
   310    310     key2.dev = statbuf.st_dev;
   311    311     key2.ino = statbuf.st_ino;
   312         -  pLock = (struct lockInfo*)sqliteHashFind(&lockHash, &key1, sizeof(key1));
          312  +  pLock = (struct lockInfo*)sqlite3HashFind(&lockHash, &key1, sizeof(key1));
   313    313     if( pLock==0 ){
   314    314       struct lockInfo *pOld;
   315    315       pLock = sqliteMallocRaw( sizeof(*pLock) );
   316    316       if( pLock==0 ) return 1;
   317    317       pLock->key = key1;
   318    318       pLock->nRef = 1;
   319    319       pLock->cnt = 0;
   320         -    pOld = sqliteHashInsert(&lockHash, &pLock->key, sizeof(key1), pLock);
          320  +    pOld = sqlite3HashInsert(&lockHash, &pLock->key, sizeof(key1), pLock);
   321    321       if( pOld!=0 ){
   322    322         assert( pOld==pLock );
   323    323         sqliteFree(pLock);
   324    324         return 1;
   325    325       }
   326    326     }else{
   327    327       pLock->nRef++;
   328    328     }
   329    329     *ppLock = pLock;
   330         -  pOpen = (struct openCnt*)sqliteHashFind(&openHash, &key2, sizeof(key2));
          330  +  pOpen = (struct openCnt*)sqlite3HashFind(&openHash, &key2, sizeof(key2));
   331    331     if( pOpen==0 ){
   332    332       struct openCnt *pOld;
   333    333       pOpen = sqliteMallocRaw( sizeof(*pOpen) );
   334    334       if( pOpen==0 ){
   335    335         releaseLockInfo(pLock);
   336    336         return 1;
   337    337       }
   338    338       pOpen->key = key2;
   339    339       pOpen->nRef = 1;
   340    340       pOpen->nLock = 0;
   341    341       pOpen->nPending = 0;
   342    342       pOpen->aPending = 0;
   343         -    pOld = sqliteHashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen);
          343  +    pOld = sqlite3HashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen);
   344    344       if( pOld!=0 ){
   345    345         assert( pOld==pOpen );
   346    346         sqliteFree(pOpen);
   347    347         releaseLockInfo(pLock);
   348    348         return 1;
   349    349       }
   350    350     }else{
................................................................................
   383    383   #define OpenCounter(X)
   384    384   #endif
   385    385   
   386    386   
   387    387   /*
   388    388   ** Delete the named file
   389    389   */
   390         -int sqliteOsDelete(const char *zFilename){
          390  +int sqlite3OsDelete(const char *zFilename){
   391    391   #if OS_UNIX
   392    392     unlink(zFilename);
   393    393   #endif
   394    394   #if OS_WIN
   395    395     DeleteFile(zFilename);
   396    396   #endif
   397    397   #if OS_MAC
................................................................................
   399    399   #endif
   400    400     return SQLITE_OK;
   401    401   }
   402    402   
   403    403   /*
   404    404   ** Return TRUE if the named file exists.
   405    405   */
   406         -int sqliteOsFileExists(const char *zFilename){
          406  +int sqlite3OsFileExists(const char *zFilename){
   407    407   #if OS_UNIX
   408    408     return access(zFilename, 0)==0;
   409    409   #endif
   410    410   #if OS_WIN
   411    411     return GetFileAttributes(zFilename) != 0xffffffff;
   412    412   #endif
   413    413   #if OS_MAC
................................................................................
   450    450   ** and *pReadonly is set to 0 if the file was opened for reading and
   451    451   ** writing or 1 if the file was opened read-only.  The function returns
   452    452   ** SQLITE_OK.
   453    453   **
   454    454   ** On failure, the function returns SQLITE_CANTOPEN and leaves
   455    455   ** *id and *pReadonly unchanged.
   456    456   */
   457         -int sqliteOsOpenReadWrite(
          457  +int sqlite3OsOpenReadWrite(
   458    458     const char *zFilename,
   459    459     OsFile *id,
   460    460     int *pReadonly
   461    461   ){
   462    462   #if OS_UNIX
   463    463     int rc;
   464    464     id->dirfd = -1;
................................................................................
   468    468       if( id->fd<0 ){
   469    469         return SQLITE_CANTOPEN; 
   470    470       }
   471    471       *pReadonly = 1;
   472    472     }else{
   473    473       *pReadonly = 0;
   474    474     }
   475         -  sqliteOsEnterMutex();
          475  +  sqlite3OsEnterMutex();
   476    476     rc = findLockInfo(id->fd, &id->pLock, &id->pOpen);
   477         -  sqliteOsLeaveMutex();
          477  +  sqlite3OsLeaveMutex();
   478    478     if( rc ){
   479    479       close(id->fd);
   480    480       return SQLITE_NOMEM;
   481    481     }
   482    482     id->locked = 0;
   483    483     TRACE3("OPEN    %-3d %s\n", id->fd, zFilename);
   484    484     OpenCounter(+1);
................................................................................
   537    537           *pReadonly = 1;
   538    538       } else
   539    539         *pReadonly = 0;
   540    540     } else
   541    541       *pReadonly = 0;
   542    542   # else
   543    543     __path2fss(zFilename, &fsSpec);
   544         -  if( !sqliteOsFileExists(zFilename) ){
          544  +  if( !sqlite3OsFileExists(zFilename) ){
   545    545       if( HCreate(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, 'SQLI', cDocumentFile) != noErr )
   546    546         return SQLITE_CANTOPEN;
   547    547     }
   548    548     if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrShPerm, &(id->refNum)) != noErr ){
   549    549       if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrPerm, &(id->refNum)) != noErr ){
   550    550         if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdPerm, &(id->refNum)) != noErr )
   551    551           return SQLITE_CANTOPEN;
................................................................................
   577    577   ** If delFlag is true, then make arrangements to automatically delete
   578    578   ** the file when it is closed.
   579    579   **
   580    580   ** On success, write the file handle into *id and return SQLITE_OK.
   581    581   **
   582    582   ** On failure, return SQLITE_CANTOPEN.
   583    583   */
   584         -int sqliteOsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){
          584  +int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){
   585    585   #if OS_UNIX
   586    586     int rc;
   587    587     if( access(zFilename, 0)==0 ){
   588    588       return SQLITE_CANTOPEN;
   589    589     }
   590    590     id->dirfd = -1;
   591    591     id->fd = open(zFilename,
   592    592                   O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, 0600);
   593    593     if( id->fd<0 ){
   594    594       return SQLITE_CANTOPEN;
   595    595     }
   596         -  sqliteOsEnterMutex();
          596  +  sqlite3OsEnterMutex();
   597    597     rc = findLockInfo(id->fd, &id->pLock, &id->pOpen);
   598         -  sqliteOsLeaveMutex();
          598  +  sqlite3OsLeaveMutex();
   599    599     if( rc ){
   600    600       close(id->fd);
   601    601       unlink(zFilename);
   602    602       return SQLITE_NOMEM;
   603    603     }
   604    604     id->locked = 0;
   605    605     if( delFlag ){
................................................................................
   655    655     if( HOpenDF(fsSpec.vRefNum, fsSpec.parID, fsSpec.name, fsRdWrPerm, &(id->refNum)) != noErr )
   656    656       return SQLITE_CANTOPEN;
   657    657   # endif
   658    658     id->refNumRF = -1;
   659    659     id->locked = 0;
   660    660     id->delOnClose = delFlag;
   661    661     if (delFlag)
   662         -    id->pathToDel = sqliteOsFullPathname(zFilename);
          662  +    id->pathToDel = sqlite3OsFullPathname(zFilename);
   663    663     OpenCounter(+1);
   664    664     return SQLITE_OK;
   665    665   #endif
   666    666   }
   667    667   
   668    668   /*
   669    669   ** Attempt to open a new file for read-only access.
   670    670   **
   671    671   ** On success, write the file handle into *id and return SQLITE_OK.
   672    672   **
   673    673   ** On failure, return SQLITE_CANTOPEN.
   674    674   */
   675         -int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){
          675  +int sqlite3OsOpenReadOnly(const char *zFilename, OsFile *id){
   676    676   #if OS_UNIX
   677    677     int rc;
   678    678     id->dirfd = -1;
   679    679     id->fd = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY);
   680    680     if( id->fd<0 ){
   681    681       return SQLITE_CANTOPEN;
   682    682     }
   683         -  sqliteOsEnterMutex();
          683  +  sqlite3OsEnterMutex();
   684    684     rc = findLockInfo(id->fd, &id->pLock, &id->pOpen);
   685         -  sqliteOsLeaveMutex();
          685  +  sqlite3OsLeaveMutex();
   686    686     if( rc ){
   687    687       close(id->fd);
   688    688       return SQLITE_NOMEM;
   689    689     }
   690    690     id->locked = 0;
   691    691     TRACE3("OPEN-RO %-3d %s\n", id->fd, zFilename);
   692    692     OpenCounter(+1);
................................................................................
   749    749   ** On success, a handle for a previously open file is at *id is
   750    750   ** updated with the new directory file descriptor and SQLITE_OK is
   751    751   ** returned.
   752    752   **
   753    753   ** On failure, the function returns SQLITE_CANTOPEN and leaves
   754    754   ** *id unchanged.
   755    755   */
   756         -int sqliteOsOpenDirectory(
          756  +int sqlite3OsOpenDirectory(
   757    757     const char *zDirname,
   758    758     OsFile *id
   759    759   ){
   760    760   #if OS_UNIX
   761    761     if( id->fd<0 ){
   762    762       /* Do not open the directory if the corresponding file is not already
   763    763       ** open. */
................................................................................
   773    773     return SQLITE_OK;
   774    774   }
   775    775   
   776    776   /*
   777    777   ** Create a temporary file name in zBuf.  zBuf must be big enough to
   778    778   ** hold at least SQLITE_TEMPNAME_SIZE characters.
   779    779   */
   780         -int sqliteOsTempFileName(char *zBuf){
          780  +int sqlite3OsTempFileName(char *zBuf){
   781    781   #if OS_UNIX
   782    782     static const char *azDirs[] = {
   783    783        "/var/tmp",
   784    784        "/usr/tmp",
   785    785        "/tmp",
   786    786        ".",
   787    787     };
................................................................................
   798    798       if( access(azDirs[i], 07) ) continue;
   799    799       zDir = azDirs[i];
   800    800       break;
   801    801     }
   802    802     do{
   803    803       sprintf(zBuf, "%s/"TEMP_FILE_PREFIX, zDir);
   804    804       j = strlen(zBuf);
   805         -    sqliteRandomness(15, &zBuf[j]);
          805  +    sqlite3Randomness(15, &zBuf[j]);
   806    806       for(i=0; i<15; i++, j++){
   807    807         zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
   808    808       }
   809    809       zBuf[j] = 0;
   810    810     }while( access(zBuf,0)==0 );
   811    811   #endif
   812    812   #if OS_WIN
................................................................................
   818    818     char zTempPath[SQLITE_TEMPNAME_SIZE];
   819    819     GetTempPath(SQLITE_TEMPNAME_SIZE-30, zTempPath);
   820    820     for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
   821    821     zTempPath[i] = 0;
   822    822     for(;;){
   823    823       sprintf(zBuf, "%s\\"TEMP_FILE_PREFIX, zTempPath);
   824    824       j = strlen(zBuf);
   825         -    sqliteRandomness(15, &zBuf[j]);
          825  +    sqlite3Randomness(15, &zBuf[j]);
   826    826       for(i=0; i<15; i++, j++){
   827    827         zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
   828    828       }
   829    829       zBuf[j] = 0;
   830         -    if( !sqliteOsFileExists(zBuf) ) break;
          830  +    if( !sqlite3OsFileExists(zBuf) ) break;
   831    831     }
   832    832   #endif
   833    833   #if OS_MAC
   834    834     static char zChars[] =
   835    835       "abcdefghijklmnopqrstuvwxyz"
   836    836       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   837    837       "0123456789";
................................................................................
   861    861       } while( infoRec.dirInfo.ioDrDirID != fsRtDirID );
   862    862     }
   863    863     if( *zTempPath == 0 )
   864    864       getcwd(zTempPath, SQLITE_TEMPNAME_SIZE-24);
   865    865     for(;;){
   866    866       sprintf(zBuf, "%s"TEMP_FILE_PREFIX, zTempPath);
   867    867       j = strlen(zBuf);
   868         -    sqliteRandomness(15, &zBuf[j]);
          868  +    sqlite3Randomness(15, &zBuf[j]);
   869    869       for(i=0; i<15; i++, j++){
   870    870         zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
   871    871       }
   872    872       zBuf[j] = 0;
   873         -    if( !sqliteOsFileExists(zBuf) ) break;
          873  +    if( !sqlite3OsFileExists(zBuf) ) break;
   874    874     }
   875    875   #endif
   876    876     return SQLITE_OK; 
   877    877   }
   878    878   
   879    879   /*
   880    880   ** Close a file.
   881    881   */
   882         -int sqliteOsClose(OsFile *id){
          882  +int sqlite3OsClose(OsFile *id){
   883    883   #if OS_UNIX
   884         -  sqliteOsUnlock(id);
          884  +  sqlite3OsUnlock(id);
   885    885     if( id->dirfd>=0 ) close(id->dirfd);
   886    886     id->dirfd = -1;
   887         -  sqliteOsEnterMutex();
          887  +  sqlite3OsEnterMutex();
   888    888     if( id->pOpen->nLock ){
   889    889       /* If there are outstanding locks, do not actually close the file just
   890    890       ** yet because that would clear those locks.  Instead, add the file
   891    891       ** descriptor to pOpen->aPending.  It will be automatically closed when
   892    892       ** the last lock is cleared.
   893    893       */
   894    894       int *aNew;
................................................................................
   903    903       }
   904    904     }else{
   905    905       /* There are no outstanding locks so we can close the file immediately */
   906    906       close(id->fd);
   907    907     }
   908    908     releaseLockInfo(id->pLock);
   909    909     releaseOpenCnt(id->pOpen);
   910         -  sqliteOsLeaveMutex();
          910  +  sqlite3OsLeaveMutex();
   911    911     TRACE2("CLOSE   %-3d\n", id->fd);
   912    912     OpenCounter(-1);
   913    913     return SQLITE_OK;
   914    914   #endif
   915    915   #if OS_WIN
   916    916     CloseHandle(id->h);
   917    917     OpenCounter(-1);
................................................................................
   935    935   }
   936    936   
   937    937   /*
   938    938   ** Read data from a file into a buffer.  Return SQLITE_OK if all
   939    939   ** bytes were read successfully and SQLITE_IOERR if anything goes
   940    940   ** wrong.
   941    941   */
   942         -int sqliteOsRead(OsFile *id, void *pBuf, int amt){
          942  +int sqlite3OsRead(OsFile *id, void *pBuf, int amt){
   943    943   #if OS_UNIX
   944    944     int got;
   945    945     SimulateIOError(SQLITE_IOERR);
   946    946     TIMER_START;
   947    947     got = read(id->fd, pBuf, amt);
   948    948     TIMER_END;
   949    949     TRACE4("READ    %-3d %7d %d\n", id->fd, last_page, elapse);
................................................................................
   986    986   #endif
   987    987   }
   988    988   
   989    989   /*
   990    990   ** Write data from a buffer into a file.  Return SQLITE_OK on success
   991    991   ** or some other error code on failure.
   992    992   */
   993         -int sqliteOsWrite(OsFile *id, const void *pBuf, int amt){
          993  +int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
   994    994   #if OS_UNIX
   995    995     int wrote = 0;
   996    996     SimulateIOError(SQLITE_IOERR);
   997    997     TIMER_START;
   998    998     while( amt>0 && (wrote = write(id->fd, pBuf, amt))>0 ){
   999    999       amt -= wrote;
  1000   1000       pBuf = &((char*)pBuf)[wrote];
................................................................................
  1045   1045     return SQLITE_OK;
  1046   1046   #endif
  1047   1047   }
  1048   1048   
  1049   1049   /*
  1050   1050   ** Move the read/write pointer in a file.
  1051   1051   */
  1052         -int sqliteOsSeek(OsFile *id, off_t offset){
         1052  +int sqlite3OsSeek(OsFile *id, off_t offset){
  1053   1053     SEEK(offset/1024 + 1);
  1054   1054   #if OS_UNIX
  1055   1055     lseek(id->fd, offset, SEEK_SET);
  1056   1056     return SQLITE_OK;
  1057   1057   #endif
  1058   1058   #if OS_WIN
  1059   1059     {
................................................................................
  1064   1064       /* TRACE3("SEEK rc=0x%x upper=0x%x\n", rc, upperBits); */
  1065   1065     }
  1066   1066     return SQLITE_OK;
  1067   1067   #endif
  1068   1068   #if OS_MAC
  1069   1069     {
  1070   1070       off_t curSize;
  1071         -    if( sqliteOsFileSize(id, &curSize) != SQLITE_OK ){
         1071  +    if( sqlite3OsFileSize(id, &curSize) != SQLITE_OK ){
  1072   1072         return SQLITE_IOERR;
  1073   1073       }
  1074   1074       if( offset >= curSize ){
  1075         -      if( sqliteOsTruncate(id, offset+1) != SQLITE_OK ){
         1075  +      if( sqlite3OsTruncate(id, offset+1) != SQLITE_OK ){
  1076   1076           return SQLITE_IOERR;
  1077   1077         }
  1078   1078       }
  1079   1079   # ifdef _LARGE_FILE
  1080   1080       if( FSSetForkPosition(id->refNum, fsFromStart, offset) != noErr ){
  1081   1081   # else
  1082   1082       if( SetFPos(id->refNum, fsFromStart, offset) != noErr ){
................................................................................
  1096   1096   ** has been created by fsync-ing the directory that contains the file.
  1097   1097   ** If we do not do this and we encounter a power failure, the directory
  1098   1098   ** entry for the journal might not exist after we reboot.  The next
  1099   1099   ** SQLite to access the file will not know that the journal exists (because
  1100   1100   ** the directory entry for the journal was never created) and the transaction
  1101   1101   ** will not roll back - possibly leading to database corruption.
  1102   1102   */
  1103         -int sqliteOsSync(OsFile *id){
         1103  +int sqlite3OsSync(OsFile *id){
  1104   1104   #if OS_UNIX
  1105   1105     SimulateIOError(SQLITE_IOERR);
  1106   1106     TRACE2("SYNC    %-3d\n", id->fd);
  1107   1107     if( fsync(id->fd) ){
  1108   1108       return SQLITE_IOERR;
  1109   1109     }else{
  1110   1110       if( id->dirfd>=0 ){
................................................................................
  1138   1138     }
  1139   1139   #endif
  1140   1140   }
  1141   1141   
  1142   1142   /*
  1143   1143   ** Truncate an open file to a specified size
  1144   1144   */
  1145         -int sqliteOsTruncate(OsFile *id, off_t nByte){
         1145  +int sqlite3OsTruncate(OsFile *id, off_t nByte){
  1146   1146     SimulateIOError(SQLITE_IOERR);
  1147   1147   #if OS_UNIX
  1148   1148     return ftruncate(id->fd, nByte)==0 ? SQLITE_OK : SQLITE_IOERR;
  1149   1149   #endif
  1150   1150   #if OS_WIN
  1151   1151     {
  1152   1152       LONG upperBits = nByte>>32;
................................................................................
  1167   1167     }
  1168   1168   #endif
  1169   1169   }
  1170   1170   
  1171   1171   /*
  1172   1172   ** Determine the current size of a file in bytes
  1173   1173   */
  1174         -int sqliteOsFileSize(OsFile *id, off_t *pSize){
         1174  +int sqlite3OsFileSize(OsFile *id, off_t *pSize){
  1175   1175   #if OS_UNIX
  1176   1176     struct stat buf;
  1177   1177     SimulateIOError(SQLITE_IOERR);
  1178   1178     if( fstat(id->fd, &buf)!=0 ){
  1179   1179       return SQLITE_IOERR;
  1180   1180     }
  1181   1181     *pSize = buf.st_size;
................................................................................
  1244   1244   ** same time, unless they are unlucky and choose the same lock byte.
  1245   1245   ** A database write lock is obtained by locking all bytes in the range.
  1246   1246   ** There can only be one writer.
  1247   1247   **
  1248   1248   ** A lock is obtained on the first byte of the lock range before acquiring
  1249   1249   ** either a read lock or a write lock.  This prevents two processes from
  1250   1250   ** attempting to get a lock at a same time.  The semantics of 
  1251         -** sqliteOsReadLock() require that if there is already a write lock, that
         1251  +** sqlite3OsReadLock() require that if there is already a write lock, that
  1252   1252   ** lock is converted into a read lock atomically.  The lock on the first
  1253   1253   ** byte allows us to drop the old write lock and get the read lock without
  1254   1254   ** another process jumping into the middle and messing us up.  The same
  1255         -** argument applies to sqliteOsWriteLock().
         1255  +** argument applies to sqlite3OsWriteLock().
  1256   1256   **
  1257   1257   ** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available,
  1258   1258   ** which means we can use reader/writer locks.  When reader writer locks
  1259   1259   ** are used, the lock is placed on the same range of bytes that is used
  1260   1260   ** for probabilistic locking in Win95/98/ME.  Hence, the locking scheme
  1261   1261   ** will support two or more Win95 readers or two or more WinNT readers.
  1262   1262   ** But a single Win95 reader will lock out all WinNT readers and a single
................................................................................
  1282   1282   ** If the file was write locked, then this reduces the lock to a read.
  1283   1283   ** If the file was read locked, then this acquires a new read lock.
  1284   1284   **
  1285   1285   ** Return SQLITE_OK on success and SQLITE_BUSY on failure.  If this
  1286   1286   ** library was compiled with large file support (LFS) but LFS is not
  1287   1287   ** available on the host, then an SQLITE_NOLFS is returned.
  1288   1288   */
  1289         -int sqliteOsReadLock(OsFile *id){
         1289  +int sqlite3OsReadLock(OsFile *id){
  1290   1290   #if OS_UNIX
  1291   1291     int rc;
  1292         -  sqliteOsEnterMutex();
         1292  +  sqlite3OsEnterMutex();
  1293   1293     if( id->pLock->cnt>0 ){
  1294   1294       if( !id->locked ){
  1295   1295         id->pLock->cnt++;
  1296   1296         id->locked = 1;
  1297   1297         id->pOpen->nLock++;
  1298   1298       }
  1299   1299       rc = SQLITE_OK;
................................................................................
  1313   1313           id->locked = 1;
  1314   1314         }
  1315   1315         id->pLock->cnt = 1;
  1316   1316       }
  1317   1317     }else{
  1318   1318       rc = SQLITE_BUSY;
  1319   1319     }
  1320         -  sqliteOsLeaveMutex();
         1320  +  sqlite3OsLeaveMutex();
  1321   1321     return rc;
  1322   1322   #endif
  1323   1323   #if OS_WIN
  1324   1324     int rc;
  1325   1325     if( id->locked>0 ){
  1326   1326       rc = SQLITE_OK;
  1327   1327     }else{
  1328   1328       int lk;
  1329   1329       int res;
  1330   1330       int cnt = 100;
  1331         -    sqliteRandomness(sizeof(lk), &lk);
         1331  +    sqlite3Randomness(sizeof(lk), &lk);
  1332   1332       lk = (lk & 0x7fffffff)%N_LOCKBYTE + 1;
  1333   1333       while( cnt-->0 && (res = LockFile(id->h, FIRST_LOCKBYTE, 0, 1, 0))==0 ){
  1334   1334         Sleep(1);
  1335   1335       }
  1336   1336       if( res ){
  1337   1337         UnlockFile(id->h, FIRST_LOCKBYTE+1, 0, N_LOCKBYTE, 0);
  1338   1338         if( isNT() ){
................................................................................
  1361   1361     if( id->locked>0 || id->refNumRF == -1 ){
  1362   1362       rc = SQLITE_OK;
  1363   1363     }else{
  1364   1364       int lk;
  1365   1365       OSErr res;
  1366   1366       int cnt = 5;
  1367   1367       ParamBlockRec params;
  1368         -    sqliteRandomness(sizeof(lk), &lk);
         1368  +    sqlite3Randomness(sizeof(lk), &lk);
  1369   1369       lk = (lk & 0x7fffffff)%N_LOCKBYTE + 1;
  1370   1370       memset(&params, 0, sizeof(params));
  1371   1371       params.ioParam.ioRefNum = id->refNumRF;
  1372   1372       params.ioParam.ioPosMode = fsFromStart;
  1373   1373       params.ioParam.ioPosOffset = FIRST_LOCKBYTE;
  1374   1374       params.ioParam.ioReqCount = 1;
  1375   1375       while( cnt-->0 && (res = PBLockRangeSync(&params))!=noErr ){
................................................................................
  1400   1400   
  1401   1401   /*
  1402   1402   ** Change the lock status to be an exclusive or write lock.  Return
  1403   1403   ** SQLITE_OK on success and SQLITE_BUSY on a failure.  If this
  1404   1404   ** library was compiled with large file support (LFS) but LFS is not
  1405   1405   ** available on the host, then an SQLITE_NOLFS is returned.
  1406   1406   */
  1407         -int sqliteOsWriteLock(OsFile *id){
         1407  +int sqlite3OsWriteLock(OsFile *id){
  1408   1408   #if OS_UNIX
  1409   1409     int rc;
  1410         -  sqliteOsEnterMutex();
         1410  +  sqlite3OsEnterMutex();
  1411   1411     if( id->pLock->cnt==0 || (id->pLock->cnt==1 && id->locked==1) ){
  1412   1412       struct flock lock;
  1413   1413       int s;
  1414   1414       lock.l_type = F_WRLCK;
  1415   1415       lock.l_whence = SEEK_SET;
  1416   1416       lock.l_start = lock.l_len = 0L;
  1417   1417       s = fcntl(id->fd, F_SETLK, &lock);
................................................................................
  1424   1424           id->locked = 1;
  1425   1425         }
  1426   1426         id->pLock->cnt = -1;
  1427   1427       }
  1428   1428     }else{
  1429   1429       rc = SQLITE_BUSY;
  1430   1430     }
  1431         -  sqliteOsLeaveMutex();
         1431  +  sqlite3OsLeaveMutex();
  1432   1432     return rc;
  1433   1433   #endif
  1434   1434   #if OS_WIN
  1435   1435     int rc;
  1436   1436     if( id->locked<0 ){
  1437   1437       rc = SQLITE_OK;
  1438   1438     }else{
................................................................................
  1510   1510   
  1511   1511   /*
  1512   1512   ** Unlock the given file descriptor.  If the file descriptor was
  1513   1513   ** not previously locked, then this routine is a no-op.  If this
  1514   1514   ** library was compiled with large file support (LFS) but LFS is not
  1515   1515   ** available on the host, then an SQLITE_NOLFS is returned.
  1516   1516   */
  1517         -int sqliteOsUnlock(OsFile *id){
         1517  +int sqlite3OsUnlock(OsFile *id){
  1518   1518   #if OS_UNIX
  1519   1519     int rc;
  1520   1520     if( !id->locked ) return SQLITE_OK;
  1521         -  sqliteOsEnterMutex();
         1521  +  sqlite3OsEnterMutex();
  1522   1522     assert( id->pLock->cnt!=0 );
  1523   1523     if( id->pLock->cnt>1 ){
  1524   1524       id->pLock->cnt--;
  1525   1525       rc = SQLITE_OK;
  1526   1526     }else{
  1527   1527       struct flock lock;
  1528   1528       int s;
................................................................................
  1551   1551           close(pOpen->aPending[i]);
  1552   1552         }
  1553   1553         sqliteFree(pOpen->aPending);
  1554   1554         pOpen->nPending = 0;
  1555   1555         pOpen->aPending = 0;
  1556   1556       }
  1557   1557     }
  1558         -  sqliteOsLeaveMutex();
         1558  +  sqlite3OsLeaveMutex();
  1559   1559     id->locked = 0;
  1560   1560     return rc;
  1561   1561   #endif
  1562   1562   #if OS_WIN
  1563   1563     int rc;
  1564   1564     if( id->locked==0 ){
  1565   1565       rc = SQLITE_OK;
................................................................................
  1600   1600   }
  1601   1601   
  1602   1602   /*
  1603   1603   ** Get information to seed the random number generator.  The seed
  1604   1604   ** is written into the buffer zBuf[256].  The calling function must
  1605   1605   ** supply a sufficiently large buffer.
  1606   1606   */
  1607         -int sqliteOsRandomSeed(char *zBuf){
         1607  +int sqlite3OsRandomSeed(char *zBuf){
  1608   1608     /* We have to initialize zBuf to prevent valgrind from reporting
  1609   1609     ** errors.  The reports issued by valgrind are incorrect - we would
  1610   1610     ** prefer that the randomness be increased by making use of the
  1611   1611     ** uninitialized space in zBuf - but valgrind errors tend to worry
  1612   1612     ** some users.  Rather than argue, it seems easier just to initialize
  1613   1613     ** the whole array and silence valgrind, even if that means less randomness
  1614   1614     ** in the random seed.
................................................................................
  1639   1639   #endif
  1640   1640     return SQLITE_OK;
  1641   1641   }
  1642   1642   
  1643   1643   /*
  1644   1644   ** Sleep for a little while.  Return the amount of time slept.
  1645   1645   */
  1646         -int sqliteOsSleep(int ms){
         1646  +int sqlite3OsSleep(int ms){
  1647   1647   #if OS_UNIX
  1648   1648   #if defined(HAVE_USLEEP) && HAVE_USLEEP
  1649   1649     usleep(ms*1000);
  1650   1650     return ms;
  1651   1651   #else
  1652   1652     sleep((ms+999)/1000);
  1653   1653     return 1000*((ms+999)/1000);
................................................................................
  1683   1683   ** The following pair of routine implement mutual exclusion for
  1684   1684   ** multi-threaded processes.  Only a single thread is allowed to
  1685   1685   ** executed code that is surrounded by EnterMutex() and LeaveMutex().
  1686   1686   **
  1687   1687   ** SQLite uses only a single Mutex.  There is not much critical
  1688   1688   ** code and what little there is executes quickly and without blocking.
  1689   1689   */
  1690         -void sqliteOsEnterMutex(){
         1690  +void sqlite3OsEnterMutex(){
  1691   1691   #ifdef SQLITE_UNIX_THREADS
  1692   1692     pthread_mutex_lock(&mutex);
  1693   1693   #endif
  1694   1694   #ifdef SQLITE_W32_THREADS
  1695   1695     static int isInit = 0;
  1696   1696     while( !isInit ){
  1697   1697       static long lock = 0;
................................................................................
  1716   1716       }
  1717   1717     }
  1718   1718     MPEnterCriticalRegion(criticalRegion, kDurationForever);
  1719   1719   #endif
  1720   1720     assert( !inMutex );
  1721   1721     inMutex = 1;
  1722   1722   }
  1723         -void sqliteOsLeaveMutex(){
         1723  +void sqlite3OsLeaveMutex(){
  1724   1724     assert( inMutex );
  1725   1725     inMutex = 0;
  1726   1726   #ifdef SQLITE_UNIX_THREADS
  1727   1727     pthread_mutex_unlock(&mutex);
  1728   1728   #endif
  1729   1729   #ifdef SQLITE_W32_THREADS
  1730   1730     LeaveCriticalSection(&cs);
................................................................................
  1736   1736   
  1737   1737   /*
  1738   1738   ** Turn a relative pathname into a full pathname.  Return a pointer
  1739   1739   ** to the full pathname stored in space obtained from sqliteMalloc().
  1740   1740   ** The calling function is responsible for freeing this space once it
  1741   1741   ** is no longer needed.
  1742   1742   */
  1743         -char *sqliteOsFullPathname(const char *zRelative){
         1743  +char *sqlite3OsFullPathname(const char *zRelative){
  1744   1744   #if OS_UNIX
  1745   1745     char *zFull = 0;
  1746   1746     if( zRelative[0]=='/' ){
  1747         -    sqliteSetString(&zFull, zRelative, (char*)0);
         1747  +    sqlite3SetString(&zFull, zRelative, (char*)0);
  1748   1748     }else{
  1749   1749       char zBuf[5000];
  1750         -    sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative,
         1750  +    sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative,
  1751   1751                       (char*)0);
  1752   1752     }
  1753   1753     return zFull;
  1754   1754   #endif
  1755   1755   #if OS_WIN
  1756   1756     char *zNotUsed;
  1757   1757     char *zFull;
................................................................................
  1762   1762     GetFullPathName(zRelative, nByte, zFull, &zNotUsed);
  1763   1763     return zFull;
  1764   1764   #endif
  1765   1765   #if OS_MAC
  1766   1766     char *zFull = 0;
  1767   1767     if( zRelative[0]==':' ){
  1768   1768       char zBuf[_MAX_PATH+1];
  1769         -    sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), &(zRelative[1]),
         1769  +    sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), &(zRelative[1]),
  1770   1770                       (char*)0);
  1771   1771     }else{
  1772   1772       if( strchr(zRelative, ':') ){
  1773         -      sqliteSetString(&zFull, zRelative, (char*)0);
         1773  +      sqlite3SetString(&zFull, zRelative, (char*)0);
  1774   1774       }else{
  1775   1775       char zBuf[_MAX_PATH+1];
  1776         -      sqliteSetString(&zFull, getcwd(zBuf, sizeof(zBuf)), zRelative, (char*)0);
         1776  +      sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), zRelative, (char*)0);
  1777   1777       }
  1778   1778     }
  1779   1779     return zFull;
  1780   1780   #endif
  1781   1781   }
  1782   1782   
  1783   1783   /*
  1784   1784   ** The following variable, if set to a non-zero value, becomes the result
  1785         -** returned from sqliteOsCurrentTime().  This is used for testing.
         1785  +** returned from sqlite3OsCurrentTime().  This is used for testing.
  1786   1786   */
  1787   1787   #ifdef SQLITE_TEST
  1788   1788   int sqlite_current_time = 0;
  1789   1789   #endif
  1790   1790   
  1791   1791   /*
  1792   1792   ** Find the current time (in Universal Coordinated Time).  Write the
  1793   1793   ** current time and date as a Julian Day number into *prNow and
  1794   1794   ** return 0.  Return 1 if the time and date cannot be found.
  1795   1795   */
  1796         -int sqliteOsCurrentTime(double *prNow){
         1796  +int sqlite3OsCurrentTime(double *prNow){
  1797   1797   #if OS_UNIX
  1798   1798     time_t t;
  1799   1799     time(&t);
  1800   1800     *prNow = t/86400.0 + 2440587.5;
  1801   1801   #endif
  1802   1802   #if OS_WIN
  1803   1803     FILETIME ft;
................................................................................
  1812   1812   #ifdef SQLITE_TEST
  1813   1813     if( sqlite_current_time ){
  1814   1814       *prNow = sqlite_current_time/86400.0 + 2440587.5;
  1815   1815     }
  1816   1816   #endif
  1817   1817     return 0;
  1818   1818   }
         1819  +
         1820  +
         1821  +

Changes to src/os.h.

   157    157   # else
   158    158       typedef SInt32 off_t;
   159    159   # endif
   160    160   # define SQLITE_TEMPNAME_SIZE _MAX_PATH
   161    161   # define SQLITE_MIN_SLEEP_MS 17
   162    162   #endif
   163    163   
   164         -int sqliteOsDelete(const char*);
   165         -int sqliteOsFileExists(const char*);
          164  +int sqlite3OsDelete(const char*);
          165  +int sqlite3OsFileExists(const char*);
   166    166   int sqliteOsFileRename(const char*, const char*);
   167         -int sqliteOsOpenReadWrite(const char*, OsFile*, int*);
   168         -int sqliteOsOpenExclusive(const char*, OsFile*, int);
   169         -int sqliteOsOpenReadOnly(const char*, OsFile*);
   170         -int sqliteOsOpenDirectory(const char*, OsFile*);
   171         -int sqliteOsTempFileName(char*);
   172         -int sqliteOsClose(OsFile*);
   173         -int sqliteOsRead(OsFile*, void*, int amt);
   174         -int sqliteOsWrite(OsFile*, const void*, int amt);
   175         -int sqliteOsSeek(OsFile*, off_t offset);
   176         -int sqliteOsSync(OsFile*);
   177         -int sqliteOsTruncate(OsFile*, off_t size);
   178         -int sqliteOsFileSize(OsFile*, off_t *pSize);
   179         -int sqliteOsReadLock(OsFile*);
   180         -int sqliteOsWriteLock(OsFile*);
   181         -int sqliteOsUnlock(OsFile*);
   182         -int sqliteOsRandomSeed(char*);
   183         -int sqliteOsSleep(int ms);
   184         -int sqliteOsCurrentTime(double*);
   185         -void sqliteOsEnterMutex(void);
   186         -void sqliteOsLeaveMutex(void);
   187         -char *sqliteOsFullPathname(const char*);
          167  +int sqlite3OsOpenReadWrite(const char*, OsFile*, int*);
          168  +int sqlite3OsOpenExclusive(const char*, OsFile*, int);
          169  +int sqlite3OsOpenReadOnly(const char*, OsFile*);
          170  +int sqlite3OsOpenDirectory(const char*, OsFile*);
          171  +int sqlite3OsTempFileName(char*);
          172  +int sqlite3OsClose(OsFile*);
          173  +int sqlite3OsRead(OsFile*, void*, int amt);
          174  +int sqlite3OsWrite(OsFile*, const void*, int amt);
          175  +int sqlite3OsSeek(OsFile*, off_t offset);
          176  +int sqlite3OsSync(OsFile*);
          177  +int sqlite3OsTruncate(OsFile*, off_t size);
          178  +int sqlite3OsFileSize(OsFile*, off_t *pSize);
          179  +int sqlite3OsReadLock(OsFile*);
          180  +int sqlite3OsWriteLock(OsFile*);
          181  +int sqlite3OsUnlock(OsFile*);
          182  +int sqlite3OsRandomSeed(char*);
          183  +int sqlite3OsSleep(int ms);
          184  +int sqlite3OsCurrentTime(double*);
          185  +void sqlite3OsEnterMutex(void);
          186  +void sqlite3OsLeaveMutex(void);
          187  +char *sqlite3OsFullPathname(const char*);
   188    188   
   189    189   
   190    190   
   191    191   #endif /* _SQLITE_OS_H_ */
          192  +
          193  +
          194  +

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.103 2004/05/07 17:57:50 drh Exp $
           21  +** @(#) $Id: pager.c,v 1.104 2004/05/08 08:23:28 danielk1977 Exp $
    22     22   */
    23     23   #include "os.h"         /* Must be first to enable large file support */
    24     24   #include "sqliteInt.h"
    25     25   #include "pager.h"
    26     26   #include <assert.h>
    27     27   #include <string.h>
    28     28   
................................................................................
   311    311   ** If the journal format is 2 or 3, read a big-endian integer.  If the
   312    312   ** journal format is 1, read an integer in the native byte-order of the
   313    313   ** host machine.
   314    314   */
   315    315   static int read32bits(int format, OsFile *fd, u32 *pRes){
   316    316     u32 res;
   317    317     int rc;
   318         -  rc = sqliteOsRead(fd, &res, sizeof(res));
          318  +  rc = sqlite3OsRead(fd, &res, sizeof(res));
   319    319     if( rc==SQLITE_OK && format>JOURNAL_FORMAT_1 ){
   320    320       unsigned char ac[4];
   321    321       memcpy(ac, &res, 4);
   322    322       res = (ac[0]<<24) | (ac[1]<<16) | (ac[2]<<8) | ac[3];
   323    323     }
   324    324     *pRes = res;
   325    325     return rc;
................................................................................
   333    333   ** bytes.  If the journal format is 1, write the integer in the native
   334    334   ** byte order.  In normal operation, only formats 2 and 3 are used.
   335    335   ** Journal format 1 is only used for testing.
   336    336   */
   337    337   static int write32bits(OsFile *fd, u32 val){
   338    338     unsigned char ac[4];
   339    339     if( journal_format<=1 ){
   340         -    return sqliteOsWrite(fd, &val, 4);
          340  +    return sqlite3OsWrite(fd, &val, 4);
   341    341     }
   342    342     ac[0] = (val>>24) & 0xff;
   343    343     ac[1] = (val>>16) & 0xff;
   344    344     ac[2] = (val>>8) & 0xff;
   345    345     ac[3] = val & 0xff;
   346         -  return sqliteOsWrite(fd, ac, 4);
          346  +  return sqlite3OsWrite(fd, ac, 4);
   347    347   }
   348    348   
   349    349   /*
   350    350   ** Write a 32-bit integer into a page header right before the
   351    351   ** page data.  This will overwrite the PgHdr.pDirty pointer.
   352    352   **
   353    353   ** The integer is big-endian for formats 2 and 3 and native byte order
................................................................................
   449    449     pPager->pLast = 0;
   450    450     pPager->pAll = 0;
   451    451     memset(pPager->aHash, 0, sizeof(pPager->aHash));
   452    452     pPager->nPage = 0;
   453    453     if( pPager->state>=SQLITE_WRITELOCK ){
   454    454       sqlite3pager_rollback(pPager);
   455    455     }
   456         -  sqliteOsUnlock(&pPager->fd);
          456  +  sqlite3OsUnlock(&pPager->fd);
   457    457     pPager->state = SQLITE_UNLOCK;
   458    458     pPager->dbSize = -1;
   459    459     pPager->nRef = 0;
   460    460     assert( pPager->journalOpen==0 );
   461    461   }
   462    462   
   463    463   /*
................................................................................
   472    472   */
   473    473   static int pager_unwritelock(Pager *pPager){
   474    474     int rc;
   475    475     PgHdr *pPg;
   476    476     if( pPager->state<SQLITE_WRITELOCK ) return SQLITE_OK;
   477    477     sqlite3pager_stmt_commit(pPager);
   478    478     if( pPager->ckptOpen ){
   479         -    sqliteOsClose(&pPager->cpfd);
          479  +    sqlite3OsClose(&pPager->cpfd);
   480    480       pPager->ckptOpen = 0;
   481    481     }
   482    482     if( pPager->journalOpen ){
   483         -    sqliteOsClose(&pPager->jfd);
          483  +    sqlite3OsClose(&pPager->jfd);
   484    484       pPager->journalOpen = 0;
   485         -    sqliteOsDelete(pPager->zJournal);
          485  +    sqlite3OsDelete(pPager->zJournal);
   486    486       sqliteFree( pPager->aInJournal );
   487    487       pPager->aInJournal = 0;
   488    488       for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
   489    489         pPg->inJournal = 0;
   490    490         pPg->dirty = 0;
   491    491         pPg->needSync = 0;
   492    492       }
   493    493     }else{
   494    494       assert( pPager->dirtyFile==0 || pPager->useJournal==0 );
   495    495     }
   496         -  rc = sqliteOsReadLock(&pPager->fd);
          496  +  rc = sqlite3OsReadLock(&pPager->fd);
   497    497     if( rc==SQLITE_OK ){
   498    498       pPager->state = SQLITE_READLOCK;
   499    499     }else{
   500    500       /* This can only happen if a process does a BEGIN, then forks and the
   501    501       ** child process does the COMMIT.  Because of the semantics of unix
   502    502       ** file locking, the unlock will fail.
   503    503       */
................................................................................
   529    529     int rc;
   530    530     PgHdr *pPg;              /* An existing page in the cache */
   531    531     PageRecord pgRec;
   532    532     u32 cksum;
   533    533   
   534    534     rc = read32bits(format, jfd, &pgRec.pgno);
   535    535     if( rc!=SQLITE_OK ) return rc;
   536         -  rc = sqliteOsRead(jfd, &pgRec.aData, sizeof(pgRec.aData));
          536  +  rc = sqlite3OsRead(jfd, &pgRec.aData, sizeof(pgRec.aData));
   537    537     if( rc!=SQLITE_OK ) return rc;
   538    538   
   539    539     /* Sanity checking on the page.  This is more important that I originally
   540    540     ** thought.  If a power failure occurs while the journal is being written,
   541    541     ** it could cause invalid data to be written into the journal.  We need to
   542    542     ** detect this invalid data (with high probability) and ignore it.
   543    543     */
................................................................................
   556    556     }
   557    557   
   558    558     /* Playback the page.  Update the in-memory copy of the page
   559    559     ** at the same time, if there is one.
   560    560     */
   561    561     pPg = pager_lookup(pPager, pgRec.pgno);
   562    562     TRACE2("PLAYBACK %d\n", pgRec.pgno);
   563         -  sqliteOsSeek(&pPager->fd, (pgRec.pgno-1)*(off_t)SQLITE_PAGE_SIZE);
   564         -  rc = sqliteOsWrite(&pPager->fd, pgRec.aData, SQLITE_PAGE_SIZE);
          563  +  sqlite3OsSeek(&pPager->fd, (pgRec.pgno-1)*(off_t)SQLITE_PAGE_SIZE);
          564  +  rc = sqlite3OsWrite(&pPager->fd, pgRec.aData, SQLITE_PAGE_SIZE);
   565    565     if( pPg ){
   566    566       /* No page should ever be rolled back that is in use, except for page
   567    567       ** 1 which is held in use in order to keep the lock on the database
   568    568       ** active.
   569    569       */
   570    570       assert( pPg->nRef==0 || pPg->pgno==1 );
   571    571       memcpy(PGHDR_TO_DATA(pPg), pgRec.aData, SQLITE_PAGE_SIZE);
................................................................................
   640    640     unsigned char aMagic[sizeof(aJournalMagic1)];
   641    641     int rc;
   642    642   
   643    643     /* Figure out how many records are in the journal.  Abort early if
   644    644     ** the journal is empty.
   645    645     */
   646    646     assert( pPager->journalOpen );
   647         -  sqliteOsSeek(&pPager->jfd, 0);
   648         -  rc = sqliteOsFileSize(&pPager->jfd, &szJ);
          647  +  sqlite3OsSeek(&pPager->jfd, 0);
          648  +  rc = sqlite3OsFileSize(&pPager->jfd, &szJ);
   649    649     if( rc!=SQLITE_OK ){
   650    650       goto end_playback;
   651    651     }
   652    652   
   653    653     /* If the journal file is too small to contain a complete header,
   654    654     ** it must mean that the process that created the journal was just
   655    655     ** beginning to write the journal file when it died.  In that case,
................................................................................
   659    659     if( szJ < sizeof(aMagic)+sizeof(Pgno) ){
   660    660       goto end_playback;
   661    661     }
   662    662   
   663    663     /* Read the beginning of the journal and truncate the
   664    664     ** database file back to its original size.
   665    665     */
   666         -  rc = sqliteOsRead(&pPager->jfd, aMagic, sizeof(aMagic));
          666  +  rc = sqlite3OsRead(&pPager->jfd, aMagic, sizeof(aMagic));
   667    667     if( rc!=SQLITE_OK ){
   668    668       rc = SQLITE_PROTOCOL;
   669    669       goto end_playback;
   670    670     }
   671    671     if( memcmp(aMagic, aJournalMagic3, sizeof(aMagic))==0 ){
   672    672       format = JOURNAL_FORMAT_3;
   673    673     }else if( memcmp(aMagic, aJournalMagic2, sizeof(aMagic))==0 ){
................................................................................
   700    700       assert( nRec*JOURNAL_PG_SZ(2)+JOURNAL_HDR_SZ(2)==szJ );
   701    701     }
   702    702     rc = read32bits(format, &pPager->jfd, &mxPg);
   703    703     if( rc!=SQLITE_OK ){
   704    704       goto end_playback;
   705    705     }
   706    706     assert( pPager->origDbSize==0 || pPager->origDbSize==mxPg );
   707         -  rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)mxPg);
          707  +  rc = sqlite3OsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)mxPg);
   708    708     if( rc!=SQLITE_OK ){
   709    709       goto end_playback;
   710    710     }
   711    711     pPager->dbSize = mxPg;
   712    712     
   713    713     /* Copy original pages out of the journal and back into the database file.
   714    714     */
................................................................................
   728    728     */
   729    729     if( rc==SQLITE_OK ){
   730    730       PgHdr *pPg;
   731    731       for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
   732    732         char zBuf[SQLITE_PAGE_SIZE];
   733    733         if( !pPg->dirty ) continue;
   734    734         if( (int)pPg->pgno <= pPager->origDbSize ){
   735         -        sqliteOsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1));
   736         -        rc = sqliteOsRead(&pPager->fd, zBuf, SQLITE_PAGE_SIZE);
          735  +        sqlite3OsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1));
          736  +        rc = sqlite3OsRead(&pPager->fd, zBuf, SQLITE_PAGE_SIZE);
   737    737           TRACE2("REFETCH %d\n", pPg->pgno);
   738    738           CODEC(pPager, zBuf, pPg->pgno, 2);
   739    739           if( rc ) break;
   740    740         }else{
   741    741           memset(zBuf, 0, SQLITE_PAGE_SIZE);
   742    742         }
   743    743         if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE) ){
................................................................................
   778    778     off_t szJ;               /* Size of the full journal */
   779    779     int nRec;                /* Number of Records */
   780    780     int i;                   /* Loop counter */
   781    781     int rc;
   782    782   
   783    783     /* Truncate the database back to its original size.
   784    784     */
   785         -  rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)pPager->ckptSize);
          785  +  rc = sqlite3OsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)pPager->ckptSize);
   786    786     pPager->dbSize = pPager->ckptSize;
   787    787   
   788    788     /* Figure out how many records are in the checkpoint journal.
   789    789     */
   790    790     assert( pPager->ckptInUse && pPager->journalOpen );
   791         -  sqliteOsSeek(&pPager->cpfd, 0);
          791  +  sqlite3OsSeek(&pPager->cpfd, 0);
   792    792     nRec = pPager->ckptNRec;
   793    793     
   794    794     /* Copy original pages out of the checkpoint journal and back into the
   795    795     ** database file.  Note that the checkpoint journal always uses format
   796    796     ** 2 instead of format 3 since it does not need to be concerned with
   797    797     ** power failures corrupting the journal and can thus omit the checksums.
   798    798     */
................................................................................
   801    801       assert( rc!=SQLITE_DONE );
   802    802       if( rc!=SQLITE_OK ) goto end_stmt_playback;
   803    803     }
   804    804   
   805    805     /* Figure out how many pages need to be copied out of the transaction
   806    806     ** journal.
   807    807     */
   808         -  rc = sqliteOsSeek(&pPager->jfd, pPager->ckptJSize);
          808  +  rc = sqlite3OsSeek(&pPager->jfd, pPager->ckptJSize);
   809    809     if( rc!=SQLITE_OK ){
   810    810       goto end_stmt_playback;
   811    811     }
   812         -  rc = sqliteOsFileSize(&pPager->jfd, &szJ);
          812  +  rc = sqlite3OsFileSize(&pPager->jfd, &szJ);
   813    813     if( rc!=SQLITE_OK ){
   814    814       goto end_stmt_playback;
   815    815     }
   816    816     nRec = (szJ - pPager->ckptJSize)/JOURNAL_PG_SZ(journal_format);
   817    817     for(i=nRec-1; i>=0; i--){
   818    818       rc = pager_playback_one_page(pPager, &pPager->jfd, journal_format);
   819    819       if( rc!=SQLITE_OK ){
................................................................................
   831    831   }
   832    832   
   833    833   /*
   834    834   ** Change the maximum number of in-memory pages that are allowed.
   835    835   **
   836    836   ** The maximum number is the absolute value of the mxPage parameter.
   837    837   ** If mxPage is negative, the noSync flag is also set.  noSync bypasses
   838         -** calls to sqliteOsSync().  The pager runs much faster with noSync on,
          838  +** calls to sqlite3OsSync().  The pager runs much faster with noSync on,
   839    839   ** but if the operating system crashes or there is an abrupt power 
   840    840   ** failure, the database file might be left in an inconsistent and
   841    841   ** unrepairable state.  
   842    842   */
   843    843   void sqlite3pager_set_cachesize(Pager *pPager, int mxPage){
   844    844     if( mxPage>=0 ){
   845    845       pPager->noSync = pPager->tempFile;
................................................................................
   854    854   }
   855    855   
   856    856   /*
   857    857   ** Adjust the robustness of the database to damage due to OS crashes
   858    858   ** or power failures by changing the number of syncs()s when writing
   859    859   ** the rollback journal.  There are three levels:
   860    860   **
   861         -**    OFF       sqliteOsSync() is never called.  This is the default
          861  +**    OFF       sqlite3OsSync() is never called.  This is the default
   862    862   **              for temporary and transient files.
   863    863   **
   864    864   **    NORMAL    The journal is synced once before writes begin on the
   865    865   **              database.  This is normally adequate protection, but
   866    866   **              it is theoretically possible, though very unlikely,
   867    867   **              that an inopertune power failure could leave the journal
   868    868   **              in a state which would cause damage to the database
................................................................................
   895    895   ** closed.
   896    896   */
   897    897   static int sqlite3pager_opentemp(char *zFile, OsFile *fd){
   898    898     int cnt = 8;
   899    899     int rc;
   900    900     do{
   901    901       cnt--;
   902         -    sqliteOsTempFileName(zFile);
   903         -    rc = sqliteOsOpenExclusive(zFile, fd, 1);
          902  +    sqlite3OsTempFileName(zFile);
          903  +    rc = sqlite3OsOpenExclusive(zFile, fd, 1);
   904    904     }while( cnt>0 && rc!=SQLITE_OK );
   905    905     return rc;
   906    906   }
   907    907   
   908    908   /*
   909    909   ** Create a new page cache and put a pointer to the page cache in *ppPager.
   910    910   ** The file to be cached need not exist.  The file is not locked until
................................................................................
   932    932     char zTemp[SQLITE_TEMPNAME_SIZE];
   933    933   
   934    934     *ppPager = 0;
   935    935     if( sqlite_malloc_failed ){
   936    936       return SQLITE_NOMEM;
   937    937     }
   938    938     if( zFilename && zFilename[0] ){
   939         -    zFullPathname = sqliteOsFullPathname(zFilename);
   940         -    rc = sqliteOsOpenReadWrite(zFullPathname, &fd, &readOnly);
          939  +    zFullPathname = sqlite3OsFullPathname(zFilename);
          940  +    rc = sqlite3OsOpenReadWrite(zFullPathname, &fd, &readOnly);
   941    941       tempFile = 0;
   942    942     }else{
   943    943       rc = sqlite3pager_opentemp(zTemp, &fd);
   944    944       zFilename = zTemp;
   945         -    zFullPathname = sqliteOsFullPathname(zFilename);
          945  +    zFullPathname = sqlite3OsFullPathname(zFilename);
   946    946       tempFile = 1;
   947    947     }
   948    948     if( sqlite_malloc_failed ){
   949    949       return SQLITE_NOMEM;
   950    950     }
   951    951     if( rc!=SQLITE_OK ){
   952    952       sqliteFree(zFullPathname);
   953    953       return SQLITE_CANTOPEN;
   954    954     }
   955    955     nameLen = strlen(zFullPathname);
   956    956     pPager = sqliteMalloc( sizeof(*pPager) + nameLen*3 + 30 );
   957    957     if( pPager==0 ){
   958         -    sqliteOsClose(&fd);
          958  +    sqlite3OsClose(&fd);
   959    959       sqliteFree(zFullPathname);
   960    960       return SQLITE_NOMEM;
   961    961     }
   962    962     SET_PAGER(pPager);
   963    963     pPager->zFilename = (char*)&pPager[1];
   964    964     pPager->zDirectory = &pPager->zFilename[nameLen+1];
   965    965     pPager->zJournal = &pPager->zDirectory[nameLen+1];
................................................................................
  1014   1014   */
  1015   1015   int sqlite3pager_pagecount(Pager *pPager){
  1016   1016     off_t n;
  1017   1017     assert( pPager!=0 );
  1018   1018     if( pPager->dbSize>=0 ){
  1019   1019       return pPager->dbSize;
  1020   1020     }
  1021         -  if( sqliteOsFileSize(&pPager->fd, &n)!=SQLITE_OK ){
         1021  +  if( sqlite3OsFileSize(&pPager->fd, &n)!=SQLITE_OK ){
  1022   1022       pPager->errMask |= PAGER_ERR_DISK;
  1023   1023       return 0;
  1024   1024     }
  1025   1025     n /= SQLITE_PAGE_SIZE;
  1026   1026     if( pPager->state!=SQLITE_UNLOCK ){
  1027   1027       pPager->dbSize = n;
  1028   1028     }
................................................................................
  1046   1046       rc = pager_errcode(pPager);
  1047   1047       return rc;
  1048   1048     }
  1049   1049     if( nPage>=(unsigned)pPager->dbSize ){
  1050   1050       return SQLITE_OK;
  1051   1051     }
  1052   1052     syncJournal(pPager);
  1053         -  rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)nPage);
         1053  +  rc = sqlite3OsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)nPage);
  1054   1054     if( rc==SQLITE_OK ){
  1055   1055       pPager->dbSize = nPage;
  1056   1056     }
  1057   1057     return rc;
  1058   1058   }
  1059   1059   
  1060   1060   /*
................................................................................
  1067   1067   ** result in a coredump.
  1068   1068   */
  1069   1069   int sqlite3pager_close(Pager *pPager){
  1070   1070     PgHdr *pPg, *pNext;
  1071   1071     switch( pPager->state ){
  1072   1072       case SQLITE_WRITELOCK: {
  1073   1073         sqlite3pager_rollback(pPager);
  1074         -      sqliteOsUnlock(&pPager->fd);
         1074  +      sqlite3OsUnlock(&pPager->fd);
  1075   1075         assert( pPager->journalOpen==0 );
  1076   1076         break;
  1077   1077       }
  1078   1078       case SQLITE_READLOCK: {
  1079         -      sqliteOsUnlock(&pPager->fd);
         1079  +      sqlite3OsUnlock(&pPager->fd);
  1080   1080         break;
  1081   1081       }
  1082   1082       default: {
  1083   1083         /* Do nothing */
  1084   1084         break;
  1085   1085       }
  1086   1086     }
  1087   1087     for(pPg=pPager->pAll; pPg; pPg=pNext){
  1088   1088       pNext = pPg->pNextAll;
  1089   1089       sqliteFree(pPg);
  1090   1090     }
  1091         -  sqliteOsClose(&pPager->fd);
         1091  +  sqlite3OsClose(&pPager->fd);
  1092   1092     assert( pPager->journalOpen==0 );
  1093   1093     /* Temp files are automatically deleted by the OS
  1094   1094     ** if( pPager->tempFile ){
  1095         -  **   sqliteOsDelete(pPager->zFilename);
         1095  +  **   sqlite3OsDelete(pPager->zFilename);
  1096   1096     ** }
  1097   1097     */
  1098   1098     CLR_PAGER(pPager);
  1099   1099     if( pPager->zFilename!=(char*)&pPager[1] ){
  1100   1100       assert( 0 );  /* Cannot happen */
  1101   1101       sqliteFree(pPager->zFilename);
  1102   1102       sqliteFree(pPager->zJournal);
................................................................................
  1190   1190         {
  1191   1191           /* Make sure the pPager->nRec counter we are keeping agrees
  1192   1192           ** with the nRec computed from the size of the journal file.
  1193   1193           */
  1194   1194           off_t hdrSz, pgSz, jSz;
  1195   1195           hdrSz = JOURNAL_HDR_SZ(journal_format);
  1196   1196           pgSz = JOURNAL_PG_SZ(journal_format);
  1197         -        rc = sqliteOsFileSize(&pPager->jfd, &jSz);
         1197  +        rc = sqlite3OsFileSize(&pPager->jfd, &jSz);
  1198   1198           if( rc!=0 ) return rc;
  1199   1199           assert( pPager->nRec*pgSz+hdrSz==jSz );
  1200   1200         }
  1201   1201   #endif
  1202   1202         if( journal_format>=3 ){
  1203   1203           /* Write the nRec value into the journal file header */
  1204   1204           off_t szJ;
  1205   1205           if( pPager->fullSync ){
  1206   1206             TRACE1("SYNC\n");
  1207         -          rc = sqliteOsSync(&pPager->jfd);
         1207  +          rc = sqlite3OsSync(&pPager->jfd);
  1208   1208             if( rc!=0 ) return rc;
  1209   1209           }
  1210         -        sqliteOsSeek(&pPager->jfd, sizeof(aJournalMagic1));
         1210  +        sqlite3OsSeek(&pPager->jfd, sizeof(aJournalMagic1));
  1211   1211           rc = write32bits(&pPager->jfd, pPager->nRec);
  1212   1212           if( rc ) return rc;
  1213   1213           szJ = JOURNAL_HDR_SZ(journal_format) +
  1214   1214                    pPager->nRec*JOURNAL_PG_SZ(journal_format);
  1215         -        sqliteOsSeek(&pPager->jfd, szJ);
         1215  +        sqlite3OsSeek(&pPager->jfd, szJ);
  1216   1216         }
  1217   1217         TRACE1("SYNC\n");
  1218         -      rc = sqliteOsSync(&pPager->jfd);
         1218  +      rc = sqlite3OsSync(&pPager->jfd);
  1219   1219         if( rc!=0 ) return rc;
  1220   1220         pPager->journalStarted = 1;
  1221   1221       }
  1222   1222       pPager->needSync = 0;
  1223   1223   
  1224   1224       /* Erase the needSync flag from every page.
  1225   1225       */
................................................................................
  1254   1254     Pager *pPager;
  1255   1255     int rc;
  1256   1256   
  1257   1257     if( pList==0 ) return SQLITE_OK;
  1258   1258     pPager = pList->pPager;
  1259   1259     while( pList ){
  1260   1260       assert( pList->dirty );
  1261         -    sqliteOsSeek(&pPager->fd, (pList->pgno-1)*(off_t)SQLITE_PAGE_SIZE);
         1261  +    sqlite3OsSeek(&pPager->fd, (pList->pgno-1)*(off_t)SQLITE_PAGE_SIZE);
  1262   1262       CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6);
  1263   1263       TRACE2("STORE %d\n", pList->pgno);
  1264         -    rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pList), SQLITE_PAGE_SIZE);
         1264  +    rc = sqlite3OsWrite(&pPager->fd, PGHDR_TO_DATA(pList), SQLITE_PAGE_SIZE);
  1265   1265       CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0);
  1266   1266       if( rc ) return rc;
  1267   1267       pList->dirty = 0;
  1268   1268       pList = pList->pDirty;
  1269   1269     }
  1270   1270     return SQLITE_OK;
  1271   1271   }
................................................................................
  1323   1323       return pager_errcode(pPager);
  1324   1324     }
  1325   1325   
  1326   1326     /* If this is the first page accessed, then get a read lock
  1327   1327     ** on the database file.
  1328   1328     */
  1329   1329     if( pPager->nRef==0 ){
  1330         -    rc = sqliteOsReadLock(&pPager->fd);
         1330  +    rc = sqlite3OsReadLock(&pPager->fd);
  1331   1331       if( rc!=SQLITE_OK ){
  1332   1332         return rc;
  1333   1333       }
  1334   1334       pPager->state = SQLITE_READLOCK;
  1335   1335   
  1336   1336       /* If a journal file exists, try to play it back.
  1337   1337       */
  1338         -    if( pPager->useJournal && sqliteOsFileExists(pPager->zJournal) ){
         1338  +    if( pPager->useJournal && sqlite3OsFileExists(pPager->zJournal) ){
  1339   1339          int rc;
  1340   1340   
  1341   1341          /* Get a write lock on the database
  1342   1342          */
  1343         -       rc = sqliteOsWriteLock(&pPager->fd);
         1343  +       rc = sqlite3OsWriteLock(&pPager->fd);
  1344   1344          if( rc!=SQLITE_OK ){
  1345         -         if( sqliteOsUnlock(&pPager->fd)!=SQLITE_OK ){
         1345  +         if( sqlite3OsUnlock(&pPager->fd)!=SQLITE_OK ){
  1346   1346              /* This should never happen! */
  1347   1347              rc = SQLITE_INTERNAL;
  1348   1348            }
  1349   1349            return rc;
  1350   1350          }
  1351   1351          pPager->state = SQLITE_WRITELOCK;
  1352   1352   
................................................................................
  1354   1354          ** we are unable to open the journal file. 
  1355   1355          **
  1356   1356          ** The journal file does not need to be locked itself.  The
  1357   1357          ** journal file is never open unless the main database file holds
  1358   1358          ** a write lock, so there is never any chance of two or more
  1359   1359          ** processes opening the journal at the same time.
  1360   1360          */
  1361         -       rc = sqliteOsOpenReadOnly(pPager->zJournal, &pPager->jfd);
         1361  +       rc = sqlite3OsOpenReadOnly(pPager->zJournal, &pPager->jfd);
  1362   1362          if( rc!=SQLITE_OK ){
  1363         -         rc = sqliteOsUnlock(&pPager->fd);
         1363  +         rc = sqlite3OsUnlock(&pPager->fd);
  1364   1364            assert( rc==SQLITE_OK );
  1365   1365            return SQLITE_BUSY;
  1366   1366          }
  1367   1367          pPager->journalOpen = 1;
  1368   1368          pPager->journalStarted = 0;
  1369   1369   
  1370   1370          /* Playback and delete the journal.  Drop the database write
................................................................................
  1479   1479           pPager->aHash[h] = pPg->pNextHash;
  1480   1480         }
  1481   1481         pPg->pNextHash = pPg->pPrevHash = 0;
  1482   1482         pPager->nOvfl++;
  1483   1483       }
  1484   1484       pPg->pgno = pgno;
  1485   1485       if( pPager->aInJournal && (int)pgno<=pPager->origDbSize ){
  1486         -      sqliteCheckMemory(pPager->aInJournal, pgno/8);
         1486  +      sqlite3CheckMemory(pPager->aInJournal, pgno/8);
  1487   1487         assert( pPager->journalOpen );
  1488   1488         pPg->inJournal = (pPager->aInJournal[pgno/8] & (1<<(pgno&7)))!=0;
  1489   1489         pPg->needSync = 0;
  1490   1490       }else{
  1491   1491         pPg->inJournal = 0;
  1492   1492         pPg->needSync = 0;
  1493   1493       }
................................................................................
  1517   1517         rc = pager_errcode(pPager);
  1518   1518         return rc;
  1519   1519       }
  1520   1520       if( pPager->dbSize<(int)pgno ){
  1521   1521         memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);
  1522   1522       }else{
  1523   1523         int rc;
  1524         -      sqliteOsSeek(&pPager->fd, (pgno-1)*(off_t)SQLITE_PAGE_SIZE);
  1525         -      rc = sqliteOsRead(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE);
         1524  +      sqlite3OsSeek(&pPager->fd, (pgno-1)*(off_t)SQLITE_PAGE_SIZE);
         1525  +      rc = sqlite3OsRead(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE);
  1526   1526         TRACE2("FETCH %d\n", pPg->pgno);
  1527   1527         CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
  1528   1528         if( rc!=SQLITE_OK ){
  1529   1529           off_t fileSize;
  1530         -        if( sqliteOsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK
         1530  +        if( sqlite3OsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK
  1531   1531                  || fileSize>=pgno*SQLITE_PAGE_SIZE ){
  1532   1532             sqlite3pager_unref(PGHDR_TO_DATA(pPg));
  1533   1533             return rc;
  1534   1534           }else{
  1535   1535             memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);
  1536   1536           }
  1537   1537         }
................................................................................
  1636   1636     int rc;
  1637   1637     assert( pPager->state==SQLITE_WRITELOCK );
  1638   1638     assert( pPager->journalOpen==0 );
  1639   1639     assert( pPager->useJournal );
  1640   1640     sqlite3pager_pagecount(pPager);
  1641   1641     pPager->aInJournal = sqliteMalloc( pPager->dbSize/8 + 1 );
  1642   1642     if( pPager->aInJournal==0 ){
  1643         -    sqliteOsReadLock(&pPager->fd);
         1643  +    sqlite3OsReadLock(&pPager->fd);
  1644   1644       pPager->state = SQLITE_READLOCK;
  1645   1645       return SQLITE_NOMEM;
  1646   1646     }
  1647         -  rc = sqliteOsOpenExclusive(pPager->zJournal, &pPager->jfd,pPager->tempFile);
         1647  +  rc = sqlite3OsOpenExclusive(pPager->zJournal, &pPager->jfd,pPager->tempFile);
  1648   1648     if( rc!=SQLITE_OK ){
  1649   1649       sqliteFree(pPager->aInJournal);
  1650   1650       pPager->aInJournal = 0;
  1651         -    sqliteOsReadLock(&pPager->fd);
         1651  +    sqlite3OsReadLock(&pPager->fd);
  1652   1652       pPager->state = SQLITE_READLOCK;
  1653   1653       return SQLITE_CANTOPEN;
  1654   1654     }
  1655         -  sqliteOsOpenDirectory(pPager->zDirectory, &pPager->jfd);
         1655  +  sqlite3OsOpenDirectory(pPager->zDirectory, &pPager->jfd);
  1656   1656     pPager->journalOpen = 1;
  1657   1657     pPager->journalStarted = 0;
  1658   1658     pPager->needSync = 0;
  1659   1659     pPager->alwaysRollback = 0;
  1660   1660     pPager->nRec = 0;
  1661   1661     if( pPager->errMask!=0 ){
  1662   1662       rc = pager_errcode(pPager);
  1663   1663       return rc;
  1664   1664     }
  1665   1665     pPager->origDbSize = pPager->dbSize;
  1666   1666     if( journal_format==JOURNAL_FORMAT_3 ){
  1667         -    rc = sqliteOsWrite(&pPager->jfd, aJournalMagic3, sizeof(aJournalMagic3));
         1667  +    rc = sqlite3OsWrite(&pPager->jfd, aJournalMagic3, sizeof(aJournalMagic3));
  1668   1668       if( rc==SQLITE_OK ){
  1669   1669         rc = write32bits(&pPager->jfd, pPager->noSync ? 0xffffffff : 0);
  1670   1670       }
  1671   1671       if( rc==SQLITE_OK ){
  1672         -      sqliteRandomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
         1672  +      sqlite3Randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
  1673   1673         rc = write32bits(&pPager->jfd, pPager->cksumInit);
  1674   1674       }
  1675   1675     }else if( journal_format==JOURNAL_FORMAT_2 ){
  1676         -    rc = sqliteOsWrite(&pPager->jfd, aJournalMagic2, sizeof(aJournalMagic2));
         1676  +    rc = sqlite3OsWrite(&pPager->jfd, aJournalMagic2, sizeof(aJournalMagic2));
  1677   1677     }else{
  1678   1678       assert( journal_format==JOURNAL_FORMAT_1 );
  1679         -    rc = sqliteOsWrite(&pPager->jfd, aJournalMagic1, sizeof(aJournalMagic1));
         1679  +    rc = sqlite3OsWrite(&pPager->jfd, aJournalMagic1, sizeof(aJournalMagic1));
  1680   1680     }
  1681   1681     if( rc==SQLITE_OK ){
  1682   1682       rc = write32bits(&pPager->jfd, pPager->dbSize);
  1683   1683     }
  1684   1684     if( pPager->ckptAutoopen && rc==SQLITE_OK ){
  1685   1685       rc = sqlite3pager_stmt_begin(pPager);
  1686   1686     }
................................................................................
  1717   1717     PgHdr *pPg = DATA_TO_PGHDR(pData);
  1718   1718     Pager *pPager = pPg->pPager;
  1719   1719     int rc = SQLITE_OK;
  1720   1720     assert( pPg->nRef>0 );
  1721   1721     assert( pPager->state!=SQLITE_UNLOCK );
  1722   1722     if( pPager->state==SQLITE_READLOCK ){
  1723   1723       assert( pPager->aInJournal==0 );
  1724         -    rc = sqliteOsWriteLock(&pPager->fd);
         1724  +    rc = sqlite3OsWriteLock(&pPager->fd);
  1725   1725       if( rc!=SQLITE_OK ){
  1726   1726         return rc;
  1727   1727       }
  1728   1728       pPager->state = SQLITE_WRITELOCK;
  1729   1729       pPager->dirtyFile = 0;
  1730   1730       TRACE1("TRANSACTION\n");
  1731   1731       if( pPager->useJournal && !pPager->tempFile ){
................................................................................
  1809   1809           store32bits(cksum, pPg, SQLITE_PAGE_SIZE);
  1810   1810           szPg = SQLITE_PAGE_SIZE+8;
  1811   1811         }else{
  1812   1812           szPg = SQLITE_PAGE_SIZE+4;
  1813   1813         }
  1814   1814         store32bits(pPg->pgno, pPg, -4);
  1815   1815         CODEC(pPager, pData, pPg->pgno, 7);
  1816         -      rc = sqliteOsWrite(&pPager->jfd, &((char*)pData)[-4], szPg);
         1816  +      rc = sqlite3OsWrite(&pPager->jfd, &((char*)pData)[-4], szPg);
  1817   1817         TRACE3("JOURNAL %d %d\n", pPg->pgno, pPg->needSync);
  1818   1818         CODEC(pPager, pData, pPg->pgno, 0);
  1819   1819         if( journal_format>=JOURNAL_FORMAT_3 ){
  1820   1820           *(u32*)PGHDR_TO_EXTRA(pPg) = saved;
  1821   1821         }
  1822   1822         if( rc!=SQLITE_OK ){
  1823   1823           sqlite3pager_rollback(pPager);
................................................................................
  1847   1847     ** the checkpoint journal always uses the simplier format 2 that lacks
  1848   1848     ** checksums.  The header is also omitted from the checkpoint journal.
  1849   1849     */
  1850   1850     if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){
  1851   1851       assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize );
  1852   1852       store32bits(pPg->pgno, pPg, -4);
  1853   1853       CODEC(pPager, pData, pPg->pgno, 7);
  1854         -    rc = sqliteOsWrite(&pPager->cpfd, &((char*)pData)[-4], SQLITE_PAGE_SIZE+4);
         1854  +    rc = sqlite3OsWrite(&pPager->cpfd, &((char*)pData)[-4], SQLITE_PAGE_SIZE+4);
  1855   1855       TRACE2("CKPT-JOURNAL %d\n", pPg->pgno);
  1856   1856       CODEC(pPager, pData, pPg->pgno, 0);
  1857   1857       if( rc!=SQLITE_OK ){
  1858   1858         sqlite3pager_rollback(pPager);
  1859   1859         pPager->errMask |= PAGER_ERR_FULL;
  1860   1860         return rc;
  1861   1861       }
................................................................................
  2001   2001       return rc;
  2002   2002     }
  2003   2003     if( pPager->state!=SQLITE_WRITELOCK ){
  2004   2004       return SQLITE_ERROR;
  2005   2005     }
  2006   2006     TRACE1("COMMIT\n");
  2007   2007     if( pPager->dirtyFile==0 ){
  2008         -    /* Exit early (without doing the time-consuming sqliteOsSync() calls)
         2008  +    /* Exit early (without doing the time-consuming sqlite3OsSync() calls)
  2009   2009       ** if there have been no changes to the database file. */
  2010   2010       assert( pPager->needSync==0 );
  2011   2011       rc = pager_unwritelock(pPager);
  2012   2012       pPager->dbSize = -1;
  2013   2013       return rc;
  2014   2014     }
  2015   2015     assert( pPager->journalOpen );
................................................................................
  2016   2016     rc = syncJournal(pPager);
  2017   2017     if( rc!=SQLITE_OK ){
  2018   2018       goto commit_abort;
  2019   2019     }
  2020   2020     pPg = pager_get_all_dirty_pages(pPager);
  2021   2021     if( pPg ){
  2022   2022       rc = pager_write_pagelist(pPg);
  2023         -    if( rc || (!pPager->noSync && sqliteOsSync(&pPager->fd)!=SQLITE_OK) ){
         2023  +    if( rc || (!pPager->noSync && sqlite3OsSync(&pPager->fd)!=SQLITE_OK) ){
  2024   2024         goto commit_abort;
  2025   2025       }
  2026   2026     }
  2027   2027     rc = pager_unwritelock(pPager);
  2028   2028     pPager->dbSize = -1;
  2029   2029     return rc;
  2030   2030   
................................................................................
  2116   2116       pPager->ckptAutoopen = 1;
  2117   2117       return SQLITE_OK;
  2118   2118     }
  2119   2119     assert( pPager->journalOpen );
  2120   2120     assert( !pPager->ckptInUse );
  2121   2121     pPager->aInCkpt = sqliteMalloc( pPager->dbSize/8 + 1 );
  2122   2122     if( pPager->aInCkpt==0 ){
  2123         -    sqliteOsReadLock(&pPager->fd);
         2123  +    sqlite3OsReadLock(&pPager->fd);
  2124   2124       return SQLITE_NOMEM;
  2125   2125     }
  2126   2126   #ifndef NDEBUG
  2127         -  rc = sqliteOsFileSize(&pPager->jfd, &pPager->ckptJSize);
         2127  +  rc = sqlite3OsFileSize(&pPager->jfd, &pPager->ckptJSize);
  2128   2128     if( rc ) goto ckpt_begin_failed;
  2129   2129     assert( pPager->ckptJSize == 
  2130   2130       pPager->nRec*JOURNAL_PG_SZ(journal_format)+JOURNAL_HDR_SZ(journal_format) );
  2131   2131   #endif
  2132   2132     pPager->ckptJSize = pPager->nRec*JOURNAL_PG_SZ(journal_format)
  2133   2133                            + JOURNAL_HDR_SZ(journal_format);
  2134   2134     pPager->ckptSize = pPager->dbSize;
................................................................................
  2151   2151   
  2152   2152   /*
  2153   2153   ** Commit a checkpoint.
  2154   2154   */
  2155   2155   int sqlite3pager_stmt_commit(Pager *pPager){
  2156   2156     if( pPager->ckptInUse ){
  2157   2157       PgHdr *pPg, *pNext;
  2158         -    sqliteOsSeek(&pPager->cpfd, 0);
  2159         -    /* sqliteOsTruncate(&pPager->cpfd, 0); */
         2158  +    sqlite3OsSeek(&pPager->cpfd, 0);
         2159  +    /* sqlite3OsTruncate(&pPager->cpfd, 0); */
  2160   2160       pPager->ckptNRec = 0;
  2161   2161       pPager->ckptInUse = 0;
  2162   2162       sqliteFree( pPager->aInCkpt );
  2163   2163       pPager->aInCkpt = 0;
  2164   2164       for(pPg=pPager->pCkpt; pPg; pPg=pNext){
  2165   2165         pNext = pPg->pNextCkpt;
  2166   2166         assert( pPg->inCkpt );
................................................................................
  2216   2216     for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){
  2217   2217       if( pPg->nRef<=0 ) continue;
  2218   2218       printf("PAGE %3d addr=0x%08x nRef=%d\n", 
  2219   2219          pPg->pgno, (int)PGHDR_TO_DATA(pPg), pPg->nRef);
  2220   2220     }
  2221   2221   }
  2222   2222   #endif
         2223  +
         2224  +
         2225  +

Changes to src/pager.h.

     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 page cache
    13     13   ** subsystem.  The page cache subsystem reads and writes a file a page
    14     14   ** at a time and provides a journal for rollback.
    15     15   **
    16         -** @(#) $Id: pager.h,v 1.27 2004/04/26 14:10:22 drh Exp $
           16  +** @(#) $Id: pager.h,v 1.28 2004/05/08 08:23:30 danielk1977 Exp $
    17     17   */
    18     18   
    19     19   /*
    20     20   ** The size of one page
    21     21   **
    22     22   ** You can change this value to another (reasonable) value you want.
    23     23   ** It need not be a power of two, though the interface to the disk
................................................................................
    99     99   int sqlite3pager_rename(Pager*, const char *zNewName);
   100    100   void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
   101    101   
   102    102   #ifdef SQLITE_TEST
   103    103   void sqlite3pager_refdump(Pager*);
   104    104   int pager3_refinfo_enable;
   105    105   #endif
          106  +
          107  +
          108  +

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.112 2004/02/22 18:40:57 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.113 2004/05/08 08:23:30 danielk1977 Exp $
    18     18   */
    19     19   %token_prefix TK_
    20     20   %token_type {Token}
    21     21   %default_type {Token}
    22     22   %extra_argument {Parse *pParse}
    23     23   %syntax_error {
    24     24     if( pParse->zErrMsg==0 ){
    25     25       if( TOKEN.z[0] ){
    26         -      sqliteErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
           26  +      sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
    27     27       }else{
    28         -      sqliteErrorMsg(pParse, "incomplete SQL statement");
           28  +      sqlite3ErrorMsg(pParse, "incomplete SQL statement");
    29     29       }
    30     30     }
    31     31   }
    32         -%name sqliteParser
           32  +%name sqlite3Parser
    33     33   %include {
    34     34   #include "sqliteInt.h"
    35     35   #include "parse.h"
    36     36   
    37     37   /*
    38     38   ** An instance of this structure holds information about the
    39     39   ** LIMIT clause of a SELECT statement.
................................................................................
    65     65   
    66     66   // Input is a single SQL command
    67     67   input ::= cmdlist.
    68     68   cmdlist ::= cmdlist ecmd.
    69     69   cmdlist ::= ecmd.
    70     70   ecmd ::= explain cmdx SEMI.
    71     71   ecmd ::= SEMI.
    72         -cmdx ::= cmd.           { sqliteExec(pParse); }
    73         -explain ::= EXPLAIN.    { sqliteBeginParse(pParse, 1); }
    74         -explain ::= .           { sqliteBeginParse(pParse, 0); }
           72  +cmdx ::= cmd.           { sqlite3Exec(pParse); }
           73  +explain ::= EXPLAIN.    { sqlite3BeginParse(pParse, 1); }
           74  +explain ::= .           { sqlite3BeginParse(pParse, 0); }
    75     75   
    76     76   ///////////////////// Begin and end transactions. ////////////////////////////
    77     77   //
    78     78   
    79         -cmd ::= BEGIN trans_opt onconf(R).  {sqliteBeginTransaction(pParse,R);}
           79  +cmd ::= BEGIN trans_opt onconf(R).  {sqlite3BeginTransaction(pParse,R);}
    80     80   trans_opt ::= .
    81     81   trans_opt ::= TRANSACTION.
    82     82   trans_opt ::= TRANSACTION nm.
    83         -cmd ::= COMMIT trans_opt.      {sqliteCommitTransaction(pParse);}
    84         -cmd ::= END trans_opt.         {sqliteCommitTransaction(pParse);}
    85         -cmd ::= ROLLBACK trans_opt.    {sqliteRollbackTransaction(pParse);}
           83  +cmd ::= COMMIT trans_opt.      {sqlite3CommitTransaction(pParse);}
           84  +cmd ::= END trans_opt.         {sqlite3CommitTransaction(pParse);}
           85  +cmd ::= ROLLBACK trans_opt.    {sqlite3RollbackTransaction(pParse);}
    86     86   
    87     87   ///////////////////// The CREATE TABLE statement ////////////////////////////
    88     88   //
    89     89   cmd ::= create_table create_table_args.
    90     90   create_table ::= CREATE(X) temp(T) TABLE nm(Y). {
    91         -   sqliteStartTable(pParse,&X,&Y,T,0);
           91  +   sqlite3StartTable(pParse,&X,&Y,T,0);
    92     92   }
    93     93   %type temp {int}
    94     94   temp(A) ::= TEMP.  {A = 1;}
    95     95   temp(A) ::= .      {A = 0;}
    96     96   create_table_args ::= LP columnlist conslist_opt RP(X). {
    97         -  sqliteEndTable(pParse,&X,0);
           97  +  sqlite3EndTable(pParse,&X,0);
    98     98   }
    99     99   create_table_args ::= AS select(S). {
   100         -  sqliteEndTable(pParse,0,S);
   101         -  sqliteSelectDelete(S);
          100  +  sqlite3EndTable(pParse,0,S);
          101  +  sqlite3SelectDelete(S);
   102    102   }
   103    103   columnlist ::= columnlist COMMA column.
   104    104   columnlist ::= column.
   105    105   
   106    106   // About the only information used for a column is the name of the
   107    107   // column.  The type is always just "text".  But the code will accept
   108    108   // an elaborate typename.  Perhaps someday we'll do something with it.
   109    109   //
   110    110   column ::= columnid type carglist. 
   111         -columnid ::= nm(X).                {sqliteAddColumn(pParse,&X);}
          111  +columnid ::= nm(X).                {sqlite3AddColumn(pParse,&X);}
   112    112   
   113    113   // An IDENTIFIER can be a generic identifier, or one of several
   114    114   // keywords.  Any non-standard keyword can also be an identifier.
   115    115   //
   116    116   %type id {Token}
   117    117   id(A) ::= ID(X).         {A = X;}
   118    118   
................................................................................
   153    153   //
   154    154   %type nm {Token}
   155    155   nm(A) ::= ID(X).         {A = X;}
   156    156   nm(A) ::= STRING(X).     {A = X;}
   157    157   nm(A) ::= JOIN_KW(X).    {A = X;}
   158    158   
   159    159   type ::= .
   160         -type ::= typename(X).                    {sqliteAddColumnType(pParse,&X,&X);}
   161         -type ::= typename(X) LP signed RP(Y).    {sqliteAddColumnType(pParse,&X,&Y);}
          160  +type ::= typename(X).                    {sqlite3AddColumnType(pParse,&X,&X);}
          161  +type ::= typename(X) LP signed RP(Y).    {sqlite3AddColumnType(pParse,&X,&Y);}
   162    162   type ::= typename(X) LP signed COMMA signed RP(Y).
   163         -                                         {sqliteAddColumnType(pParse,&X,&Y);}
          163  +                                         {sqlite3AddColumnType(pParse,&X,&Y);}
   164    164   %type typename {Token}
   165    165   typename(A) ::= ids(X).           {A = X;}
   166    166   typename(A) ::= typename(X) ids.  {A = X;}
   167    167   %type signed {int}
   168    168   signed(A) ::= INTEGER(X).         { A = atoi(X.z); }
   169    169   signed(A) ::= PLUS INTEGER(X).    { A = atoi(X.z); }
   170    170   signed(A) ::= MINUS INTEGER(X).   { A = -atoi(X.z); }
   171    171   carglist ::= carglist carg.
   172    172   carglist ::= .
   173    173   carg ::= CONSTRAINT nm ccons.
   174    174   carg ::= ccons.
   175         -carg ::= DEFAULT STRING(X).          {sqliteAddDefaultValue(pParse,&X,0);}
   176         -carg ::= DEFAULT ID(X).              {sqliteAddDefaultValue(pParse,&X,0);}
   177         -carg ::= DEFAULT INTEGER(X).         {sqliteAddDefaultValue(pParse,&X,0);}
   178         -carg ::= DEFAULT PLUS INTEGER(X).    {sqliteAddDefaultValue(pParse,&X,0);}
   179         -carg ::= DEFAULT MINUS INTEGER(X).   {sqliteAddDefaultValue(pParse,&X,1);}
   180         -carg ::= DEFAULT FLOAT(X).           {sqliteAddDefaultValue(pParse,&X,0);}
   181         -carg ::= DEFAULT PLUS FLOAT(X).      {sqliteAddDefaultValue(pParse,&X,0);}
   182         -carg ::= DEFAULT MINUS FLOAT(X).     {sqliteAddDefaultValue(pParse,&X,1);}
          175  +carg ::= DEFAULT STRING(X).          {sqlite3AddDefaultValue(pParse,&X,0);}
          176  +carg ::= DEFAULT ID(X).              {sqlite3AddDefaultValue(pParse,&X,0);}
          177  +carg ::= DEFAULT INTEGER(X).         {sqlite3AddDefaultValue(pParse,&X,0);}
          178  +carg ::= DEFAULT PLUS INTEGER(X).    {sqlite3AddDefaultValue(pParse,&X,0);}
          179  +carg ::= DEFAULT MINUS INTEGER(X).   {sqlite3AddDefaultValue(pParse,&X,1);}
          180  +carg ::= DEFAULT FLOAT(X).           {sqlite3AddDefaultValue(pParse,&X,0);}
          181  +carg ::= DEFAULT PLUS FLOAT(X).      {sqlite3AddDefaultValue(pParse,&X,0);}
          182  +carg ::= DEFAULT MINUS FLOAT(X).     {sqlite3AddDefaultValue(pParse,&X,1);}
   183    183   carg ::= DEFAULT NULL. 
   184    184   
   185    185   // In addition to the type name, we also care about the primary key and
   186    186   // UNIQUE constraints.
   187    187   //
   188    188   ccons ::= NULL onconf.
   189         -ccons ::= NOT NULL onconf(R).               {sqliteAddNotNull(pParse, R);}
   190         -ccons ::= PRIMARY KEY sortorder onconf(R).  {sqliteAddPrimaryKey(pParse,0,R);}
   191         -ccons ::= UNIQUE onconf(R).           {sqliteCreateIndex(pParse,0,0,0,R,0,0);}
          189  +ccons ::= NOT NULL onconf(R).               {sqlite3AddNotNull(pParse, R);}
          190  +ccons ::= PRIMARY KEY sortorder onconf(R).  {sqlite3AddPrimaryKey(pParse,0,R);}
          191  +ccons ::= UNIQUE onconf(R).           {sqlite3CreateIndex(pParse,0,0,0,R,0,0);}
   192    192   ccons ::= CHECK LP expr RP onconf.
   193    193   ccons ::= REFERENCES nm(T) idxlist_opt(TA) refargs(R).
   194         -                                {sqliteCreateForeignKey(pParse,0,&T,TA,R);}
   195         -ccons ::= defer_subclause(D).   {sqliteDeferForeignKey(pParse,D);}
          194  +                                {sqlite3CreateForeignKey(pParse,0,&T,TA,R);}
          195  +ccons ::= defer_subclause(D).   {sqlite3DeferForeignKey(pParse,D);}
   196    196   ccons ::= COLLATE id(C).  {
   197         -   sqliteAddCollateType(pParse, sqliteCollateType(C.z, C.n));
          197  +   sqlite3AddCollateType(pParse, sqlite3CollateType(C.z, C.n));
   198    198   }
   199    199   
   200    200   // The next group of rules parses the arguments to a REFERENCES clause
   201    201   // that determine if the referential integrity checking is deferred or
   202    202   // or immediate and which determine what action to take if a ref-integ
   203    203   // check fails.
   204    204   //
................................................................................
   229    229   conslist_opt ::= .
   230    230   conslist_opt ::= COMMA conslist.
   231    231   conslist ::= conslist COMMA tcons.
   232    232   conslist ::= conslist tcons.
   233    233   conslist ::= tcons.
   234    234   tcons ::= CONSTRAINT nm.
   235    235   tcons ::= PRIMARY KEY LP idxlist(X) RP onconf(R).
   236         -                                             {sqliteAddPrimaryKey(pParse,X,R);}
          236  +                                             {sqlite3AddPrimaryKey(pParse,X,R);}
   237    237   tcons ::= UNIQUE LP idxlist(X) RP onconf(R).
   238         -                                       {sqliteCreateIndex(pParse,0,0,X,R,0,0);}
          238  +                                       {sqlite3CreateIndex(pParse,0,0,X,R,0,0);}
   239    239   tcons ::= CHECK expr onconf.
   240    240   tcons ::= FOREIGN KEY LP idxlist(FA) RP
   241    241             REFERENCES nm(T) idxlist_opt(TA) refargs(R) defer_subclause_opt(D). {
   242         -    sqliteCreateForeignKey(pParse, FA, &T, TA, R);
   243         -    sqliteDeferForeignKey(pParse, D);
          242  +    sqlite3CreateForeignKey(pParse, FA, &T, TA, R);
          243  +    sqlite3DeferForeignKey(pParse, D);
   244    244   }
   245    245   %type defer_subclause_opt {int}
   246    246   defer_subclause_opt(A) ::= .                    {A = 0;}
   247    247   defer_subclause_opt(A) ::= defer_subclause(X).  {A = X;}
   248    248   
   249    249   // The following is a non-standard extension that allows us to declare the
   250    250   // default behavior when there is a constraint conflict.
................................................................................
   260    260   resolvetype(A) ::= ABORT.                    { A = OE_Abort; }
   261    261   resolvetype(A) ::= FAIL.                     { A = OE_Fail; }
   262    262   resolvetype(A) ::= IGNORE.                   { A = OE_Ignore; }
   263    263   resolvetype(A) ::= REPLACE.                  { A = OE_Replace; }
   264    264   
   265    265   ////////////////////////// The DROP TABLE /////////////////////////////////////
   266    266   //
   267         -cmd ::= DROP TABLE nm(X).          {sqliteDropTable(pParse,&X,0);}
          267  +cmd ::= DROP TABLE nm(X).          {sqlite3DropTable(pParse,&X,0);}
   268    268   
   269    269   ///////////////////// The CREATE VIEW statement /////////////////////////////
   270    270   //
   271    271   cmd ::= CREATE(X) temp(T) VIEW nm(Y) AS select(S). {
   272         -  sqliteCreateView(pParse, &X, &Y, S, T);
          272  +  sqlite3CreateView(pParse, &X, &Y, S, T);
   273    273   }
   274    274   cmd ::= DROP VIEW nm(X). {
   275         -  sqliteDropTable(pParse, &X, 1);
          275  +  sqlite3DropTable(pParse, &X, 1);
   276    276   }
   277    277   
   278    278   //////////////////////// The SELECT statement /////////////////////////////////
   279    279   //
   280    280   cmd ::= select(X).  {
   281         -  sqliteSelect(pParse, X, SRT_Callback, 0, 0, 0, 0);
   282         -  sqliteSelectDelete(X);
          281  +  sqlite3Select(pParse, X, SRT_Callback, 0, 0, 0, 0);
          282  +  sqlite3SelectDelete(X);
   283    283   }
   284    284   
   285    285   %type select {Select*}
   286         -%destructor select {sqliteSelectDelete($$);}
          286  +%destructor select {sqlite3SelectDelete($$);}
   287    287   %type oneselect {Select*}
   288         -%destructor oneselect {sqliteSelectDelete($$);}
          288  +%destructor oneselect {sqlite3SelectDelete($$);}
   289    289   
   290    290   select(A) ::= oneselect(X).                      {A = X;}
   291    291   select(A) ::= select(X) multiselect_op(Y) oneselect(Z).  {
   292    292     if( Z ){
   293    293       Z->op = Y;
   294    294       Z->pPrior = X;
   295    295     }
................................................................................
   298    298   %type multiselect_op {int}
   299    299   multiselect_op(A) ::= UNION.      {A = TK_UNION;}
   300    300   multiselect_op(A) ::= UNION ALL.  {A = TK_ALL;}
   301    301   multiselect_op(A) ::= INTERSECT.  {A = TK_INTERSECT;}
   302    302   multiselect_op(A) ::= EXCEPT.     {A = TK_EXCEPT;}
   303    303   oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y)
   304    304                    groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). {
   305         -  A = sqliteSelectNew(W,X,Y,P,Q,Z,D,L.limit,L.offset);
          305  +  A = sqlite3SelectNew(W,X,Y,P,Q,Z,D,L.limit,L.offset);
   306    306   }
   307    307   
   308    308   // The "distinct" nonterminal is true (1) if the DISTINCT keyword is
   309    309   // present and false (0) if it is not.
   310    310   //
   311    311   %type distinct {int}
   312    312   distinct(A) ::= DISTINCT.   {A = 1;}
................................................................................
   315    315   
   316    316   // selcollist is a list of expressions that are to become the return
   317    317   // values of the SELECT statement.  The "*" in statements like
   318    318   // "SELECT * FROM ..." is encoded as a special expression with an
   319    319   // opcode of TK_ALL.
   320    320   //
   321    321   %type selcollist {ExprList*}
   322         -%destructor selcollist {sqliteExprListDelete($$);}
          322  +%destructor selcollist {sqlite3ExprListDelete($$);}
   323    323   %type sclp {ExprList*}
   324         -%destructor sclp {sqliteExprListDelete($$);}
          324  +%destructor sclp {sqlite3ExprListDelete($$);}
   325    325   sclp(A) ::= selcollist(X) COMMA.             {A = X;}
   326    326   sclp(A) ::= .                                {A = 0;}
   327    327   selcollist(A) ::= sclp(P) expr(X) as(Y).     {
   328         -   A = sqliteExprListAppend(P,X,Y.n?&Y:0);
          328  +   A = sqlite3ExprListAppend(P,X,Y.n?&Y:0);
   329    329   }
   330    330   selcollist(A) ::= sclp(P) STAR. {
   331         -  A = sqliteExprListAppend(P, sqliteExpr(TK_ALL, 0, 0, 0), 0);
          331  +  A = sqlite3ExprListAppend(P, sqlite3Expr(TK_ALL, 0, 0, 0), 0);
   332    332   }
   333    333   selcollist(A) ::= sclp(P) nm(X) DOT STAR. {
   334         -  Expr *pRight = sqliteExpr(TK_ALL, 0, 0, 0);
   335         -  Expr *pLeft = sqliteExpr(TK_ID, 0, 0, &X);
   336         -  A = sqliteExprListAppend(P, sqliteExpr(TK_DOT, pLeft, pRight, 0), 0);
          334  +  Expr *pRight = sqlite3Expr(TK_ALL, 0, 0, 0);
          335  +  Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &X);
          336  +  A = sqlite3ExprListAppend(P, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0);
   337    337   }
   338    338   
   339    339   // An option "AS <id>" phrase that can follow one of the expressions that
   340    340   // define the result set, or one of the tables in the FROM clause.
   341    341   //
   342    342   %type as {Token}
   343    343   as(X) ::= AS nm(Y).    { X = Y; }
   344    344   as(X) ::= ids(Y).      { X = Y; }
   345    345   as(X) ::= .            { X.n = 0; }
   346    346   
   347    347   
   348    348   %type seltablist {SrcList*}
   349         -%destructor seltablist {sqliteSrcListDelete($$);}
          349  +%destructor seltablist {sqlite3SrcListDelete($$);}
   350    350   %type stl_prefix {SrcList*}
   351         -%destructor stl_prefix {sqliteSrcListDelete($$);}
          351  +%destructor stl_prefix {sqlite3SrcListDelete($$);}
   352    352   %type from {SrcList*}
   353         -%destructor from {sqliteSrcListDelete($$);}
          353  +%destructor from {sqlite3SrcListDelete($$);}
   354    354   
   355    355   // A complete FROM clause.
   356    356   //
   357    357   from(A) ::= .                                 {A = sqliteMalloc(sizeof(*A));}
   358    358   from(A) ::= FROM seltablist(X).               {A = X;}
   359    359   
   360    360   // "seltablist" is a "Select Table List" - the content of the FROM clause
................................................................................
   362    362   //
   363    363   stl_prefix(A) ::= seltablist(X) joinop(Y).    {
   364    364      A = X;
   365    365      if( A && A->nSrc>0 ) A->a[A->nSrc-1].jointype = Y;
   366    366   }
   367    367   stl_prefix(A) ::= .                           {A = 0;}
   368    368   seltablist(A) ::= stl_prefix(X) nm(Y) dbnm(D) as(Z) on_opt(N) using_opt(U). {
   369         -  A = sqliteSrcListAppend(X,&Y,&D);
   370         -  if( Z.n ) sqliteSrcListAddAlias(A,&Z);
          369  +  A = sqlite3SrcListAppend(X,&Y,&D);
          370  +  if( Z.n ) sqlite3SrcListAddAlias(A,&Z);
   371    371     if( N ){
   372    372       if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
   373         -    else { sqliteExprDelete(N); }
          373  +    else { sqlite3ExprDelete(N); }
   374    374     }
   375    375     if( U ){
   376    376       if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
   377         -    else { sqliteIdListDelete(U); }
          377  +    else { sqlite3IdListDelete(U); }
   378    378     }
   379    379   }
   380    380   seltablist(A) ::= stl_prefix(X) LP seltablist_paren(S) RP
   381    381                     as(Z) on_opt(N) using_opt(U). {
   382         -  A = sqliteSrcListAppend(X,0,0);
          382  +  A = sqlite3SrcListAppend(X,0,0);
   383    383     A->a[A->nSrc-1].pSelect = S;
   384         -  if( Z.n ) sqliteSrcListAddAlias(A,&Z);
          384  +  if( Z.n ) sqlite3SrcListAddAlias(A,&Z);
   385    385     if( N ){
   386    386       if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pOn = N; }
   387         -    else { sqliteExprDelete(N); }
          387  +    else { sqlite3ExprDelete(N); }
   388    388     }
   389    389     if( U ){
   390    390       if( A && A->nSrc>1 ){ A->a[A->nSrc-2].pUsing = U; }
   391         -    else { sqliteIdListDelete(U); }
          391  +    else { sqlite3IdListDelete(U); }
   392    392     }
   393    393   }
   394    394   
   395    395   // A seltablist_paren nonterminal represents anything in a FROM that
   396    396   // is contained inside parentheses.  This can be either a subquery or
   397    397   // a grouping of table and subqueries.
   398    398   //
   399    399   %type seltablist_paren {Select*}
   400         -%destructor seltablist_paren {sqliteSelectDelete($$);}
          400  +%destructor seltablist_paren {sqlite3SelectDelete($$);}
   401    401   seltablist_paren(A) ::= select(S).      {A = S;}
   402    402   seltablist_paren(A) ::= seltablist(F).  {
   403         -   A = sqliteSelectNew(0,F,0,0,0,0,0,-1,0);
          403  +   A = sqlite3SelectNew(0,F,0,0,0,0,0,-1,0);
   404    404   }
   405    405   
   406    406   %type dbnm {Token}
   407    407   dbnm(A) ::= .          {A.z=0; A.n=0;}
   408    408   dbnm(A) ::= DOT nm(X). {A = X;}
   409    409   
   410    410   %type joinop {int}
   411    411   %type joinop2 {int}
   412    412   joinop(X) ::= COMMA.                   { X = JT_INNER; }
   413    413   joinop(X) ::= JOIN.                    { X = JT_INNER; }
   414         -joinop(X) ::= JOIN_KW(A) JOIN.         { X = sqliteJoinType(pParse,&A,0,0); }
   415         -joinop(X) ::= JOIN_KW(A) nm(B) JOIN.   { X = sqliteJoinType(pParse,&A,&B,0); }
          414  +joinop(X) ::= JOIN_KW(A) JOIN.         { X = sqlite3JoinType(pParse,&A,0,0); }
          415  +joinop(X) ::= JOIN_KW(A) nm(B) JOIN.   { X = sqlite3JoinType(pParse,&A,&B,0); }
   416    416   joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.
   417         -                                       { X = sqliteJoinType(pParse,&A,&B,&C); }
          417  +                                       { X = sqlite3JoinType(pParse,&A,&B,&C); }
   418    418   
   419    419   %type on_opt {Expr*}
   420         -%destructor on_opt {sqliteExprDelete($$);}
          420  +%destructor on_opt {sqlite3ExprDelete($$);}
   421    421   on_opt(N) ::= ON expr(E).   {N = E;}
   422    422   on_opt(N) ::= .             {N = 0;}
   423    423   
   424    424   %type using_opt {IdList*}
   425         -%destructor using_opt {sqliteIdListDelete($$);}
          425  +%destructor using_opt {sqlite3IdListDelete($$);}
   426    426   using_opt(U) ::= USING LP idxlist(L) RP.  {U = L;}
   427    427   using_opt(U) ::= .                        {U = 0;}
   428    428   
   429    429   
   430    430   %type orderby_opt {ExprList*}
   431         -%destructor orderby_opt {sqliteExprListDelete($$);}
          431  +%destructor orderby_opt {sqlite3ExprListDelete($$);}
   432    432   %type sortlist {ExprList*}
   433         -%destructor sortlist {sqliteExprListDelete($$);}
          433  +%destructor sortlist {sqlite3ExprListDelete($$);}
   434    434   %type sortitem {Expr*}
   435         -%destructor sortitem {sqliteExprDelete($$);}
          435  +%destructor sortitem {sqlite3ExprDelete($$);}
   436    436   
   437    437   orderby_opt(A) ::= .                          {A = 0;}
   438    438   orderby_opt(A) ::= ORDER BY sortlist(X).      {A = X;}
   439    439   sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). {
   440         -  A = sqliteExprListAppend(X,Y,0);
          440  +  A = sqlite3ExprListAppend(X,Y,0);
   441    441     if( A ) A->a[A->nExpr-1].sortOrder = C+Z;
   442    442   }
   443    443   sortlist(A) ::= sortitem(Y) collate(C) sortorder(Z). {
   444         -  A = sqliteExprListAppend(0,Y,0);
          444  +  A = sqlite3ExprListAppend(0,Y,0);
   445    445     if( A ) A->a[0].sortOrder = C+Z;
   446    446   }
   447    447   sortitem(A) ::= expr(X).   {A = X;}
   448    448   
   449    449   %type sortorder {int}
   450    450   %type collate {int}
   451    451   
   452    452   sortorder(A) ::= ASC.           {A = SQLITE_SO_ASC;}
   453    453   sortorder(A) ::= DESC.          {A = SQLITE_SO_DESC;}
   454    454   sortorder(A) ::= .              {A = SQLITE_SO_ASC;}
   455    455   collate(C) ::= .                {C = SQLITE_SO_UNK;}
   456         -collate(C) ::= COLLATE id(X).   {C = sqliteCollateType(X.z, X.n);}
          456  +collate(C) ::= COLLATE id(X).   {C = sqlite3CollateType(X.z, X.n);}
   457    457   
   458    458   %type groupby_opt {ExprList*}
   459         -%destructor groupby_opt {sqliteExprListDelete($$);}
          459  +%destructor groupby_opt {sqlite3ExprListDelete($$);}
   460    460   groupby_opt(A) ::= .                      {A = 0;}
   461    461   groupby_opt(A) ::= GROUP BY exprlist(X).  {A = X;}
   462    462   
   463    463   %type having_opt {Expr*}
   464         -%destructor having_opt {sqliteExprDelete($$);}
          464  +%destructor having_opt {sqlite3ExprDelete($$);}
   465    465   having_opt(A) ::= .                {A = 0;}
   466    466   having_opt(A) ::= HAVING expr(X).  {A = X;}
   467    467   
   468    468   %type limit_opt {struct LimitVal}
   469    469   limit_opt(A) ::= .                     {A.limit = -1; A.offset = 0;}
   470    470   limit_opt(A) ::= LIMIT signed(X).      {A.limit = X; A.offset = 0;}
   471    471   limit_opt(A) ::= LIMIT signed(X) OFFSET signed(Y). 
................................................................................
   472    472                                          {A.limit = X; A.offset = Y;}
   473    473   limit_opt(A) ::= LIMIT signed(X) COMMA signed(Y). 
   474    474                                          {A.limit = Y; A.offset = X;}
   475    475   
   476    476   /////////////////////////// The DELETE statement /////////////////////////////
   477    477   //
   478    478   cmd ::= DELETE FROM nm(X) dbnm(D) where_opt(Y). {
   479         -   sqliteDeleteFrom(pParse, sqliteSrcListAppend(0,&X,&D), Y);
          479  +   sqlite3DeleteFrom(pParse, sqlite3SrcListAppend(0,&X,&D), Y);
   480    480   }
   481    481   
   482    482   %type where_opt {Expr*}
   483         -%destructor where_opt {sqliteExprDelete($$);}
          483  +%destructor where_opt {sqlite3ExprDelete($$);}
   484    484   
   485    485   where_opt(A) ::= .                    {A = 0;}
   486    486   where_opt(A) ::= WHERE expr(X).       {A = X;}
   487    487   
   488    488   %type setlist {ExprList*}
   489         -%destructor setlist {sqliteExprListDelete($$);}
          489  +%destructor setlist {sqlite3ExprListDelete($$);}
   490    490   
   491    491   ////////////////////////// The UPDATE command ////////////////////////////////
   492    492   //
   493    493   cmd ::= UPDATE orconf(R) nm(X) dbnm(D) SET setlist(Y) where_opt(Z).
   494         -    {sqliteUpdate(pParse,sqliteSrcListAppend(0,&X,&D),Y,Z,R);}
          494  +    {sqlite3Update(pParse,sqlite3SrcListAppend(0,&X,&D),Y,Z,R);}
   495    495   
   496    496   setlist(A) ::= setlist(Z) COMMA nm(X) EQ expr(Y).
   497         -    {A = sqliteExprListAppend(Z,Y,&X);}
   498         -setlist(A) ::= nm(X) EQ expr(Y).   {A = sqliteExprListAppend(0,Y,&X);}
          497  +    {A = sqlite3ExprListAppend(Z,Y,&X);}
          498  +setlist(A) ::= nm(X) EQ expr(Y).   {A = sqlite3ExprListAppend(0,Y,&X);}
   499    499   
   500    500   ////////////////////////// The INSERT command /////////////////////////////////
   501    501   //
   502    502   cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) 
   503    503           VALUES LP itemlist(Y) RP.
   504         -            {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), Y, 0, F, R);}
          504  +            {sqlite3Insert(pParse, sqlite3SrcListAppend(0,&X,&D), Y, 0, F, R);}
   505    505   cmd ::= insert_cmd(R) INTO nm(X) dbnm(D) inscollist_opt(F) select(S).
   506         -            {sqliteInsert(pParse, sqliteSrcListAppend(0,&X,&D), 0, S, F, R);}
          506  +            {sqlite3Insert(pParse, sqlite3SrcListAppend(0,&X,&D), 0, S, F, R);}
   507    507   
   508    508   %type insert_cmd {int}
   509    509   insert_cmd(A) ::= INSERT orconf(R).   {A = R;}
   510    510   insert_cmd(A) ::= REPLACE.            {A = OE_Replace;}
   511    511   
   512    512   
   513    513   %type itemlist {ExprList*}
   514         -%destructor itemlist {sqliteExprListDelete($$);}
          514  +%destructor itemlist {sqlite3ExprListDelete($$);}
   515    515   
   516         -itemlist(A) ::= itemlist(X) COMMA expr(Y).  {A = sqliteExprListAppend(X,Y,0);}
   517         -itemlist(A) ::= expr(X).                    {A = sqliteExprListAppend(0,X,0);}
          516  +itemlist(A) ::= itemlist(X) COMMA expr(Y).  {A = sqlite3ExprListAppend(X,Y,0);}
          517  +itemlist(A) ::= expr(X).                    {A = sqlite3ExprListAppend(0,X,0);}
   518    518   
   519    519   %type inscollist_opt {IdList*}
   520         -%destructor inscollist_opt {sqliteIdListDelete($$);}
          520  +%destructor inscollist_opt {sqlite3IdListDelete($$);}
   521    521   %type inscollist {IdList*}
   522         -%destructor inscollist {sqliteIdListDelete($$);}
          522  +%destructor inscollist {sqlite3IdListDelete($$);}
   523    523   
   524    524   inscollist_opt(A) ::= .                       {A = 0;}
   525    525   inscollist_opt(A) ::= LP inscollist(X) RP.    {A = X;}
   526         -inscollist(A) ::= inscollist(X) COMMA nm(Y).  {A = sqliteIdListAppend(X,&Y);}
   527         -inscollist(A) ::= nm(Y).                      {A = sqliteIdListAppend(0,&Y);}
          526  +inscollist(A) ::= inscollist(X) COMMA nm(Y).  {A = sqlite3IdListAppend(X,&Y);}
          527  +inscollist(A) ::= nm(Y).                      {A = sqlite3IdListAppend(0,&Y);}
   528    528   
   529    529   /////////////////////////// Expression Processing /////////////////////////////
   530    530   //
   531    531   
   532    532   %type expr {Expr*}
   533         -%destructor expr {sqliteExprDelete($$);}
          533  +%destructor expr {sqlite3ExprDelete($$);}
   534    534   
   535         -expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqliteExprSpan(A,&B,&E); }
   536         -expr(A) ::= NULL(X).             {A = sqliteExpr(TK_NULL, 0, 0, &X);}
   537         -expr(A) ::= ID(X).               {A = sqliteExpr(TK_ID, 0, 0, &X);}
   538         -expr(A) ::= JOIN_KW(X).          {A = sqliteExpr(TK_ID, 0, 0, &X);}
          535  +expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqlite3ExprSpan(A,&B,&E); }
          536  +expr(A) ::= NULL(X).             {A = sqlite3Expr(TK_NULL, 0, 0, &X);}
          537  +expr(A) ::= ID(X).               {A = sqlite3Expr(TK_ID, 0, 0, &X);}
          538  +expr(A) ::= JOIN_KW(X).          {A = sqlite3Expr(TK_ID, 0, 0, &X);}
   539    539   expr(A) ::= nm(X) DOT nm(Y). {
   540         -  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
   541         -  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
   542         -  A = sqliteExpr(TK_DOT, temp1, temp2, 0);
          540  +  Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &X);
          541  +  Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &Y);
          542  +  A = sqlite3Expr(TK_DOT, temp1, temp2, 0);
   543    543   }
   544    544   expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
   545         -  Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
   546         -  Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
   547         -  Expr *temp3 = sqliteExpr(TK_ID, 0, 0, &Z);
   548         -  Expr *temp4 = sqliteExpr(TK_DOT, temp2, temp3, 0);
   549         -  A = sqliteExpr(TK_DOT, temp1, temp4, 0);
          545  +  Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &X);
          546  +  Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &Y);
          547  +  Expr *temp3 = sqlite3Expr(TK_ID, 0, 0, &Z);
          548  +  Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0);
          549  +  A = sqlite3Expr(TK_DOT, temp1, temp4, 0);
   550    550   }
   551         -expr(A) ::= INTEGER(X).      {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
   552         -expr(A) ::= FLOAT(X).        {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
   553         -expr(A) ::= STRING(X).       {A = sqliteExpr(TK_STRING, 0, 0, &X);}
          551  +expr(A) ::= INTEGER(X).      {A = sqlite3Expr(TK_INTEGER, 0, 0, &X);}
          552  +expr(A) ::= FLOAT(X).        {A = sqlite3Expr(TK_FLOAT, 0, 0, &X);}
          553  +expr(A) ::= STRING(X).       {A = sqlite3Expr(TK_STRING, 0, 0, &X);}
   554    554   expr(A) ::= VARIABLE(X).     {
   555         -  A = sqliteExpr(TK_VARIABLE, 0, 0, &X);
          555  +  A = sqlite3Expr(TK_VARIABLE, 0, 0, &X);
   556    556     if( A ) A->iTable = ++pParse->nVar;
   557    557   }
   558    558   expr(A) ::= ID(X) LP exprlist(Y) RP(E). {
   559         -  A = sqliteExprFunction(Y, &X);
   560         -  sqliteExprSpan(A,&X,&E);
          559  +  A = sqlite3ExprFunction(Y, &X);
          560  +  sqlite3ExprSpan(A,&X,&E);
   561    561   }
   562    562   expr(A) ::= ID(X) LP STAR RP(E). {
   563         -  A = sqliteExprFunction(0, &X);
   564         -  sqliteExprSpan(A,&X,&E);
          563  +  A = sqlite3ExprFunction(0, &X);
          564  +  sqlite3ExprSpan(A,&X,&E);
   565    565   }
   566         -expr(A) ::= expr(X) AND expr(Y).   {A = sqliteExpr(TK_AND, X, Y, 0);}
   567         -expr(A) ::= expr(X) OR expr(Y).    {A = sqliteExpr(TK_OR, X, Y, 0);}
   568         -expr(A) ::= expr(X) LT expr(Y).    {A = sqliteExpr(TK_LT, X, Y, 0);}
   569         -expr(A) ::= expr(X) GT expr(Y).    {A = sqliteExpr(TK_GT, X, Y, 0);}
   570         -expr(A) ::= expr(X) LE expr(Y).    {A = sqliteExpr(TK_LE, X, Y, 0);}
   571         -expr(A) ::= expr(X) GE expr(Y).    {A = sqliteExpr(TK_GE, X, Y, 0);}
   572         -expr(A) ::= expr(X) NE expr(Y).    {A = sqliteExpr(TK_NE, X, Y, 0);}
   573         -expr(A) ::= expr(X) EQ expr(Y).    {A = sqliteExpr(TK_EQ, X, Y, 0);}
   574         -expr(A) ::= expr(X) BITAND expr(Y). {A = sqliteExpr(TK_BITAND, X, Y, 0);}
   575         -expr(A) ::= expr(X) BITOR expr(Y).  {A = sqliteExpr(TK_BITOR, X, Y, 0);}
   576         -expr(A) ::= expr(X) LSHIFT expr(Y). {A = sqliteExpr(TK_LSHIFT, X, Y, 0);}
   577         -expr(A) ::= expr(X) RSHIFT expr(Y). {A = sqliteExpr(TK_RSHIFT, X, Y, 0);}
          566  +expr(A) ::= expr(X) AND expr(Y).   {A = sqlite3Expr(TK_AND, X, Y, 0);}
          567  +expr(A) ::= expr(X) OR expr(Y).    {A = sqlite3Expr(TK_OR, X, Y, 0);}
          568  +expr(A) ::= expr(X) LT expr(Y).    {A = sqlite3Expr(TK_LT, X, Y, 0);}
          569  +expr(A) ::= expr(X) GT expr(Y).    {A = sqlite3Expr(TK_GT, X, Y, 0);}
          570  +expr(A) ::= expr(X) LE expr(Y).    {A = sqlite3Expr(TK_LE, X, Y, 0);}
          571  +expr(A) ::= expr(X) GE expr(Y).    {A = sqlite3Expr(TK_GE, X, Y, 0);}
          572  +expr(A) ::= expr(X) NE expr(Y).    {A = sqlite3Expr(TK_NE, X, Y, 0);}
          573  +expr(A) ::= expr(X) EQ expr(Y).    {A = sqlite3Expr(TK_EQ, X, Y, 0);}
          574  +expr(A) ::= expr(X) BITAND expr(Y). {A = sqlite3Expr(TK_BITAND, X, Y, 0);}
          575  +expr(A) ::= expr(X) BITOR expr(Y).  {A = sqlite3Expr(TK_BITOR, X, Y, 0);}
          576  +expr(A) ::= expr(X) LSHIFT expr(Y). {A = sqlite3Expr(TK_LSHIFT, X, Y, 0);}
          577  +expr(A) ::= expr(X) RSHIFT expr(Y). {A = sqlite3Expr(TK_RSHIFT, X, Y, 0);}
   578    578   expr(A) ::= expr(X) likeop(OP) expr(Y).  [LIKE]  {
   579         -  ExprList *pList = sqliteExprListAppend(0, Y, 0);
   580         -  pList = sqliteExprListAppend(pList, X, 0);
   581         -  A = sqliteExprFunction(pList, 0);
          579  +  ExprList *pList = sqlite3ExprListAppend(0, Y, 0);
          580  +  pList = sqlite3ExprListAppend(pList, X, 0);
          581  +  A = sqlite3ExprFunction(pList, 0);
   582    582     if( A ) A->op = OP;
   583         -  sqliteExprSpan(A, &X->span, &Y->span);
          583  +  sqlite3ExprSpan(A, &X->span, &Y->span);
   584    584   }
   585    585   expr(A) ::= expr(X) NOT likeop(OP) expr(Y). [LIKE] {
   586         -  ExprList *pList = sqliteExprListAppend(0, Y, 0);
   587         -  pList = sqliteExprListAppend(pList, X, 0);
   588         -  A = sqliteExprFunction(pList, 0);
          586  +  ExprList *pList = sqlite3ExprListAppend(0, Y, 0);
          587  +  pList = sqlite3ExprListAppend(pList, X, 0);
          588  +  A = sqlite3ExprFunction(pList, 0);
   589    589     if( A ) A->op = OP;
   590         -  A = sqliteExpr(TK_NOT, A, 0, 0);
   591         -  sqliteExprSpan(A,&X->span,&Y->span);
          590  +  A = sqlite3Expr(TK_NOT, A, 0, 0);
          591  +  sqlite3ExprSpan(A,&X->span,&Y->span);
   592    592   }
   593    593   %type likeop {int}
   594    594   likeop(A) ::= LIKE. {A = TK_LIKE;}
   595    595   likeop(A) ::= GLOB. {A = TK_GLOB;}
   596         -expr(A) ::= expr(X) PLUS expr(Y).  {A = sqliteExpr(TK_PLUS, X, Y, 0);}
   597         -expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);}
   598         -expr(A) ::= expr(X) STAR expr(Y).  {A = sqliteExpr(TK_STAR, X, Y, 0);}
   599         -expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);}
   600         -expr(A) ::= expr(X) REM expr(Y).   {A = sqliteExpr(TK_REM, X, Y, 0);}
   601         -expr(A) ::= expr(X) CONCAT expr(Y). {A = sqliteExpr(TK_CONCAT, X, Y, 0);}
          596  +expr(A) ::= expr(X) PLUS expr(Y).  {A = sqlite3Expr(TK_PLUS, X, Y, 0);}
          597  +expr(A) ::= expr(X) MINUS expr(Y). {A = sqlite3Expr(TK_MINUS, X, Y, 0);}
          598  +expr(A) ::= expr(X) STAR expr(Y).  {A = sqlite3Expr(TK_STAR, X, Y, 0);}
          599  +expr(A) ::= expr(X) SLASH expr(Y). {A = sqlite3Expr(TK_SLASH, X, Y, 0);}
          600  +expr(A) ::= expr(X) REM expr(Y).   {A = sqlite3Expr(TK_REM, X, Y, 0);}
          601  +expr(A) ::= expr(X) CONCAT expr(Y). {A = sqlite3Expr(TK_CONCAT, X, Y, 0);}
   602    602   expr(A) ::= expr(X) ISNULL(E). {
   603         -  A = sqliteExpr(TK_ISNULL, X, 0, 0);
   604         -  sqliteExprSpan(A,&X->span,&E);
          603  +  A = sqlite3Expr(TK_ISNULL, X, 0, 0);
          604  +  sqlite3ExprSpan(A,&X->span,&E);
   605    605   }
   606    606   expr(A) ::= expr(X) IS NULL(E). {
   607         -  A = sqliteExpr(TK_ISNULL, X, 0, 0);
   608         -  sqliteExprSpan(A,&X->span,&E);
          607  +  A = sqlite3Expr(TK_ISNULL, X, 0, 0);
          608  +  sqlite3ExprSpan(A,&X->span,&E);
   609    609   }
   610    610   expr(A) ::= expr(X) NOTNULL(E). {
   611         -  A = sqliteExpr(TK_NOTNULL, X, 0, 0);
   612         -  sqliteExprSpan(A,&X->span,&E);
          611  +  A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
          612  +  sqlite3ExprSpan(A,&X->span,&E);
   613    613   }
   614    614   expr(A) ::= expr(X) NOT NULL(E). {
   615         -  A = sqliteExpr(TK_NOTNULL, X, 0, 0);
   616         -  sqliteExprSpan(A,&X->span,&E);
          615  +  A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
          616  +  sqlite3ExprSpan(A,&X->span,&E);
   617    617   }
   618    618   expr(A) ::= expr(X) IS NOT NULL(E). {
   619         -  A = sqliteExpr(TK_NOTNULL, X, 0, 0);
   620         -  sqliteExprSpan(A,&X->span,&E);
          619  +  A = sqlite3Expr(TK_NOTNULL, X, 0, 0);
          620  +  sqlite3ExprSpan(A,&X->span,&E);
   621    621   }
   622    622   expr(A) ::= NOT(B) expr(X). {
   623         -  A = sqliteExpr(TK_NOT, X, 0, 0);
   624         -  sqliteExprSpan(A,&B,&X->span);
          623  +  A = sqlite3Expr(TK_NOT, X, 0, 0);
          624  +  sqlite3ExprSpan(A,&B,&X->span);
   625    625   }
   626    626   expr(A) ::= BITNOT(B) expr(X). {
   627         -  A = sqliteExpr(TK_BITNOT, X, 0, 0);
   628         -  sqliteExprSpan(A,&B,&X->span);
          627  +  A = sqlite3Expr(TK_BITNOT, X, 0, 0);
          628  +  sqlite3ExprSpan(A,&B,&X->span);
   629    629   }
   630    630   expr(A) ::= MINUS(B) expr(X). [UMINUS] {
   631         -  A = sqliteExpr(TK_UMINUS, X, 0, 0);
   632         -  sqliteExprSpan(A,&B,&X->span);
          631  +  A = sqlite3Expr(TK_UMINUS, X, 0, 0);
          632  +  sqlite3ExprSpan(A,&B,&X->span);
   633    633   }
   634    634   expr(A) ::= PLUS(B) expr(X). [UPLUS] {
   635         -  A = sqliteExpr(TK_UPLUS, X, 0, 0);
   636         -  sqliteExprSpan(A,&B,&X->span);
          635  +  A = sqlite3Expr(TK_UPLUS, X, 0, 0);
          636  +  sqlite3ExprSpan(A,&B,&X->span);
   637    637   }
   638    638   expr(A) ::= LP(B) select(X) RP(E). {
   639         -  A = sqliteExpr(TK_SELECT, 0, 0, 0);
          639  +  A = sqlite3Expr(TK_SELECT, 0, 0, 0);
   640    640     if( A ) A->pSelect = X;
   641         -  sqliteExprSpan(A,&B,&E);
          641  +  sqlite3ExprSpan(A,&B,&E);
   642    642   }
   643    643   expr(A) ::= expr(W) BETWEEN expr(X) AND expr(Y). {
   644         -  ExprList *pList = sqliteExprListAppend(0, X, 0);
   645         -  pList = sqliteExprListAppend(pList, Y, 0);
   646         -  A = sqliteExpr(TK_BETWEEN, W, 0, 0);
          644  +  ExprList *pList = sqlite3ExprListAppend(0, X, 0);
          645  +  pList = sqlite3ExprListAppend(pList, Y, 0);
          646  +  A = sqlite3Expr(TK_BETWEEN, W, 0, 0);
   647    647     if( A ) A->pList = pList;
   648         -  sqliteExprSpan(A,&W->span,&Y->span);
          648  +  sqlite3ExprSpan(A,&W->span,&Y->span);
   649    649   }
   650    650   expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). {
   651         -  ExprList *pList = sqliteExprListAppend(0, X, 0);
   652         -  pList = sqliteExprListAppend(pList, Y, 0);
   653         -  A = sqliteExpr(TK_BETWEEN, W, 0, 0);
          651  +  ExprList *pList = sqlite3ExprListAppend(0, X, 0);
          652  +  pList = sqlite3ExprListAppend(pList, Y, 0);
          653  +  A = sqlite3Expr(TK_BETWEEN, W, 0, 0);
   654    654     if( A ) A->pList = pList;
   655         -  A = sqliteExpr(TK_NOT, A, 0, 0);
   656         -  sqliteExprSpan(A,&W->span,&Y->span);
          655  +  A = sqlite3Expr(TK_NOT, A, 0, 0);
          656  +  sqlite3ExprSpan(A,&W->span,&Y->span);
   657    657   }
   658    658   expr(A) ::= expr(X) IN LP exprlist(Y) RP(E).  {
   659         -  A = sqliteExpr(TK_IN, X, 0, 0);
          659  +  A = sqlite3Expr(TK_IN, X, 0, 0);
   660    660     if( A ) A->pList = Y;
   661         -  sqliteExprSpan(A,&X->span,&E);
          661  +  sqlite3ExprSpan(A,&X->span,&E);
   662    662   }
   663    663   expr(A) ::= expr(X) IN LP select(Y) RP(E).  {
   664         -  A = sqliteExpr(TK_IN, X, 0, 0);
          664  +  A = sqlite3Expr(TK_IN, X, 0, 0);
   665    665     if( A ) A->pSelect = Y;
   666         -  sqliteExprSpan(A,&X->span,&E);
          666  +  sqlite3ExprSpan(A,&X->span,&E);
   667    667   }
   668    668   expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP(E).  {
   669         -  A = sqliteExpr(TK_IN, X, 0, 0);
          669  +  A = sqlite3Expr(TK_IN, X, 0, 0);
   670    670     if( A ) A->pList = Y;
   671         -  A = sqliteExpr(TK_NOT, A, 0, 0);
   672         -  sqliteExprSpan(A,&X->span,&E);
          671  +  A = sqlite3Expr(TK_NOT, A, 0, 0);
          672  +  sqlite3ExprSpan(A,&X->span,&E);
   673    673   }
   674    674   expr(A) ::= expr(X) NOT IN LP select(Y) RP(E).  {
   675         -  A = sqliteExpr(TK_IN, X, 0, 0);
          675  +  A = sqlite3Expr(TK_IN, X, 0, 0);
   676    676     if( A ) A->pSelect = Y;
   677         -  A = sqliteExpr(TK_NOT, A, 0, 0);
   678         -  sqliteExprSpan(A,&X->span,&E);
          677  +  A = sqlite3Expr(TK_NOT, A, 0, 0);
          678  +  sqlite3ExprSpan(A,&X->span,&E);
   679    679   }
   680    680   expr(A) ::= expr(X) IN nm(Y) dbnm(D). {
   681         -  SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
   682         -  A = sqliteExpr(TK_IN, X, 0, 0);
   683         -  if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
   684         -  sqliteExprSpan(A,&X->span,D.z?&D:&Y);
          681  +  SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
          682  +  A = sqlite3Expr(TK_IN, X, 0, 0);
          683  +  if( A ) A->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,-1,0);
          684  +  sqlite3ExprSpan(A,&X->span,D.z?&D:&Y);
   685    685   }
   686    686   expr(A) ::= expr(X) NOT IN nm(Y) dbnm(D). {
   687         -  SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
   688         -  A = sqliteExpr(TK_IN, X, 0, 0);
   689         -  if( A ) A->pSelect = sqliteSelectNew(0,pSrc,0,0,0,0,0,-1,0);
   690         -  A = sqliteExpr(TK_NOT, A, 0, 0);
   691         -  sqliteExprSpan(A,&X->span,D.z?&D:&Y);
          687  +  SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
          688  +  A = sqlite3Expr(TK_IN, X, 0, 0);
          689  +  if( A ) A->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,-1,0);
          690  +  A = sqlite3Expr(TK_NOT, A, 0, 0);
          691  +  sqlite3ExprSpan(A,&X->span,D.z?&D:&Y);
   692    692   }
   693    693   
   694    694   
   695    695   /* CASE expressions */
   696    696   expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
   697         -  A = sqliteExpr(TK_CASE, X, Z, 0);
          697  +  A = sqlite3Expr(TK_CASE, X, Z, 0);
   698    698     if( A ) A->pList = Y;
   699         -  sqliteExprSpan(A, &C, &E);
          699  +  sqlite3ExprSpan(A, &C, &E);
   700    700   }
   701    701   %type case_exprlist {ExprList*}
   702         -%destructor case_exprlist {sqliteExprListDelete($$);}
          702  +%destructor case_exprlist {sqlite3ExprListDelete($$);}
   703    703   case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
   704         -  A = sqliteExprListAppend(X, Y, 0);
   705         -  A = sqliteExprListAppend(A, Z, 0);
          704  +  A = sqlite3ExprListAppend(X, Y, 0);
          705  +  A = sqlite3ExprListAppend(A, Z, 0);
   706    706   }
   707    707   case_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {
   708         -  A = sqliteExprListAppend(0, Y, 0);
   709         -  A = sqliteExprListAppend(A, Z, 0);
          708  +  A = sqlite3ExprListAppend(0, Y, 0);
          709  +  A = sqlite3ExprListAppend(A, Z, 0);
   710    710   }
   711    711   %type case_else {Expr*}
   712    712   case_else(A) ::=  ELSE expr(X).         {A = X;}
   713    713   case_else(A) ::=  .                     {A = 0;} 
   714    714   %type case_operand {Expr*}
   715    715   case_operand(A) ::= expr(X).            {A = X;} 
   716    716   case_operand(A) ::= .                   {A = 0;} 
   717    717   
   718    718   %type exprlist {ExprList*}
   719         -%destructor exprlist {sqliteExprListDelete($$);}
          719  +%destructor exprlist {sqlite3ExprListDelete($$);}
   720    720   %type expritem {Expr*}
   721         -%destructor expritem {sqliteExprDelete($$);}
          721  +%destructor expritem {sqlite3ExprDelete($$);}
   722    722   
   723    723   exprlist(A) ::= exprlist(X) COMMA expritem(Y). 
   724         -   {A = sqliteExprListAppend(X,Y,0);}
   725         -exprlist(A) ::= expritem(X).            {A = sqliteExprListAppend(0,X,0);}
          724  +   {A = sqlite3ExprListAppend(X,Y,0);}
          725  +exprlist(A) ::= expritem(X).            {A = sqlite3ExprListAppend(0,X,0);}
   726    726   expritem(A) ::= expr(X).                {A = X;}
   727    727   expritem(A) ::= .                       {A = 0;}
   728    728   
   729    729   ///////////////////////////// The CREATE INDEX command ///////////////////////
   730    730   //
   731    731   cmd ::= CREATE(S) uniqueflag(U) INDEX nm(X)
   732    732           ON nm(Y) dbnm(D) LP idxlist(Z) RP(E) onconf(R). {
   733         -  SrcList *pSrc = sqliteSrcListAppend(0, &Y, &D);
          733  +  SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D);
   734    734     if( U!=OE_None ) U = R;
   735    735     if( U==OE_Default) U = OE_Abort;
   736         -  sqliteCreateIndex(pParse, &X, pSrc, Z, U, &S, &E);
          736  +  sqlite3CreateIndex(pParse, &X, pSrc, Z, U, &S, &E);
   737    737   }
   738    738   
   739    739   %type uniqueflag {int}
   740    740   uniqueflag(A) ::= UNIQUE.  { A = OE_Abort; }
   741    741   uniqueflag(A) ::= .        { A = OE_None; }
   742    742   
   743    743   %type idxlist {IdList*}
   744         -%destructor idxlist {sqliteIdListDelete($$);}
          744  +%destructor idxlist {sqlite3IdListDelete($$);}
   745    745   %type idxlist_opt {IdList*}
   746         -%destructor idxlist_opt {sqliteIdListDelete($$);}
          746  +%destructor idxlist_opt {sqlite3IdListDelete($$);}
   747    747   %type idxitem {Token}
   748    748   
   749    749   idxlist_opt(A) ::= .                         {A = 0;}
   750    750   idxlist_opt(A) ::= LP idxlist(X) RP.         {A = X;}
   751         -idxlist(A) ::= idxlist(X) COMMA idxitem(Y).  {A = sqliteIdListAppend(X,&Y);}
   752         -idxlist(A) ::= idxitem(Y).                   {A = sqliteIdListAppend(0,&Y);}
          751  +idxlist(A) ::= idxlist(X) COMMA idxitem(Y).  {A = sqlite3IdListAppend(X,&Y);}
          752  +idxlist(A) ::= idxitem(Y).                   {A = sqlite3IdListAppend(0,&Y);}
   753    753   idxitem(A) ::= nm(X) sortorder.              {A = X;}
   754    754   
   755    755   ///////////////////////////// The DROP INDEX command /////////////////////////
   756    756   //
   757    757   
   758    758   cmd ::= DROP INDEX nm(X) dbnm(Y).   {
   759         -  sqliteDropIndex(pParse, sqliteSrcListAppend(0,&X,&Y));
          759  +  sqlite3DropIndex(pParse, sqlite3SrcListAppend(0,&X,&Y));
   760    760   }
   761    761   
   762    762   
   763    763   ///////////////////////////// The COPY command ///////////////////////////////
   764    764   //
   765    765   cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y) USING DELIMITERS STRING(Z).
   766         -    {sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,&Z,R);}
          766  +    {sqlite3Copy(pParse,sqlite3SrcListAppend(0,&X,&D),&Y,&Z,R);}
   767    767   cmd ::= COPY orconf(R) nm(X) dbnm(D) FROM nm(Y).
   768         -    {sqliteCopy(pParse,sqliteSrcListAppend(0,&X,&D),&Y,0,R);}
          768  +    {sqlite3Copy(pParse,sqlite3SrcListAppend(0,&X,&D),&Y,0,R);}
   769    769   
   770    770   ///////////////////////////// The VACUUM command /////////////////////////////
   771    771   //
   772         -cmd ::= VACUUM.                {sqliteVacuum(pParse,0);}
   773         -cmd ::= VACUUM nm(X).         {sqliteVacuum(pParse,&X);}
          772  +cmd ::= VACUUM.                {sqlite3Vacuum(pParse,0);}
          773  +cmd ::= VACUUM nm(X).         {sqlite3Vacuum(pParse,&X);}
   774    774   
   775    775   ///////////////////////////// The PRAGMA command /////////////////////////////
   776    776   //
   777         -cmd ::= PRAGMA ids(X) EQ nm(Y).         {sqlitePragma(pParse,&X,&Y,0);}
   778         -cmd ::= PRAGMA ids(X) EQ ON(Y).          {sqlitePragma(pParse,&X,&Y,0);}
   779         -cmd ::= PRAGMA ids(X) EQ plus_num(Y).    {sqlitePragma(pParse,&X,&Y,0);}
   780         -cmd ::= PRAGMA ids(X) EQ minus_num(Y).   {sqlitePragma(pParse,&X,&Y,1);}
   781         -cmd ::= PRAGMA ids(X) LP nm(Y) RP.      {sqlitePragma(pParse,&X,&Y,0);}
   782         -cmd ::= PRAGMA ids(X).                   {sqlitePragma(pParse,&X,&X,0);}
          777  +cmd ::= PRAGMA ids(X) EQ nm(Y).         {sqlite3Pragma(pParse,&X,&Y,0);}
          778  +cmd ::= PRAGMA ids(X) EQ ON(Y).          {sqlite3Pragma(pParse,&X,&Y,0);}
          779  +cmd ::= PRAGMA ids(X) EQ plus_num(Y).    {sqlite3Pragma(pParse,&X,&Y,0);}
          780  +cmd ::= PRAGMA ids(X) EQ minus_num(Y).   {sqlite3Pragma(pParse,&X,&Y,1);}
          781  +cmd ::= PRAGMA ids(X) LP nm(Y) RP.      {sqlite3Pragma(pParse,&X,&Y,0);}
          782  +cmd ::= PRAGMA ids(X).                   {sqlite3Pragma(pParse,&X,&X,0);}
   783    783   plus_num(A) ::= plus_opt number(X).   {A = X;}
   784    784   minus_num(A) ::= MINUS number(X).     {A = X;}
   785    785   number(A) ::= INTEGER(X).  {A = X;}
   786    786   number(A) ::= FLOAT(X).    {A = X;}
   787    787   plus_opt ::= PLUS.
   788    788   plus_opt ::= .
   789    789   
   790    790   //////////////////////////// The CREATE TRIGGER command /////////////////////
   791    791   
   792    792   cmd ::= CREATE(A) trigger_decl BEGIN trigger_cmd_list(S) END(Z). {
   793    793     Token all;
   794    794     all.z = A.z;
   795    795     all.n = (Z.z - A.z) + Z.n;
   796         -  sqliteFinishTrigger(pParse, S, &all);
          796  +  sqlite3FinishTrigger(pParse, S, &all);
   797    797   }
   798    798   
   799    799   trigger_decl ::= temp(T) TRIGGER nm(B) trigger_time(C) trigger_event(D)
   800    800                    ON nm(E) dbnm(DB) foreach_clause(F) when_clause(G). {
   801         -  SrcList *pTab = sqliteSrcListAppend(0, &E, &DB);
   802         -  sqliteBeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);
          801  +  SrcList *pTab = sqlite3SrcListAppend(0, &E, &DB);
          802  +  sqlite3BeginTrigger(pParse, &B, C, D.a, D.b, pTab, F, G, T);
   803    803   }
   804    804   
   805    805   %type trigger_time  {int}
   806    806   trigger_time(A) ::= BEFORE.      { A = TK_BEFORE; }
   807    807   trigger_time(A) ::= AFTER.       { A = TK_AFTER;  }
   808    808   trigger_time(A) ::= INSTEAD OF.  { A = TK_INSTEAD;}
   809    809   trigger_time(A) ::= .            { A = TK_BEFORE; }
   810    810   
   811    811   %type trigger_event {struct TrigEvent}
   812         -%destructor trigger_event {sqliteIdListDelete($$.b);}
          812  +%destructor trigger_event {sqlite3IdListDelete($$.b);}
   813    813   trigger_event(A) ::= DELETE. { A.a = TK_DELETE; A.b = 0; }
   814    814   trigger_event(A) ::= INSERT. { A.a = TK_INSERT; A.b = 0; }
   815    815   trigger_event(A) ::= UPDATE. { A.a = TK_UPDATE; A.b = 0;}
   816    816   trigger_event(A) ::= UPDATE OF inscollist(X). {A.a = TK_UPDATE; A.b = X; }
   817    817   
   818    818   %type foreach_clause {int}
   819    819   foreach_clause(A) ::= .                   { A = TK_ROW; }
................................................................................
   821    821   foreach_clause(A) ::= FOR EACH STATEMENT. { A = TK_STATEMENT; }
   822    822   
   823    823   %type when_clause {Expr *}
   824    824   when_clause(A) ::= .             { A = 0; }
   825    825   when_clause(A) ::= WHEN expr(X). { A = X; }
   826    826   
   827    827   %type trigger_cmd_list {TriggerStep *}
   828         -%destructor trigger_cmd_list {sqliteDeleteTriggerStep($$);}
          828  +%destructor trigger_cmd_list {sqlite3DeleteTriggerStep($$);}
   829    829   trigger_cmd_list(A) ::= trigger_cmd(X) SEMI trigger_cmd_list(Y). {
   830    830     X->pNext = Y;
   831    831     A = X;
   832    832   }
   833    833   trigger_cmd_list(A) ::= . { A = 0; }
   834    834   
   835    835   %type trigger_cmd {TriggerStep *}
   836         -%destructor trigger_cmd {sqliteDeleteTriggerStep($$);}
          836  +%destructor trigger_cmd {sqlite3DeleteTriggerStep($$);}
   837    837   // UPDATE 
   838    838   trigger_cmd(A) ::= UPDATE orconf(R) nm(X) SET setlist(Y) where_opt(Z).  
   839         -               { A = sqliteTriggerUpdateStep(&X, Y, Z, R); }
          839  +               { A = sqlite3TriggerUpdateStep(&X, Y, Z, R); }
   840    840   
   841    841   // INSERT
   842    842   trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) 
   843    843     VALUES LP itemlist(Y) RP.  
   844         -{A = sqliteTriggerInsertStep(&X, F, Y, 0, R);}
          844  +{A = sqlite3TriggerInsertStep(&X, F, Y, 0, R);}
   845    845   
   846    846   trigger_cmd(A) ::= insert_cmd(R) INTO nm(X) inscollist_opt(F) select(S).
   847         -               {A = sqliteTriggerInsertStep(&X, F, 0, S, R);}
          847  +               {A = sqlite3TriggerInsertStep(&X, F, 0, S, R);}
   848    848   
   849    849   // DELETE
   850    850   trigger_cmd(A) ::= DELETE FROM nm(X) where_opt(Y).
   851         -               {A = sqliteTriggerDeleteStep(&X, Y);}
          851  +               {A = sqlite3TriggerDeleteStep(&X, Y);}
   852    852   
   853    853   // SELECT
   854         -trigger_cmd(A) ::= select(X).  {A = sqliteTriggerSelectStep(X); }
          854  +trigger_cmd(A) ::= select(X).  {A = sqlite3TriggerSelectStep(X); }
   855    855   
   856    856   // The special RAISE expression that may occur in trigger programs
   857    857   expr(A) ::= RAISE(X) LP IGNORE RP(Y).  {
   858         -  A = sqliteExpr(TK_RAISE, 0, 0, 0); 
          858  +  A = sqlite3Expr(TK_RAISE, 0, 0, 0); 
   859    859     A->iColumn = OE_Ignore;
   860         -  sqliteExprSpan(A, &X, &Y);
          860  +  sqlite3ExprSpan(A, &X, &Y);
   861    861   }
   862    862   expr(A) ::= RAISE(X) LP ROLLBACK COMMA nm(Z) RP(Y).  {
   863         -  A = sqliteExpr(TK_RAISE, 0, 0, &Z); 
          863  +  A = sqlite3Expr(TK_RAISE, 0, 0, &Z); 
   864    864     A->iColumn = OE_Rollback;
   865         -  sqliteExprSpan(A, &X, &Y);
          865  +  sqlite3ExprSpan(A, &X, &Y);
   866    866   }
   867    867   expr(A) ::= RAISE(X) LP ABORT COMMA nm(Z) RP(Y).  {
   868         -  A = sqliteExpr(TK_RAISE, 0, 0, &Z); 
          868  +  A = sqlite3Expr(TK_RAISE, 0, 0, &Z); 
   869    869     A->iColumn = OE_Abort;
   870         -  sqliteExprSpan(A, &X, &Y);
          870  +  sqlite3ExprSpan(A, &X, &Y);
   871    871   }
   872    872   expr(A) ::= RAISE(X) LP FAIL COMMA nm(Z) RP(Y).  {
   873         -  A = sqliteExpr(TK_RAISE, 0, 0, &Z); 
          873  +  A = sqlite3Expr(TK_RAISE, 0, 0, &Z); 
   874    874     A->iColumn = OE_Fail;
   875         -  sqliteExprSpan(A, &X, &Y);
          875  +  sqlite3ExprSpan(A, &X, &Y);
   876    876   }
   877    877   
   878    878   ////////////////////////  DROP TRIGGER statement //////////////////////////////
   879    879   cmd ::= DROP TRIGGER nm(X) dbnm(D). {
   880         -  sqliteDropTrigger(pParse,sqliteSrcListAppend(0,&X,&D));
          880  +  sqlite3DropTrigger(pParse,sqlite3SrcListAppend(0,&X,&D));
   881    881   }
   882    882   
   883    883   //////////////////////// ATTACH DATABASE file AS name /////////////////////////
   884    884   cmd ::= ATTACH database_kw_opt ids(F) AS nm(D) key_opt(K). {
   885         -  sqliteAttach(pParse, &F, &D, &K);
          885  +  sqlite3Attach(pParse, &F, &D, &K);
   886    886   }
   887    887   %type key_opt {Token}
   888    888   key_opt(A) ::= USING ids(X).  { A = X; }
   889    889   key_opt(A) ::= .              { A.z = 0; A.n = 0; }
   890    890   
   891    891   database_kw_opt ::= DATABASE.
   892    892   database_kw_opt ::= .
   893    893   
   894    894   //////////////////////// DETACH DATABASE name /////////////////////////////////
   895    895   cmd ::= DETACH database_kw_opt nm(D). {
   896         -  sqliteDetach(pParse, &D);
          896  +  sqlite3Detach(pParse, &D);
   897    897   }
          898  +
          899  +
          900  +

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.19 2004/04/23 17:04:45 drh Exp $
           14  +** $Id: pragma.c,v 1.20 2004/05/08 08:23:31 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /*
    20     20   ** Interpret the given string as a boolean value.
    21     21   */
................................................................................
    23     23     static char *azTrue[] = { "yes", "on", "true" };
    24     24     int i;
    25     25     if( z[0]==0 ) return 0;
    26     26     if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){
    27     27       return atoi(z);
    28     28     }
    29     29     for(i=0; i<sizeof(azTrue)/sizeof(azTrue[0]); i++){
    30         -    if( sqliteStrICmp(z,azTrue[i])==0 ) return 1;
           30  +    if( sqlite3StrICmp(z,azTrue[i])==0 ) return 1;
    31     31     }
    32     32     return 0;
    33     33   }
    34     34   
    35     35   /*
    36     36   ** Interpret the given string as a safety level.  Return 0 for OFF,
    37     37   ** 1 for ON or NORMAL and 2 for FULL.  Return 1 for an empty or 
    38     38   ** unrecognized string argument.
    39     39   **
    40     40   ** Note that the values returned are one less that the values that
    41         -** should be passed into sqliteBtreeSetSafetyLevel().  The is done
           41  +** should be passed into sqlite3BtreeSetSafetyLevel().  The is done
    42     42   ** to support legacy SQL code.  The safety level used to be boolean
    43     43   ** and older scripts may have used numbers 0 for OFF and 1 for ON.
    44     44   */
    45     45   static int getSafetyLevel(char *z){
    46     46     static const struct {
    47     47       const char *zWord;
    48     48       int val;
................................................................................
    57     57     };
    58     58     int i;
    59     59     if( z[0]==0 ) return 1;
    60     60     if( isdigit(z[0]) || (z[0]=='-' && isdigit(z[1])) ){
    61     61       return atoi(z);
    62     62     }
    63     63     for(i=0; i<sizeof(aKey)/sizeof(aKey[0]); i++){
    64         -    if( sqliteStrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
           64  +    if( sqlite3StrICmp(z,aKey[i].zWord)==0 ) return aKey[i].val;
    65     65     }
    66     66     return 1;
    67     67   }
    68     68   
    69     69   /*
    70     70   ** Interpret the given string as a temp db location. Return 1 for file
    71     71   ** backed temporary databases, 2 for the Red-Black tree in memory database
    72     72   ** and 0 to use the compile-time default.
    73     73   */
    74     74   static int getTempStore(const char *z){
    75     75     if( z[0]>='0' && z[0]<='2' ){
    76     76       return z[0] - '0';
    77         -  }else if( sqliteStrICmp(z, "file")==0 ){
           77  +  }else if( sqlite3StrICmp(z, "file")==0 ){
    78     78       return 1;
    79         -  }else if( sqliteStrICmp(z, "memory")==0 ){
           79  +  }else if( sqlite3StrICmp(z, "memory")==0 ){
    80     80       return 2;
    81     81     }else{
    82     82       return 0;
    83     83     }
    84     84   }
    85     85   
    86     86   /*
................................................................................
    90     90   */
    91     91   static int changeTempStorage(Parse *pParse, const char *zStorageType){
    92     92     int ts = getTempStore(zStorageType);
    93     93     sqlite *db = pParse->db;
    94     94     if( db->temp_store==ts ) return SQLITE_OK;
    95     95     if( db->aDb[1].pBt!=0 ){
    96     96       if( db->flags & SQLITE_InTrans ){
    97         -      sqliteErrorMsg(pParse, "temporary storage cannot be changed "
           97  +      sqlite3ErrorMsg(pParse, "temporary storage cannot be changed "
    98     98           "from within a transaction");
    99     99         return SQLITE_ERROR;
   100    100       }
   101         -    sqliteBtreeClose(db->aDb[1].pBt);
          101  +    sqlite3BtreeClose(db->aDb[1].pBt);
   102    102       db->aDb[1].pBt = 0;
   103         -    sqliteResetInternalSchema(db, 0);
          103  +    sqlite3ResetInternalSchema(db, 0);
   104    104     }
   105    105     db->temp_store = ts;
   106    106     return SQLITE_OK;
   107    107   }
   108    108   
   109    109   /*
   110    110   ** Check to see if zRight and zLeft refer to a pragma that queries
................................................................................
   121    121       { "short_column_names",       SQLITE_ShortColNames },
   122    122       { "show_datatypes",           SQLITE_ReportTypes   },
   123    123       { "count_changes",            SQLITE_CountRows     },
   124    124       { "empty_result_callbacks",   SQLITE_NullCallback  },
   125    125     };
   126    126     int i;
   127    127     for(i=0; i<sizeof(aPragma)/sizeof(aPragma[0]); i++){
   128         -    if( sqliteStrICmp(zLeft, aPragma[i].zName)==0 ){
          128  +    if( sqlite3StrICmp(zLeft, aPragma[i].zName)==0 ){
   129    129         sqlite *db = pParse->db;
   130    130         Vdbe *v;
   131         -      if( strcmp(zLeft,zRight)==0 && (v = sqliteGetVdbe(pParse))!=0 ){
   132         -        sqliteVdbeOp3(v, OP_ColumnName, 0, 1, aPragma[i].zName, P3_STATIC);
   133         -        sqliteVdbeOp3(v, OP_ColumnName, 1, 0, "boolean", P3_STATIC);
   134         -        sqliteVdbeCode(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0,
          131  +      if( strcmp(zLeft,zRight)==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
          132  +        sqlite3VdbeOp3(v, OP_ColumnName, 0, 1, aPragma[i].zName, P3_STATIC);
          133  +        sqlite3VdbeOp3(v, OP_ColumnName, 1, 0, "boolean", P3_STATIC);
          134  +        sqlite3VdbeCode(v, OP_Integer, (db->flags & aPragma[i].mask)!=0, 0,
   135    135                             OP_Callback, 1, 0,
   136    136                             0);
   137    137         }else if( getBoolean(zRight) ){
   138    138           db->flags |= aPragma[i].mask;
   139    139         }else{
   140    140           db->flags &= ~aPragma[i].mask;
   141    141         }
................................................................................
   152    152   **
   153    153   **      PRAGMA id = value
   154    154   **
   155    155   ** The identifier might also be a string.  The value is a string, and
   156    156   ** identifier, or a number.  If minusFlag is true, then the value is
   157    157   ** a number that was preceded by a minus sign.
   158    158   */
   159         -void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
          159  +void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
   160    160     char *zLeft = 0;
   161    161     char *zRight = 0;
   162    162     sqlite *db = pParse->db;
   163         -  Vdbe *v = sqliteGetVdbe(pParse);
          163  +  Vdbe *v = sqlite3GetVdbe(pParse);
   164    164     if( v==0 ) return;
   165    165   
   166    166     zLeft = sqliteStrNDup(pLeft->z, pLeft->n);
   167         -  sqliteDequote(zLeft);
          167  +  sqlite3Dequote(zLeft);
   168    168     if( minusFlag ){
   169    169       zRight = 0;
   170         -    sqliteSetNString(&zRight, "-", 1, pRight->z, pRight->n, 0);
          170  +    sqlite3SetNString(&zRight, "-", 1, pRight->z, pRight->n, 0);
   171    171     }else{
   172    172       zRight = sqliteStrNDup(pRight->z, pRight->n);
   173         -    sqliteDequote(zRight);
          173  +    sqlite3Dequote(zRight);
   174    174     }
   175         -  if( sqliteAuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, 0) ){
          175  +  if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, 0) ){
   176    176       sqliteFree(zLeft);
   177    177       sqliteFree(zRight);
   178    178       return;
   179    179     }
   180    180    
   181    181     /*
   182    182     **  PRAGMA default_cache_size
................................................................................
   190    190     **
   191    191     ** The default cache size is stored in meta-value 2 of page 1 of the
   192    192     ** database file.  The cache size is actually the absolute value of
   193    193     ** this memory location.  The sign of meta-value 2 determines the
   194    194     ** synchronous setting.  A negative value means synchronous is off
   195    195     ** and a positive value means synchronous is on.
   196    196     */
   197         -  if( sqliteStrICmp(zLeft,"default_cache_size")==0 ){
          197  +  if( sqlite3StrICmp(zLeft,"default_cache_size")==0 ){
   198    198       static VdbeOpList getCacheSize[] = {
   199    199         { OP_ReadCookie,  0, 2,        0},
   200    200         { OP_AbsValue,    0, 0,        0},
   201    201         { OP_Dup,         0, 0,        0},
   202    202         { OP_Integer,     0, 0,        0},
   203    203         { OP_Ne,          0, 6,        0},
   204    204         { OP_Integer,     0, 0,        0},  /* 5 */
   205    205         { OP_ColumnName,  0, 1,        "cache_size"},
   206    206         { OP_Callback,    1, 0,        0},
   207    207       };
   208    208       int addr;
   209    209       if( pRight->z==pLeft->z ){
   210         -      addr = sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
   211         -      sqliteVdbeChangeP1(v, addr+5, MAX_PAGES);
          210  +      addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
          211  +      sqlite3VdbeChangeP1(v, addr+5, MAX_PAGES);
   212    212       }else{
   213    213         int size = atoi(zRight);
   214    214         if( size<0 ) size = -size;
   215         -      sqliteBeginWriteOperation(pParse, 0, 0);
   216         -      sqliteVdbeAddOp(v, OP_Integer, size, 0);
   217         -      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2);
   218         -      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0);
   219         -      sqliteVdbeAddOp(v, OP_Ge, 0, addr+3);
   220         -      sqliteVdbeAddOp(v, OP_Negative, 0, 0);
   221         -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2);
   222         -      sqliteEndWriteOperation(pParse);
          215  +      sqlite3BeginWriteOperation(pParse, 0, 0);
          216  +      sqlite3VdbeAddOp(v, OP_Integer, size, 0);
          217  +      sqlite3VdbeAddOp(v, OP_ReadCookie, 0, 2);
          218  +      addr = sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
          219  +      sqlite3VdbeAddOp(v, OP_Ge, 0, addr+3);
          220  +      sqlite3VdbeAddOp(v, OP_Negative, 0, 0);
          221  +      sqlite3VdbeAddOp(v, OP_SetCookie, 0, 2);
          222  +      sqlite3EndWriteOperation(pParse);
   223    223         db->cache_size = db->cache_size<0 ? -size : size;
   224         -      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
          224  +      sqlite3BtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
   225    225       }
   226    226     }else
   227    227   
   228    228     /*
   229    229     **  PRAGMA cache_size
   230    230     **  PRAGMA cache_size=N
   231    231     **
................................................................................
   235    235     ** file itself.  The value returned is the maximum number of
   236    236     ** pages in the page cache.  The second form sets the local
   237    237     ** page cache size value.  It does not change the persistent
   238    238     ** cache size stored on the disk so the cache size will revert
   239    239     ** to its default value when the database is closed and reopened.
   240    240     ** N should be a positive integer.
   241    241     */
   242         -  if( sqliteStrICmp(zLeft,"cache_size")==0 ){
          242  +  if( sqlite3StrICmp(zLeft,"cache_size")==0 ){
   243    243       static VdbeOpList getCacheSize[] = {
   244    244         { OP_ColumnName,  0, 1,        "cache_size"},
   245    245         { OP_Callback,    1, 0,        0},
   246    246       };
   247    247       if( pRight->z==pLeft->z ){
   248    248         int size = db->cache_size;;
   249    249         if( size<0 ) size = -size;
   250         -      sqliteVdbeAddOp(v, OP_Integer, size, 0);
   251         -      sqliteVdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
          250  +      sqlite3VdbeAddOp(v, OP_Integer, size, 0);
          251  +      sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize);
   252    252       }else{
   253    253         int size = atoi(zRight);
   254    254         if( size<0 ) size = -size;
   255    255         if( db->cache_size<0 ) size = -size;
   256    256         db->cache_size = size;
   257         -      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
          257  +      sqlite3BtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
   258    258       }
   259    259     }else
   260    260   
   261    261     /*
   262    262     **  PRAGMA default_synchronous
   263    263     **  PRAGMA default_synchronous=ON|OFF|NORMAL|FULL
   264    264     **
................................................................................
   273    273     ** but a power failure can leave the database in an inconsistent state.
   274    274     ** If synchronous is ON or NORMAL, SQLite will do an fsync() system call to
   275    275     ** make sure data is being written to disk.  The risk of corruption due to
   276    276     ** a power loss in this mode is negligible but non-zero.  If synchronous
   277    277     ** is FULL, extra fsync()s occur to reduce the risk of corruption to near
   278    278     ** zero, but with a write performance penalty.  The default mode is NORMAL.
   279    279     */
   280         -  if( sqliteStrICmp(zLeft,"default_synchronous")==0 ){
          280  +  if( sqlite3StrICmp(zLeft,"default_synchronous")==0 ){
   281    281       static VdbeOpList getSync[] = {
   282    282         { OP_ColumnName,  0, 1,        "synchronous"},
   283    283         { OP_ReadCookie,  0, 3,        0},
   284    284         { OP_Dup,         0, 0,        0},
   285    285         { OP_If,          0, 0,        0},  /* 3 */
   286    286         { OP_ReadCookie,  0, 2,        0},
   287    287         { OP_Integer,     0, 0,        0},
................................................................................
   289    289         { OP_AddImm,      1, 0,        0},
   290    290         { OP_Callback,    1, 0,        0},
   291    291         { OP_Halt,        0, 0,        0},
   292    292         { OP_AddImm,     -1, 0,        0},  /* 10 */
   293    293         { OP_Callback,    1, 0,        0}
   294    294       };
   295    295       if( pRight->z==pLeft->z ){
   296         -      int addr = sqliteVdbeAddOpList(v, ArraySize(getSync), getSync);
   297         -      sqliteVdbeChangeP2(v, addr+3, addr+10);
          296  +      int addr = sqlite3VdbeAddOpList(v, ArraySize(getSync), getSync);
          297  +      sqlite3VdbeChangeP2(v, addr+3, addr+10);
   298    298       }else{
   299    299         int addr;
   300    300         int size = db->cache_size;
   301    301         if( size<0 ) size = -size;
   302         -      sqliteBeginWriteOperation(pParse, 0, 0);
   303         -      sqliteVdbeAddOp(v, OP_ReadCookie, 0, 2);
   304         -      sqliteVdbeAddOp(v, OP_Dup, 0, 0);
   305         -      addr = sqliteVdbeAddOp(v, OP_Integer, 0, 0);
   306         -      sqliteVdbeAddOp(v, OP_Ne, 0, addr+3);
   307         -      sqliteVdbeAddOp(v, OP_AddImm, MAX_PAGES, 0);
   308         -      sqliteVdbeAddOp(v, OP_AbsValue, 0, 0);
          302  +      sqlite3BeginWriteOperation(pParse, 0, 0);
          303  +      sqlite3VdbeAddOp(v, OP_ReadCookie, 0, 2);
          304  +      sqlite3VdbeAddOp(v, OP_Dup, 0, 0);
          305  +      addr = sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
          306  +      sqlite3VdbeAddOp(v, OP_Ne, 0, addr+3);
          307  +      sqlite3VdbeAddOp(v, OP_AddImm, MAX_PAGES, 0);
          308  +      sqlite3VdbeAddOp(v, OP_AbsValue, 0, 0);
   309    309         db->safety_level = getSafetyLevel(zRight)+1;
   310    310         if( db->safety_level==1 ){
   311         -        sqliteVdbeAddOp(v, OP_Negative, 0, 0);
          311  +        sqlite3VdbeAddOp(v, OP_Negative, 0, 0);
   312    312           size = -size;
   313    313         }
   314         -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 2);
   315         -      sqliteVdbeAddOp(v, OP_Integer, db->safety_level, 0);
   316         -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 3);
   317         -      sqliteEndWriteOperation(pParse);
          314  +      sqlite3VdbeAddOp(v, OP_SetCookie, 0, 2);
          315  +      sqlite3VdbeAddOp(v, OP_Integer, db->safety_level, 0);
          316  +      sqlite3VdbeAddOp(v, OP_SetCookie, 0, 3);
          317  +      sqlite3EndWriteOperation(pParse);
   318    318         db->cache_size = size;
   319         -      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
   320         -      sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
          319  +      sqlite3BtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
          320  +      sqlite3BtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
   321    321       }
   322    322     }else
   323    323   
   324    324     /*
   325    325     **   PRAGMA synchronous
   326    326     **   PRAGMA synchronous=OFF|ON|NORMAL|FULL
   327    327     **
   328    328     ** Return or set the local value of the synchronous flag.  Changing
   329    329     ** the local value does not make changes to the disk file and the
   330    330     ** default value will be restored the next time the database is
   331    331     ** opened.
   332    332     */
   333         -  if( sqliteStrICmp(zLeft,"synchronous")==0 ){
          333  +  if( sqlite3StrICmp(zLeft,"synchronous")==0 ){
   334    334       static VdbeOpList getSync[] = {
   335    335         { OP_ColumnName,  0, 1,        "synchronous"},
   336    336         { OP_Callback,    1, 0,        0},
   337    337       };
   338    338       if( pRight->z==pLeft->z ){
   339         -      sqliteVdbeAddOp(v, OP_Integer, db->safety_level-1, 0);
   340         -      sqliteVdbeAddOpList(v, ArraySize(getSync), getSync);
          339  +      sqlite3VdbeAddOp(v, OP_Integer, db->safety_level-1, 0);
          340  +      sqlite3VdbeAddOpList(v, ArraySize(getSync), getSync);
   341    341       }else{
   342    342         int size = db->cache_size;
   343    343         if( size<0 ) size = -size;
   344    344         db->safety_level = getSafetyLevel(zRight)+1;
   345    345         if( db->safety_level==1 ) size = -size;
   346    346         db->cache_size = size;
   347         -      sqliteBtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
   348         -      sqliteBtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
          347  +      sqlite3BtreeSetCacheSize(db->aDb[0].pBt, db->cache_size);
          348  +      sqlite3BtreeSetSafetyLevel(db->aDb[0].pBt, db->safety_level);
   349    349       }
   350    350     }else
   351    351   
   352    352   #ifndef NDEBUG
   353         -  if( sqliteStrICmp(zLeft, "trigger_overhead_test")==0 ){
          353  +  if( sqlite3StrICmp(zLeft, "trigger_overhead_test")==0 ){
   354    354       if( getBoolean(zRight) ){
   355    355         always_code_trigger_setup = 1;
   356    356       }else{
   357    357         always_code_trigger_setup = 0;
   358    358       }
   359    359     }else
   360    360   #endif
   361    361   
   362    362     if( flagPragma(pParse, zLeft, zRight) ){
   363    363       /* The flagPragma() call also generates any necessary code */
   364    364     }else
   365    365   
   366         -  if( sqliteStrICmp(zLeft, "table_info")==0 ){
          366  +  if( sqlite3StrICmp(zLeft, "table_info")==0 ){
   367    367       Table *pTab;
   368         -    pTab = sqliteFindTable(db, zRight, 0);
          368  +    pTab = sqlite3FindTable(db, zRight, 0);
   369    369       if( pTab ){
   370    370         static VdbeOpList tableInfoPreface[] = {
   371    371           { OP_ColumnName,  0, 0,       "cid"},
   372    372           { OP_ColumnName,  1, 0,       "name"},
   373    373           { OP_ColumnName,  2, 0,       "type"},
   374    374           { OP_ColumnName,  3, 0,       "notnull"},
   375    375           { OP_ColumnName,  4, 0,       "dflt_value"},
   376    376           { OP_ColumnName,  5, 1,       "pk"},
   377    377         };
   378    378         int i;
   379         -      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
   380         -      sqliteViewGetColumnNames(pParse, pTab);
          379  +      sqlite3VdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
          380  +      sqlite3ViewGetColumnNames(pParse, pTab);
   381    381         for(i=0; i<pTab->nCol; i++){
   382         -        sqliteVdbeAddOp(v, OP_Integer, i, 0);
   383         -        sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zName, 0);
   384         -        sqliteVdbeOp3(v, OP_String, 0, 0,
          382  +        sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          383  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[i].zName, 0);
          384  +        sqlite3VdbeOp3(v, OP_String, 0, 0,
   385    385              pTab->aCol[i].zType ? pTab->aCol[i].zType : "numeric", 0);
   386         -        sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0);
   387         -        sqliteVdbeOp3(v, OP_String, 0, 0,
          386  +        sqlite3VdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0);
          387  +        sqlite3VdbeOp3(v, OP_String, 0, 0,
   388    388              pTab->aCol[i].zDflt, P3_STATIC);
   389         -        sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].isPrimKey, 0);
   390         -        sqliteVdbeAddOp(v, OP_Callback, 6, 0);
          389  +        sqlite3VdbeAddOp(v, OP_Integer, pTab->aCol[i].isPrimKey, 0);
          390  +        sqlite3VdbeAddOp(v, OP_Callback, 6, 0);
   391    391         }
   392    392       }
   393    393     }else
   394    394   
   395         -  if( sqliteStrICmp(zLeft, "index_info")==0 ){
          395  +  if( sqlite3StrICmp(zLeft, "index_info")==0 ){
   396    396       Index *pIdx;
   397    397       Table *pTab;
   398         -    pIdx = sqliteFindIndex(db, zRight, 0);
          398  +    pIdx = sqlite3FindIndex(db, zRight, 0);
   399    399       if( pIdx ){
   400    400         static VdbeOpList tableInfoPreface[] = {
   401    401           { OP_ColumnName,  0, 0,       "seqno"},
   402    402           { OP_ColumnName,  1, 0,       "cid"},
   403    403           { OP_ColumnName,  2, 1,       "name"},
   404    404         };
   405    405         int i;
   406    406         pTab = pIdx->pTable;
   407         -      sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
          407  +      sqlite3VdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
   408    408         for(i=0; i<pIdx->nColumn; i++){
   409    409           int cnum = pIdx->aiColumn[i];
   410         -        sqliteVdbeAddOp(v, OP_Integer, i, 0);
   411         -        sqliteVdbeAddOp(v, OP_Integer, cnum, 0);
          410  +        sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          411  +        sqlite3VdbeAddOp(v, OP_Integer, cnum, 0);
   412    412           assert( pTab->nCol>cnum );
   413         -        sqliteVdbeOp3(v, OP_String, 0, 0, pTab->aCol[cnum].zName, 0);
   414         -        sqliteVdbeAddOp(v, OP_Callback, 3, 0);
          413  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pTab->aCol[cnum].zName, 0);
          414  +        sqlite3VdbeAddOp(v, OP_Callback, 3, 0);
   415    415         }
   416    416       }
   417    417     }else
   418    418   
   419         -  if( sqliteStrICmp(zLeft, "index_list")==0 ){
          419  +  if( sqlite3StrICmp(zLeft, "index_list")==0 ){
   420    420       Index *pIdx;
   421    421       Table *pTab;
   422         -    pTab = sqliteFindTable(db, zRight, 0);
          422  +    pTab = sqlite3FindTable(db, zRight, 0);
   423    423       if( pTab ){
   424         -      v = sqliteGetVdbe(pParse);
          424  +      v = sqlite3GetVdbe(pParse);
   425    425         pIdx = pTab->pIndex;
   426    426       }
   427    427       if( pTab && pIdx ){
   428    428         int i = 0; 
   429    429         static VdbeOpList indexListPreface[] = {
   430    430           { OP_ColumnName,  0, 0,       "seq"},
   431    431           { OP_ColumnName,  1, 0,       "name"},
   432    432           { OP_ColumnName,  2, 1,       "unique"},
   433    433         };
   434    434   
   435         -      sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
          435  +      sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   436    436         while(pIdx){
   437         -        sqliteVdbeAddOp(v, OP_Integer, i, 0);
   438         -        sqliteVdbeOp3(v, OP_String, 0, 0, pIdx->zName, 0);
   439         -        sqliteVdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0);
   440         -        sqliteVdbeAddOp(v, OP_Callback, 3, 0);
          437  +        sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          438  +        sqlite3VdbeOp3(v, OP_String, 0, 0, pIdx->zName, 0);
          439  +        sqlite3VdbeAddOp(v, OP_Integer, pIdx->onError!=OE_None, 0);
          440  +        sqlite3VdbeAddOp(v, OP_Callback, 3, 0);
   441    441           ++i;
   442    442           pIdx = pIdx->pNext;
   443    443         }
   444    444       }
   445    445     }else
   446    446   
   447         -  if( sqliteStrICmp(zLeft, "foreign_key_list")==0 ){
          447  +  if( sqlite3StrICmp(zLeft, "foreign_key_list")==0 ){
   448    448       FKey *pFK;
   449    449       Table *pTab;
   450         -    pTab = sqliteFindTable(db, zRight, 0);
          450  +    pTab = sqlite3FindTable(db, zRight, 0);
   451    451       if( pTab ){
   452         -      v = sqliteGetVdbe(pParse);
          452  +      v = sqlite3GetVdbe(pParse);
   453    453         pFK = pTab->pFKey;
   454    454       }
   455    455       if( pTab && pFK ){
   456    456         int i = 0; 
   457    457         static VdbeOpList indexListPreface[] = {
   458    458           { OP_ColumnName,  0, 0,       "id"},
   459    459           { OP_ColumnName,  1, 0,       "seq"},
   460    460           { OP_ColumnName,  2, 0,       "table"},
   461    461           { OP_ColumnName,  3, 0,       "from"},
   462    462           { OP_ColumnName,  4, 1,       "to"},
   463    463         };
   464    464   
   465         -      sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
          465  +      sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   466    466         while(pFK){
   467    467           int j;
   468    468           for(j=0; j<pFK->nCol; j++){
   469         -          sqliteVdbeAddOp(v, OP_Integer, i, 0);
   470         -          sqliteVdbeAddOp(v, OP_Integer, j, 0);
   471         -          sqliteVdbeOp3(v, OP_String, 0, 0, pFK->zTo, 0);
   472         -          sqliteVdbeOp3(v, OP_String, 0, 0,
          469  +          sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          470  +          sqlite3VdbeAddOp(v, OP_Integer, j, 0);
          471  +          sqlite3VdbeOp3(v, OP_String, 0, 0, pFK->zTo, 0);
          472  +          sqlite3VdbeOp3(v, OP_String, 0, 0,
   473    473                              pTab->aCol[pFK->aCol[j].iFrom].zName, 0);
   474         -          sqliteVdbeOp3(v, OP_String, 0, 0, pFK->aCol[j].zCol, 0);
   475         -          sqliteVdbeAddOp(v, OP_Callback, 5, 0);
          474  +          sqlite3VdbeOp3(v, OP_String, 0, 0, pFK->aCol[j].zCol, 0);
          475  +          sqlite3VdbeAddOp(v, OP_Callback, 5, 0);
   476    476           }
   477    477           ++i;
   478    478           pFK = pFK->pNextFrom;
   479    479         }
   480    480       }
   481    481     }else
   482    482   
   483         -  if( sqliteStrICmp(zLeft, "database_list")==0 ){
          483  +  if( sqlite3StrICmp(zLeft, "database_list")==0 ){
   484    484       int i;
   485    485       static VdbeOpList indexListPreface[] = {
   486    486         { OP_ColumnName,  0, 0,       "seq"},
   487    487         { OP_ColumnName,  1, 0,       "name"},
   488    488         { OP_ColumnName,  2, 1,       "file"},
   489    489       };
   490    490   
   491         -    sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
          491  +    sqlite3VdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
   492    492       for(i=0; i<db->nDb; i++){
   493    493         if( db->aDb[i].pBt==0 ) continue;
   494    494         assert( db->aDb[i].zName!=0 );
   495         -      sqliteVdbeAddOp(v, OP_Integer, i, 0);
   496         -      sqliteVdbeOp3(v, OP_String, 0, 0, db->aDb[i].zName, 0);
   497         -      sqliteVdbeOp3(v, OP_String, 0, 0,
   498         -           sqliteBtreeGetFilename(db->aDb[i].pBt), 0);
   499         -      sqliteVdbeAddOp(v, OP_Callback, 3, 0);
          495  +      sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          496  +      sqlite3VdbeOp3(v, OP_String, 0, 0, db->aDb[i].zName, 0);
          497  +      sqlite3VdbeOp3(v, OP_String, 0, 0,
          498  +           sqlite3BtreeGetFilename(db->aDb[i].pBt), 0);
          499  +      sqlite3VdbeAddOp(v, OP_Callback, 3, 0);
   500    500       }
   501    501     }else
   502    502   
   503    503   
   504    504     /*
   505    505     **   PRAGMA temp_store
   506    506     **   PRAGMA temp_store = "default"|"memory"|"file"
................................................................................
   508    508     ** Return or set the local value of the temp_store flag.  Changing
   509    509     ** the local value does not make changes to the disk file and the default
   510    510     ** value will be restored the next time the database is opened.
   511    511     **
   512    512     ** Note that it is possible for the library compile-time options to
   513    513     ** override this setting
   514    514     */
   515         -  if( sqliteStrICmp(zLeft, "temp_store")==0 ){
          515  +  if( sqlite3StrICmp(zLeft, "temp_store")==0 ){
   516    516       static VdbeOpList getTmpDbLoc[] = {
   517    517         { OP_ColumnName,  0, 1,        "temp_store"},
   518    518         { OP_Callback,    1, 0,        0},
   519    519       };
   520    520       if( pRight->z==pLeft->z ){
   521         -      sqliteVdbeAddOp(v, OP_Integer, db->temp_store, 0);
   522         -      sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
          521  +      sqlite3VdbeAddOp(v, OP_Integer, db->temp_store, 0);
          522  +      sqlite3VdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
   523    523       }else{
   524    524         changeTempStorage(pParse, zRight);
   525    525       }
   526    526     }else
   527    527   
   528    528     /*
   529    529     **   PRAGMA default_temp_store
................................................................................
   532    532     ** Return or set the value of the persistent temp_store flag.  Any
   533    533     ** change does not take effect until the next time the database is
   534    534     ** opened.
   535    535     **
   536    536     ** Note that it is possible for the library compile-time options to
   537    537     ** override this setting
   538    538     */
   539         -  if( sqliteStrICmp(zLeft, "default_temp_store")==0 ){
          539  +  if( sqlite3StrICmp(zLeft, "default_temp_store")==0 ){
   540    540       static VdbeOpList getTmpDbLoc[] = {
   541    541         { OP_ColumnName,  0, 1,        "temp_store"},
   542    542         { OP_ReadCookie,  0, 5,        0},
   543    543         { OP_Callback,    1, 0,        0}};
   544    544       if( pRight->z==pLeft->z ){
   545         -      sqliteVdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
          545  +      sqlite3VdbeAddOpList(v, ArraySize(getTmpDbLoc), getTmpDbLoc);
   546    546       }else{
   547         -      sqliteBeginWriteOperation(pParse, 0, 0);
   548         -      sqliteVdbeAddOp(v, OP_Integer, getTempStore(zRight), 0);
   549         -      sqliteVdbeAddOp(v, OP_SetCookie, 0, 5);
   550         -      sqliteEndWriteOperation(pParse);
          547  +      sqlite3BeginWriteOperation(pParse, 0, 0);
          548  +      sqlite3VdbeAddOp(v, OP_Integer, getTempStore(zRight), 0);
          549  +      sqlite3VdbeAddOp(v, OP_SetCookie, 0, 5);
          550  +      sqlite3EndWriteOperation(pParse);
   551    551       }
   552    552     }else
   553    553   
   554    554   #ifndef NDEBUG
   555         -  if( sqliteStrICmp(zLeft, "parser_trace")==0 ){
   556         -    extern void sqliteParserTrace(FILE*, char *);
          555  +  if( sqlite3StrICmp(zLeft, "parser_trace")==0 ){
          556  +    extern void sqlite3ParserTrace(FILE*, char *);
   557    557       if( getBoolean(zRight) ){
   558         -      sqliteParserTrace(stdout, "parser: ");
          558  +      sqlite3ParserTrace(stdout, "parser: ");
   559    559       }else{
   560         -      sqliteParserTrace(0, 0);
          560  +      sqlite3ParserTrace(0, 0);
   561    561       }
   562    562     }else
   563    563   #endif
   564    564   
   565         -  if( sqliteStrICmp(zLeft, "integrity_check")==0 ){
          565  +  if( sqlite3StrICmp(zLeft, "integrity_check")==0 ){
   566    566       int i, j, addr;
   567    567   
   568    568       /* Code that initializes the integrity check program.  Set the
   569    569       ** error count 0
   570    570       */
   571    571       static VdbeOpList initCode[] = {
   572    572         { OP_Integer,     0, 0,        0},
................................................................................
   606    606         { OP_Integer,     0, 0,        0},
   607    607         { OP_Ne,          0, 0,        0},    /* 2 */
   608    608         { OP_String,      0, 0,        "ok"},
   609    609         { OP_Callback,    1, 0,        0},
   610    610       };
   611    611   
   612    612       /* Initialize the VDBE program */
   613         -    sqliteVdbeAddOpList(v, ArraySize(initCode), initCode);
          613  +    sqlite3VdbeAddOpList(v, ArraySize(initCode), initCode);
   614    614   
   615    615       /* Do an integrity check on each database file */
   616    616       for(i=0; i<db->nDb; i++){
   617    617         HashElem *x;
   618    618   
   619    619         /* Do an integrity check of the B-Tree
   620    620         */
   621         -      addr = sqliteVdbeAddOpList(v, ArraySize(checkDb), checkDb);
   622         -      sqliteVdbeChangeP1(v, addr+1, i);
   623         -      sqliteVdbeChangeP2(v, addr+3, addr+7);
   624         -      sqliteVdbeChangeP2(v, addr+6, addr+4);
   625         -      sqliteVdbeChangeP2(v, addr+7, i);
   626         -      sqliteVdbeChangeP2(v, addr+10, addr+ArraySize(checkDb));
   627         -      sqliteVdbeChangeP3(v, addr+13, db->aDb[i].zName, P3_STATIC);
          621  +      addr = sqlite3VdbeAddOpList(v, ArraySize(checkDb), checkDb);
          622  +      sqlite3VdbeChangeP1(v, addr+1, i);
          623  +      sqlite3VdbeChangeP2(v, addr+3, addr+7);
          624  +      sqlite3VdbeChangeP2(v, addr+6, addr+4);
          625  +      sqlite3VdbeChangeP2(v, addr+7, i);
          626  +      sqlite3VdbeChangeP2(v, addr+10, addr+ArraySize(checkDb));
          627  +      sqlite3VdbeChangeP3(v, addr+13, db->aDb[i].zName, P3_STATIC);
   628    628   
   629    629         /* Make sure all the indices are constructed correctly.
   630    630         */
   631         -      sqliteCodeVerifySchema(pParse, i);
          631  +      sqlite3CodeVerifySchema(pParse, i);
   632    632         for(x=sqliteHashFirst(&db->aDb[i].tblHash); x; x=sqliteHashNext(x)){
   633    633           Table *pTab = sqliteHashData(x);
   634    634           Index *pIdx;
   635    635           int loopTop;
   636    636   
   637    637           if( pTab->pIndex==0 ) continue;
   638         -        sqliteVdbeAddOp(v, OP_Integer, i, 0);
   639         -        sqliteVdbeOp3(v, OP_OpenRead, 1, pTab->tnum, pTab->zName, 0);
          638  +        sqlite3VdbeAddOp(v, OP_Integer, i, 0);
          639  +        sqlite3VdbeOp3(v, OP_OpenRead, 1, pTab->tnum, pTab->zName, 0);
   640    640           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
   641    641             if( pIdx->tnum==0 ) continue;
   642         -          sqliteVdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
   643         -          sqliteVdbeOp3(v, OP_OpenRead, j+2, pIdx->tnum, pIdx->zName, 0);
          642  +          sqlite3VdbeAddOp(v, OP_Integer, pIdx->iDb, 0);
          643  +          sqlite3VdbeOp3(v, OP_OpenRead, j+2, pIdx->tnum, pIdx->zName, 0);
   644    644           }
   645         -        sqliteVdbeAddOp(v, OP_Integer, 0, 0);
   646         -        sqliteVdbeAddOp(v, OP_MemStore, 1, 1);
   647         -        loopTop = sqliteVdbeAddOp(v, OP_Rewind, 1, 0);
   648         -        sqliteVdbeAddOp(v, OP_MemIncr, 1, 0);
          645  +        sqlite3VdbeAddOp(v, OP_Integer, 0, 0);
          646  +        sqlite3VdbeAddOp(v, OP_MemStore, 1, 1);
          647  +        loopTop = sqlite3VdbeAddOp(v, OP_Rewind, 1, 0);
          648  +        sqlite3VdbeAddOp(v, OP_MemIncr, 1, 0);
   649    649           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
   650    650             int k, jmp2;
   651    651             static VdbeOpList idxErr[] = {
   652    652               { OP_MemIncr,     0,  0,  0},
   653    653               { OP_String,      0,  0,  "rowid "},
   654    654               { OP_Recno,       1,  0,  0},
   655    655               { OP_String,      0,  0,  " missing from index "},
   656    656               { OP_String,      0,  0,  0},    /* 4 */
   657    657               { OP_Concat,      4,  0,  0},
   658    658               { OP_Callback,    1,  0,  0},
   659    659             };
   660         -          sqliteVdbeAddOp(v, OP_Recno, 1, 0);
          660  +          sqlite3VdbeAddOp(v, OP_Recno, 1, 0);
   661    661             for(k=0; k<pIdx->nColumn; k++){
   662    662               int idx = pIdx->aiColumn[k];
   663    663               if( idx==pTab->iPKey ){
   664         -              sqliteVdbeAddOp(v, OP_Recno, 1, 0);
          664  +              sqlite3VdbeAddOp(v, OP_Recno, 1, 0);
   665    665               }else{
   666         -              sqliteVdbeAddOp(v, OP_Column, 1, idx);
          666  +              sqlite3VdbeAddOp(v, OP_Column, 1, idx);
   667    667               }
   668    668             }
   669         -          sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
   670         -          if( db->file_format>=4 ) sqliteAddIdxKeyType(v, pIdx);
   671         -          jmp2 = sqliteVdbeAddOp(v, OP_Found, j+2, 0);
   672         -          addr = sqliteVdbeAddOpList(v, ArraySize(idxErr), idxErr);
   673         -          sqliteVdbeChangeP3(v, addr+4, pIdx->zName, P3_STATIC);
   674         -          sqliteVdbeChangeP2(v, jmp2, sqliteVdbeCurrentAddr(v));
          669  +          sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
          670  +          if( db->file_format>=4 ) sqlite3AddIdxKeyType(v, pIdx);
          671  +          jmp2 = sqlite3VdbeAddOp(v, OP_Found, j+2, 0);
          672  +          addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr);
          673  +          sqlite3VdbeChangeP3(v, addr+4, pIdx->zName, P3_STATIC);
          674  +          sqlite3VdbeChangeP2(v, jmp2, sqlite3VdbeCurrentAddr(v));
   675    675           }
   676         -        sqliteVdbeAddOp(v, OP_Next, 1, loopTop+1);
   677         -        sqliteVdbeChangeP2(v, loopTop, sqliteVdbeCurrentAddr(v));
          676  +        sqlite3VdbeAddOp(v, OP_Next, 1, loopTop+1);
          677  +        sqlite3VdbeChangeP2(v, loopTop, sqlite3VdbeCurrentAddr(v));
   678    678           for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
   679    679             static VdbeOpList cntIdx[] = {
   680    680                { OP_Integer,      0,  0,  0},
   681    681                { OP_MemStore,     2,  1,  0},
   682    682                { OP_Rewind,       0,  0,  0},  /* 2 */
   683    683                { OP_MemIncr,      2,  0,  0},
   684    684                { OP_Next,         0,  0,  0},  /* 4 */
................................................................................
   688    688                { OP_MemIncr,      0,  0,  0},
   689    689                { OP_String,       0,  0,  "wrong # of entries in index "},
   690    690                { OP_String,       0,  0,  0},  /* 10 */
   691    691                { OP_Concat,       2,  0,  0},
   692    692                { OP_Callback,     1,  0,  0},
   693    693             };
   694    694             if( pIdx->tnum==0 ) continue;
   695         -          addr = sqliteVdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
   696         -          sqliteVdbeChangeP1(v, addr+2, j+2);
   697         -          sqliteVdbeChangeP2(v, addr+2, addr+5);
   698         -          sqliteVdbeChangeP1(v, addr+4, j+2);
   699         -          sqliteVdbeChangeP2(v, addr+4, addr+3);
   700         -          sqliteVdbeChangeP2(v, addr+7, addr+ArraySize(cntIdx));
   701         -          sqliteVdbeChangeP3(v, addr+10, pIdx->zName, P3_STATIC);
          695  +          addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx);
          696  +          sqlite3VdbeChangeP1(v, addr+2, j+2);
          697  +          sqlite3VdbeChangeP2(v, addr+2, addr+5);
          698  +          sqlite3VdbeChangeP1(v, addr+4, j+2);
          699  +          sqlite3VdbeChangeP2(v, addr+4, addr+3);
          700  +          sqlite3VdbeChangeP2(v, addr+7, addr+ArraySize(cntIdx));
          701  +          sqlite3VdbeChangeP3(v, addr+10, pIdx->zName, P3_STATIC);
   702    702           }
   703    703         } 
   704    704       }
   705         -    addr = sqliteVdbeAddOpList(v, ArraySize(endCode), endCode);
   706         -    sqliteVdbeChangeP2(v, addr+2, addr+ArraySize(endCode));
          705  +    addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode);
          706  +    sqlite3VdbeChangeP2(v, addr+2, addr+ArraySize(endCode));
   707    707     }else
   708    708   
   709    709     {}
   710    710     sqliteFree(zLeft);
   711    711     sqliteFree(zRight);
   712    712   }
          713  +
          714  +
          715  +

Changes to src/printf.c.

   342    342       **                               is -1.
   343    343       **   xtype                       The class of the conversion.
   344    344       **   infop                       Pointer to the appropriate info struct.
   345    345       */
   346    346       switch( xtype ){
   347    347         case etRADIX:
   348    348           if( flag_longlong )   longvalue = va_arg(ap,INT64_TYPE);
   349         -        else if( flag_long )  longvalue = va_arg(ap,long ing);
          349  +        else if( flag_long )  longvalue = va_arg(ap,long int);
   350    350           else                  longvalue = va_arg(ap,int);
   351    351   #if 1
   352    352           /* For the format %#x, the value zero is printed "0" not "0x0".
   353    353           ** I think this is stupid. */
   354    354           if( longvalue==0 ) flag_alternateform = 0;
   355    355   #else
   356    356           /* More sensible: turn off the prefix for octal (to prevent "00"),
................................................................................
   726    726     return sqliteRealloc(old,size);
   727    727   }
   728    728   
   729    729   /*
   730    730   ** Print into memory obtained from sqliteMalloc().  Use the internal
   731    731   ** %-conversion extensions.
   732    732   */
   733         -char *sqliteVMPrintf(const char *zFormat, va_list ap){
          733  +char *sqlite3VMPrintf(const char *zFormat, va_list ap){
   734    734     char zBase[1000];
   735    735     return base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
   736    736   }
   737    737   
   738    738   /*
   739    739   ** Print into memory obtained from sqliteMalloc().  Use the internal
   740    740   ** %-conversion extensions.
   741    741   */
   742         -char *sqliteMPrintf(const char *zFormat, ...){
          742  +char *sqlite3MPrintf(const char *zFormat, ...){
   743    743     va_list ap;
   744    744     char *z;
   745    745     char zBase[1000];
   746    746     va_start(ap, zFormat);
   747    747     z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
   748    748     va_end(ap);
   749    749     return z;
................................................................................
   859    859     int rc;
   860    860   
   861    861     zSql = sqlite_vmprintf(sqlFormat, ap);
   862    862     rc = sqlite_get_table(db, zSql, resultp, nrow, ncolumn, errmsg);
   863    863     free(zSql);
   864    864     return rc;
   865    865   }
          866  +
          867  +
          868  +

Changes to src/random.c.

    11     11   *************************************************************************
    12     12   ** This file contains code to implement a pseudo-random number
    13     13   ** generator (PRNG) for SQLite.
    14     14   **
    15     15   ** Random numbers are used by some of the database backends in order
    16     16   ** to generate random integer keys for tables or random filenames.
    17     17   **
    18         -** $Id: random.c,v 1.11 2004/02/11 09:46:33 drh Exp $
           18  +** $Id: random.c,v 1.12 2004/05/08 08:23:32 danielk1977 Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   
    23     23   
    24     24   /*
    25     25   ** Get a single 8-bit random value from the RC4 PRNG.  The Mutex
................................................................................
    56     56     ** number generator) not as an encryption device.
    57     57     */
    58     58     if( !prng.isInit ){
    59     59       int i;
    60     60       char k[256];
    61     61       prng.j = 0;
    62     62       prng.i = 0;
    63         -    sqliteOsRandomSeed(k);
           63  +    sqlite3OsRandomSeed(k);
    64     64       for(i=0; i<256; i++){
    65     65         prng.s[i] = i;
    66     66       }
    67     67       for(i=0; i<256; i++){
    68     68         prng.j += prng.s[i] + k[i];
    69     69         t = prng.s[prng.j];
    70     70         prng.s[prng.j] = prng.s[i];
................................................................................
    83     83     t += prng.s[prng.i];
    84     84     return prng.s[t];
    85     85   }
    86     86   
    87     87   /*
    88     88   ** Return N random bytes.
    89     89   */
    90         -void sqliteRandomness(int N, void *pBuf){
           90  +void sqlite3Randomness(int N, void *pBuf){
    91     91     unsigned char *zBuf = pBuf;
    92         -  sqliteOsEnterMutex();
           92  +  sqlite3OsEnterMutex();
    93     93     while( N-- ){
    94     94       *(zBuf++) = randomByte();
    95     95     }
    96         -  sqliteOsLeaveMutex();
           96  +  sqlite3OsLeaveMutex();
    97     97   }
           98  +
           99  +
          100  +

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.161 2004/03/13 14:00:36 drh Exp $
           15  +** $Id: select.c,v 1.162 2004/05/08 08:23:32 danielk1977 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.
    23     23   */
    24         -Select *sqliteSelectNew(
           24  +Select *sqlite3SelectNew(
    25     25     ExprList *pEList,     /* which columns to include in the result */
    26     26     SrcList *pSrc,        /* the FROM clause -- which tables to scan */
    27     27     Expr *pWhere,         /* the WHERE clause */
    28     28     ExprList *pGroupBy,   /* the GROUP BY clause */
    29     29     Expr *pHaving,        /* the HAVING clause */
    30     30     ExprList *pOrderBy,   /* the ORDER BY clause */
    31     31     int isDistinct,       /* true if the DISTINCT keyword is present */
    32     32     int nLimit,           /* LIMIT value.  -1 means not used */
    33     33     int nOffset           /* OFFSET value.  0 means no offset */
    34     34   ){
    35     35     Select *pNew;
    36     36     pNew = sqliteMalloc( sizeof(*pNew) );
    37     37     if( pNew==0 ){
    38         -    sqliteExprListDelete(pEList);
    39         -    sqliteSrcListDelete(pSrc);
    40         -    sqliteExprDelete(pWhere);
    41         -    sqliteExprListDelete(pGroupBy);
    42         -    sqliteExprDelete(pHaving);
    43         -    sqliteExprListDelete(pOrderBy);
           38  +    sqlite3ExprListDelete(pEList);
           39  +    sqlite3SrcListDelete(pSrc);
           40  +    sqlite3ExprDelete(pWhere);
           41  +    sqlite3ExprListDelete(pGroupBy);
           42  +    sqlite3ExprDelete(pHaving);
           43  +    sqlite3ExprListDelete(pOrderBy);
    44     44     }else{
    45     45       if( pEList==0 ){
    46         -      pEList = sqliteExprListAppend(0, sqliteExpr(TK_ALL,0,0,0), 0);
           46  +      pEList = sqlite3ExprListAppend(0, sqlite3Expr(TK_ALL,0,0,0), 0);
    47     47       }
    48     48       pNew->pEList = pEList;
    49     49       pNew->pSrc = pSrc;
    50     50       pNew->pWhere = pWhere;
    51     51       pNew->pGroupBy = pGroupBy;
    52     52       pNew->pHaving = pHaving;
    53     53       pNew->pOrderBy = pOrderBy;
................................................................................
    73     73   **     JT_RIGHT
    74     74   **
    75     75   ** A full outer join is the combination of JT_LEFT and JT_RIGHT.
    76     76   **
    77     77   ** If an illegal or unsupported join type is seen, then still return
    78     78   ** a join type, but put an error in the pParse structure.
    79     79   */
    80         -int sqliteJoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
           80  +int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *pC){
    81     81     int jointype = 0;
    82     82     Token *apAll[3];
    83     83     Token *p;
    84     84     static struct {
    85     85       const char *zKeyword;
    86     86       int nChar;
    87     87       int code;
................................................................................
    98     98     apAll[0] = pA;
    99     99     apAll[1] = pB;
   100    100     apAll[2] = pC;
   101    101     for(i=0; i<3 && apAll[i]; i++){
   102    102       p = apAll[i];
   103    103       for(j=0; j<sizeof(keywords)/sizeof(keywords[0]); j++){
   104    104         if( p->n==keywords[j].nChar 
   105         -          && sqliteStrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){
          105  +          && sqlite3StrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){
   106    106           jointype |= keywords[j].code;
   107    107           break;
   108    108         }
   109    109       }
   110    110       if( j>=sizeof(keywords)/sizeof(keywords[0]) ){
   111    111         jointype |= JT_ERROR;
   112    112         break;
................................................................................
   116    116        (jointype & (JT_INNER|JT_OUTER))==(JT_INNER|JT_OUTER) ||
   117    117        (jointype & JT_ERROR)!=0
   118    118     ){
   119    119       static Token dummy = { 0, 0 };
   120    120       char *zSp1 = " ", *zSp2 = " ";
   121    121       if( pB==0 ){ pB = &dummy; zSp1 = 0; }
   122    122       if( pC==0 ){ pC = &dummy; zSp2 = 0; }
   123         -    sqliteSetNString(&pParse->zErrMsg, "unknown or unsupported join type: ", 0,
          123  +    sqlite3SetNString(&pParse->zErrMsg, "unknown or unsupported join type: ", 0,
   124    124          pA->z, pA->n, zSp1, 1, pB->z, pB->n, zSp2, 1, pC->z, pC->n, 0);
   125    125       pParse->nErr++;
   126    126       jointype = JT_INNER;
   127    127     }else if( jointype & JT_RIGHT ){
   128         -    sqliteErrorMsg(pParse, 
          128  +    sqlite3ErrorMsg(pParse, 
   129    129         "RIGHT and FULL OUTER JOINs are not currently supported");
   130    130       jointype = JT_INNER;
   131    131     }
   132    132     return jointype;
   133    133   }
   134    134   
   135    135   /*
   136    136   ** Return the index of a column in a table.  Return -1 if the column
   137    137   ** is not contained in the table.
   138    138   */
   139    139   static int columnIndex(Table *pTab, const char *zCol){
   140    140     int i;
   141    141     for(i=0; i<pTab->nCol; i++){
   142         -    if( sqliteStrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
          142  +    if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
   143    143     }
   144    144     return -1;
   145    145   }
   146    146   
   147    147   /*
   148    148   ** Add a term to the WHERE expression in *ppExpr that requires the
   149    149   ** zCol column to be equal in the two tables pTab1 and pTab2.
................................................................................
   158    158     Expr *pE1a, *pE1b, *pE1c;
   159    159     Expr *pE2a, *pE2b, *pE2c;
   160    160     Expr *pE;
   161    161   
   162    162     dummy.z = zCol;
   163    163     dummy.n = strlen(zCol);
   164    164     dummy.dyn = 0;
   165         -  pE1a = sqliteExpr(TK_ID, 0, 0, &dummy);
   166         -  pE2a = sqliteExpr(TK_ID, 0, 0, &dummy);
          165  +  pE1a = sqlite3Expr(TK_ID, 0, 0, &dummy);
          166  +  pE2a = sqlite3Expr(TK_ID, 0, 0, &dummy);
   167    167     dummy.z = pTab1->zName;
   168    168     dummy.n = strlen(dummy.z);
   169         -  pE1b = sqliteExpr(TK_ID, 0, 0, &dummy);
          169  +  pE1b = sqlite3Expr(TK_ID, 0, 0, &dummy);
   170    170     dummy.z = pTab2->zName;
   171    171     dummy.n = strlen(dummy.z);
   172         -  pE2b = sqliteExpr(TK_ID, 0, 0, &dummy);
   173         -  pE1c = sqliteExpr(TK_DOT, pE1b, pE1a, 0);
   174         -  pE2c = sqliteExpr(TK_DOT, pE2b, pE2a, 0);
   175         -  pE = sqliteExpr(TK_EQ, pE1c, pE2c, 0);
          172  +  pE2b = sqlite3Expr(TK_ID, 0, 0, &dummy);
          173  +  pE1c = sqlite3Expr(TK_DOT, pE1b, pE1a, 0);
          174  +  pE2c = sqlite3Expr(TK_DOT, pE2b, pE2a, 0);
          175  +  pE = sqlite3Expr(TK_EQ,