/ Check-in [9dca7ce5]
Login

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

Overview
Comment:Merge latest trunk changes with this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | android-large-filles
Files: files | file ages | folders
SHA1: 9dca7ce55797b3eb617859f6189c1a2ec6f66566
User & Date: dan 2014-09-06 16:52:18
Context
2014-09-06
17:06
Fixes to os_unix.c to support database (and other) files larger than 2GiB on Android. check-in: ad7063aa user: dan tags: trunk
16:52
Merge latest trunk changes with this branch. Closed-Leaf check-in: 9dca7ce5 user: dan tags: android-large-filles
16:49
Fixes to os_unix.c to support database (and other) files larger than 2GiB. check-in: e7fae33c user: dan tags: android-large-filles
16:39
Fix typos in comments. No code changes. check-in: e62aab5e user: peter.d.reid tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/alter.c.

   170    170     int len = 0;
   171    171     char *zRet;
   172    172     sqlite3 *db = sqlite3_context_db_handle(context);
   173    173   
   174    174     UNUSED_PARAMETER(NotUsed);
   175    175   
   176    176     /* The principle used to locate the table name in the CREATE TRIGGER 
   177         -  ** statement is that the table name is the first token that is immediatedly
   178         -  ** preceded by either TK_ON or TK_DOT and immediatedly followed by one
          177  +  ** statement is that the table name is the first token that is immediately
          178  +  ** preceded by either TK_ON or TK_DOT and immediately followed by one
   179    179     ** of TK_WHEN, TK_BEGIN or TK_FOR.
   180    180     */
   181    181     if( zSql ){
   182    182       do {
   183    183   
   184    184         if( !*zCsr ){
   185    185           /* Ran out of input before finding the table name. Return NULL. */

Changes to src/analyze.c.

    31     31   ** SQLITE_ENABLE_STAT3 defined.  The functionality of sqlite_stat3
    32     32   ** is a superset of sqlite_stat2.  The sqlite_stat4 is an enhanced
    33     33   ** version of sqlite_stat3 and is only available when compiled with
    34     34   ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later.  It is
    35     35   ** not possible to enable both STAT3 and STAT4 at the same time.  If they
    36     36   ** are both enabled, then STAT4 takes precedence.
    37     37   **
    38         -** For most applications, sqlite_stat1 provides all the statisics required
           38  +** For most applications, sqlite_stat1 provides all the statistics required
    39     39   ** for the query planner to make good choices.
    40     40   **
    41     41   ** Format of sqlite_stat1:
    42     42   **
    43     43   ** There is normally one row per index, with the index identified by the
    44     44   ** name in the idx column.  The tbl column is the name of the table to
    45     45   ** which the index belongs.  In each such row, the stat column will be
................................................................................
   383    383   **
   384    384   ** For indexes on ordinary rowid tables, N==K+1.  But for indexes on
   385    385   ** WITHOUT ROWID tables, N=K+P where P is the number of columns in the
   386    386   ** PRIMARY KEY of the table.  The covering index that implements the
   387    387   ** original WITHOUT ROWID table as N==K as a special case.
   388    388   **
   389    389   ** This routine allocates the Stat4Accum object in heap memory. The return 
   390         -** value is a pointer to the the Stat4Accum object.  The datatype of the
          390  +** value is a pointer to the Stat4Accum object.  The datatype of the
   391    391   ** return value is BLOB, but it is really just a pointer to the Stat4Accum
   392    392   ** object.
   393    393   */
   394    394   static void statInit(
   395    395     sqlite3_context *context,
   396    396     int argc,
   397    397     sqlite3_value **argv
................................................................................
  1579   1579         tRowcnt nSum = 0;         /* Number of terms contributing to sumEq */
  1580   1580         tRowcnt avgEq = 0;
  1581   1581         tRowcnt nDLt = pFinal->anDLt[iCol];
  1582   1582   
  1583   1583         /* Set nSum to the number of distinct (iCol+1) field prefixes that
  1584   1584         ** occur in the stat4 table for this index before pFinal. Set
  1585   1585         ** sumEq to the sum of the nEq values for column iCol for the same
  1586         -      ** set (adding the value only once where there exist dupicate 
         1586  +      ** set (adding the value only once where there exist duplicate 
  1587   1587         ** prefixes).  */
  1588   1588         for(i=0; i<(pIdx->nSample-1); i++){
  1589   1589           if( aSample[i].anDLt[iCol]!=aSample[i+1].anDLt[iCol] ){
  1590   1590             sumEq += aSample[i].anEq[iCol];
  1591   1591             nSum++;
  1592   1592           }
  1593   1593         }

Changes to src/btmutex.c.

   102    102   ** and thus help the sqlite3BtreeLock() routine to run much faster
   103    103   ** in the common case.
   104    104   */
   105    105   static void SQLITE_NOINLINE btreeLockCarefully(Btree *p){
   106    106     Btree *pLater;
   107    107   
   108    108     /* In most cases, we should be able to acquire the lock we
   109         -  ** want without having to go throught the ascending lock
          109  +  ** want without having to go through the ascending lock
   110    110     ** procedure that follows.  Just be sure not to block.
   111    111     */
   112    112     if( sqlite3_mutex_try(p->pBt->mutex)==SQLITE_OK ){
   113    113       p->pBt->db = p->db;
   114    114       p->locked = 1;
   115    115       return;
   116    116     }

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         -** This file implements a external (disk-based) database using BTrees.
           12  +** This file implements an external (disk-based) database using BTrees.
    13     13   ** See the header comment on "btreeInt.h" for additional information.
    14     14   ** Including a description of file format and an overview of operation.
    15     15   */
    16     16   #include "btreeInt.h"
    17     17   
    18     18   /*
    19     19   ** The header string that appears at the beginning of every
................................................................................
  1140   1140   ** Defragment the page given.  All Cells are moved to the
  1141   1141   ** end of the page and all free space is collected into one
  1142   1142   ** big FreeBlk that occurs in between the header and cell
  1143   1143   ** pointer array and the cell content area.
  1144   1144   */
  1145   1145   static int defragmentPage(MemPage *pPage){
  1146   1146     int i;                     /* Loop counter */
  1147         -  int pc;                    /* Address of a i-th cell */
         1147  +  int pc;                    /* Address of the i-th cell */
  1148   1148     int hdr;                   /* Offset to the page header */
  1149   1149     int size;                  /* Size of a cell */
  1150   1150     int usableSize;            /* Number of usable bytes on a page */
  1151   1151     int cellOffset;            /* Offset to the cell pointer array */
  1152   1152     int cbrk;                  /* Offset to the cell content area */
  1153   1153     int nCell;                 /* Number of cells on the page */
  1154   1154     unsigned char *data;       /* The page data */
................................................................................
  2597   2597   ** in assert() expressions, so it is only compiled if NDEBUG is not
  2598   2598   ** defined.
  2599   2599   **
  2600   2600   ** Only write cursors are counted if wrOnly is true.  If wrOnly is
  2601   2601   ** false then all cursors are counted.
  2602   2602   **
  2603   2603   ** For the purposes of this routine, a cursor is any cursor that
  2604         -** is capable of reading or writing to the databse.  Cursors that
         2604  +** is capable of reading or writing to the database.  Cursors that
  2605   2605   ** have been tripped into the CURSOR_FAULT state are not counted.
  2606   2606   */
  2607   2607   static int countValidCursors(BtShared *pBt, int wrOnly){
  2608   2608     BtCursor *pCur;
  2609   2609     int r = 0;
  2610   2610     for(pCur=pBt->pCursor; pCur; pCur=pCur->pNext){
  2611   2611       if( (wrOnly==0 || (pCur->curFlags & BTCF_WriteFlag)!=0)
................................................................................
  3061   3061   
  3062   3062   /*
  3063   3063   ** Perform a single step of an incremental-vacuum. If successful, return
  3064   3064   ** SQLITE_OK. If there is no work to do (and therefore no point in 
  3065   3065   ** calling this function again), return SQLITE_DONE. Or, if an error 
  3066   3066   ** occurs, return some other error code.
  3067   3067   **
  3068         -** More specificly, this function attempts to re-organize the database so 
         3068  +** More specifically, this function attempts to re-organize the database so 
  3069   3069   ** that the last page of the file currently in use is no longer in use.
  3070   3070   **
  3071   3071   ** Parameter nFin is the number of pages that this database would contain
  3072   3072   ** were this function called until it returns SQLITE_DONE.
  3073   3073   **
  3074   3074   ** If the bCommit parameter is non-zero, this function assumes that the 
  3075   3075   ** caller will keep calling incrVacuumStep() until it returns SQLITE_DONE 
  3076         -** or an error. bCommit is passed true for an auto-vacuum-on-commmit 
         3076  +** or an error. bCommit is passed true for an auto-vacuum-on-commit 
  3077   3077   ** operation, or false for an incremental vacuum.
  3078   3078   */
  3079   3079   static int incrVacuumStep(BtShared *pBt, Pgno nFin, Pgno iLastPg, int bCommit){
  3080   3080     Pgno nFreeList;           /* Number of pages still on the free-list */
  3081   3081     int rc;
  3082   3082   
  3083   3083     assert( sqlite3_mutex_held(pBt->mutex) );
................................................................................
  3536   3536   
  3537   3537     btreeEndTransaction(p);
  3538   3538     sqlite3BtreeLeave(p);
  3539   3539     return rc;
  3540   3540   }
  3541   3541   
  3542   3542   /*
  3543         -** Start a statement subtransaction. The subtransaction can can be rolled
         3543  +** Start a statement subtransaction. The subtransaction can be rolled
  3544   3544   ** back independently of the main transaction. You must start a transaction 
  3545   3545   ** before starting a subtransaction. The subtransaction is ended automatically 
  3546   3546   ** if the main transaction commits or rolls back.
  3547   3547   **
  3548   3548   ** Statement subtransactions are used around individual SQL statements
  3549   3549   ** that are contained within a BEGIN...COMMIT block.  If a constraint
  3550   3550   ** error occurs within the statement, the effect of that one statement
................................................................................
  3770   3770   ** BtCursor.info is a cache of the information in the current cell.
  3771   3771   ** Using this cache reduces the number of calls to btreeParseCell().
  3772   3772   **
  3773   3773   ** 2007-06-25:  There is a bug in some versions of MSVC that cause the
  3774   3774   ** compiler to crash when getCellInfo() is implemented as a macro.
  3775   3775   ** But there is a measureable speed advantage to using the macro on gcc
  3776   3776   ** (when less compiler optimizations like -Os or -O0 are used and the
  3777         -** compiler is not doing agressive inlining.)  So we use a real function
         3777  +** compiler is not doing aggressive inlining.)  So we use a real function
  3778   3778   ** for MSVC and a macro for everything else.  Ticket #2457.
  3779   3779   */
  3780   3780   #ifndef NDEBUG
  3781   3781     static void assertCellInfo(BtCursor *pCur){
  3782   3782       CellInfo info;
  3783   3783       int iPage = pCur->iPage;
  3784   3784       memset(&info, 0, sizeof(info));
................................................................................
  3987   3987   ** Data is read to or from the buffer pBuf.
  3988   3988   **
  3989   3989   ** The content being read or written might appear on the main page
  3990   3990   ** or be scattered out on multiple overflow pages.
  3991   3991   **
  3992   3992   ** If the current cursor entry uses one or more overflow pages and the
  3993   3993   ** eOp argument is not 2, this function may allocate space for and lazily 
  3994         -** popluates the overflow page-list cache array (BtCursor.aOverflow). 
         3994  +** populates the overflow page-list cache array (BtCursor.aOverflow). 
  3995   3995   ** Subsequent calls use this cache to make seeking to the supplied offset 
  3996   3996   ** more efficient.
  3997   3997   **
  3998   3998   ** Once an overflow page-list cache has been allocated, it may be
  3999   3999   ** invalidated if some other cursor writes to the same table, or if
  4000   4000   ** the cursor is moved to a different row. Additionally, in auto-vacuum
  4001   4001   ** mode, the following events may invalidate an overflow page-list cache.
................................................................................
  4189   4189       return SQLITE_CORRUPT_BKPT;
  4190   4190     }
  4191   4191     return rc;
  4192   4192   }
  4193   4193   
  4194   4194   /*
  4195   4195   ** Read part of the key associated with cursor pCur.  Exactly
  4196         -** "amt" bytes will be transfered into pBuf[].  The transfer
         4196  +** "amt" bytes will be transferred into pBuf[].  The transfer
  4197   4197   ** begins at "offset".
  4198   4198   **
  4199   4199   ** The caller must ensure that pCur is pointing to a valid row
  4200   4200   ** in the table.
  4201   4201   **
  4202   4202   ** Return SQLITE_OK on success or an error code if anything goes
  4203   4203   ** wrong.  An error is returned if "offset+amt" is larger than
................................................................................
  5885   5885   }
  5886   5886   
  5887   5887   /*
  5888   5888   ** Add a list of cells to a page.  The page should be initially empty.
  5889   5889   ** The cells are guaranteed to fit on the page.
  5890   5890   */
  5891   5891   static void assemblePage(
  5892         -  MemPage *pPage,   /* The page to be assemblied */
         5892  +  MemPage *pPage,   /* The page to be assembled */
  5893   5893     int nCell,        /* The number of cells to add to this page */
  5894   5894     u8 **apCell,      /* Pointers to cell bodies */
  5895   5895     u16 *aSize        /* Sizes of the cells */
  5896   5896   ){
  5897   5897     int i;            /* Loop counter */
  5898   5898     u8 *pCellptr;     /* Address of next cell pointer */
  5899   5899     int cellbody;     /* Address of next cell body */
................................................................................
  6551   6551       if( rc ) goto balance_cleanup;
  6552   6552       releasePage(apOld[i]);
  6553   6553       apOld[i] = 0;
  6554   6554       i++;
  6555   6555     }
  6556   6556   
  6557   6557     /*
  6558         -  ** Put the new pages in accending order.  This helps to
         6558  +  ** Put the new pages in ascending order.  This helps to
  6559   6559     ** keep entries in the disk file in order so that a scan
  6560   6560     ** of the table is a linear scan through the file.  That
  6561   6561     ** in turn helps the operating system to deliver pages
  6562   6562     ** from the disk more rapidly.
  6563   6563     **
  6564   6564     ** An O(n^2) insertion sort algorithm is used, but since
  6565   6565     ** n is never more than NB (a small constant), that should
................................................................................
  6946   6946            && pPage->aiOvfl[0]==pPage->nCell
  6947   6947            && pParent->pgno!=1
  6948   6948            && pParent->nCell==iIdx
  6949   6949           ){
  6950   6950             /* Call balance_quick() to create a new sibling of pPage on which
  6951   6951             ** to store the overflow cell. balance_quick() inserts a new cell
  6952   6952             ** into pParent, which may cause pParent overflow. If this
  6953         -          ** happens, the next interation of the do-loop will balance pParent 
         6953  +          ** happens, the next iteration of the do-loop will balance pParent 
  6954   6954             ** use either balance_nonroot() or balance_deeper(). Until this
  6955   6955             ** happens, the overflow cell is stored in the aBalanceQuickSpace[]
  6956   6956             ** buffer. 
  6957   6957             **
  6958   6958             ** The purpose of the following assert() is to check that only a
  6959   6959             ** single call to balance_quick() is made for each call to this
  6960   6960             ** function. If this were not verified, a subtle bug involving reuse
................................................................................
  7023   7023   ** For an INTKEY table, only the nKey value of the key is used.  pKey is
  7024   7024   ** ignored.  For a ZERODATA table, the pData and nData are both ignored.
  7025   7025   **
  7026   7026   ** If the seekResult parameter is non-zero, then a successful call to
  7027   7027   ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already
  7028   7028   ** been performed. seekResult is the search result returned (a negative
  7029   7029   ** number if pCur points at an entry that is smaller than (pKey, nKey), or
  7030         -** a positive value if pCur points at an etry that is larger than 
         7030  +** a positive value if pCur points at an entry that is larger than 
  7031   7031   ** (pKey, nKey)). 
  7032   7032   **
  7033   7033   ** If the seekResult parameter is non-zero, then the caller guarantees that
  7034   7034   ** cursor pCur is pointing at the existing copy of a row that is to be
  7035   7035   ** overwritten.  If the seekResult parameter is 0, then cursor pCur may
  7036   7036   ** point to any entry or to no entry at all and so this function has to seek
  7037   7037   ** the cursor before the new key can be inserted.
................................................................................
  7180   7180   
  7181   7181   end_insert:
  7182   7182     return rc;
  7183   7183   }
  7184   7184   
  7185   7185   /*
  7186   7186   ** Delete the entry that the cursor is pointing to.  The cursor
  7187         -** is left pointing at a arbitrary location.
         7187  +** is left pointing at an arbitrary location.
  7188   7188   */
  7189   7189   int sqlite3BtreeDelete(BtCursor *pCur){
  7190   7190     Btree *p = pCur->pBtree;
  7191   7191     BtShared *pBt = p->pBt;              
  7192   7192     int rc;                              /* Return code */
  7193   7193     MemPage *pPage;                      /* Page to delete cell from */
  7194   7194     unsigned char *pCell;                /* Pointer to cell to delete */
................................................................................
  7878   7878     pCheck->aPgRef[iPg/8] |= (1 << (iPg & 0x07));
  7879   7879   }
  7880   7880   
  7881   7881   
  7882   7882   /*
  7883   7883   ** Add 1 to the reference count for page iPage.  If this is the second
  7884   7884   ** reference to the page, add an error message to pCheck->zErrMsg.
  7885         -** Return 1 if there are 2 ore more references to the page and 0 if
         7885  +** Return 1 if there are 2 or more references to the page and 0 if
  7886   7886   ** if this is the first reference to the page.
  7887   7887   **
  7888   7888   ** Also check that the page number is in bounds.
  7889   7889   */
  7890   7890   static int checkRef(IntegrityCk *pCheck, Pgno iPage, char *zContext){
  7891   7891     if( iPage==0 ) return 1;
  7892   7892     if( iPage>pCheck->nPage ){

Changes to src/btreeInt.h.

     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         -** This file implements a external (disk-based) database using BTrees.
           12  +** This file implements an external (disk-based) database using BTrees.
    13     13   ** For a detailed discussion of BTrees, refer to
    14     14   **
    15     15   **     Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3:
    16     16   **     "Sorting And Searching", pages 473-480. Addison-Wesley
    17     17   **     Publishing Company, Reading, Massachusetts.
    18     18   **
    19     19   ** The basic idea is that each page of the file contains N database
................................................................................
   131    131   **      3       2      number of cells on this page
   132    132   **      5       2      first byte of the cell content area
   133    133   **      7       1      number of fragmented free bytes
   134    134   **      8       4      Right child (the Ptr(N) value).  Omitted on leaves.
   135    135   **
   136    136   ** The flags define the format of this btree page.  The leaf flag means that
   137    137   ** this page has no children.  The zerodata flag means that this page carries
   138         -** only keys and no data.  The intkey flag means that the key is a integer
          138  +** only keys and no data.  The intkey flag means that the key is an integer
   139    139   ** which is stored in the key size entry of the cell header rather than in
   140    140   ** the payload area.
   141    141   **
   142    142   ** The cell pointer array begins on the first byte after the page header.
   143    143   ** The cell pointer array contains zero or more 2-byte numbers which are
   144    144   ** offsets from the beginning of the page to the cell content in the cell
   145    145   ** content area.  The cell pointers occur in sorted order.  The system strives
................................................................................
   540    540   **   The table that this cursor was opened on still exists, but has been 
   541    541   **   modified since the cursor was last used. The cursor position is saved
   542    542   **   in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in 
   543    543   **   this state, restoreCursorPosition() can be called to attempt to
   544    544   **   seek the cursor to the saved position.
   545    545   **
   546    546   ** CURSOR_FAULT:
   547         -**   A unrecoverable error (an I/O error or a malloc failure) has occurred
          547  +**   An unrecoverable error (an I/O error or a malloc failure) has occurred
   548    548   **   on a different connection that shares the BtShared cache with this
   549    549   **   cursor.  The error has left the cache in an inconsistent state.
   550    550   **   Do nothing else with this cursor.  Any attempt to use the cursor
   551    551   **   should return the error code stored in BtCursor.skip
   552    552   */
   553    553   #define CURSOR_INVALID           0
   554    554   #define CURSOR_VALID             1

Changes to src/build.c.

  1615   1615   ** are appropriate for a WITHOUT ROWID table instead of a rowid table.
  1616   1616   ** Changes include:
  1617   1617   **
  1618   1618   **     (1)  Convert the OP_CreateTable into an OP_CreateIndex.  There is
  1619   1619   **          no rowid btree for a WITHOUT ROWID.  Instead, the canonical
  1620   1620   **          data storage is a covering index btree.
  1621   1621   **     (2)  Bypass the creation of the sqlite_master table entry
  1622         -**          for the PRIMARY KEY as the the primary key index is now
         1622  +**          for the PRIMARY KEY as the primary key index is now
  1623   1623   **          identified by the sqlite_master table entry of the table itself.
  1624   1624   **     (3)  Set the Index.tnum of the PRIMARY KEY Index object in the
  1625   1625   **          schema to the rootpage from the main table.
  1626   1626   **     (4)  Set all columns of the PRIMARY KEY schema object to be NOT NULL.
  1627   1627   **     (5)  Add all table columns to the PRIMARY KEY Index object
  1628   1628   **          so that the PRIMARY KEY is a covering index.  The surplus
  1629   1629   **          columns are part of KeyInfo.nXField and are not used for
................................................................................
  1636   1636     Index *pPk;
  1637   1637     int nPk;
  1638   1638     int i, j;
  1639   1639     sqlite3 *db = pParse->db;
  1640   1640     Vdbe *v = pParse->pVdbe;
  1641   1641   
  1642   1642     /* Convert the OP_CreateTable opcode that would normally create the
  1643         -  ** root-page for the table into a OP_CreateIndex opcode.  The index
         1643  +  ** root-page for the table into an OP_CreateIndex opcode.  The index
  1644   1644     ** created will become the PRIMARY KEY index.
  1645   1645     */
  1646   1646     if( pParse->addrCrTab ){
  1647   1647       assert( v );
  1648   1648       sqlite3VdbeGetOp(v, pParse->addrCrTab)->opcode = OP_CreateIndex;
  1649   1649     }
  1650   1650   
................................................................................
  2650   2650     int iSorter;                   /* Cursor opened by OpenSorter (if in use) */
  2651   2651     int addr1;                     /* Address of top of loop */
  2652   2652     int addr2;                     /* Address to jump to for next iteration */
  2653   2653     int tnum;                      /* Root page of index */
  2654   2654     int iPartIdxLabel;             /* Jump to this label to skip a row */
  2655   2655     Vdbe *v;                       /* Generate code into this virtual machine */
  2656   2656     KeyInfo *pKey;                 /* KeyInfo for index */
  2657         -  int regRecord;                 /* Register holding assemblied index record */
         2657  +  int regRecord;                 /* Register holding assembled index record */
  2658   2658     sqlite3 *db = pParse->db;      /* The database connection */
  2659   2659     int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);
  2660   2660   
  2661   2661   #ifndef SQLITE_OMIT_AUTHORIZATION
  2662   2662     if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,
  2663   2663         db->aDb[iDb].zName ) ){
  2664   2664       return;
................................................................................
  3250   3250     return pRet;
  3251   3251   }
  3252   3252   
  3253   3253   /*
  3254   3254   ** Fill the Index.aiRowEst[] array with default information - information
  3255   3255   ** to be used when we have not run the ANALYZE command.
  3256   3256   **
  3257         -** aiRowEst[0] is suppose to contain the number of elements in the index.
         3257  +** aiRowEst[0] is supposed to contain the number of elements in the index.
  3258   3258   ** Since we do not know, guess 1 million.  aiRowEst[1] is an estimate of the
  3259   3259   ** number of rows in the table that match any particular value of the
  3260   3260   ** first column of the index.  aiRowEst[2] is an estimate of the number
  3261   3261   ** of rows that match any particular combination of the first 2 columns
  3262   3262   ** of the index.  And so forth.  It must always be the case that
  3263   3263   *
  3264   3264   **           aiRowEst[N]<=aiRowEst[N-1]
................................................................................
  3629   3629   /*
  3630   3630   ** This routine is called by the parser to add a new term to the
  3631   3631   ** end of a growing FROM clause.  The "p" parameter is the part of
  3632   3632   ** the FROM clause that has already been constructed.  "p" is NULL
  3633   3633   ** if this is the first term of the FROM clause.  pTable and pDatabase
  3634   3634   ** are the name of the table and database named in the FROM clause term.
  3635   3635   ** pDatabase is NULL if the database name qualifier is missing - the
  3636         -** usual case.  If the term has a alias, then pAlias points to the
         3636  +** usual case.  If the term has an alias, then pAlias points to the
  3637   3637   ** alias token.  If the term is a subquery, then pSubquery is the
  3638   3638   ** SELECT statement that the subquery encodes.  The pTable and
  3639   3639   ** pDatabase parameters are NULL for subqueries.  The pOn and pUsing
  3640   3640   ** parameters are the content of the ON and USING clauses.
  3641   3641   **
  3642   3642   ** Return a new SrcList which encodes is the FROM with the new
  3643   3643   ** term added.

Changes to src/callback.c.

   138    138   /*
   139    139   ** Locate and return an entry from the db.aCollSeq hash table. If the entry
   140    140   ** specified by zName and nName is not found and parameter 'create' is
   141    141   ** true, then create a new entry. Otherwise return NULL.
   142    142   **
   143    143   ** Each pointer stored in the sqlite3.aCollSeq hash table contains an
   144    144   ** array of three CollSeq structures. The first is the collation sequence
   145         -** prefferred for UTF-8, the second UTF-16le, and the third UTF-16be.
          145  +** preferred for UTF-8, the second UTF-16le, and the third UTF-16be.
   146    146   **
   147    147   ** Stored immediately after the three collation sequences is a copy of
   148    148   ** the collation sequence name. A pointer to this string is stored in
   149    149   ** each collation sequence structure.
   150    150   */
   151    151   static CollSeq *findCollSeqEntry(
   152    152     sqlite3 *db,          /* Database connection */

Changes to src/complete.c.

    66     66   **   (2) NORMAL    We are in the middle of statement which ends with a single
    67     67   **                 semicolon.
    68     68   **
    69     69   **   (3) EXPLAIN   The keyword EXPLAIN has been seen at the beginning of 
    70     70   **                 a statement.
    71     71   **
    72     72   **   (4) CREATE    The keyword CREATE has been seen at the beginning of a
    73         -**                 statement, possibly preceeded by EXPLAIN and/or followed by
           73  +**                 statement, possibly preceded by EXPLAIN and/or followed by
    74     74   **                 TEMP or TEMPORARY
    75     75   **
    76     76   **   (5) TRIGGER   We are in the middle of a trigger definition that must be
    77     77   **                 ended by a semicolon, the keyword END, and another semicolon.
    78     78   **
    79     79   **   (6) SEMI      We've seen the first semicolon in the ";END;" that occurs at
    80     80   **                 the end of a trigger definition.
    81     81   **
    82     82   **   (7) END       We've seen the ";END" of the ";END;" that occurs at the end
    83         -**                 of a trigger difinition.
           83  +**                 of a trigger definition.
    84     84   **
    85     85   ** Transitions between states above are determined by tokens extracted
    86     86   ** from the input.  The following tokens are significant:
    87     87   **
    88     88   **   (0) tkSEMI      A semicolon.
    89     89   **   (1) tkWS        Whitespace.
    90     90   **   (2) tkOTHER     Any other SQL token.
................................................................................
   119    119        /* 4  CREATE: */ {    1,  4,     2,       2,      2,    4,       5,   2, },
   120    120        /* 5 TRIGGER: */ {    6,  5,     5,       5,      5,    5,       5,   5, },
   121    121        /* 6    SEMI: */ {    6,  6,     5,       5,      5,    5,       5,   7, },
   122    122        /* 7     END: */ {    1,  7,     5,       5,      5,    5,       5,   5, },
   123    123     };
   124    124   #else
   125    125     /* If triggers are not supported by this compile then the statement machine
   126         -  ** used to detect the end of a statement is much simplier
          126  +  ** used to detect the end of a statement is much simpler
   127    127     */
   128    128     static const u8 trans[3][3] = {
   129    129                        /* Token:           */
   130    130        /* State:       **  SEMI  WS  OTHER */
   131    131        /* 0 INVALID: */ {    1,  0,     2, },
   132    132        /* 1   START: */ {    1,  1,     2, },
   133    133        /* 2  NORMAL: */ {    1,  2,     2, },

Changes to src/date.c.

    20     20   ** dates and times are stored as the number of days since noon
    21     21   ** in Greenwich on November 24, 4714 B.C. according to the Gregorian
    22     22   ** calendar system. 
    23     23   **
    24     24   ** 1970-01-01 00:00:00 is JD 2440587.5
    25     25   ** 2000-01-01 00:00:00 is JD 2451544.5
    26     26   **
    27         -** This implemention requires years to be expressed as a 4-digit number
           27  +** This implementation requires years to be expressed as a 4-digit number
    28     28   ** which means that only dates between 0000-01-01 and 9999-12-31 can
    29     29   ** be represented, even though julian day numbers allow a much wider
    30     30   ** range of dates.
    31     31   **
    32     32   ** The Gregorian calendar system is used for all dates and times,
    33     33   ** even those that predate the Gregorian calendar.  Historians usually
    34     34   ** use the Julian calendar for dates prior to 1582-10-15 and for some

Changes to src/delete.c.

    86     86   ** pWhere argument is an optional WHERE clause that restricts the
    87     87   ** set of rows in the view that are to be added to the ephemeral table.
    88     88   */
    89     89   void sqlite3MaterializeView(
    90     90     Parse *pParse,       /* Parsing context */
    91     91     Table *pView,        /* View definition */
    92     92     Expr *pWhere,        /* Optional WHERE clause to be added */
    93         -  int iCur             /* Cursor number for ephemerial table */
           93  +  int iCur             /* Cursor number for ephemeral table */
    94     94   ){
    95     95     SelectDest dest;
    96     96     Select *pSel;
    97     97     SrcList *pFrom;
    98     98     sqlite3 *db = pParse->db;
    99     99     int iDb = sqlite3SchemaToIndex(db, pView->pSchema);
   100    100     pWhere = sqlite3ExprDup(db, pWhere, 0);
................................................................................
   244    244     int iKey;              /* Memory cell holding key of row to be deleted */
   245    245     i16 nKey;              /* Number of memory cells in the row key */
   246    246     int iEphCur = 0;       /* Ephemeral table holding all primary key values */
   247    247     int iRowSet = 0;       /* Register for rowset of rows to delete */
   248    248     int addrBypass = 0;    /* Address of jump over the delete logic */
   249    249     int addrLoop = 0;      /* Top of the delete loop */
   250    250     int addrDelete = 0;    /* Jump directly to the delete logic */
   251         -  int addrEphOpen = 0;   /* Instruction to open the Ephermeral table */
          251  +  int addrEphOpen = 0;   /* Instruction to open the Ephemeral table */
   252    252    
   253    253   #ifndef SQLITE_OMIT_TRIGGER
   254    254     int isView;                  /* True if attempting to delete from a view */
   255    255     Trigger *pTrigger;           /* List of table triggers, if required */
   256    256   #endif
   257    257   
   258    258     memset(&sContext, 0, sizeof(sContext));
................................................................................
   324    324     if( v==0 ){
   325    325       goto delete_from_cleanup;
   326    326     }
   327    327     if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
   328    328     sqlite3BeginWriteOperation(pParse, 1, iDb);
   329    329   
   330    330     /* If we are trying to delete from a view, realize that view into
   331         -  ** a ephemeral table.
          331  +  ** an ephemeral table.
   332    332     */
   333    333   #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
   334    334     if( isView ){
   335    335       sqlite3MaterializeView(pParse, pTab, pWhere, iTabCur);
   336    336       iDataCur = iIdxCur = iTabCur;
   337    337     }
   338    338   #endif
................................................................................
   378    378       if( HasRowid(pTab) ){
   379    379         /* For a rowid table, initialize the RowSet to an empty set */
   380    380         pPk = 0;
   381    381         nPk = 1;
   382    382         iRowSet = ++pParse->nMem;
   383    383         sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
   384    384       }else{
   385         -      /* For a WITHOUT ROWID table, create an ephermeral table used to
          385  +      /* For a WITHOUT ROWID table, create an ephemeral table used to
   386    386         ** hold all primary keys for rows to be deleted. */
   387    387         pPk = sqlite3PrimaryKeyIndex(pTab);
   388    388         assert( pPk!=0 );
   389    389         nPk = pPk->nKeyCol;
   390    390         iPk = pParse->nMem+1;
   391    391         pParse->nMem += nPk;
   392    392         iEphCur = pParse->nTab++;
................................................................................
   553    553     sqlite3AuthContextPop(&sContext);
   554    554     sqlite3SrcListDelete(db, pTabList);
   555    555     sqlite3ExprDelete(db, pWhere);
   556    556     sqlite3DbFree(db, aToOpen);
   557    557     return;
   558    558   }
   559    559   /* Make sure "isView" and other macros defined above are undefined. Otherwise
   560         -** thely may interfere with compilation of other functions in this file
          560  +** they may interfere with compilation of other functions in this file
   561    561   ** (or in another file, if this file becomes part of the amalgamation).  */
   562    562   #ifdef isView
   563    563    #undef isView
   564    564   #endif
   565    565   #ifdef pTrigger
   566    566    #undef pTrigger
   567    567   #endif

Changes to src/expr.c.

    18     18   ** Return the 'affinity' of the expression pExpr if any.
    19     19   **
    20     20   ** If pExpr is a column, a reference to a column via an 'AS' alias,
    21     21   ** or a sub-select with a column as the return value, then the 
    22     22   ** affinity of that column is returned. Otherwise, 0x00 is returned,
    23     23   ** indicating no affinity for the expression.
    24     24   **
    25         -** i.e. the WHERE clause expresssions in the following statements all
           25  +** i.e. the WHERE clause expressions in the following statements all
    26     26   ** have an affinity:
    27     27   **
    28     28   ** CREATE TABLE t1(a);
    29     29   ** SELECT * FROM t1 WHERE a;
    30     30   ** SELECT a AS b FROM t1 WHERE b;
    31     31   ** SELECT * FROM t1 WHERE (select a from t1);
    32     32   */
................................................................................
   497    497         pRoot->flags |= EP_Collate & pLeft->flags;
   498    498       }
   499    499       exprSetHeight(pRoot);
   500    500     }
   501    501   }
   502    502   
   503    503   /*
   504         -** Allocate a Expr node which joins as many as two subtrees.
          504  +** Allocate an Expr node which joins as many as two subtrees.
   505    505   **
   506    506   ** One or both of the subtrees can be NULL.  Return a pointer to the new
   507    507   ** Expr node.  Or, if an OOM error occurs, set pParse->db->mallocFailed,
   508    508   ** free the subtrees and return NULL.
   509    509   */
   510    510   Expr *sqlite3PExpr(
   511    511     Parse *pParse,          /* Parsing context */
................................................................................
   607    607   **
   608    608   ** Wildcards of the form "?nnn" are assigned the number "nnn".  We make
   609    609   ** sure "nnn" is not too be to avoid a denial of service attack when
   610    610   ** the SQL statement comes from an external source.
   611    611   **
   612    612   ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number
   613    613   ** as the previous instance of the same wildcard.  Or if this is the first
   614         -** instance of the wildcard, the next sequenial variable number is
          614  +** instance of the wildcard, the next sequential variable number is
   615    615   ** assigned.
   616    616   */
   617    617   void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
   618    618     sqlite3 *db = pParse->db;
   619    619     const char *z;
   620    620   
   621    621     if( pExpr==0 ) return;
................................................................................
   742    742   ** return value with EP_Reduced|EP_TokenOnly.
   743    743   **
   744    744   ** Note that with flags==EXPRDUP_REDUCE, this routines works on full-size
   745    745   ** (unreduced) Expr objects as they or originally constructed by the parser.
   746    746   ** During expression analysis, extra information is computed and moved into
   747    747   ** later parts of teh Expr object and that extra information might get chopped
   748    748   ** off if the expression is reduced.  Note also that it does not work to
   749         -** make a EXPRDUP_REDUCE copy of a reduced expression.  It is only legal
          749  +** make an EXPRDUP_REDUCE copy of a reduced expression.  It is only legal
   750    750   ** to reduce a pristine expression tree from the parser.  The implementation
   751    751   ** of dupedExprStructSize() contain multiple assert() statements that attempt
   752    752   ** to enforce this constraint.
   753    753   */
   754    754   static int dupedExprStructSize(Expr *p, int flags){
   755    755     int nSize;
   756    756     assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */
................................................................................
   811    811   }
   812    812   
   813    813   /*
   814    814   ** This function is similar to sqlite3ExprDup(), except that if pzBuffer 
   815    815   ** is not NULL then *pzBuffer is assumed to point to a buffer large enough 
   816    816   ** to store the copy of expression p, the copies of p->u.zToken
   817    817   ** (if applicable), and the copies of the p->pLeft and p->pRight expressions,
   818         -** if any. Before returning, *pzBuffer is set to the first byte passed the
          818  +** if any. Before returning, *pzBuffer is set to the first byte past the
   819    819   ** portion of the buffer copied into by this function.
   820    820   */
   821    821   static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){
   822    822     Expr *pNew = 0;                      /* Value to return */
   823    823     if( p ){
   824    824       const int isReduced = (flags&EXPRDUP_REDUCE);
   825    825       u8 *zAlloc;
................................................................................
  1537   1537   ** An existing b-tree might be used if the RHS expression pX is a simple
  1538   1538   ** subquery such as:
  1539   1539   **
  1540   1540   **     SELECT <column> FROM <table>
  1541   1541   **
  1542   1542   ** If the RHS of the IN operator is a list or a more complex subquery, then
  1543   1543   ** an ephemeral table might need to be generated from the RHS and then
  1544         -** pX->iTable made to point to the ephermeral table instead of an
         1544  +** pX->iTable made to point to the ephemeral table instead of an
  1545   1545   ** existing table.
  1546   1546   **
  1547   1547   ** The inFlags parameter must contain exactly one of the bits
  1548   1548   ** IN_INDEX_MEMBERSHIP or IN_INDEX_LOOP.  If inFlags contains
  1549   1549   ** IN_INDEX_MEMBERSHIP, then the generated table will be used for a
  1550   1550   ** fast membership test.  When the IN_INDEX_LOOP bit is set, the
  1551   1551   ** IN index will be used to loop over all values of the RHS of the
................................................................................
  1667   1667       }
  1668   1668     }
  1669   1669   
  1670   1670     /* If no preexisting index is available for the IN clause
  1671   1671     ** and IN_INDEX_NOOP is an allowed reply
  1672   1672     ** and the RHS of the IN operator is a list, not a subquery
  1673   1673     ** and the RHS is not contant or has two or fewer terms,
  1674         -  ** then it is not worth creating an ephermeral table to evaluate
         1674  +  ** then it is not worth creating an ephemeral table to evaluate
  1675   1675     ** the IN operator so return IN_INDEX_NOOP.
  1676   1676     */
  1677   1677     if( eType==0
  1678   1678      && (inFlags & IN_INDEX_NOOP_OK)
  1679   1679      && !ExprHasProperty(pX, EP_xIsSelect)
  1680   1680      && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
  1681   1681     ){
................................................................................
  2754   2754         pDef = sqlite3FindFunction(db, zId, nId, nFarg, enc, 0);
  2755   2755         if( pDef==0 || pDef->xFunc==0 ){
  2756   2756           sqlite3ErrorMsg(pParse, "unknown function: %.*s()", nId, zId);
  2757   2757           break;
  2758   2758         }
  2759   2759   
  2760   2760         /* Attempt a direct implementation of the built-in COALESCE() and
  2761         -      ** IFNULL() functions.  This avoids unnecessary evalation of
         2761  +      ** IFNULL() functions.  This avoids unnecessary evaluation of
  2762   2762         ** arguments past the first non-NULL argument.
  2763   2763         */
  2764   2764         if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
  2765   2765           int endCoalesce = sqlite3VdbeMakeLabel(v);
  2766   2766           assert( nFarg>=2 );
  2767   2767           sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
  2768   2768           for(i=1; i<nFarg; i++){
................................................................................
  3193   3193       sqlite3ExprCodeAtInit(pParse, pExpr, target, 0);
  3194   3194     }else{
  3195   3195       sqlite3ExprCode(pParse, pExpr, target);
  3196   3196     }
  3197   3197   }
  3198   3198   
  3199   3199   /*
  3200         -** Generate code that evalutes the given expression and puts the result
         3200  +** Generate code that evaluates the given expression and puts the result
  3201   3201   ** in register target.
  3202   3202   **
  3203   3203   ** Also make a copy of the expression results into another "cache" register
  3204   3204   ** and modify the expression so that the next time it is evaluated,
  3205   3205   ** the result is a copy of the cache register.
  3206   3206   **
  3207   3207   ** This routine is used for expressions that are used multiple 
................................................................................
  3548   3548   **    x BETWEEN y AND z
  3549   3549   **
  3550   3550   ** The above is equivalent to 
  3551   3551   **
  3552   3552   **    x>=y AND x<=z
  3553   3553   **
  3554   3554   ** Code it as such, taking care to do the common subexpression
  3555         -** elementation of x.
         3555  +** elimination of x.
  3556   3556   */
  3557   3557   static void exprCodeBetween(
  3558   3558     Parse *pParse,    /* Parsing and code generating context */
  3559   3559     Expr *pExpr,      /* The BETWEEN expression */
  3560   3560     int dest,         /* Jump here if the jump is taken */
  3561   3561     int jumpIfTrue,   /* Take the jump if the BETWEEN is true */
  3562   3562     int jumpIfNull    /* Take the jump if the BETWEEN is NULL */
................................................................................
  4285   4285   }
  4286   4286   
  4287   4287   /*
  4288   4288   ** Deallocate a register, making available for reuse for some other
  4289   4289   ** purpose.
  4290   4290   **
  4291   4291   ** If a register is currently being used by the column cache, then
  4292         -** the dallocation is deferred until the column cache line that uses
         4292  +** the deallocation is deferred until the column cache line that uses
  4293   4293   ** the register becomes stale.
  4294   4294   */
  4295   4295   void sqlite3ReleaseTempReg(Parse *pParse, int iReg){
  4296   4296     if( iReg && pParse->nTempReg<ArraySize(pParse->aTempReg) ){
  4297   4297       int i;
  4298   4298       struct yColCache *p;
  4299   4299       for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){

Changes to src/fkey.c.

   169    169   **
   170    170   **   3) No parent key columns were provided explicitly as part of the
   171    171   **      foreign key definition, and the parent table does not have a
   172    172   **      PRIMARY KEY, or
   173    173   **
   174    174   **   4) No parent key columns were provided explicitly as part of the
   175    175   **      foreign key definition, and the PRIMARY KEY of the parent table 
   176         -**      consists of a a different number of columns to the child key in 
          176  +**      consists of a different number of columns to the child key in 
   177    177   **      the child table.
   178    178   **
   179    179   ** then non-zero is returned, and a "foreign key mismatch" error loaded
   180    180   ** into pParse. If an OOM error occurs, non-zero is returned and the
   181    181   ** pParse->db->mallocFailed flag is set.
   182    182   */
   183    183   int sqlite3FkLocateIndex(

Changes to src/func.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         -** This file contains the C-language implementions for many of the SQL
           12  +** This file contains the C-language implementations for many of the SQL
    13     13   ** functions of SQLite.  (Some function, and in particular the date and
    14     14   ** time functions, are implemented separately.)
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <stdlib.h>
    18     18   #include <assert.h>
    19     19   #include "vdbeInt.h"
................................................................................
  1634   1634     assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );
  1635   1635     assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );
  1636   1636     *pIsNocase = (pDef->funcFlags & SQLITE_FUNC_CASE)==0;
  1637   1637     return 1;
  1638   1638   }
  1639   1639   
  1640   1640   /*
  1641         -** All all of the FuncDef structures in the aBuiltinFunc[] array above
         1641  +** All of the FuncDef structures in the aBuiltinFunc[] array above
  1642   1642   ** to the global function hash table.  This occurs at start-time (as
  1643   1643   ** a consequence of calling sqlite3_initialize()).
  1644   1644   **
  1645   1645   ** After this routine runs
  1646   1646   */
  1647   1647   void sqlite3RegisterGlobalFunctions(void){
  1648   1648     /*

Changes to src/global.c.

     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     12   **
    13         -** This file contains definitions of global variables and contants.
           13  +** This file contains definitions of global variables and constants.
    14     14   */
    15     15   #include "sqliteInt.h"
    16     16   
    17     17   /* An array to map all upper-case characters into their corresponding
    18     18   ** lower-case character. 
    19     19   **
    20     20   ** SQLite only considers US-ASCII (or EBCDIC) characters.  We do not

Changes to src/insert.c.

   406    406   **         insert the select result into <table> from R..R+n
   407    407   **         goto C
   408    408   **      D: cleanup
   409    409   **
   410    410   ** The 4th template is used if the insert statement takes its
   411    411   ** values from a SELECT but the data is being inserted into a table
   412    412   ** that is also read as part of the SELECT.  In the third form,
   413         -** we have to use a intermediate table to store the results of
          413  +** we have to use an intermediate table to store the results of
   414    414   ** the select.  The template is like this:
   415    415   **
   416    416   **         X <- A
   417    417   **         goto B
   418    418   **      A: setup for the SELECT
   419    419   **         loop over the tables in the SELECT
   420    420   **           load value into register R..R+n
................................................................................
   571    571   
   572    572     /* If this is an AUTOINCREMENT table, look up the sequence number in the
   573    573     ** sqlite_sequence table and store it in memory cell regAutoinc.
   574    574     */
   575    575     regAutoinc = autoIncBegin(pParse, iDb, pTab);
   576    576   
   577    577     /* Allocate registers for holding the rowid of the new row,
   578         -  ** the content of the new row, and the assemblied row record.
          578  +  ** the content of the new row, and the assembled row record.
   579    579     */
   580    580     regRowid = regIns = pParse->nMem+1;
   581    581     pParse->nMem += pTab->nCol + 1;
   582    582     if( IsVirtual(pTab) ){
   583    583       regRowid++;
   584    584       pParse->nMem++;
   585    585     }
................................................................................
  1023   1023     sqlite3ExprListDelete(db, pList);
  1024   1024     sqlite3SelectDelete(db, pSelect);
  1025   1025     sqlite3IdListDelete(db, pColumn);
  1026   1026     sqlite3DbFree(db, aRegIdx);
  1027   1027   }
  1028   1028   
  1029   1029   /* Make sure "isView" and other macros defined above are undefined. Otherwise
  1030         -** thely may interfere with compilation of other functions in this file
         1030  +** they may interfere with compilation of other functions in this file
  1031   1031   ** (or in another file, if this file becomes part of the amalgamation).  */
  1032   1032   #ifdef isView
  1033   1033    #undef isView
  1034   1034   #endif
  1035   1035   #ifdef pTrigger
  1036   1036    #undef pTrigger
  1037   1037   #endif
................................................................................
  1139   1139     Index *pIdx;         /* Pointer to one of the indices */
  1140   1140     Index *pPk = 0;      /* The PRIMARY KEY index */
  1141   1141     sqlite3 *db;         /* Database connection */
  1142   1142     int i;               /* loop counter */
  1143   1143     int ix;              /* Index loop counter */
  1144   1144     int nCol;            /* Number of columns */
  1145   1145     int onError;         /* Conflict resolution strategy */
  1146         -  int j1;              /* Addresss of jump instruction */
         1146  +  int j1;              /* Address of jump instruction */
  1147   1147     int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
  1148   1148     int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
  1149   1149     int ipkTop = 0;      /* Top of the rowid change constraint check */
  1150   1150     int ipkBottom = 0;   /* Bottom of the rowid change constraint check */
  1151   1151     u8 isUpdate;         /* True if this is an UPDATE operation */
  1152   1152     u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
  1153   1153     int regRowid = -1;   /* Register holding ROWID value */
................................................................................
  1543   1543     int appendBias,     /* True if this is likely to be an append */
  1544   1544     int useSeekResult   /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */
  1545   1545   ){
  1546   1546     Vdbe *v;            /* Prepared statements under construction */
  1547   1547     Index *pIdx;        /* An index being inserted or updated */
  1548   1548     u8 pik_flags;       /* flag values passed to the btree insert */
  1549   1549     int regData;        /* Content registers (after the rowid) */
  1550         -  int regRec;         /* Register holding assemblied record for the table */
         1550  +  int regRec;         /* Register holding assembled record for the table */
  1551   1551     int i;              /* Loop counter */
  1552   1552     u8 bAffinityDone = 0; /* True if OP_Affinity has been run already */
  1553   1553   
  1554   1554     v = sqlite3GetVdbe(pParse);
  1555   1555     assert( v!=0 );
  1556   1556     assert( pTab->pSelect==0 );  /* This table is not a VIEW */
  1557   1557     for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){
................................................................................
  1668   1668   
  1669   1669   
  1670   1670   #ifdef SQLITE_TEST
  1671   1671   /*
  1672   1672   ** The following global variable is incremented whenever the
  1673   1673   ** transfer optimization is used.  This is used for testing
  1674   1674   ** purposes only - to make sure the transfer optimization really
  1675         -** is happening when it is suppose to.
         1675  +** is happening when it is supposed to.
  1676   1676   */
  1677   1677   int sqlite3_xferopt_count;
  1678   1678   #endif /* SQLITE_TEST */
  1679   1679   
  1680   1680   
  1681   1681   #ifndef SQLITE_OMIT_XFER_OPT
  1682   1682   /*
................................................................................
  1735   1735   
  1736   1736   /*
  1737   1737   ** Attempt the transfer optimization on INSERTs of the form
  1738   1738   **
  1739   1739   **     INSERT INTO tab1 SELECT * FROM tab2;
  1740   1740   **
  1741   1741   ** The xfer optimization transfers raw records from tab2 over to tab1.  
  1742         -** Columns are not decoded and reassemblied, which greatly improves
         1742  +** Columns are not decoded and reassembled, which greatly improves
  1743   1743   ** performance.  Raw index records are transferred in the same way.
  1744   1744   **
  1745   1745   ** The xfer optimization is only attempted if tab1 and tab2 are compatible.
  1746   1746   ** There are lots of rules for determining compatibility - see comments
  1747   1747   ** embedded in the code for details.
  1748   1748   **
  1749   1749   ** This routine returns TRUE if the optimization is guaranteed to be used.

Changes to src/main.c.

  2849   2849   ** by the next COMMIT or ROLLBACK.
  2850   2850   */
  2851   2851   int sqlite3_get_autocommit(sqlite3 *db){
  2852   2852     return db->autoCommit;
  2853   2853   }
  2854   2854   
  2855   2855   /*
  2856         -** The following routines are subtitutes for constants SQLITE_CORRUPT,
         2856  +** The following routines are substitutes for constants SQLITE_CORRUPT,
  2857   2857   ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_IOERR and possibly other error
  2858         -** constants.  They server two purposes:
         2858  +** constants.  They serve two purposes:
  2859   2859   **
  2860   2860   **   1.  Serve as a convenient place to set a breakpoint in a debugger
  2861   2861   **       to detect when version error conditions occurs.
  2862   2862   **
  2863   2863   **   2.  Invoke sqlite3_log() to provide the source code location where
  2864   2864   **       a low-level error is first detected.
  2865   2865   */
................................................................................
  3165   3165       ** Set the PENDING byte to the value in the argument, if X>0.
  3166   3166       ** Make no changes if X==0.  Return the value of the pending byte
  3167   3167       ** as it existing before this routine was called.
  3168   3168       **
  3169   3169       ** IMPORTANT:  Changing the PENDING byte from 0x40000000 results in
  3170   3170       ** an incompatible database file format.  Changing the PENDING byte
  3171   3171       ** while any database connection is open results in undefined and
  3172         -    ** dileterious behavior.
         3172  +    ** deleterious behavior.
  3173   3173       */
  3174   3174       case SQLITE_TESTCTRL_PENDING_BYTE: {
  3175   3175         rc = PENDING_BYTE;
  3176   3176   #ifndef SQLITE_OMIT_WSD
  3177   3177         {
  3178   3178           unsigned int newVal = va_arg(ap, unsigned int);
  3179   3179           if( newVal ) sqlite3PendingByte = newVal;

Changes to src/mem1.c.

   184    184   
   185    185   /*
   186    186   ** Like realloc().  Resize an allocation previously obtained from
   187    187   ** sqlite3MemMalloc().
   188    188   **
   189    189   ** For this low-level interface, we know that pPrior!=0.  Cases where
   190    190   ** pPrior==0 while have been intercepted by higher-level routine and
   191         -** redirected to xMalloc.  Similarly, we know that nByte>0 becauses
          191  +** redirected to xMalloc.  Similarly, we know that nByte>0 because
   192    192   ** cases where nByte<=0 will have been intercepted by higher-level
   193    193   ** routines and redirected to xFree.
   194    194   */
   195    195   static void *sqlite3MemRealloc(void *pPrior, int nByte){
   196    196   #ifdef SQLITE_MALLOCSIZE
   197    197     void *p = SQLITE_REALLOC(pPrior, nByte);
   198    198     if( p==0 ){

Changes to src/mem5.c.

    24     24   ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.
    25     25   **
    26     26   ** This memory allocator uses the following algorithm:
    27     27   **
    28     28   **   1.  All memory allocations sizes are rounded up to a power of 2.
    29     29   **
    30     30   **   2.  If two adjacent free blocks are the halves of a larger block,
    31         -**       then the two blocks are coalesed into the single larger block.
           31  +**       then the two blocks are coalesced into the single larger block.
    32     32   **
    33     33   **   3.  New memory is allocated from the first available free block.
    34     34   **
    35     35   ** This algorithm is described in: J. M. Robson. "Bounds for Some Functions
    36     36   ** Concerning Dynamic Storage Allocation". Journal of the Association for
    37     37   ** Computing Machinery, Volume 21, Number 8, July 1974, pages 491-499.
    38     38   ** 

Changes to src/memjournal.c.

    22     22   typedef struct FileChunk FileChunk;
    23     23   
    24     24   /* Space to hold the rollback journal is allocated in increments of
    25     25   ** this many bytes.
    26     26   **
    27     27   ** The size chosen is a little less than a power of two.  That way,
    28     28   ** the FileChunk object will have a size that almost exactly fills
    29         -** a power-of-two allocation.  This mimimizes wasted space in power-of-two
           29  +** a power-of-two allocation.  This minimizes wasted space in power-of-two
    30     30   ** memory allocators.
    31     31   */
    32     32   #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))
    33     33   
    34     34   /*
    35     35   ** The rollback journal is composed of a linked list of these structures.
    36     36   */

Changes to src/mutex.h.

    21     21   */
    22     22   
    23     23   
    24     24   /*
    25     25   ** Figure out what version of the code to use.  The choices are
    26     26   **
    27     27   **   SQLITE_MUTEX_OMIT         No mutex logic.  Not even stubs.  The
    28         -**                             mutexes implemention cannot be overridden
           28  +**                             mutexes implementation cannot be overridden
    29     29   **                             at start-time.
    30     30   **
    31     31   **   SQLITE_MUTEX_NOOP         For single-threaded applications.  No
    32     32   **                             mutual exclusion is provided.  But this
    33     33   **                             implementation can be overridden at
    34     34   **                             start-time.
    35     35   **

Changes to src/os.h.

   116    116   **
   117    117   ** The following #defines specify the range of bytes used for locking.
   118    118   ** SHARED_SIZE is the number of bytes available in the pool from which
   119    119   ** a random byte is selected for a shared lock.  The pool of bytes for
   120    120   ** shared locks begins at SHARED_FIRST. 
   121    121   **
   122    122   ** The same locking strategy and
   123         -** byte ranges are used for Unix.  This leaves open the possiblity of having
          123  +** byte ranges are used for Unix.  This leaves open the possibility of having
   124    124   ** clients on win95, winNT, and unix all talking to the same shared file
   125    125   ** and all locking correctly.  To do so would require that samba (or whatever
   126    126   ** tool is being used for file sharing) implements locks correctly between
   127    127   ** windows and unix.  I'm guessing that isn't likely to happen, but by
   128    128   ** using the same locking range we are at least open to the possibility.
   129    129   **
   130    130   ** Locking in windows is manditory.  For this reason, we cannot store

Changes to src/os_unix.c.

   635    635   }
   636    636   #endif
   637    637   
   638    638   
   639    639   #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
   640    640   /*
   641    641   ** Helper function for printing out trace information from debugging
   642         -** binaries. This returns the string represetation of the supplied
          642  +** binaries. This returns the string representation of the supplied
   643    643   ** integer lock-type.
   644    644   */
   645    645   static const char *azFileLock(int eFileLock){
   646    646     switch( eFileLock ){
   647    647       case NO_LOCK: return "NONE";
   648    648       case SHARED_LOCK: return "SHARED";
   649    649       case RESERVED_LOCK: return "RESERVED";
................................................................................
  3115   3115   /*
  3116   3116   ** Seek to the offset passed as the second argument, then read cnt 
  3117   3117   ** bytes into pBuf. Return the number of bytes actually read.
  3118   3118   **
  3119   3119   ** NB:  If you define USE_PREAD or USE_PREAD64, then it might also
  3120   3120   ** be necessary to define _XOPEN_SOURCE to be 500.  This varies from
  3121   3121   ** one system to another.  Since SQLite does not define USE_PREAD
  3122         -** any any form by default, we will not attempt to define _XOPEN_SOURCE.
         3122  +** in any form by default, we will not attempt to define _XOPEN_SOURCE.
  3123   3123   ** See tickets #2741 and #2681.
  3124   3124   **
  3125   3125   ** To avoid stomping the errno value on a failed read the lastErrno value
  3126   3126   ** is set before returning.
  3127   3127   */
  3128   3128   static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
  3129   3129     int got;
................................................................................
  3747   3747     }
  3748   3748   #endif
  3749   3749   
  3750   3750     return SQLITE_OK;
  3751   3751   }
  3752   3752   
  3753   3753   /*
  3754         -** If *pArg is inititially negative then this is a query.  Set *pArg to
         3754  +** If *pArg is initially negative then this is a query.  Set *pArg to
  3755   3755   ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
  3756   3756   **
  3757   3757   ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
  3758   3758   */
  3759   3759   static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){
  3760   3760     if( *pArg<0 ){
  3761   3761       *pArg = (pFile->ctrlFlags & mask)!=0;
................................................................................
  3954   3954   }
  3955   3955   #endif /* __QNXNTO__ */
  3956   3956   
  3957   3957   /*
  3958   3958   ** Return the device characteristics for the file.
  3959   3959   **
  3960   3960   ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.
  3961         -** However, that choice is contraversial since technically the underlying
         3961  +** However, that choice is controversial since technically the underlying
  3962   3962   ** file system does not always provide powersafe overwrites.  (In other
  3963   3963   ** words, after a power-loss event, parts of the file that were never
  3964   3964   ** written might end up being altered.)  However, non-PSOW behavior is very,
  3965   3965   ** very rare.  And asserting PSOW makes a large reduction in the amount
  3966   3966   ** of required I/O for journaling, since a lot of padding is eliminated.
  3967   3967   **  Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control
  3968   3968   ** available to turn it off and URI query parameter available to turn it off.
................................................................................
  4926   4926   ** the correct finder-function for that VFS.
  4927   4927   **
  4928   4928   ** Most finder functions return a pointer to a fixed sqlite3_io_methods
  4929   4929   ** object.  The only interesting finder-function is autolockIoFinder, which
  4930   4930   ** looks at the filesystem type and tries to guess the best locking
  4931   4931   ** strategy from that.
  4932   4932   **
  4933         -** For finder-funtion F, two objects are created:
         4933  +** For finder-function F, two objects are created:
  4934   4934   **
  4935   4935   **    (1) The real finder-function named "FImpt()".
  4936   4936   **
  4937   4937   **    (2) A constant pointer to this function named just "F".
  4938   4938   **
  4939   4939   **
  4940   4940   ** A pointer to the F pointer is used as the pAppData value for VFS
................................................................................
  5188   5188   }
  5189   5189   static const sqlite3_io_methods 
  5190   5190     *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
  5191   5191   
  5192   5192   #endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
  5193   5193   
  5194   5194   /*
  5195         -** An abstract type for a pointer to a IO method finder function:
         5195  +** An abstract type for a pointer to an IO method finder function:
  5196   5196   */
  5197   5197   typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*);
  5198   5198   
  5199   5199   
  5200   5200   /****************************************************************************
  5201   5201   **************************** sqlite3_vfs methods ****************************
  5202   5202   **
................................................................................
  5502   5502     /* A stat() call may fail for various reasons. If this happens, it is
  5503   5503     ** almost certain that an open() call on the same path will also fail.
  5504   5504     ** For this reason, if an error occurs in the stat() call here, it is
  5505   5505     ** ignored and -1 is returned. The caller will try to open a new file
  5506   5506     ** descriptor on the same path, fail, and return an error to SQLite.
  5507   5507     **
  5508   5508     ** Even if a subsequent open() call does succeed, the consequences of
  5509         -  ** not searching for a resusable file descriptor are not dire.  */
         5509  +  ** not searching for a reusable file descriptor are not dire.  */
  5510   5510     if( 0==osStat(zPath, &sStat) ){
  5511   5511       unixInodeInfo *pInode;
  5512   5512   
  5513   5513       unixEnterMutex();
  5514   5514       pInode = inodeList;
  5515   5515       while( pInode && (pInode->fileId.dev!=sStat.st_dev
  5516   5516                        || pInode->fileId.ino!=sStat.st_ino) ){
................................................................................
  5533   5533   /*
  5534   5534   ** This function is called by unixOpen() to determine the unix permissions
  5535   5535   ** to create new files with. If no error occurs, then SQLITE_OK is returned
  5536   5536   ** and a value suitable for passing as the third argument to open(2) is
  5537   5537   ** written to *pMode. If an IO error occurs, an SQLite error code is 
  5538   5538   ** returned and the value of *pMode is not modified.
  5539   5539   **
  5540         -** In most cases cases, this routine sets *pMode to 0, which will become
         5540  +** In most cases, this routine sets *pMode to 0, which will become
  5541   5541   ** an indication to robust_open() to create the file using
  5542   5542   ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask.
  5543   5543   ** But if the file being opened is a WAL or regular journal file, then 
  5544   5544   ** this function queries the file-system for the permissions on the 
  5545   5545   ** corresponding database file and sets *pMode to this value. Whenever 
  5546   5546   ** possible, WAL and journal files are created using the same permissions 
  5547   5547   ** as the associated database file.
................................................................................
  6325   6325   **
  6326   6326   ** The conch file - to use a proxy file, sqlite must first "hold the conch"
  6327   6327   ** by taking an sqlite-style shared lock on the conch file, reading the
  6328   6328   ** contents and comparing the host's unique host ID (see below) and lock
  6329   6329   ** proxy path against the values stored in the conch.  The conch file is
  6330   6330   ** stored in the same directory as the database file and the file name
  6331   6331   ** is patterned after the database file name as ".<databasename>-conch".
  6332         -** If the conch file does not exist, or it's contents do not match the
         6332  +** If the conch file does not exist, or its contents do not match the
  6333   6333   ** host ID and/or proxy path, then the lock is escalated to an exclusive
  6334   6334   ** lock and the conch file contents is updated with the host ID and proxy
  6335   6335   ** path and the lock is downgraded to a shared lock again.  If the conch
  6336   6336   ** is held by another process (with a shared lock), the exclusive lock
  6337   6337   ** will fail and SQLITE_BUSY is returned.
  6338   6338   **
  6339   6339   ** The proxy file - a single-byte file used for all advisory file locks
................................................................................
  6377   6377   **       lock proxy files, only used when LOCKPROXYDIR is not set.
  6378   6378   **    
  6379   6379   **    
  6380   6380   ** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,
  6381   6381   ** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will
  6382   6382   ** force proxy locking to be used for every database file opened, and 0
  6383   6383   ** will force automatic proxy locking to be disabled for all database
  6384         -** files (explicity calling the SQLITE_SET_LOCKPROXYFILE pragma or
         6384  +** files (explicitly calling the SQLITE_SET_LOCKPROXYFILE pragma or
  6385   6385   ** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).
  6386   6386   */
  6387   6387   
  6388   6388   /*
  6389   6389   ** Proxy locking is only available on MacOSX 
  6390   6390   */
  6391   6391   #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE

Changes to src/os_win.c.

  3124   3124     pFile->locktype = (u8)locktype;
  3125   3125     OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
  3126   3126              pFile->h, pFile->locktype, sqlite3ErrName(rc)));
  3127   3127     return rc;
  3128   3128   }
  3129   3129   
  3130   3130   /*
  3131         -** If *pArg is inititially negative then this is a query.  Set *pArg to
         3131  +** If *pArg is initially negative then this is a query.  Set *pArg to
  3132   3132   ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set.
  3133   3133   **
  3134   3134   ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags.
  3135   3135   */
  3136   3136   static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){
  3137   3137     if( *pArg<0 ){
  3138   3138       *pArg = (pFile->ctrlFlags & mask)!=0;
................................................................................
  4138   4138              osGetCurrentProcessId(), pFd, iOff, p));
  4139   4139   
  4140   4140     if( p ){
  4141   4141       pFd->nFetchOut--;
  4142   4142     }else{
  4143   4143       /* FIXME:  If Windows truly always prevents truncating or deleting a
  4144   4144       ** file while a mapping is held, then the following winUnmapfile() call
  4145         -    ** is unnecessary can can be omitted - potentially improving
         4145  +    ** is unnecessary can be omitted - potentially improving
  4146   4146       ** performance.  */
  4147   4147       winUnmapfile(pFd);
  4148   4148     }
  4149   4149   
  4150   4150     assert( pFd->nFetchOut>=0 );
  4151   4151   #endif
  4152   4152   

Changes to src/pager.c.

    72     72   ** 
    73     73   ** (6) If a master journal file is used, then all writes to the database file
    74     74   **     are synced prior to the master journal being deleted.
    75     75   ** 
    76     76   ** Definition: Two databases (or the same database at two points it time)
    77     77   ** are said to be "logically equivalent" if they give the same answer to
    78     78   ** all queries.  Note in particular the content of freelist leaf
    79         -** pages can be changed arbitarily without effecting the logical equivalence
           79  +** pages can be changed arbitrarily without affecting the logical equivalence
    80     80   ** of the database.
    81     81   ** 
    82     82   ** (7) At any time, if any subset, including the empty set and the total set,
    83     83   **     of the unsynced changes to a rollback journal are removed and the 
    84         -**     journal is rolled back, the resulting database file will be logical
           84  +**     journal is rolled back, the resulting database file will be logically
    85     85   **     equivalent to the database file at the beginning of the transaction.
    86     86   ** 
    87     87   ** (8) When a transaction is rolled back, the xTruncate method of the VFS
    88     88   **     is called to restore the database file to the same size it was at
    89     89   **     the beginning of the transaction.  (In some VFSes, the xTruncate
    90     90   **     method is a no-op, but that does not change the fact the SQLite will
    91     91   **     invoke it.)
................................................................................
   374    374   **
   375    375   ** This is usually safe. If an xUnlock fails or appears to fail, there may 
   376    376   ** be a few redundant xLock() calls or a lock may be held for longer than
   377    377   ** required, but nothing really goes wrong.
   378    378   **
   379    379   ** The exception is when the database file is unlocked as the pager moves
   380    380   ** from ERROR to OPEN state. At this point there may be a hot-journal file 
   381         -** in the file-system that needs to be rolled back (as part of a OPEN->SHARED
          381  +** in the file-system that needs to be rolled back (as part of an OPEN->SHARED
   382    382   ** transition, by the same pager or any other). If the call to xUnlock()
   383    383   ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
   384    384   ** can confuse the call to xCheckReservedLock() call made later as part
   385    385   ** of hot-journal detection.
   386    386   **
   387    387   ** xCheckReservedLock() is defined as returning true "if there is a RESERVED 
   388    388   ** lock held by this process or any others". So xCheckReservedLock may 
................................................................................
   457    457   ** Bits of the Pager.doNotSpill flag.  See further description below.
   458    458   */
   459    459   #define SPILLFLAG_OFF         0x01      /* Never spill cache.  Set via pragma */
   460    460   #define SPILLFLAG_ROLLBACK    0x02      /* Current rolling back, so do not spill */
   461    461   #define SPILLFLAG_NOSYNC      0x04      /* Spill is ok, but do not sync */
   462    462   
   463    463   /*
   464         -** A open page cache is an instance of struct Pager. A description of
          464  +** An open page cache is an instance of struct Pager. A description of
   465    465   ** some of the more important member variables follows:
   466    466   **
   467    467   ** eState
   468    468   **
   469    469   **   The current 'state' of the pager object. See the comment and state
   470    470   **   diagram above for a description of the pager state.
   471    471   **
................................................................................
   629    629     u8 tempFile;                /* zFilename is a temporary or immutable file */
   630    630     u8 noLock;                  /* Do not lock (except in WAL mode) */
   631    631     u8 readOnly;                /* True for a read-only database */
   632    632     u8 memDb;                   /* True to inhibit all file I/O */
   633    633   
   634    634     /**************************************************************************
   635    635     ** The following block contains those class members that change during
   636         -  ** routine opertion.  Class members not in this block are either fixed
          636  +  ** routine operation.  Class members not in this block are either fixed
   637    637     ** when the pager is first created or else only change when there is a
   638    638     ** significant mode change (such as changing the page_size, locking_mode,
   639    639     ** or the journal_mode).  From another view, these class members describe
   640    640     ** the "state" of the pager, while other class members describe the
   641    641     ** "configuration" of the pager.
   642    642     */
   643    643     u8 eState;                  /* Pager state (OPEN, READER, WRITER_LOCKED..) */
................................................................................
  2493   2493   **
  2494   2494   ** If the main database file is not open, or the pager is not in either
  2495   2495   ** DBMOD or OPEN state, this function is a no-op. Otherwise, the size 
  2496   2496   ** of the file is changed to nPage pages (nPage*pPager->pageSize bytes). 
  2497   2497   ** If the file on disk is currently larger than nPage pages, then use the VFS
  2498   2498   ** xTruncate() method to truncate it.
  2499   2499   **
  2500         -** Or, it might might be the case that the file on disk is smaller than 
         2500  +** Or, it might be the case that the file on disk is smaller than 
  2501   2501   ** nPage pages. Some operating system implementations can get confused if 
  2502   2502   ** you try to truncate a file to some size that is larger than it 
  2503   2503   ** currently is, so detect this case and write a single zero byte to 
  2504   2504   ** the end of the new file instead.
  2505   2505   **
  2506   2506   ** If successful, return SQLITE_OK. If an IO error occurs while modifying
  2507   2507   ** the database file, return the error code to the caller.
................................................................................
  2552   2552     }
  2553   2553     return iRet;
  2554   2554   }
  2555   2555   
  2556   2556   /*
  2557   2557   ** Set the value of the Pager.sectorSize variable for the given
  2558   2558   ** pager based on the value returned by the xSectorSize method
  2559         -** of the open database file. The sector size will be used used 
         2559  +** of the open database file. The sector size will be used 
  2560   2560   ** to determine the size and alignment of journal header and 
  2561   2561   ** master journal pointers within created journal files.
  2562   2562   **
  2563   2563   ** For temporary files the effective sector size is always 512 bytes.
  2564   2564   **
  2565   2565   ** Otherwise, for non-temporary files, the effective sector size is
  2566   2566   ** the value returned by the xSectorSize() method rounded up to 32 if
................................................................................
  3614   3614       if( rc==SQLITE_OK ){
  3615   3615         pNew = (char *)sqlite3PageMalloc(pageSize);
  3616   3616         if( !pNew ) rc = SQLITE_NOMEM;
  3617   3617       }
  3618   3618   
  3619   3619       if( rc==SQLITE_OK ){
  3620   3620         pager_reset(pPager);
  3621         -      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
  3622         -      pPager->pageSize = pageSize;
  3623   3621         sqlite3PageFree(pPager->pTmpSpace);
  3624   3622         pPager->pTmpSpace = pNew;
  3625   3623         rc = sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
  3626   3624       }
         3625  +    if( rc==SQLITE_OK ){
         3626  +      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
         3627  +      pPager->pageSize = pageSize;
         3628  +    }
  3627   3629     }
  3628   3630   
  3629   3631     *pPageSize = pPager->pageSize;
  3630   3632     if( rc==SQLITE_OK ){
  3631   3633       if( nReserve<0 ) nReserve = pPager->nReserve;
  3632   3634       assert( nReserve>=0 && nReserve<1000 );
  3633   3635       pPager->nReserve = (i16)nReserve;
................................................................................
  3752   3754   ** the lock. If the lock is obtained successfully, set the Pager.state 
  3753   3755   ** variable to locktype before returning.
  3754   3756   */
  3755   3757   static int pager_wait_on_lock(Pager *pPager, int locktype){
  3756   3758     int rc;                              /* Return code */
  3757   3759   
  3758   3760     /* Check that this is either a no-op (because the requested lock is 
  3759         -  ** already held, or one of the transistions that the busy-handler
         3761  +  ** already held), or one of the transitions that the busy-handler
  3760   3762     ** may be invoked during, according to the comment above
  3761   3763     ** sqlite3PagerSetBusyhandler().
  3762   3764     */
  3763   3765     assert( (pPager->eLock>=locktype)
  3764   3766          || (pPager->eLock==NO_LOCK && locktype==SHARED_LOCK)
  3765   3767          || (pPager->eLock==RESERVED_LOCK && locktype==EXCLUSIVE_LOCK)
  3766   3768     );
................................................................................
  4380   4382     ** pages belonging to the same sector.
  4381   4383     **
  4382   4384     ** The doNotSpill ROLLBACK and OFF bits inhibits all cache spilling
  4383   4385     ** regardless of whether or not a sync is required.  This is set during
  4384   4386     ** a rollback or by user request, respectively.
  4385   4387     **
  4386   4388     ** Spilling is also prohibited when in an error state since that could
  4387         -  ** lead to database corruption.   In the current implementaton it 
         4389  +  ** lead to database corruption.   In the current implementation it 
  4388   4390     ** is impossible for sqlite3PcacheFetch() to be called with createFlag==3
  4389   4391     ** while in the error state, hence it is impossible for this routine to
  4390   4392     ** be called in the error state.  Nevertheless, we include a NEVER()
  4391   4393     ** test for the error state as a safeguard against future changes.
  4392   4394     */
  4393   4395     if( NEVER(pPager->errCode) ) return SQLITE_OK;
  4394   4396     testcase( pPager->doNotSpill & SPILLFLAG_ROLLBACK );
................................................................................
  4920   4922               }
  4921   4923               if( !jrnlOpen ){
  4922   4924                 sqlite3OsClose(pPager->jfd);
  4923   4925               }
  4924   4926               *pExists = (first!=0);
  4925   4927             }else if( rc==SQLITE_CANTOPEN ){
  4926   4928               /* If we cannot open the rollback journal file in order to see if
  4927         -            ** its has a zero header, that might be due to an I/O error, or
         4929  +            ** it has a zero header, that might be due to an I/O error, or
  4928   4930               ** it might be due to the race condition described above and in
  4929   4931               ** ticket #3883.  Either way, assume that the journal is hot.
  4930   4932               ** This might be a false positive.  But if it is, then the
  4931   4933               ** automatic journal playback and recovery mechanism will deal
  4932   4934               ** with it under an EXCLUSIVE lock where we do not need to
  4933   4935               ** worry so much with race conditions.
  4934   4936               */

Changes to src/pcache.c.

   386    386       pCache->pPage1 = pPgHdr;
   387    387     }
   388    388     return pPgHdr;
   389    389   }
   390    390   
   391    391   /*
   392    392   ** Decrement the reference count on a page. If the page is clean and the
   393         -** reference count drops to 0, then it is made elible for recycling.
          393  +** reference count drops to 0, then it is made eligible for recycling.
   394    394   */
   395    395   void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){
   396    396     assert( p->nRef>0 );
   397    397     p->nRef--;
   398    398     if( p->nRef==0 ){
   399    399       p->pCache->nRef--;
   400    400       if( (p->flags&PGHDR_DIRTY)==0 ){

Changes to src/pcache1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file implements the default page cache implementation (the
    14     14   ** sqlite3_pcache interface). It also contains part of the implementation
    15     15   ** of the SQLITE_CONFIG_PAGECACHE and sqlite3_release_memory() features.
    16         -** If the default page cache implementation is overriden, then neither of
           16  +** If the default page cache implementation is overridden, then neither of
    17     17   ** these two features are available.
    18     18   */
    19     19   
    20     20   #include "sqliteInt.h"
    21     21   
    22     22   typedef struct PCache1 PCache1;
    23     23   typedef struct PgHdr1 PgHdr1;
    24     24   typedef struct PgFreeslot PgFreeslot;
    25     25   typedef struct PGroup PGroup;
    26     26   
    27     27   /* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set 
    28         -** of one or more PCaches that are able to recycle each others unpinned
           28  +** of one or more PCaches that are able to recycle each other's unpinned
    29     29   ** pages when they are under memory pressure.  A PGroup is an instance of
    30     30   ** the following object.
    31     31   **
    32     32   ** This page cache implementation works in one of two modes:
    33     33   **
    34     34   **   (1)  Every PCache is the sole member of its own PGroup.  There is
    35     35   **        one PGroup per PCache.

Changes to src/printf.c.

   900    900     z = sqlite3VMPrintf(db, zFormat, ap);
   901    901     va_end(ap);
   902    902     return z;
   903    903   }
   904    904   
   905    905   /*
   906    906   ** Like sqlite3MPrintf(), but call sqlite3DbFree() on zStr after formatting
   907         -** the string and before returnning.  This routine is intended to be used
          907  +** the string and before returning.  This routine is intended to be used
   908    908   ** to modify an existing string.  For example:
   909    909   **
   910    910   **       x = sqlite3MPrintf(db, x, "prefix %s suffix", x);
   911    911   **
   912    912   */
   913    913   char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zFormat, ...){
   914    914     va_list ap;

Changes to src/resolve.c.

  1114   1114         }
  1115   1115       }
  1116   1116     }
  1117   1117     return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType);
  1118   1118   }
  1119   1119   
  1120   1120   /*
  1121         -** Resolve names in the SELECT statement p and all of its descendents.
         1121  +** Resolve names in the SELECT statement p and all of its descendants.
  1122   1122   */
  1123   1123   static int resolveSelectStep(Walker *pWalker, Select *p){
  1124   1124     NameContext *pOuterNC;  /* Context that contains this SELECT */
  1125   1125     NameContext sNC;        /* Name context of this SELECT */
  1126   1126     int isCompound;         /* True if p is a compound select */
  1127   1127     int nCompound;          /* Number of compound terms processed so far */
  1128   1128     Parse *pParse;          /* Parsing context */

Changes to src/rowset.c.

    46     46   ** value added by the INSERT will not be visible to the second TEST.
    47     47   ** The initial batch number is zero, so if the very first TEST contains
    48     48   ** a non-zero batch number, it will see all prior INSERTs.
    49     49   **
    50     50   ** No INSERTs may occurs after a SMALLEST.  An assertion will fail if
    51     51   ** that is attempted.
    52     52   **
    53         -** The cost of an INSERT is roughly constant.  (Sometime new memory
           53  +** The cost of an INSERT is roughly constant.  (Sometimes new memory
    54     54   ** has to be allocated on an INSERT.)  The cost of a TEST with a new
    55     55   ** batch number is O(NlogN) where N is the number of elements in the RowSet.
    56     56   ** The cost of a TEST using the same batch number is O(logN).  The cost
    57     57   ** of the first SMALLEST is O(NlogN).  Second and subsequent SMALLEST
    58     58   ** primitives are constant time.  The cost of DESTROY is O(N).
    59     59   **
    60     60   ** There is an added cost of O(N) when switching between TEST and
................................................................................
   439    439     }
   440    440   }
   441    441   
   442    442   /*
   443    443   ** Check to see if element iRowid was inserted into the rowset as
   444    444   ** part of any insert batch prior to iBatch.  Return 1 or 0.
   445    445   **
   446         -** If this is the first test of a new batch and if there exist entires
   447         -** on pRowSet->pEntry, then sort those entires into the forest at
          446  +** If this is the first test of a new batch and if there exist entries
          447  +** on pRowSet->pEntry, then sort those entries into the forest at
   448    448   ** pRowSet->pForest so that they can be tested.
   449    449   */
   450    450   int sqlite3RowSetTest(RowSet *pRowSet, int iBatch, sqlite3_int64 iRowid){
   451    451     struct RowSetEntry *p, *pTree;
   452    452   
   453    453     /* This routine is never called after sqlite3RowSetNext() */
   454    454     assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );

Changes to src/select.c.

  1006   1006   **
  1007   1007   ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting
  1008   1008   ** KeyInfo structure is appropriate for initializing a virtual index to
  1009   1009   ** implement that clause.  If the ExprList is the result set of a SELECT
  1010   1010   ** then the KeyInfo structure is appropriate for initializing a virtual
  1011   1011   ** index to implement a DISTINCT test.
  1012   1012   **
  1013         -** Space to hold the KeyInfo structure is obtain from malloc.  The calling
         1013  +** Space to hold the KeyInfo structure is obtained from malloc.  The calling
  1014   1014   ** function is responsible for seeing that this structure is eventually
  1015   1015   ** freed.
  1016   1016   */
  1017   1017   static KeyInfo *keyInfoFromExprList(
  1018   1018     Parse *pParse,       /* Parsing context */
  1019   1019     ExprList *pList,     /* Form the KeyInfo object from this ExprList */
  1020   1020     int iStart,          /* Begin with this column of pList */
................................................................................
  1537   1537         sqlite3VdbeSetColName(v, i, COLNAME_NAME, z, SQLITE_DYNAMIC);
  1538   1538       }
  1539   1539     }
  1540   1540     generateColumnTypes(pParse, pTabList, pEList);
  1541   1541   }
  1542   1542   
  1543   1543   /*
  1544         -** Given a an expression list (which is really the list of expressions
         1544  +** Given an expression list (which is really the list of expressions
  1545   1545   ** that form the result set of a SELECT statement) compute appropriate
  1546   1546   ** column names for a table that would hold the expression list.
  1547   1547   **
  1548   1548   ** All column names will be unique.
  1549   1549   **
  1550   1550   ** Only the column names are computed.  Column.zType, Column.zColl,
  1551   1551   ** and other fields of Column are zeroed.
................................................................................
  1610   1610       }
  1611   1611       if( db->mallocFailed ){
  1612   1612         sqlite3DbFree(db, zName);
  1613   1613         break;
  1614   1614       }
  1615   1615   
  1616   1616       /* Make sure the column name is unique.  If the name is not unique,
  1617         -    ** append a integer to the name so that it becomes unique.
         1617  +    ** append an integer to the name so that it becomes unique.
  1618   1618       */
  1619   1619       nName = sqlite3Strlen30(zName);
  1620   1620       for(j=cnt=0; j<i; j++){
  1621   1621         if( sqlite3StrICmp(aCol[j].zName, zName)==0 ){
  1622   1622           char *zNewName;
  1623   1623           int k;
  1624   1624           for(k=nName-1; k>1 && sqlite3Isdigit(zName[k]); k--){}
................................................................................
  3094   3094   ** optimized.
  3095   3095   **
  3096   3096   ** This routine attempts to rewrite queries such as the above into
  3097   3097   ** a single flat select, like this:
  3098   3098   **
  3099   3099   **     SELECT x+y AS a FROM t1 WHERE z<100 AND a>5
  3100   3100   **
  3101         -** The code generated for this simpification gives the same result
         3101  +** The code generated for this simplification gives the same result
  3102   3102   ** but only has to scan the data once.  And because indices might 
  3103   3103   ** exist on the table t1, a complete scan of the data might be
  3104   3104   ** avoided.
  3105   3105   **
  3106   3106   ** Flattening is only attempted if all of the following are true:
  3107   3107   **
  3108   3108   **   (1)  The subquery and the outer query do not both use aggregates.
................................................................................
  3238   3238     pSub = pSubitem->pSelect;
  3239   3239     assert( pSub!=0 );
  3240   3240     if( isAgg && subqueryIsAgg ) return 0;                 /* Restriction (1)  */
  3241   3241     if( subqueryIsAgg && pSrc->nSrc>1 ) return 0;          /* Restriction (2)  */
  3242   3242     pSubSrc = pSub->pSrc;
  3243   3243     assert( pSubSrc );
  3244   3244     /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
  3245         -  ** not arbitrary expresssions, we allowed some combining of LIMIT and OFFSET
         3245  +  ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET
  3246   3246     ** because they could be computed at compile-time.  But when LIMIT and OFFSET
  3247   3247     ** became arbitrary expressions, we were forced to add restrictions (13)
  3248   3248     ** and (14). */
  3249   3249     if( pSub->pLimit && p->pLimit ) return 0;              /* Restriction (13) */
  3250   3250     if( pSub->pOffset ) return 0;                          /* Restriction (14) */
  3251   3251     if( (p->selFlags & SF_Compound)!=0 && pSub->pLimit ){
  3252   3252       return 0;                                            /* Restriction (15) */
................................................................................
  3624   3624   
  3625   3625     assert( *ppMinMax==0 || (*ppMinMax)->nExpr==1 );
  3626   3626     return eRet;
  3627   3627   }
  3628   3628   
  3629   3629   /*
  3630   3630   ** The select statement passed as the first argument is an aggregate query.
  3631         -** The second argment is the associated aggregate-info object. This 
         3631  +** The second argument is the associated aggregate-info object. This 
  3632   3632   ** function tests if the SELECT is of the form:
  3633   3633   **
  3634   3634   **   SELECT count(*) FROM <tbl>
  3635   3635   **
  3636   3636   ** where table is a database table, not a sub-select or view. If the query
  3637   3637   ** does match this pattern, then a pointer to the Table object representing
  3638   3638   ** <tbl> is returned. Otherwise, 0 is returned.
................................................................................
  3954   3954   **         element of the FROM clause.
  3955   3955   **
  3956   3956   **    (2)  Fill in the pTabList->a[].pTab fields in the SrcList that 
  3957   3957   **         defines FROM clause.  When views appear in the FROM clause,
  3958   3958   **         fill pTabList->a[].pSelect with a copy of the SELECT statement
  3959   3959   **         that implements the view.  A copy is made of the view's SELECT
  3960   3960   **         statement so that we can freely modify or delete that statement
  3961         -**         without worrying about messing up the presistent representation
         3961  +**         without worrying about messing up the persistent representation
  3962   3962   **         of the view.
  3963   3963   **
  3964         -**    (3)  Add terms to the WHERE clause to accomodate the NATURAL keyword
         3964  +**    (3)  Add terms to the WHERE clause to accommodate the NATURAL keyword
  3965   3965   **         on joins and the ON and USING clause of joins.
  3966   3966   **
  3967   3967   **    (4)  Scan the list of columns in the result set (pEList) looking
  3968   3968   **         for instances of the "*" operator or the TABLE.* operator.
  3969   3969   **         If found, expand each "*" to be every column in every table
  3970   3970   **         and TABLE.* to be every column in TABLE.
  3971   3971   **

Changes to src/sqlite.h.in.

  2090   2090   ** the handler returns 0 which causes [sqlite3_step()] to return
  2091   2091   ** [SQLITE_BUSY].
  2092   2092   **
  2093   2093   ** ^Calling this routine with an argument less than or equal to zero
  2094   2094   ** turns off all busy handlers.
  2095   2095   **
  2096   2096   ** ^(There can only be a single busy handler for a particular
  2097         -** [database connection] any any given moment.  If another busy handler
         2097  +** [database connection] at any given moment.  If another busy handler
  2098   2098   ** was defined  (using [sqlite3_busy_handler()]) prior to calling
  2099   2099   ** this routine, that other busy handler is cleared.)^
  2100   2100   **
  2101   2101   ** See also:  [PRAGMA busy_timeout]
  2102   2102   */
  2103   2103   int sqlite3_busy_timeout(sqlite3*, int ms);
  2104   2104   
................................................................................
  4160   4160   ** extract values from the [sqlite3_value] objects.
  4161   4161   **
  4162   4162   ** These routines work only with [protected sqlite3_value] objects.
  4163   4163   ** Any attempt to use these routines on an [unprotected sqlite3_value]
  4164   4164   ** object results in undefined behavior.
  4165   4165   **
  4166   4166   ** ^These routines work just like the corresponding [column access functions]
  4167         -** except that  these routines take a single [protected sqlite3_value] object
         4167  +** except that these routines take a single [protected sqlite3_value] object
  4168   4168   ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
  4169   4169   **
  4170   4170   ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  4171   4171   ** in the native byte-order of the host machine.  ^The
  4172   4172   ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  4173   4173   ** extract UTF-16 strings as big-endian and little-endian respectively.
  4174   4174   **
................................................................................
  6353   6353   ** <dd>This parameter returns the number malloc attempts that might have
  6354   6354   ** been satisfied using lookaside memory but failed due to all lookaside
  6355   6355   ** memory already being in use.
  6356   6356   ** Only the high-water value is meaningful;
  6357   6357   ** the current value is always zero.)^
  6358   6358   **
  6359   6359   ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
  6360         -** <dd>This parameter returns the approximate number of of bytes of heap
         6360  +** <dd>This parameter returns the approximate number of bytes of heap
  6361   6361   ** memory used by all pager caches associated with the database connection.)^
  6362   6362   ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
  6363   6363   **
  6364   6364   ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
  6365         -** <dd>This parameter returns the approximate number of of bytes of heap
         6365  +** <dd>This parameter returns the approximate number of bytes of heap
  6366   6366   ** memory used to store the schema for all databases associated
  6367   6367   ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ 
  6368   6368   ** ^The full amount of memory used by the schemas is reported, even if the
  6369   6369   ** schema memory is shared with other database connections due to
  6370   6370   ** [shared cache mode] being enabled.
  6371   6371   ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
  6372   6372   **
  6373   6373   ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
  6374         -** <dd>This parameter returns the approximate number of of bytes of heap
         6374  +** <dd>This parameter returns the approximate number of bytes of heap
  6375   6375   ** and lookaside memory used by all prepared statements associated with
  6376   6376   ** the database connection.)^
  6377   6377   ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
  6378   6378   ** </dd>
  6379   6379   **
  6380   6380   ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
  6381   6381   ** <dd>This parameter returns the number of pager cache hits that have

Changes to src/sqlite3ext.h.

    24     24   /*
    25     25   ** The following structure holds pointers to all of the SQLite API
    26     26   ** routines.
    27     27   **
    28     28   ** WARNING:  In order to maintain backwards compatibility, add new
    29     29   ** interfaces to the end of this structure only.  If you insert new
    30     30   ** interfaces in the middle of this structure, then older different
    31         -** versions of SQLite will not be able to load each others' shared
           31  +** versions of SQLite will not be able to load each other's shared
    32     32   ** libraries!
    33     33   */
    34     34   struct sqlite3_api_routines {
    35     35     void * (*aggregate_context)(sqlite3_context*,int nBytes);
    36     36     int  (*aggregate_count)(sqlite3_context*);
    37     37     int  (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
    38     38     int  (*bind_double)(sqlite3_stmt*,int,double);
................................................................................
   250    250     const char *(*uri_parameter)(const char*,const char*);
   251    251     char *(*vsnprintf)(int,char*,const char*,va_list);
   252    252     int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
   253    253   };
   254    254   
   255    255   /*
   256    256   ** The following macros redefine the API routines so that they are
   257         -** redirected throught the global sqlite3_api structure.
          257  +** redirected through the global sqlite3_api structure.
   258    258   **
   259    259   ** This header file is also used by the loadext.c source file
   260    260   ** (part of the main SQLite library - not an extension) so that
   261    261   ** it can get access to the sqlite3_api_routines structure
   262    262   ** definition.  But the main library does not want to redefine
   263    263   ** the API.  So the redefinition macros are only valid if the
   264    264   ** SQLITE_CORE macros is undefined.

Changes to src/sqliteInt.h.

   347    347   # define NEVER(X)       ((X)?(assert(0),1):0)
   348    348   #else
   349    349   # define ALWAYS(X)      (X)
   350    350   # define NEVER(X)       (X)
   351    351   #endif
   352    352   
   353    353   /*
   354         -** Return true (non-zero) if the input is a integer that is too large
          354  +** Return true (non-zero) if the input is an integer that is too large
   355    355   ** to fit in 32-bits.  This macro is used inside of various testcase()
   356    356   ** macros to verify that we have tested SQLite for large-file support.
   357    357   */
   358    358   #define IS_BIG_INT(X)  (((X)&~(i64)0xffffffff)!=0)
   359    359   
   360    360   /*
   361    361   ** The macro unlikely() is a hint that surrounds a boolean
................................................................................
   635    635   
   636    636   /*
   637    637   ** Assert that the pointer X is aligned to an 8-byte boundary.  This
   638    638   ** macro is used only within assert() to verify that the code gets
   639    639   ** all alignment restrictions correct.
   640    640   **
   641    641   ** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the
   642         -** underlying malloc() implemention might return us 4-byte aligned
          642  +** underlying malloc() implementation might return us 4-byte aligned
   643    643   ** pointers.  In that case, only verify 4-byte alignment.
   644    644   */
   645    645   #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
   646    646   # define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&3)==0)
   647    647   #else
   648    648   # define EIGHT_BYTE_ALIGNMENT(X)   ((((char*)(X) - (char*)0)&7)==0)
   649    649   #endif
................................................................................
  1155   1155   #define SQLITE_DistinctOpt    0x0020   /* DISTINCT using indexes */
  1156   1156   #define SQLITE_CoverIdxScan   0x0040   /* Covering index scans */
  1157   1157   #define SQLITE_OrderByIdxJoin 0x0080   /* ORDER BY of joins via index */
  1158   1158   #define SQLITE_SubqCoroutine  0x0100   /* Evaluate subqueries as coroutines */
  1159   1159   #define SQLITE_Transitive     0x0200   /* Transitive constraints */
  1160   1160   #define SQLITE_OmitNoopJoin   0x0400   /* Omit unused tables in joins */
  1161   1161   #define SQLITE_Stat3          0x0800   /* Use the SQLITE_STAT3 table */
  1162         -#define SQLITE_AdjustOutEst   0x1000   /* Adjust output estimates using WHERE */
  1163   1162   #define SQLITE_AllOpts        0xffff   /* All optimizations */
  1164   1163   
  1165   1164   /*
  1166   1165   ** Macros for testing whether or not optimizations are enabled or disabled.
  1167   1166   */
  1168   1167   #ifndef SQLITE_OMIT_BUILTIN_TEST
  1169   1168   #define OptimizationDisabled(db, mask)  (((db)->dbOptFlags&(mask))!=0)
................................................................................
  2880   2879   #define SQLITE_CORRUPT_BKPT sqlite3CorruptError(__LINE__)
  2881   2880   #define SQLITE_MISUSE_BKPT sqlite3MisuseError(__LINE__)
  2882   2881   #define SQLITE_CANTOPEN_BKPT sqlite3CantopenError(__LINE__)
  2883   2882   
  2884   2883   
  2885   2884   /*
  2886   2885   ** FTS4 is really an extension for FTS3.  It is enabled using the
  2887         -** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also all
  2888         -** the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3.
         2886  +** SQLITE_ENABLE_FTS3 macro.  But to avoid confusion we also call
         2887  +** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
  2889   2888   */
  2890   2889   #if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
  2891   2890   # define SQLITE_ENABLE_FTS3
  2892   2891   #endif
  2893   2892   
  2894   2893   /*
  2895   2894   ** The ctype.h header is needed for non-ASCII systems.  It is also

Changes to src/table.c.

   178    178     return rc;
   179    179   }
   180    180   
   181    181   /*
   182    182   ** This routine frees the space the sqlite3_get_table() malloced.
   183    183   */
   184    184   void sqlite3_free_table(
   185         -  char **azResult            /* Result returned from from sqlite3_get_table() */
          185  +  char **azResult            /* Result returned from sqlite3_get_table() */
   186    186   ){
   187    187     if( azResult ){
   188    188       int i, n;
   189    189       azResult--;
   190    190       assert( azResult!=0 );
   191    191       n = SQLITE_PTR_TO_INT(azResult[0]);
   192    192       for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }
   193    193       sqlite3_free(azResult);
   194    194     }
   195    195   }
   196    196   
   197    197   #endif /* SQLITE_OMIT_GET_TABLE */

Changes to src/tclsqlite.c.

   756    756       Tcl_IncrRefCount(pCmd);
   757    757       rc = Tcl_EvalObjEx(p->interp, pCmd, 0);
   758    758       Tcl_DecrRefCount(pCmd);
   759    759     }else{
   760    760       /* If there are arguments to the function, make a shallow copy of the
   761    761       ** script object, lappend the arguments, then evaluate the copy.
   762    762       **
   763         -    ** By "shallow" copy, we mean a only the outer list Tcl_Obj is duplicated.
          763  +    ** By "shallow" copy, we mean only the outer list Tcl_Obj is duplicated.
   764    764       ** The new Tcl_Obj contains pointers to the original list elements. 
   765    765       ** That way, when Tcl_EvalObjv() is run and shimmers the first element
   766    766       ** of the list to tclCmdNameType, that alternate representation will
   767    767       ** be preserved and reused on the next invocation.
   768    768       */
   769    769       Tcl_Obj **aArg;
   770    770       int nArg;

Changes to src/test1.c.

  2601   2601   **   "test_collate <enc> <lhs> <rhs>"
  2602   2602   **
  2603   2603   ** The <lhs> and <rhs> are the two values being compared, encoded in UTF-8.
  2604   2604   ** The <enc> parameter is the encoding of the collation function that
  2605   2605   ** SQLite selected to call. The TCL test script implements the
  2606   2606   ** "test_collate" proc.
  2607   2607   **
  2608         -** Note that this will only work with one intepreter at a time, as the
         2608  +** Note that this will only work with one interpreter at a time, as the
  2609   2609   ** interp pointer to use when evaluating the TCL script is stored in
  2610   2610   ** pTestCollateInterp.
  2611   2611   */
  2612   2612   static Tcl_Interp* pTestCollateInterp;
  2613   2613   static int test_collate_func(
  2614   2614     void *pCtx, 
  2615   2615     int nA, const void *zA,
................................................................................
  3754   3754     return TCL_OK;
  3755   3755   }
  3756   3756   
  3757   3757   /*
  3758   3758   ** Usage: sqlite3_prepare_tkt3134 DB
  3759   3759   **
  3760   3760   ** Generate a prepared statement for a zero-byte string as a test
  3761         -** for ticket #3134.  The string should be preceeded by a zero byte.
         3761  +** for ticket #3134.  The string should be preceded by a zero byte.
  3762   3762   */
  3763   3763   static int test_prepare_tkt3134(
  3764   3764     void * clientData,
  3765   3765     Tcl_Interp *interp,
  3766   3766     int objc,
  3767   3767     Tcl_Obj *CONST objv[]
  3768   3768   ){

Changes to src/test_intarray.c.

    33     33     void (*xFree)(void*);     /* Function used to free a[] */
    34     34   };
    35     35   
    36     36   /* Objects used internally by the virtual table implementation */
    37     37   typedef struct intarray_vtab intarray_vtab;
    38     38   typedef struct intarray_cursor intarray_cursor;
    39     39   
    40         -/* A intarray table object */
           40  +/* An intarray table object */
    41     41   struct intarray_vtab {
    42     42     sqlite3_vtab base;            /* Base class */
    43     43     sqlite3_intarray *pContent;   /* Content of the integer array */
    44     44   };
    45     45   
    46         -/* A intarray cursor object */
           46  +/* An intarray cursor object */
    47     47   struct intarray_cursor {
    48     48     sqlite3_vtab_cursor base;    /* Base class */
    49     49     int i;                       /* Current cursor position */
    50     50   };
    51     51   
    52     52   /*
    53     53   ** None of this works unless we have virtual tables.

Changes to src/test_malloc.c.

   692    692       return TCL_ERROR;
   693    693     }
   694    694     nPending = faultsimPending();
   695    695     Tcl_SetObjResult(interp, Tcl_NewIntObj(nPending));
   696    696     return TCL_OK;
   697    697   }
   698    698   
          699  +/*
          700  +** The following global variable keeps track of the number of tests
          701  +** that have run.  This variable is only useful when running in the
          702  +** debugger.
          703  +*/
          704  +static int sqlite3_memdebug_title_count = 0;
   699    705   
   700    706   /*
   701    707   ** Usage:    sqlite3_memdebug_settitle TITLE
   702    708   **
   703    709   ** Set a title string stored with each allocation.  The TITLE is
   704    710   ** typically the name of the test that was running when the
   705    711   ** allocation occurred.  The TITLE is stored with the allocation
................................................................................
   709    715   */
   710    716   static int test_memdebug_settitle(
   711    717     void * clientData,
   712    718     Tcl_Interp *interp,
   713    719     int objc,
   714    720     Tcl_Obj *CONST objv[]
   715    721   ){
          722  +  sqlite3_memdebug_title_count++;
   716    723     if( objc!=2 ){
   717    724       Tcl_WrongNumArgs(interp, 1, objv, "TITLE");
   718    725       return TCL_ERROR;
   719    726     }
   720    727   #ifdef SQLITE_MEMDEBUG
   721    728     {
   722    729       const char *zTitle;
................................................................................
   876    883   }
   877    884   
   878    885   /*
   879    886   ** Usage:    sqlite3_config_scratch SIZE N
   880    887   **
   881    888   ** Set the scratch memory buffer using SQLITE_CONFIG_SCRATCH.
   882    889   ** The buffer is static and is of limited size.  N might be
   883         -** adjusted downward as needed to accomodate the requested size.
          890  +** adjusted downward as needed to accommodate the requested size.
   884    891   ** The revised value of N is returned.
   885    892   **
   886    893   ** A negative SIZE causes the buffer pointer to be NULL.
   887    894   */
   888    895   static int test_config_scratch(
   889    896     void * clientData,
   890    897     Tcl_Interp *interp,
................................................................................
   916    923   }
   917    924   
   918    925   /*
   919    926   ** Usage:    sqlite3_config_pagecache SIZE N
   920    927   **
   921    928   ** Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE.
   922    929   ** The buffer is static and is of limited size.  N might be
   923         -** adjusted downward as needed to accomodate the requested size.
          930  +** adjusted downward as needed to accommodate the requested size.
   924    931   ** The revised value of N is returned.
   925    932   **
   926    933   ** A negative SIZE causes the buffer pointer to be NULL.
   927    934   */
   928    935   static int test_config_pagecache(
   929    936     void * clientData,
   930    937     Tcl_Interp *interp,

Changes to src/test_schema.c.

   185    185         while( SQLITE_ROW!=sqlite3_step(pCur->pDbList) ){
   186    186           rc = finalize(&pCur->pDbList);
   187    187           goto next_exit;
   188    188         }
   189    189   
   190    190         /* Set zSql to the SQL to pull the list of tables from the 
   191    191         ** sqlite_master (or sqlite_temp_master) table of the database
   192         -      ** identfied by the row pointed to by the SQL statement pCur->pDbList
          192  +      ** identified by the row pointed to by the SQL statement pCur->pDbList
   193    193         ** (iterating through a "PRAGMA database_list;" statement).
   194    194         */
   195    195         if( sqlite3_column_int(pCur->pDbList, 0)==1 ){
   196    196           zSql = sqlite3_mprintf(
   197    197               "SELECT name FROM sqlite_temp_master WHERE type='table'"
   198    198           );
   199    199         }else{

Changes to src/tokenize.c.

    73     73   ** allowed in an identifier.  For 7-bit characters, 
    74     74   ** sqlite3IsIdChar[X] must be 1.
    75     75   **
    76     76   ** For EBCDIC, the rules are more complex but have the same
    77     77   ** end result.
    78     78   **
    79     79   ** Ticket #1066.  the SQL standard does not allow '$' in the
    80         -** middle of identfiers.  But many SQL implementations do. 
           80  +** middle of identifiers.  But many SQL implementations do. 
    81     81   ** SQLite will allow '$' in identifiers for compatibility.
    82     82   ** But the feature is undocumented.
    83     83   */
    84     84   #ifdef SQLITE_ASCII
    85     85   #define IdChar(C)  ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
    86     86   #endif
    87     87   #ifdef SQLITE_EBCDIC

Changes to src/trigger.c.

   123    123   
   124    124     /* A long-standing parser bug is that this syntax was allowed:
   125    125     **
   126    126     **    CREATE TRIGGER attached.demo AFTER INSERT ON attached.tab ....
   127    127     **                                                 ^^^^^^^^
   128    128     **
   129    129     ** To maintain backwards compatibility, ignore the database
   130         -  ** name on pTableName if we are reparsing our of SQLITE_MASTER.
          130  +  ** name on pTableName if we are reparsing out of SQLITE_MASTER.
   131    131     */
   132    132     if( db->init.busy && iDb!=1 ){
   133    133       sqlite3DbFree(db, pTableName->a[0].zDatabase);
   134    134       pTableName->a[0].zDatabase = 0;
   135    135     }
   136    136   
   137    137     /* If the trigger name was unqualified, and the table is a temp table,

Changes to src/update.c.

   323    323   
   324    324     /* Start the view context. */
   325    325     if( isView ){
   326    326       sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
   327    327     }
   328    328   
   329    329     /* If we are trying to update a view, realize that view into
   330         -  ** a ephemeral table.
          330  +  ** an ephemeral table.
   331    331     */
   332    332   #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
   333    333     if( isView ){
   334    334       sqlite3MaterializeView(pParse, pTab, pWhere, iDataCur);
   335    335     }
   336    336   #endif
   337    337   
................................................................................
   484    484       }
   485    485       if( chngRowid==0 && pPk==0 ){
   486    486         sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid);
   487    487       }
   488    488     }
   489    489   
   490    490     /* Populate the array of registers beginning at regNew with the new
   491         -  ** row data. This array is used to check constaints, create the new
          491  +  ** row data. This array is used to check constants, create the new
   492    492     ** table and index records, and as the values for any new.* references
   493    493     ** made by triggers.
   494    494     **
   495    495     ** If there are one or more BEFORE triggers, then do not populate the
   496    496     ** registers associated with columns that are (a) not modified by
   497    497     ** this UPDATE statement and (b) not accessed by new.* references. The
   498    498     ** values for registers not modified by the UPDATE must be reloaded from 
................................................................................
   664    664     sqlite3DbFree(db, aXRef); /* Also frees aRegIdx[] and aToOpen[] */
   665    665     sqlite3SrcListDelete(db, pTabList);
   666    666     sqlite3ExprListDelete(db, pChanges);
   667    667     sqlite3ExprDelete(db, pWhere);
   668    668     return;
   669    669   }
   670    670   /* Make sure "isView" and other macros defined above are undefined. Otherwise
   671         -** thely may interfere with compilation of other functions in this file
          671  +** they may interfere with compilation of other functions in this file
   672    672   ** (or in another file, if this file becomes part of the amalgamation).  */
   673    673   #ifdef isView
   674    674    #undef isView
   675    675   #endif
   676    676   #ifdef pTrigger
   677    677    #undef pTrigger
   678    678   #endif
   679    679   
   680    680   #ifndef SQLITE_OMIT_VIRTUALTABLE
   681    681   /*
   682    682   ** Generate code for an UPDATE of a virtual table.
   683    683   **
   684         -** The strategy is that we create an ephemerial table that contains
          684  +** The strategy is that we create an ephemeral table that contains
   685    685   ** for each row to be changed:
   686    686   **
   687    687   **   (A)  The original rowid of that row.
   688    688   **   (B)  The revised rowid for the row. (note1)
   689    689   **   (C)  The content of every column in the row.
   690    690   **
   691    691   ** Then we loop over this ephemeral table and for each row in
   692         -** the ephermeral table call VUpdate.
          692  +** the ephemeral table call VUpdate.
   693    693   **
   694    694   ** When finished, drop the ephemeral table.
   695    695   **
   696    696   ** (note1) Actually, if we know in advance that (A) is always the same
   697    697   ** as (B) we only store (A), then duplicate (A) when pulling
   698    698   ** it out of the ephemeral table before calling VUpdate.
   699    699   */

Changes to src/util.c.

   200    200   ** is added to the dequoted string.
   201    201   **
   202    202   ** The return value is -1 if no dequoting occurs or the length of the
   203    203   ** dequoted string, exclusive of the zero terminator, if dequoting does
   204    204   ** occur.
   205    205   **
   206    206   ** 2002-Feb-14: This routine is extended to remove MS-Access style
   207         -** brackets from around identifers.  For example:  "[a-b-c]" becomes
          207  +** brackets from around identifiers.  For example:  "[a-b-c]" becomes
   208    208   ** "a-b-c".
   209    209   */
   210    210   int sqlite3Dequote(char *z){
   211    211     char quote;
   212    212     int i, j;
   213    213     if( z==0 ) return -1;
   214    214     quote = z[0];

Changes to src/vacuum.c.

    83     83   **        original database.
    84     84   **
    85     85   ** The transient database requires temporary disk space approximately
    86     86   ** equal to the size of the original database.  The copy operation of
    87     87   ** step (3) requires additional temporary disk space approximately equal
    88     88   ** to the size of the original database for the rollback journal.
    89     89   ** Hence, temporary disk space that is approximately 2x the size of the
    90         -** orginal database is required.  Every page of the database is written
           90  +** original database is required.  Every page of the database is written
    91     91   ** approximately 3 times:  Once for step (2) and twice for step (3).
    92     92   ** Two writes per page are required in step (3) because the original
    93     93   ** database content must be written into the rollback journal prior to
    94     94   ** overwriting the database with the vacuumed content.
    95     95   **
    96     96   ** Only 1x temporary space and only 1x writes would be required if
    97     97   ** the copy of step (3) were replace by deleting the original database

Changes to src/vdbe.c.

  2556   2556     ** like this:
  2557   2557     **
  2558   2558     ** ------------------------------------------------------------------------
  2559   2559     ** | hdr-size | type 0 | type 1 | ... | type N-1 | data0 | ... | data N-1 | 
  2560   2560     ** ------------------------------------------------------------------------
  2561   2561     **
  2562   2562     ** Data(0) is taken from register P1.  Data(1) comes from register P1+1
  2563         -  ** and so froth.
         2563  +  ** and so forth.
  2564   2564     **
  2565   2565     ** Each type field is a varint representing the serial type of the 
  2566   2566     ** corresponding data element (see sqlite3VdbeSerialType()). The
  2567   2567     ** hdr-size field is also a varint which is the offset from the beginning
  2568   2568     ** of the record to data0.
  2569   2569     */
  2570   2570     nData = 0;         /* Number of bytes of data space */
................................................................................
  3543   3543     pC->nullRow = 0;
  3544   3544   #ifdef SQLITE_DEBUG
  3545   3545     pC->seekOp = pOp->opcode;
  3546   3546   #endif
  3547   3547     if( pC->isTable ){
  3548   3548       /* The input value in P3 might be of any type: integer, real, string,
  3549   3549       ** blob, or NULL.  But it needs to be an integer before we can do
  3550         -    ** the seek, so covert it. */
         3550  +    ** the seek, so convert it. */
  3551   3551       pIn3 = &aMem[pOp->p3];
  3552   3552       if( (pIn3->flags & (MEM_Int|MEM_Real))==0 ){
  3553   3553         applyNumericAffinity(pIn3, 0);
  3554   3554       }
  3555   3555       iKey = sqlite3VdbeIntValue(pIn3);
  3556   3556       pC->rowidIsValid = 0;
  3557   3557   

Changes to src/vdbeInt.h.

   234    234   ** is for use inside assert() statements only.
   235    235   */
   236    236   #ifdef SQLITE_DEBUG
   237    237   #define memIsValid(M)  ((M)->flags & MEM_Undefined)==0
   238    238   #endif
   239    239   
   240    240   /*
   241         -** Each auxilliary data pointer stored by a user defined function 
          241  +** Each auxiliary data pointer stored by a user defined function 
   242    242   ** implementation calling sqlite3_set_auxdata() is stored in an instance
   243    243   ** of this structure. All such structures associated with a single VM
   244    244   ** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed
   245    245   ** when the VM is halted (if not before).
   246    246   */
   247    247   struct AuxData {
   248    248     int iOp;                        /* Instruction number of OP_Function opcode */
................................................................................
   249    249     int iArg;                       /* Index of function argument. */
   250    250     void *pAux;                     /* Aux data pointer */
   251    251     void (*xDelete)(void *);        /* Destructor for the aux data */
   252    252     AuxData *pNext;                 /* Next element in list */
   253    253   };
   254    254   
   255    255   /*
   256         -** The "context" argument for a installable function.  A pointer to an
          256  +** The "context" argument for an installable function.  A pointer to an
   257    257   ** instance of this structure is the first argument to the routines used
   258    258   ** implement the SQL functions.
   259    259   **
   260    260   ** There is a typedef for this structure in sqlite.h.  So all routines,
   261    261   ** even the public interface to SQLite, can use a pointer to this structure.
   262    262   ** But this file is the only place where the internal details of this
   263    263   ** structure are known.

Changes to src/vdbeapi.c.

   208    208     return aType[pVal->flags&MEM_AffMask];
   209    209   }
   210    210   
   211    211   /**************************** sqlite3_result_  *******************************
   212    212   ** The following routines are used by user-defined functions to specify
   213    213   ** the function result.
   214    214   **
   215         -** The setStrOrError() funtion calls sqlite3VdbeMemSetStr() to store the
          215  +** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the
   216    216   ** result as a string or blob but if the string or blob is too large, it
   217    217   ** then sets the error code to SQLITE_TOOBIG
   218    218   */
   219    219   static void setResultStrOrError(
   220    220     sqlite3_context *pCtx,  /* Function context */
   221    221     const char *z,          /* String pointer */
   222    222     int n,                  /* Bytes in string, or negative */
................................................................................
   641    641       return createAggContext(p, nByte);
   642    642     }else{
   643    643       return (void*)p->pMem->z;
   644    644     }
   645    645   }
   646    646   
   647    647   /*
   648         -** Return the auxilary data pointer, if any, for the iArg'th argument to
          648  +** Return the auxiliary data pointer, if any, for the iArg'th argument to
   649    649   ** the user-function defined by pCtx.
   650    650   */
   651    651   void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
   652    652     AuxData *pAuxData;
   653    653   
   654    654     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
   655    655     for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
................................................................................
   656    656       if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
   657    657     }
   658    658   
   659    659     return (pAuxData ? pAuxData->pAux : 0);
   660    660   }
   661    661   
   662    662   /*
   663         -** Set the auxilary data pointer and delete function, for the iArg'th
          663  +** Set the auxiliary data pointer and delete function, for the iArg'th
   664    664   ** argument to the user-function defined by pCtx. Any previous value is
   665    665   ** deleted by calling the delete function specified when it was set.
   666    666   */
   667    667   void sqlite3_set_auxdata(
   668    668     sqlite3_context *pCtx, 
   669    669     int iArg, 
   670    670     void *pAux, 
................................................................................
   702    702     if( xDelete ){
   703    703       xDelete(pAux);
   704    704     }
   705    705   }
   706    706   
   707    707   #ifndef SQLITE_OMIT_DEPRECATED
   708    708   /*
   709         -** Return the number of times the Step function of a aggregate has been 
          709  +** Return the number of times the Step function of an aggregate has been 
   710    710   ** called.
   711    711   **
   712    712   ** This function is deprecated.  Do not use it for new code.  It is
   713    713   ** provide only to avoid breaking legacy code.  New aggregate function
   714    714   ** implementations should keep their own counts within their aggregate
   715    715   ** context.
   716    716   */
................................................................................
   972    972   #endif /* SQLITE_OMIT_UTF16 */
   973    973   #endif /* SQLITE_OMIT_DECLTYPE */
   974    974   
   975    975   #ifdef SQLITE_ENABLE_COLUMN_METADATA
   976    976   /*
   977    977   ** Return the name of the database from which a result column derives.
   978    978   ** NULL is returned if the result column is an expression or constant or
   979         -** anything else which is not an unabiguous reference to a database column.
          979  +** anything else which is not an unambiguous reference to a database column.
   980    980   */
   981    981   const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
   982    982     return columnName(
   983    983         pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
   984    984   }
   985    985   #ifndef SQLITE_OMIT_UTF16
   986    986   const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
................................................................................
   988    988         pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
   989    989   }
   990    990   #endif /* SQLITE_OMIT_UTF16 */
   991    991   
   992    992   /*
   993    993   ** Return the name of the table from which a result column derives.
   994    994   ** NULL is returned if the result column is an expression or constant or
   995         -** anything else which is not an unabiguous reference to a database column.
          995  +** anything else which is not an unambiguous reference to a database column.
   996    996   */
   997    997   const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
   998    998     return columnName(
   999    999         pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
  1000   1000   }
  1001   1001   #ifndef SQLITE_OMIT_UTF16
  1002   1002   const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
................................................................................
  1004   1004         pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
  1005   1005   }
  1006   1006   #endif /* SQLITE_OMIT_UTF16 */
  1007   1007   
  1008   1008   /*
  1009   1009   ** Return the name of the table column from which a result column derives.
  1010   1010   ** NULL is returned if the result column is an expression or constant or
  1011         -** anything else which is not an unabiguous reference to a database column.
         1011  +** anything else which is not an unambiguous reference to a database column.
  1012   1012   */
  1013   1013   const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
  1014   1014     return columnName(
  1015   1015         pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
  1016   1016   }
  1017   1017   #ifndef SQLITE_OMIT_UTF16
  1018   1018   const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
................................................................................
  1284   1284   }
  1285   1285   
  1286   1286   #ifndef SQLITE_OMIT_DEPRECATED
  1287   1287   /*
  1288   1288   ** Deprecated external interface.  Internal/core SQLite code
  1289   1289   ** should call sqlite3TransferBindings.
  1290   1290   **
  1291         -** Is is misuse to call this routine with statements from different
         1291  +** It is misuse to call this routine with statements from different
  1292   1292   ** database connections.  But as this is a deprecated interface, we
  1293   1293   ** will not bother to check for that condition.
  1294   1294   **
  1295   1295   ** If the two statements contain a different number of bindings, then
  1296   1296   ** an SQLITE_ERROR is returned.  Nothing else can go wrong, so otherwise
  1297   1297   ** SQLITE_OK is returned.
  1298   1298   */

Changes to src/vdbeaux.c.

   891    891   ** Return the opcode for a given address.  If the address is -1, then
   892    892   ** return the most recently inserted opcode.
   893    893   **
   894    894   ** If a memory allocation error has occurred prior to the calling of this
   895    895   ** routine, then a pointer to a dummy VdbeOp will be returned.  That opcode
   896    896   ** is readable but not writable, though it is cast to a writable value.
   897    897   ** The return of a dummy opcode allows the call to continue functioning
   898         -** after a OOM fault without having to check to see if the return from 
          898  +** after an OOM fault without having to check to see if the return from 
   899    899   ** this routine is a valid pointer.  But because the dummy.opcode is 0,
   900    900   ** dummy will never be written to.  This is verified by code inspection and
   901    901   ** by running with Valgrind.
   902    902   */
   903    903   VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
   904    904     /* C89 specifies that the constant "dummy" will be initialized to all
   905    905     ** zeros, which is correct.  MSVC generates a warning, nevertheless. */
................................................................................
  1606   1606   /*
  1607   1607   ** Prepare a virtual machine for execution for the first time after
  1608   1608   ** creating the virtual machine.  This involves things such
  1609   1609   ** as allocating stack space and initializing the program counter.
  1610   1610   ** After the VDBE has be prepped, it can be executed by one or more
  1611   1611   ** calls to sqlite3VdbeExec().  
  1612   1612   **
  1613         -** This function may be called exact once on a each virtual machine.
         1613  +** This function may be called exactly once on each virtual machine.
  1614   1614   ** After this routine is called the VM has been "packaged" and is ready
  1615         -** to run.  After this routine is called, futher calls to 
         1615  +** to run.  After this routine is called, further calls to 
  1616   1616   ** sqlite3VdbeAddOp() functions are prohibited.  This routine disconnects
  1617   1617   ** the Vdbe from the Parse object that helped generate it so that the
  1618   1618   ** the Vdbe becomes an independent entity and the Parse object can be
  1619   1619   ** destroyed.
  1620   1620   **
  1621   1621   ** Use the sqlite3VdbeRewind() procedure to restore a virtual machine back
  1622   1622   ** to its initial state after it has been run.
................................................................................
  1986   1986       if( rc==SQLITE_OK ){
  1987   1987         sqlite3VtabCommit(db);
  1988   1988       }
  1989   1989     }
  1990   1990   
  1991   1991     /* The complex case - There is a multi-file write-transaction active.
  1992   1992     ** This requires a master journal file to ensure the transaction is
  1993         -  ** committed atomicly.
         1993  +  ** committed atomically.
  1994   1994     */
  1995   1995   #ifndef SQLITE_OMIT_DISKIO
  1996   1996     else{
  1997   1997       sqlite3_vfs *pVfs = db->pVfs;
  1998   1998       int needSync = 0;
  1999   1999       char *zMaster = 0;   /* File-name for the master journal */
  2000   2000       char const *zMainFile = sqlite3BtreeGetFilename(db->aDb[0].pBt);
................................................................................
  2634   2634   ** function invoked by the OP_Function opcode at instruction iOp of 
  2635   2635   ** VM pVdbe, and only then if:
  2636   2636   **
  2637   2637   **    * the associated function parameter is the 32nd or later (counting
  2638   2638   **      from left to right), or
  2639   2639   **
  2640   2640   **    * the corresponding bit in argument mask is clear (where the first
  2641         -**      function parameter corrsponds to bit 0 etc.).
         2641  +**      function parameter corresponds to bit 0 etc.).
  2642   2642   */
  2643   2643   void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){
  2644   2644     AuxData **pp = &pVdbe->pAuxData;
  2645   2645     while( *pp ){
  2646   2646       AuxData *pAux = *pp;
  2647   2647       if( (iOp<0)
  2648   2648        || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & MASKBIT32(pAux->iArg))))
................................................................................
  2738   2738     return SQLITE_OK;
  2739   2739   }
  2740   2740   
  2741   2741   /*
  2742   2742   ** Something has moved cursor "p" out of place.  Maybe the row it was
  2743   2743   ** pointed to was deleted out from under it.  Or maybe the btree was
  2744   2744   ** rebalanced.  Whatever the cause, try to restore "p" to the place it
  2745         -** is suppose to be pointing.  If the row was deleted out from under the
         2745  +** is supposed to be pointing.  If the row was deleted out from under the
  2746   2746   ** cursor, set the cursor to point to a NULL row.
  2747   2747   */
  2748   2748   static int SQLITE_NOINLINE handleMovedCursor(VdbeCursor *p){
  2749   2749     int isDifferentRow, rc;
  2750   2750     assert( p->pCursor!=0 );
  2751   2751     assert( sqlite3BtreeCursorHasMoved(p->pCursor) );
  2752   2752     rc = sqlite3BtreeCursorRestore(p->pCursor, &isDifferentRow);
................................................................................
  3263   3263     /* No memory allocation is ever used on mem1.  Prove this using
  3264   3264     ** the following assert().  If the assert() fails, it indicates a
  3265   3265     ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).
  3266   3266     */
  3267   3267     assert( mem1.zMalloc==0 );
  3268   3268   
  3269   3269     /* rc==0 here means that one of the keys ran out of fields and
  3270         -  ** all the fields up to that point were equal. Return the the default_rc
         3270  +  ** all the fields up to that point were equal. Return the default_rc
  3271   3271     ** value.  */
  3272   3272     rc = pPKey2->default_rc;
  3273   3273   
  3274   3274   debugCompareEnd:
  3275   3275     if( desiredResult==0 && rc==0 ) return 1;
  3276   3276     if( desiredResult<0 && rc<0 ) return 1;
  3277   3277     if( desiredResult>0 && rc>0 ) return 1;
................................................................................
  3454   3454   }
  3455   3455   
  3456   3456   /*
  3457   3457   ** This function compares the two table rows or index records
  3458   3458   ** specified by {nKey1, pKey1} and pPKey2.  It returns a negative, zero
  3459   3459   ** or positive integer if key1 is less than, equal to or 
  3460   3460   ** greater than key2.  The {nKey1, pKey1} key must be a blob
  3461         -** created by th OP_MakeRecord opcode of the VDBE.  The pPKey2
         3461  +** created by the OP_MakeRecord opcode of the VDBE.  The pPKey2
  3462   3462   ** key must be a parsed key such as obtained from
  3463   3463   ** sqlite3VdbeParseRecord.
  3464   3464   **
  3465   3465   ** If argument bSkip is non-zero, it is assumed that the caller has already
  3466   3466   ** determined that the first fields of the keys are equal.
  3467   3467   **
  3468   3468   ** Key1 and Key2 do not have to contain the same number of fields. If all 
................................................................................
  3644   3644   
  3645   3645     /* No memory allocation is ever used on mem1.  Prove this using
  3646   3646     ** the following assert().  If the assert() fails, it indicates a
  3647   3647     ** memory leak and a need to call sqlite3VdbeMemRelease(&mem1).  */
  3648   3648     assert( mem1.zMalloc==0 );
  3649   3649   
  3650   3650     /* rc==0 here means that one or both of the keys ran out of fields and
  3651         -  ** all the fields up to that point were equal. Return the the default_rc
         3651  +  ** all the fields up to that point were equal. Return the default_rc
  3652   3652     ** value.  */
  3653   3653     assert( CORRUPT_DB 
  3654   3654          || vdbeRecordCompareDebug(nKey1, pKey1, pPKey2, pPKey2->default_rc) 
  3655   3655          || pKeyInfo->db->mallocFailed
  3656   3656     );
  3657   3657     return pPKey2->default_rc;
  3658   3658   }

Changes to src/vdbemem.c.

    33     33     assert( (p->flags & MEM_Dyn)!=0 || p->xDel==0 );
    34     34   
    35     35     /* If p holds a string or blob, the Mem.z must point to exactly
    36     36     ** one of the following:
    37     37     **
    38     38     **   (1) Memory in Mem.zMalloc and managed by the Mem object
    39     39     **   (2) Memory to be freed using Mem.xDel
    40         -  **   (3) An ephermal string or blob
           40  +  **   (3) An ephemeral string or blob
    41     41     **   (4) A static string or blob
    42     42     */
    43     43     if( (p->flags & (MEM_Str|MEM_Blob)) && p->z!=0 ){
    44     44       assert( 
    45     45         ((p->z==p->zMalloc)? 1 : 0) +
    46     46         ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +
    47     47         ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +
................................................................................
   236    236   ** Existing representations MEM_Int and MEM_Real are invalidated if
   237    237   ** bForce is true but are retained if bForce is false.
   238    238   **
   239    239   ** A MEM_Null value will never be passed to this function. This function is
   240    240   ** used for converting values to text for returning to the user (i.e. via
   241    241   ** sqlite3_value_text()), or for ensuring that values to be used as btree
   242    242   ** keys are strings. In the former case a NULL pointer is returned the
   243         -** user and the later is an internal programming error.
          243  +** user and the latter is an internal programming error.
   244    244   */
   245    245   int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){
   246    246     int fg = pMem->flags;
   247    247     const int nByte = 32;
   248    248   
   249    249     assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
   250    250     assert( !(fg&MEM_Zero) );
................................................................................
   401    401   
   402    402   /*
   403    403   ** Return some kind of integer value which is the best we can do
   404    404   ** at representing the value that *pMem describes as an integer.
   405    405   ** If pMem is an integer, then the value is exact.  If pMem is
   406    406   ** a floating-point then the value returned is the integer part.
   407    407   ** If pMem is a string or blob, then we make an attempt to convert
   408         -** it into a integer and return that.  If pMem represents an
          408  +** it into an integer and return that.  If pMem represents an
   409    409   ** an SQL-NULL value, return 0.
   410    410   **
   411    411   ** If pMem represents a string value, its encoding might be changed.
   412    412   */
   413    413   i64 sqlite3VdbeIntValue(Mem *pMem){
   414    414     int flags;
   415    415     assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
................................................................................
   693    693       return n>p->db->aLimit[SQLITE_LIMIT_LENGTH];
   694    694     }
   695    695     return 0; 
   696    696   }
   697    697   
   698    698   #ifdef SQLITE_DEBUG
   699    699   /*
   700         -** This routine prepares a memory cell for modication by breaking
          700  +** This routine prepares a memory cell for modification by breaking
   701    701   ** its link to a shallow copy and by marking any current shallow
   702    702   ** copies of this cell as invalid.
   703    703   **
   704    704   ** This is used for testing and debugging only - to make sure shallow
   705    705   ** copies are not misused.
   706    706   */
   707    707   void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){

Changes to src/vdbesort.c.

  2055   2055                  );
  2056   2056     pReader->pIncr->pTask->bDone = 1;
  2057   2057     return pRet;
  2058   2058   }
  2059   2059   
  2060   2060   /*
  2061   2061   ** Use a background thread to invoke vdbePmaReaderIncrMergeInit(INCRINIT_TASK) 
  2062         -** on the the PmaReader object passed as the first argument.
         2062  +** on the PmaReader object passed as the first argument.
  2063   2063   **
  2064   2064   ** This call will initialize the various fields of the pReadr->pIncr 
  2065   2065   ** structure and, if it is a multi-threaded IncrMerger, launch a 
  2066   2066   ** background thread to populate aFile[1].
  2067   2067   */
  2068   2068   static int vdbePmaReaderBgIncrInit(PmaReader *pReadr){
  2069   2069     void *pCtx = (void*)pReadr;

Changes to src/vdbetrace.c.

    60     60   **
    61     61   ** The calling function is responsible for making sure the memory returned
    62     62   ** is eventually freed.
    63     63   **
    64     64   ** ALGORITHM:  Scan the input string looking for host parameters in any of
    65     65   ** these forms:  ?, ?N, $A, @A, :A.  Take care to avoid text within
    66     66   ** string literals, quoted identifier names, and comments.  For text forms,
    67         -** the host parameter index is found by scanning the perpared
           67  +** the host parameter index is found by scanning the prepared
    68     68   ** statement for the corresponding OP_Variable opcode.  Once the host
    69     69   ** parameter index is known, locate the value in p->aVar[].  Then render
    70     70   ** the value as a literal in place of the host parameter name.
    71     71   */
    72     72   char *sqlite3VdbeExpandSql(
    73     73     Vdbe *p,                 /* The prepared statement being evaluated */
    74     74     const char *zRawSql      /* Raw text of the SQL statement */

Changes to src/wal.c.

   570    570     return (volatile WalIndexHdr*)pWal->apWiData[0];
   571    571   }
   572    572   
   573    573   /*
   574    574   ** The argument to this macro must be of type u32. On a little-endian
   575    575   ** architecture, it returns the u32 value that results from interpreting
   576    576   ** the 4 bytes as a big-endian value. On a big-endian architecture, it
   577         -** returns the value that would be produced by intepreting the 4 bytes
          577  +** returns the value that would be produced by interpreting the 4 bytes
   578    578   ** of the input value as a little-endian integer.
   579    579   */
   580    580   #define BYTESWAP32(x) ( \
   581    581       (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8)  \
   582    582     + (((x)&0x00FF0000)>>8)  + (((x)&0xFF000000)>>24) \
   583    583   )
   584    584   
................................................................................
   984    984       int idx;                      /* Value to write to hash-table slot */
   985    985       int nCollide;                 /* Number of hash collisions */
   986    986   
   987    987       idx = iFrame - iZero;
   988    988       assert( idx <= HASHTABLE_NSLOT/2 + 1 );
   989    989       
   990    990       /* If this is the first entry to be added to this hash-table, zero the
   991         -    ** entire hash table and aPgno[] array before proceding. 
          991  +    ** entire hash table and aPgno[] array before proceeding. 
   992    992       */
   993    993       if( idx==1 ){
   994    994         int nByte = (int)((u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1]);
   995    995         memset((void*)&aPgno[1], 0, nByte);
   996    996       }
   997    997   
   998    998       /* If the entry in aPgno[] is already set, then the previous writer
................................................................................
  1642   1642   **
  1643   1643   ** Fsync is also called on the database file if (and only if) the entire
  1644   1644   ** WAL content is copied into the database file.  This second fsync makes
  1645   1645   ** it safe to delete the WAL since the new content will persist in the
  1646   1646   ** database file.
  1647   1647   **
  1648   1648   ** This routine uses and updates the nBackfill field of the wal-index header.
  1649         -** This is the only routine tha will increase the value of nBackfill.  
         1649  +** This is the only routine that will increase the value of nBackfill.  
  1650   1650   ** (A WAL reset or recovery will revert nBackfill to zero, but not increase
  1651   1651   ** its value.)
  1652   1652   **
  1653   1653   ** The caller must be holding sufficient locks to ensure that no other
  1654   1654   ** checkpoint is running (in any other thread or process) at the same
  1655   1655   ** time.
  1656   1656   */
................................................................................
  1946   1946   
  1947   1947   /*
  1948   1948   ** Read the wal-index header from the wal-index and into pWal->hdr.
  1949   1949   ** If the wal-header appears to be corrupt, try to reconstruct the
  1950   1950   ** wal-index from the WAL before returning.
  1951   1951   **
  1952   1952   ** Set *pChanged to 1 if the wal-index header value in pWal->hdr is
  1953         -** changed by this opertion.  If pWal->hdr is unchanged, set *pChanged
         1953  +** changed by this operation.  If pWal->hdr is unchanged, set *pChanged
  1954   1954   ** to 0.
  1955   1955   **
  1956   1956   ** If the wal-index header is successfully read, return SQLITE_OK. 
  1957   1957   ** Otherwise an SQLite error code.
  1958   1958   */
  1959   1959   static int walIndexReadHdr(Wal *pWal, int *pChanged){
  1960   1960     int rc;                         /* Return code */
................................................................................
  2150   2150       walShmBarrier(pWal);
  2151   2151       if( rc==SQLITE_OK ){
  2152   2152         if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
  2153   2153           /* It is not safe to allow the reader to continue here if frames
  2154   2154           ** may have been appended to the log before READ_LOCK(0) was obtained.
  2155   2155           ** When holding READ_LOCK(0), the reader ignores the entire log file,
  2156   2156           ** which implies that the database file contains a trustworthy
  2157         -        ** snapshoT. Since holding READ_LOCK(0) prevents a checkpoint from
         2157  +        ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
  2158   2158           ** happening, this is usually correct.
  2159   2159           **
  2160   2160           ** However, if frames have been appended to the log (or if the log 
  2161   2161           ** is wrapped and written for that matter) before the READ_LOCK(0)
  2162   2162           ** is obtained, that is not necessarily true. A checkpointer may
  2163   2163           ** have started to backfill the appended frames but crashed before
  2164   2164           ** it finished. Leaving a corrupt image in the database file.
................................................................................
  2818   2818     }
  2819   2819   
  2820   2820     /* If this is the end of a transaction, then we might need to pad
  2821   2821     ** the transaction and/or sync the WAL file.
  2822   2822     **
  2823   2823     ** Padding and syncing only occur if this set of frames complete a
  2824   2824     ** transaction and if PRAGMA synchronous=FULL.  If synchronous==NORMAL
  2825         -  ** or synchonous==OFF, then no padding or syncing are needed.
         2825  +  ** or synchronous==OFF, then no padding or syncing are needed.
  2826   2826     **
  2827   2827     ** If SQLITE_IOCAP_POWERSAFE_OVERWRITE is defined, then padding is not
  2828   2828     ** needed and only the sync is done.  If padding is needed, then the
  2829   2829     ** final frame is repeated (with its commit mark) until the next sector
  2830   2830     ** boundary is crossed.  Only the part of the WAL prior to the last
  2831   2831     ** sector boundary is synced; the part of the last frame that extends
  2832   2832     ** past the sector boundary is written after the sync.

Changes to src/walker.c.

    15     15   #include "sqliteInt.h"
    16     16   #include <stdlib.h>
    17     17   #include <string.h>
    18     18   
    19     19   
    20     20   /*
    21     21   ** Walk an expression tree.  Invoke the callback once for each node
    22         -** of the expression, while decending.  (In other words, the callback
           22  +** of the expression, while descending.  (In other words, the callback
    23     23   ** is invoked before visiting children.)
    24     24   **
    25     25   ** The return value from the callback should be one of the WRC_*
    26     26   ** constants to specify how to proceed with the walk.
    27     27   **
    28     28   **    WRC_Continue      Continue descending down the tree.
    29     29   **

Changes to src/where.c.

   697    697           Vdbe *v = pParse->pVdbe;
   698    698           sqlite3VdbeSetVarmask(v, pRight->iColumn);
   699    699           if( *pisComplete && pRight->u.zToken[1] ){
   700    700             /* If the rhs of the LIKE expression is a variable, and the current
   701    701             ** value of the variable means there is no need to invoke the LIKE
   702    702             ** function, then no OP_Variable will be added to the program.
   703    703             ** This causes problems for the sqlite3_bind_parameter_name()
   704         -          ** API. To workaround them, add a dummy OP_Variable here.
          704  +          ** API. To work around them, add a dummy OP_Variable here.
   705    705             */ 
   706    706             int r1 = sqlite3GetTempReg(pParse);
   707    707             sqlite3ExprCodeTarget(pParse, pRight, r1);
   708    708             sqlite3VdbeChangeP3(v, sqlite3VdbeCurrentAddr(v)-1, 0);
   709    709             sqlite3ReleaseTempReg(pParse, r1);
   710    710           }
   711    711         }
................................................................................
   817    817   ** From another point of view, "indexable" means that the subterm could
   818    818   ** potentially be used with an index if an appropriate index exists.
   819    819   ** This analysis does not consider whether or not the index exists; that
   820    820   ** is decided elsewhere.  This analysis only looks at whether subterms
   821    821   ** appropriate for indexing exist.
   822    822   **
   823    823   ** All examples A through E above satisfy case 2.  But if a term
   824         -** also statisfies case 1 (such as B) we know that the optimizer will
          824  +** also satisfies case 1 (such as B) we know that the optimizer will
   825    825   ** always prefer case 1, so in that case we pretend that case 2 is not
   826    826   ** satisfied.
   827    827   **
   828    828   ** It might be the case that multiple tables are indexable.  For example,
   829    829   ** (E) above is indexable on tables P, Q, and R.
   830    830   **
   831    831   ** Terms that satisfy case 2 are candidates for lookup by using
................................................................................
   975    975             /* This is the 2-bit case and we are on the second iteration and
   976    976             ** current term is from the first iteration.  So skip this term. */
   977    977             assert( j==1 );
   978    978             continue;
   979    979           }
   980    980           if( (chngToIN & getMask(&pWInfo->sMaskSet, pOrTerm->leftCursor))==0 ){
   981    981             /* This term must be of the form t1.a==t2.b where t2 is in the
   982         -          ** chngToIN set but t1 is not.  This term will be either preceeded
          982  +          ** chngToIN set but t1 is not.  This term will be either preceded
   983    983             ** or follwed by an inverted copy (t2.b==t1.a).  Skip this term 
   984    984             ** and use its inversion. */
   985    985             testcase( pOrTerm->wtFlags & TERM_COPIED );
   986    986             testcase( pOrTerm->wtFlags & TERM_VIRTUAL );
   987    987             assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );
   988    988             continue;
   989    989           }
................................................................................
  1386   1386     /* Prevent ON clause terms of a LEFT JOIN from being used to drive
  1387   1387     ** an index for tables to the left of the join.
  1388   1388     */
  1389   1389     pTerm->prereqRight |= extraRight;
  1390   1390   }
  1391   1391   
  1392   1392   /*
  1393         -** This function searches pList for a entry that matches the iCol-th column
         1393  +** This function searches pList for an entry that matches the iCol-th column
  1394   1394   ** of index pIdx.
  1395   1395   **
  1396   1396   ** If such an expression is found, its index in pList->a[] is returned. If
  1397   1397   ** no expression is found, -1 is returned.
  1398   1398   */
  1399   1399   static int findIndexCol(
  1400   1400     Parse *pParse,                  /* Parse context */
................................................................................
  2136   2136   **
  2137   2137   ** then nEq is set to 0.
  2138   2138   **
  2139   2139   ** When this function is called, *pnOut is set to the sqlite3LogEst() of the
  2140   2140   ** number of rows that the index scan is expected to visit without 
  2141   2141   ** considering the range constraints. If nEq is 0, this is the number of 
  2142   2142   ** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)
  2143         -** to account for the range contraints pLower and pUpper.
         2143  +** to account for the range constraints pLower and pUpper.
  2144   2144   ** 
  2145   2145   ** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be
  2146   2146   ** used, a single range inequality reduces the search space by a factor of 4. 
  2147   2147   ** and a pair of constraints (x>? AND x<?) reduces the expected number of
  2148   2148   ** rows visited by a factor of 64.
  2149   2149   */
  2150   2150   static int whereRangeScanEst(
................................................................................
  3413   3413       **       A: <loop body>                 # Return data, whatever.
  3414   3414       **
  3415   3415       **          Return     2                # Jump back to the Gosub
  3416   3416       **
  3417   3417       **       B: <after the loop>
  3418   3418       **
  3419   3419       ** Added 2014-05-26: If the table is a WITHOUT ROWID table, then
  3420         -    ** use an ephermeral index instead of a RowSet to record the primary
         3420  +    ** use an ephemeral index instead of a RowSet to record the primary
  3421   3421       ** keys of the rows we have already seen.
  3422   3422       **
  3423   3423       */
  3424   3424       WhereClause *pOrWc;    /* The OR-clause broken out into subterms */
  3425   3425       SrcList *pOrTab;       /* Shortened table list or OR-clause generation */
  3426   3426       Index *pCov = 0;             /* Potential covering index (or NULL) */
  3427   3427       int iCovCur = pParse->nTab++;  /* Cursor used for index scans (if any) */
................................................................................
  3464   3464           memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
  3465   3465         }
  3466   3466       }else{
  3467   3467         pOrTab = pWInfo->pTabList;
  3468   3468       }
  3469   3469   
  3470   3470       /* Initialize the rowset register to contain NULL. An SQL NULL is 
  3471         -    ** equivalent to an empty rowset.  Or, create an ephermeral index
         3471  +    ** equivalent to an empty rowset.  Or, create an ephemeral index
  3472   3472       ** capable of holding primary keys in the case of a WITHOUT ROWID.
  3473   3473       **
  3474   3474       ** Also initialize regReturn to contain the address of the instruction 
  3475   3475       ** immediately following the OP_Return at the bottom of the loop. This
  3476   3476       ** is required in a few obscure LEFT JOIN cases where control jumps
  3477   3477       ** over the top of the loop into the body of it. In this case the 
  3478   3478       ** correct response for the end-of-loop code (the OP_Return) is to 
................................................................................
  4217   4217   ** WHERE clause that reference the loop but which are not used by an
  4218   4218   ** index.
  4219   4219   **
  4220   4220   ** In the current implementation, the first extra WHERE clause term reduces
  4221   4221   ** the number of output rows by a factor of 10 and each additional term
  4222   4222   ** reduces the number of output rows by sqrt(2).
  4223   4223   */
  4224         -static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
         4224  +static void whereLoopOutputAdjust(
         4225  +  WhereClause *pWC,      /* The WHERE clause */
         4226  +  WhereLoop *pLoop,      /* The loop to adjust downward */
         4227  +  LogEst nRow            /* Number of rows in the entire table */
         4228  +){
  4225   4229     WhereTerm *pTerm, *pX;
  4226   4230     Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
  4227   4231     int i, j;
         4232  +  int nEq = 0;    /* Number of = constraints not within likely()/unlikely() */
  4228   4233   
  4229         -  if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
  4230         -    return;
  4231         -  }
  4232   4234     for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
  4233   4235       if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
  4234   4236       if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
  4235   4237       if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
  4236   4238       for(j=pLoop->nLTerm-1; j>=0; j--){
  4237   4239         pX = pLoop->aLTerm[j];
  4238   4240         if( pX==0 ) continue;
  4239   4241         if( pX==pTerm ) break;
  4240   4242         if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
  4241   4243       }
  4242   4244       if( j<0 ){
  4243         -      pLoop->nOut += (pTerm->truthProb<=0 ? pTerm->truthProb : -1);
         4245  +      if( pTerm->truthProb<=0 ){
         4246  +        pLoop->nOut += pTerm->truthProb;
         4247  +      }else{
         4248  +        pLoop->nOut--;
         4249  +        if( pTerm->eOperator&WO_EQ ) nEq++;
         4250  +      }
  4244   4251       }
         4252  +  }
         4253  +  /* TUNING:  If there is at least one equality constraint in the WHERE
         4254  +  ** clause that does not have a likelihood() explicitly assigned to it
         4255  +  ** then do not let the estimated number of output rows exceed half 
         4256  +  ** the number of rows in the table. */
         4257  +  if( nEq && pLoop->nOut>nRow-10 ){
         4258  +    pLoop->nOut = nRow - 10;
  4245   4259     }
  4246   4260   }
  4247   4261   
  4248   4262   /*
  4249   4263   ** Adjust the cost C by the costMult facter T.  This only occurs if
  4250   4264   ** compiled with -DSQLITE_ENABLE_COSTMULT
  4251   4265   */
................................................................................
  4284   4298     u16 saved_nLTerm;               /* Original value of pNew->nLTerm */
  4285   4299     u16 saved_nEq;                  /* Original value of pNew->u.btree.nEq */
  4286   4300     u16 saved_nSkip;                /* Original value of pNew->u.btree.nSkip */
  4287   4301     u32 saved_wsFlags;              /* Original value of pNew->wsFlags */
  4288   4302     LogEst saved_nOut;              /* Original value of pNew->nOut */
  4289   4303     int iCol;                       /* Index of the column in the table */
  4290   4304     int rc = SQLITE_OK;             /* Return code */
         4305  +  LogEst rSize;                   /* Number of rows in the table */
  4291   4306     LogEst rLogSize;                /* Logarithm of table size */
  4292   4307     WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */
  4293   4308   
  4294   4309     pNew = pBuilder->pNew;
  4295   4310     if( db->mallocFailed ) return SQLITE_NOMEM;
  4296   4311   
  4297   4312     assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 );
................................................................................
  4313   4328     saved_nEq = pNew->u.btree.nEq;
  4314   4329     saved_nSkip = pNew->u.btree.nSkip;
  4315   4330     saved_nLTerm = pNew->nLTerm;
  4316   4331     saved_wsFlags = pNew->wsFlags;
  4317   4332     saved_prereq = pNew->prereq;
  4318   4333     saved_nOut = pNew->nOut;
  4319   4334     pNew->rSetup = 0;
  4320         -  rLogSize = estLog(pProbe->aiRowLogEst[0]);
         4335  +  rSize = pProbe->aiRowLogEst[0];
         4336  +  rLogSize = estLog(rSize);
  4321   4337   
  4322   4338     /* Consider using a skip-scan if there are no WHERE clause constraints
  4323   4339     ** available for the left-most terms of the index, and if the average
  4324   4340     ** number of repeats in the left-most terms is at least 18. 
  4325   4341     **
  4326   4342     ** The magic number 18 is selected on the basis that scanning 17 rows
  4327   4343     ** is almost always quicker than an index seek (even though if the index
................................................................................
  4490   4506         pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16);
  4491   4507       }
  4492   4508       ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult);
  4493   4509   
  4494   4510       nOutUnadjusted = pNew->nOut;
  4495   4511       pNew->rRun += nInMul + nIn;
  4496   4512       pNew->nOut += nInMul + nIn;
  4497         -    whereLoopOutputAdjust(pBuilder->pWC, pNew);
         4513  +    whereLoopOutputAdjust(pBuilder->pWC, pNew, rSize);
  4498   4514       rc = whereLoopInsert(pBuilder, pNew);
  4499   4515   
  4500   4516       if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
  4501   4517         pNew->nOut = saved_nOut;
  4502   4518       }else{
  4503   4519         pNew->nOut = nOutUnadjusted;
  4504   4520       }
................................................................................
  4703   4719           /* TUNING: One-time cost for computing the automatic index is
  4704   4720           ** approximately 7*N*log2(N) where N is the number of rows in
  4705   4721           ** the table being indexed. */
  4706   4722           pNew->rSetup = rLogSize + rSize + 28;  assert( 28==sqlite3LogEst(7) );
  4707   4723           ApplyCostMultiplier(pNew->rSetup, pTab->costMult);
  4708   4724           /* TUNING: Each index lookup yields 20 rows in the table.  This
  4709   4725           ** is more than the usual guess of 10 rows, since we have no way
  4710         -        ** of knowning how selective the index will ultimately be.  It would
         4726  +        ** of knowing how selective the index will ultimately be.  It would
  4711   4727           ** not be unreasonable to make this value much larger. */
  4712   4728           pNew->nOut = 43;  assert( 43==sqlite3LogEst(20) );
  4713   4729           pNew->rRun = sqlite3LogEstAdd(rLogSize,pNew->nOut);
  4714   4730           pNew->wsFlags = WHERE_AUTO_INDEX;
  4715   4731           pNew->prereq = mExtra | pTerm->prereqRight;
  4716   4732           rc = whereLoopInsert(pBuilder, pNew);
  4717   4733         }
................................................................................
  4744   4760         pNew->wsFlags = WHERE_IPK;
  4745   4761   
  4746   4762         /* Full table scan */
  4747   4763         pNew->iSortIdx = b ? iSortIdx : 0;
  4748   4764         /* TUNING: Cost of full table scan is (N*3.0). */
  4749   4765         pNew->rRun = rSize + 16;
  4750   4766         ApplyCostMultiplier(pNew->rRun, pTab->costMult);
  4751         -      whereLoopOutputAdjust(pWC, pNew);
         4767  +      whereLoopOutputAdjust(pWC, pNew, rSize);
  4752   4768         rc = whereLoopInsert(pBuilder, pNew);
  4753   4769         pNew->nOut = rSize;
  4754   4770         if( rc ) break;
  4755   4771       }else{
  4756   4772         Bitmask m;
  4757   4773         if( pProbe->isCovering ){
  4758   4774           pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
................................................................................
  4780   4796           ** index and table rows. If this is a non-covering index scan,
  4781   4797           ** also add the cost of visiting table rows (N*3.0).  */
  4782   4798           pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow;
  4783   4799           if( m!=0 ){
  4784   4800             pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16);
  4785   4801           }
  4786   4802           ApplyCostMultiplier(pNew->rRun, pTab->costMult);
  4787         -        whereLoopOutputAdjust(pWC, pNew);
         4803  +        whereLoopOutputAdjust(pWC, pNew, rSize);
  4788   4804           rc = whereLoopInsert(pBuilder, pNew);
  4789   4805           pNew->nOut = rSize;
  4790   4806           if( rc ) break;
  4791   4807         }
  4792   4808       }
  4793   4809   
  4794   4810       rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
................................................................................
  5133   5149   **   N==0:  No terms of the ORDER BY clause are satisfied
  5134   5150   **   N<0:   Unknown yet how many terms of ORDER BY might be satisfied.   
  5135   5151   **
  5136   5152   ** Note that processing for WHERE_GROUPBY and WHERE_DISTINCTBY is not as
  5137   5153   ** strict.  With GROUP BY and DISTINCT the only requirement is that
  5138   5154   ** equivalent rows appear immediately adjacent to one another.  GROUP BY
  5139   5155   ** and DISTINCT do not require rows to appear in any particular order as long
  5140         -** as equivelent rows are grouped together.  Thus for GROUP BY and DISTINCT
         5156  +** as equivalent rows are grouped together.  Thus for GROUP BY and DISTINCT
  5141   5157   ** the pOrderBy terms can be matched in any order.  With ORDER BY, the 
  5142   5158   ** pOrderBy terms must be matched in strict left-to-right order.
  5143   5159   */
  5144   5160   static i8 wherePathSatisfiesOrderBy(
  5145   5161     WhereInfo *pWInfo,    /* The WHERE clause */
  5146   5162     ExprList *pOrderBy,   /* ORDER BY or GROUP BY or DISTINCT clause to check */
  5147   5163     WherePath *pPath,     /* The WherePath to check */

Changes to src/whereInt.h.

   172    172   ** Then a WherePath object is a path through the graph that visits some
   173    173   ** or all of the WhereLoop objects once.
   174    174   **
   175    175   ** The "solver" works by creating the N best WherePath objects of length
   176    176   ** 1.  Then using those as a basis to compute the N best WherePath objects
   177    177   ** of length 2.  And so forth until the length of WherePaths equals the
   178    178   ** number of nodes in the FROM clause.  The best (lowest cost) WherePath
   179         -** at the end is the choosen query plan.
          179  +** at the end is the chosen query plan.
   180    180   */
   181    181   struct WherePath {
   182    182     Bitmask maskLoop;     /* Bitmask of all WhereLoop objects in this path */
   183    183     Bitmask revLoop;      /* aLoop[]s that should be reversed for ORDER BY */
   184    184     LogEst nRow;          /* Estimated number of rows generated by this path */
   185    185     LogEst rCost;         /* Total cost of this path */
   186    186     LogEst rUnsorted;     /* Total cost of this path ignoring sorting costs */

Changes to test/whereJ.test.

   369    369        AND t3b.id BETWEEN t2b.minChild AND t2b.maxChild
   370    370        AND t4.id BETWEEN t3a.minChild AND t3b.maxChild
   371    371     ORDER BY t4.x;
   372    372   } {~/SCAN/}
   373    373   
   374    374   ############################################################################
   375    375   
   376         -ifcapable stat4 {
   377         -  # Create and populate table.
   378         -  do_execsql_test 3.1 { CREATE TABLE t1(a, b, c) }
   379         -  for {set i 0} {$i < 32} {incr i 2} {
   380         -    for {set x 0} {$x < 100} {incr x} {
   381         -      execsql { INSERT INTO t1 VALUES($i, $x, $c) }
   382         -      incr c
   383         -    }
   384         -    execsql { INSERT INTO t1 VALUES($i+1, 5, $c) }
          376  +# Create and populate table.
          377  +do_execsql_test 3.1 { CREATE TABLE t1(a, b, c) }
          378  +for {set i 0} {$i < 32} {incr i 2} {
          379  +  for {set x 0} {$x < 100} {incr x} {
          380  +    execsql { INSERT INTO t1 VALUES($i, $x, $c) }
   385    381       incr c
   386    382     }
   387         -  
   388         -  do_execsql_test 3.2 {
   389         -    SELECT a, count(*) FROM t1 GROUP BY a HAVING a < 8;
   390         -  } {
   391         -    0 100 1 1 2 100 3 1 4 100 5 1 6 100 7 1
   392         -  }
   393         -  
   394         -  do_execsql_test 3.3 {
   395         -    CREATE INDEX idx_ab ON t1(a, b);
   396         -    CREATE INDEX idx_c ON t1(c);
   397         -    ANALYZE;
   398         -  } {}
   399         -  
   400         -  # This one should use index "idx_c".
   401         -  do_eqp_test 3.4 {
   402         -    SELECT * FROM t1 WHERE 
   403         -      a = 4 AND b BETWEEN 20 AND 80           -- Matches 80 rows
   404         -        AND
   405         -      c BETWEEN 150 AND 160                   -- Matches 10 rows
   406         -  } {
   407         -    0 0 0 {SEARCH TABLE t1 USING INDEX idx_c (c>? AND c<?)}
   408         -  }
   409         -  
   410         -  # This one should use index "idx_ab".
   411         -  do_eqp_test 3.5 {
   412         -    SELECT * FROM t1 WHERE 
   413         -      a = 5 AND b BETWEEN 20 AND 80           -- Matches 1 row
   414         -        AND
   415         -      c BETWEEN 150 AND 160                   -- Matches 10 rows
   416         -  } {
   417         -    0 0 0 {SEARCH TABLE t1 USING INDEX idx_ab (a=? AND b>? AND b<?)}
   418         -  }
          383  +  execsql { INSERT INTO t1 VALUES($i+1, 5, $c) }
          384  +  incr c
          385  +}
          386  +
          387  +do_execsql_test 3.2 {
          388  +  SELECT a, count(*) FROM t1 GROUP BY a HAVING a < 8;
          389  +} {
          390  +  0 100 1 1 2 100 3 1 4 100 5 1 6 100 7 1
          391  +}
          392  +
          393  +do_execsql_test 3.3 {
          394  +  CREATE INDEX idx_ab ON t1(a, b);
          395  +  CREATE INDEX idx_c ON t1(c);
          396  +  ANALYZE;
          397  +} {}
          398  +
          399  +# This one should use index "idx_c".
          400  +do_eqp_test 3.4 {
          401  +  SELECT * FROM t1 WHERE 
          402  +    a = 4 AND b BETWEEN 20 AND 80           -- Matches 80 rows
          403  +      AND
          404  +    c BETWEEN 150 AND 160                   -- Matches 10 rows
          405  +} {
          406  +  0 0 0 {SEARCH TABLE t1 USING INDEX idx_c (c>? AND c<?)}
          407  +}
          408  +
          409  +# This one should use index "idx_ab".
          410  +do_eqp_test 3.5 {
          411  +  SELECT * FROM t1 WHERE 
          412  +    a = 5 AND b BETWEEN 20 AND 80           -- Matches 1 row
          413  +      AND
          414  +    c BETWEEN 150 AND 160                   -- Matches 10 rows
          415  +} {
          416  +  0 0 0 {SEARCH TABLE t1 USING INDEX idx_ab (a=? AND b>? AND b<?)}
   419    417   }
          418  +
          419  +###########################################################################################
          420  +
          421  +# Reset the database and setup for a test case derived from actual SQLite users
          422  +#
          423  +db close
          424  +sqlite3 db test.db
          425  +do_execsql_test 4.1 {
          426  +  CREATE TABLE le(
          427  +    le_id largeint,
          428  +    xid char(31),
          429  +    type smallint,
          430  +    name char(255) DEFAULT '',
          431  +    mtime largeint DEFAULT 0,
          432  +    muuid int DEFAULT 0
          433  +  );
          434  +  CREATE TABLE cx(
          435  +    cx_id largeint,
          436  +    code char(31),
          437  +    type smallint,
          438  +    name char(31),
          439  +    description varchar,
          440  +    role smallint,
          441  +    mtime largeint DEFAULT 0,
          442  +    muuid int DEFAULT 0,
          443  +    le_id largeint DEFAULT 0,
          444  +    imco smallint DEFAULT 0
          445  +  );
          446  +  CREATE TABLE px(
          447  +    px_id largeint,
          448  +    cx_id largeint,
          449  +    px_tid largeint,
          450  +    name char(31),
          451  +    description varchar DEFAULT '',
          452  +    ia smallint,
          453  +    sl smallint,
          454  +    le_id largeint DEFAULT 0,
          455  +    mtime largeint DEFAULT 0,
          456  +    muuid int DEFAULT 0
          457  +  );
          458  +  CREATE INDEX le_id on le (le_id);
          459  +  CREATE INDEX c_id on cx (cx_id);
          460  +  CREATE INDEX c_leid on cx (le_id);
          461  +  CREATE INDEX p_id on px (px_id);
          462  +  CREATE INDEX p_cid0 on px (cx_id);
          463  +  CREATE INDEX p_pt on px (px_tid);
          464  +  CREATE INDEX p_leid on px (le_id);
          465  +} {}
          466  +do_execsql_test 4.2 {
          467  +  ANALYZE sqlite_master;
          468  +  INSERT INTO sqlite_stat1 VALUES('le','le_id','1979 1');
          469  +  INSERT INTO sqlite_stat1 VALUES('cx','c_leid','852 171');
          470  +  INSERT INTO sqlite_stat1 VALUES('cx','c_id','852 1');
          471  +  INSERT INTO sqlite_stat1 VALUES('px','p_leid','114443 63');
          472  +  INSERT INTO sqlite_stat1 VALUES('px','p_pt','114443 22889');
          473  +  INSERT INTO sqlite_stat1 VALUES('px','p_cid0','114443 181');
          474  +  INSERT INTO sqlite_stat1 VALUES('px','p_id','114443 1');
          475  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','162 162','162 162',X'030202013903fb');
          476  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','208 208','208 208',X'0302020253012d');
          477  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','219 219','219 219',X'030202025e0131');
          478  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','248 248','248 248',X'030202027b014e');
          479  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','265 265','265 265',X'030202028c015f');
          480  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','358 358','358 358',X'03020202e901bc');
          481  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','439 439','439 439',X'030202033a020d');
          482  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','657 657','657 657',X'030202041402b4');
          483  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','659 659','659 659',X'030202041602b6');
          484  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','681 681','681 681',X'030202042c02cc');
          485  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','831 831','831 831',X'03020204c20482');
          486  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','852 852','852 852',X'03020204d70497');
          487  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','870 870','870 870',X'03020204e904a9');
          488  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','879 879','879 879',X'03020204f204b2');
          489  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1099 1099','1099 1099',X'03020205ce058e');
          490  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1273 1273','1273 1273',X'030202067c05a9');
          491  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1319 1319','1319 1319',X'03020206e30730');
          492  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1330 1330','1330 1330',X'0302020700035b');
          493  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1539 1539','1539 1539',X'03020207d105d8');
          494  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1603 1603','1603 1603',X'03020208390780');
          495  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1759 1759','1759 1759',X'030202092f0618');
          496  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1843 1843','1843 1843',X'03020209880650');
          497  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1915 1915','1915 1915',X'03020209d0068b');
          498  +  INSERT INTO sqlite_stat4 VALUES('le','le_id','1 1','1927 1927','1927 1927',X'03020209dc0697');
          499  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 94','0 94',X'0308015f');
          500  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 189','0 189',X'03080200be');
          501  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 284','0 284',X'0308020120');
          502  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 379','0 379',X'030802017f');
          503  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 474','0 474',X'03080201de');
          504  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 569','0 569',X'030802023d');
          505  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 664','0 664',X'030802029f');
          506  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','846 1','0 759','0 759',X'03080202fe');
          507  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','3 1','846 847','1 847',X'0301024500e6');
          508  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','849 849','2 849',X'03010246027e');
          509  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','850 850','3 850',X'0301024700c9');
          510  +  INSERT INTO sqlite_stat4 VALUES('cx','c_leid','1 1','851 851','4 851',X'03010248027f');
          511  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','94 94','94 94',X'03020200b801a8');
          512  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','113 113','113 113',X'03020200d101ad');
          513  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','171 171','171 171',X'030201011d2a');
          514  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','177 177','177 177',X'030202012600f2');
          515  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','189 189','189 189',X'030202013501c8');
          516  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','206 206','206 206',X'030201014f2d');
          517  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','231 231','231 231',X'030202016d00fc');
          518  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','284 284','284 284',X'03020201b702d0');
          519  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','291 291','291 291',X'03020101c042');
          520  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','311 311','311 311',X'03020201d801e7');
          521  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','339 339','339 339',X'03020101f74b');
          522  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','347 347','347 347',X'03020202030118');
          523  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','379 379','379 379',X'030202022f01fa');
          524  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','393 393','393 393',X'030201023f55');
          525  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','407 407','407 407',X'03020202500201');
          526  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','413 413','413 413',X'03020102565a');
          527  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','468 468','468 468',X'030201029468');
          528  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','474 474','474 474',X'030202029a0211');
          529  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','517 517','517 517',X'03020102cc76');
          530  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','548 548','548 548',X'03020202f00223');
          531  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','569 569','569 569',X'03020203090087');
          532  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','664 664','664 664',X'03020203740163');
          533  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','759 759','759 759',X'03020203e800b3');
          534  +  INSERT INTO sqlite_stat4 VALUES('cx','c_id','1 1','803 803','803 803',X'030202041b026f');
          535  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 12715','0 12715',X'030802345b');
          536  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 25431','0 25431',X'0308026718');
          537  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 38147','0 38147',X'030803009a5c');
          538  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 50863','0 50863',X'03080300cdbe');
          539  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 63579','0 63579',X'0308030100e8');
          540  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 76295','0 76295',X'03080301351d');
          541  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 89011','0 89011',X'03080301674c');
          542  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110728 1','0 101727','0 101727',X'030803019b99');
          543  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','28 1','110824 110843','16 110843',X'0301037a0107f1');
          544  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','53 1','110873 110875','25 110875',X'0302020095275a');
          545  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','32 1','110927 110936','27 110936',X'030203009b009b4a');
          546  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','51 1','110980 111017','30 111017',X'03020300a4016c00');
          547  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','67 1','111047 111059','38 111059',X'03020200af2611');
          548  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','60 1','111136 111156','43 111156',X'03020300bc009aeb');
          549  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','42 1','111222 111239','59 111239',X'03020300d200b17b');
          550  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111264 111266','60 111266',X'03020200d426d6');
          551  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','27 1','111733 111757','159 111757',X'030203014e017e1b');
          552  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','36 1','111760 111773','160 111773',X'030203014f00a2b9');
          553  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','29 1','111822 111833','167 111833',X'0302030176009c22');
          554  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','75 1','113031 113095','1190 113095',X'030203068501912c');
          555  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','132 1','113230 113263','1252 113263',X'0302030711009ee6');
          556  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','110 1','113851 113918','1572 113918',X'03020308e9011ca2');
          557  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','78 1','114212 114217','1791 114217',X'03020209e13b24');
          558  +  INSERT INTO sqlite_stat4 VALUES('px','p_leid','112 1','114303 114351','1799 114351',X'03020309ea0128f2');
          559  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 12715','0 12715',X'030802477e');
          560  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 25431','0 25431',X'0308027c20');
          561  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 38147','0 38147',X'03080300c211');
          562  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 50863','0 50863',X'03080300fbe5');
          563  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 63579','0 63579',X'0308030140ff');
          564  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 76295','0 76295',X'03080301792d');
          565  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','89824 1','0 89011','0 89011',X'03080301bb68');
          566  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','24217 1','89824 101727','1 101727',X'03090300da12');
          567  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','154 1','114041 114154','2 114154',X'0301030200e5e9');
          568  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','198 1','114195 114351','3 114351',X'03010303015cb1');
          569  +  INSERT INTO sqlite_stat4 VALUES('px','p_pt','50 1','114393 114441','4 114441',X'0301030401b2ef');
          570  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3867 1','3 3736','2 3736',X'03010337015c6a');
          571  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4194 1','4177 8209','5 8209',X'0301033b015075');
          572  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','4335 1','8371 11129','6 11129',X'0301033d0156fc');
          573  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1740 1','12706 12715','7 12715',X'0301023e34b9');
          574  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1680 1','14446 15487','8 15487',X'0301033f011694');
          575  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','7163 1','20116 25431','32 25431',X'03020300a400ed26');
          576  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1525 1','29100 29302','42 29302',X'03020200bb00d1');
          577  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3703 1','30655 33323','45 33323',X'03020300be013fa5');
          578  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2612 1','37767 38147','61 38147',X'03020200e32828');
          579  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1882 1','40545 41584','63 41584',X'03020300ea01a35a');
          580  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6984 1','44110 50863','73 50863',X'0302030102017467');
          581  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1728 1','51230 51680','75 51680',X'030203010400b3e0');
          582  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2805 1','55491 57936','95 57936',X'030203014101a004');
          583  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2837 1','58934 59506','103 59506',X'030203015900a283');
          584  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','94 1','63492 63579','137 63579',X'0302030191016319');
          585  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','3573 1','63591 64497','140 64497',X'030203019c00822e');
          586  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','5037 1','70917 73033','160 73033',X'03020301c70091d9');
          587  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1940 1','75954 76295','161 76295',X'03020201c817f1');
          588  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1927 1','83926 84371','209 84371',X'03020202114295');
          589  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1522 1','86601 88117','213 88117',X'030203021b01b7b5');
          590  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','210 1','88906 89011','226 89011',X'030203022800dbbb');
          591  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','6165 1','92125 98066','258 98066',X'030203024d0189ac');
          592  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','2900 1','100721 101727','293 101727',X'030203027500cf39');
          593  +  INSERT INTO sqlite_stat4 VALUES('px','p_cid0','1501 1','110012 110154','503 110154',X'0302020380493a');
          594  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','11129 11129','11129 11129',X'03030300d84e014d51');
          595  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','12715 12715','12715 12715',X'03030200de816f51');
          596  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','13030 13030','13030 13030',X'03030200e05b6fc4');
          597  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','25431 25431','25431 25431',X'0303030123df00efb0');
          598  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','29302 29302','29302 29302',X'030302013a2812c7');
          599  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','35463 35463','35463 35463',X'03030301666e00f866');
          600  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38147 38147','38147 38147',X'030302017a391b74');
          601  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','38525 38525','38525 38525',X'030303017c6e00fb58');
          602  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','50863 50863','50863 50863',X'03030201b68724dd');
          603  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','58461 58461','58461 58461',X'03030201d95b2e1e');
          604  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','59506 59506','59506 59506',X'03030301dd7000a0fb');
          605  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63468 63468','63468 63468',X'03030301ecea011405');
          606  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','63579 63579','63579 63579',X'03030201ed5932d5');
          607  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','64497 64497','64497 64497',X'03030301f0ef00a680');
          608  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','73033 73033','73033 73033',X'0303030225b90190e5');
          609  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','75650 75650','75650 75650',X'030303023a19019362');
          610  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','76295 76295','76295 76295',X'030303023e9801940c');
          611  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','79152 79152','79152 79152',X'030303024be50196b9');
          612  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','83249 83249','83249 83249',X'0303030261750123b1');
          613  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','89011 89011','89011 89011',X'030303027b3900c3af');
          614  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','98066 98066','98066 98066',X'03030302a76500ce54');
          615  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101590 101590','101590 101590',X'03030302b63d00d3b5');
          616  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','101727 101727','101727 101727',X'03030202b6f24e9b');
          617  +  INSERT INTO sqlite_stat4 VALUES('px','p_id','1 1','107960 107960','107960 107960',X'03030302d8ce0136ad');
          618  +  ANALYZE sqlite_master;
          619  +} {}
          620  +
          621  +# The following query should do a full table scan of cx in the outer loop.
          622  +# It is not correct to search table px using indx p_pt in the outer loop
          623  +# with cx in the middle loop.  Test case from Bloomberg on 2014-09-05.
          624  +#
          625  +do_execsql_test 4.2 {
          626  +  EXPLAIN QUERY PLAN
          627  +  SELECT
          628  +     px.name,
          629  +     px.description
          630  +  FROM
          631  +     le,
          632  +     cx,
          633  +     px
          634  +  WHERE
          635  +     cx.code = '2990'
          636  +     AND cx.type=2
          637  +     AND px.cx_id = cx.cx_id
          638  +     AND px.px_tid = 0
          639  +     AND px.le_id = le.le_id;
          640  +} {/.*SCAN TABLE cx.*SEARCH TABLE px.*SEARCH TABLE le.*/}
   420    641   
   421    642   
   422    643   finish_test