/ Check-in [0bc594e8]
Login

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

Overview
Comment:Data structure cleanup. Remove unused fields. Rearrange other files for tighter packing and reduced memory usage.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0bc594e861ae1142e8c6c83f39b095e1432856bf
User & Date: drh 2012-02-02 15:50:17
Context
2012-02-02
18:46
When non-aggregate columns occur in an aggregate query with a single min() or max(), then the values of the non-aggregate columns are taken from one of the rows that was the min() or max(). check-in: fa13edd3 user: drh tags: trunk
17:35
For queries of the form "SELECT p, max(q) FROM t1", the value of column p returned is the one on the same row that holds the maximum value of q. check-in: adb29232 user: drh tags: output-minmax-row
15:50
Data structure cleanup. Remove unused fields. Rearrange other files for tighter packing and reduced memory usage. check-in: 0bc594e8 user: drh tags: trunk
03:38
Simplified array allocation in the IdList and AggInfo objects. check-in: 25df2a74 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  1634   1634                                sqlite3Strlen30(p->zName),p);
  1635   1635       if( pOld ){
  1636   1636         assert( p==pOld );  /* Malloc must have failed inside HashInsert() */
  1637   1637         db->mallocFailed = 1;
  1638   1638         return;
  1639   1639       }
  1640   1640       pParse->pNewTable = 0;
  1641         -    db->nTable++;
  1642   1641       db->flags |= SQLITE_InternChanges;
  1643   1642   
  1644   1643   #ifndef SQLITE_OMIT_ALTERTABLE
  1645   1644       if( !p->pSelect ){
  1646   1645         const char *zName = (const char *)pParse->sNameToken.z;
  1647   1646         int nName;
  1648   1647         assert( !pSelect && pCons && pEnd );

Changes to src/pcache.h.

    23     23   ** structure.
    24     24   */
    25     25   struct PgHdr {
    26     26     sqlite3_pcache_page *pPage;    /* Pcache object page handle */
    27     27     void *pData;                   /* Page data */
    28     28     void *pExtra;                  /* Extra content */
    29     29     PgHdr *pDirty;                 /* Transient list of dirty pages */
    30         -  Pgno pgno;                     /* Page number for this page */
    31     30     Pager *pPager;                 /* The pager this page is part of */
           31  +  Pgno pgno;                     /* Page number for this page */
    32     32   #ifdef SQLITE_CHECK_PAGES
    33     33     u32 pageHash;                  /* Hash of page content */
    34     34   #endif
    35     35     u16 flags;                     /* PGHDR flags defined below */
    36     36   
    37     37     /**********************************************************************
    38     38     ** Elements above are public.  All that follows is private to pcache.c

Changes to src/sqliteInt.h.

   793    793   */
   794    794   struct FuncDefHash {
   795    795     FuncDef *a[23];       /* Hash table for functions */
   796    796   };
   797    797   
   798    798   /*
   799    799   ** Each database connection is an instance of the following structure.
   800         -**
   801         -** The sqlite.lastRowid records the last insert rowid generated by an
   802         -** insert statement.  Inserts on views do not affect its value.  Each
   803         -** trigger has its own context, so that lastRowid can be updated inside
   804         -** triggers as usual.  The previous value will be restored once the trigger
   805         -** exits.  Upon entering a before or instead of trigger, lastRowid is no
   806         -** longer (since after version 2.8.12) reset to -1.
   807         -**
   808         -** The sqlite.nChange does not count changes within triggers and keeps no
   809         -** context.  It is reset at start of sqlite3_exec.
   810         -** The sqlite.lsChange represents the number of changes made by the last
   811         -** insert, update, or delete statement.  It remains constant throughout the
   812         -** length of a statement and is then updated by OP_SetCounts.  It keeps a
   813         -** context stack just like lastRowid so that the count of changes
   814         -** within a trigger is not seen outside the trigger.  Changes to views do not
   815         -** affect the value of lsChange.
   816         -** The sqlite.csChange keeps track of the number of current changes (since
   817         -** the last statement) and is used to update sqlite_lsChange.
   818         -**
   819         -** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16
   820         -** store the most recent error code and, if applicable, string. The
   821         -** internal function sqlite3Error() is used to set these variables
   822         -** consistently.
   823    800   */
   824    801   struct sqlite3 {
   825    802     sqlite3_vfs *pVfs;            /* OS Interface */
   826         -  int nDb;                      /* Number of backends currently in use */
          803  +  struct Vdbe *pVdbe;           /* List of active virtual machines */
          804  +  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */
          805  +  sqlite3_mutex *mutex;         /* Connection mutex */
   827    806     Db *aDb;                      /* All backends */
          807  +  int nDb;                      /* Number of backends currently in use */
   828    808     int flags;                    /* Miscellaneous flags. See below */
          809  +  i64 lastRowid;                /* ROWID of most recent insert (see above) */
   829    810     unsigned int openFlags;       /* Flags passed to sqlite3_vfs.xOpen() */
   830    811     int errCode;                  /* Most recent error code (SQLITE_*) */
   831    812     int errMask;                  /* & result codes with this before returning */
   832    813     u8 autoCommit;                /* The auto-commit flag. */
   833    814     u8 temp_store;                /* 1: file 2: memory 0: default */
   834    815     u8 mallocFailed;              /* True if we have seen a malloc failure */
   835    816     u8 dfltLockMode;              /* Default locking-mode for attached dbs */
   836    817     signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
   837    818     u8 suppressErr;               /* Do not issue error messages if true */
   838    819     u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */
          820  +  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
   839    821     int nextPagesize;             /* Pagesize after VACUUM if >0 */
   840         -  int nTable;                   /* Number of tables in the database */
   841         -  CollSeq *pDfltColl;           /* The default collating sequence (BINARY) */
   842         -  i64 lastRowid;                /* ROWID of most recent insert (see above) */
   843    822     u32 magic;                    /* Magic number for detect library misuse */
   844    823     int nChange;                  /* Value returned by sqlite3_changes() */
   845    824     int nTotalChange;             /* Value returned by sqlite3_total_changes() */
   846         -  sqlite3_mutex *mutex;         /* Connection mutex */
   847    825     int aLimit[SQLITE_N_LIMIT];   /* Limits */
   848    826     struct sqlite3InitInfo {      /* Information used during initialization */
   849         -    int iDb;                    /* When back is being initialized */
   850    827       int newTnum;                /* Rootpage of table being initialized */
          828  +    u8 iDb;                     /* Which db file is being initialized */
   851    829       u8 busy;                    /* TRUE if currently initializing */
   852    830       u8 orphanTrigger;           /* Last statement is orphaned TEMP trigger */
   853    831     } init;
   854         -  int nExtension;               /* Number of loaded extensions */
   855         -  void **aExtension;            /* Array of shared library handles */
   856         -  struct Vdbe *pVdbe;           /* List of active virtual machines */
   857    832     int activeVdbeCnt;            /* Number of VDBEs currently executing */
   858    833     int writeVdbeCnt;             /* Number of active VDBEs that are writing */
   859    834     int vdbeExecCnt;              /* Number of nested calls to VdbeExec() */
          835  +  int nExtension;               /* Number of loaded extensions */
          836  +  void **aExtension;            /* Array of shared library handles */
   860    837     void (*xTrace)(void*,const char*);        /* Trace function */
   861    838     void *pTraceArg;                          /* Argument to the trace function */
   862    839     void (*xProfile)(void*,const char*,u64);  /* Profiling function */
   863    840     void *pProfileArg;                        /* Argument to profile function */
   864    841     void *pCommitArg;                 /* Argument to xCommitCallback() */   
   865    842     int (*xCommitCallback)(void*);    /* Invoked at every commit. */
   866    843     void *pRollbackArg;               /* Argument to xRollbackCallback() */   
................................................................................
   889    866   #endif
   890    867   #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
   891    868     int (*xProgress)(void *);     /* The progress callback */
   892    869     void *pProgressArg;           /* Argument to the progress callback */
   893    870     int nProgressOps;             /* Number of opcodes for progress callback */
   894    871   #endif
   895    872   #ifndef SQLITE_OMIT_VIRTUALTABLE
          873  +  int nVTrans;                  /* Allocated size of aVTrans */
   896    874     Hash aModule;                 /* populated by sqlite3_create_module() */
   897    875     VtabCtx *pVtabCtx;            /* Context for active vtab connect/create */
   898    876     VTable **aVTrans;             /* Virtual tables with open transactions */
   899         -  int nVTrans;                  /* Allocated size of aVTrans */
   900    877     VTable *pDisconnect;    /* Disconnect these in next sqlite3_prepare() */
   901    878   #endif
   902    879     FuncDefHash aFunc;            /* Hash table of connection functions */
   903    880     Hash aCollSeq;                /* All collating sequences */
   904    881     BusyHandler busyHandler;      /* Busy callback */
   905         -  int busyTimeout;              /* Busy handler timeout, in msec */
   906    882     Db aDbStatic[2];              /* Static space for the 2 default backends */
   907    883     Savepoint *pSavepoint;        /* List of active savepoints */
          884  +  int busyTimeout;              /* Busy handler timeout, in msec */
   908    885     int nSavepoint;               /* Number of non-transaction savepoints */
   909    886     int nStatement;               /* Number of nested statement-transactions  */
   910         -  u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
   911    887     i64 nDeferredCons;            /* Net deferred constraints this transaction. */
   912    888     int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
   913    889   
   914    890   #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
   915    891     /* The following variables are all protected by the STATIC_MASTER 
   916    892     ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 
   917    893     **
................................................................................
  1035   1011   /*
  1036   1012   ** Possible values for FuncDef.flags
  1037   1013   */
  1038   1014   #define SQLITE_FUNC_LIKE     0x01 /* Candidate for the LIKE optimization */
  1039   1015   #define SQLITE_FUNC_CASE     0x02 /* Case-sensitive LIKE-type function */
  1040   1016   #define SQLITE_FUNC_EPHEM    0x04 /* Ephemeral.  Delete with VDBE */
  1041   1017   #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
  1042         -#define SQLITE_FUNC_PRIVATE  0x10 /* Allowed for internal use only */
  1043   1018   #define SQLITE_FUNC_COUNT    0x20 /* Built-in count(*) aggregate */
  1044   1019   #define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
  1045   1020   
  1046   1021   /*
  1047   1022   ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
  1048   1023   ** used to create the initializers for the FuncDef structures.
  1049   1024   **
................................................................................
  1318   1293   ** Allowed values for Tabe.tabFlags.
  1319   1294   */
  1320   1295   #define TF_Readonly        0x01    /* Read-only system table */
  1321   1296   #define TF_Ephemeral       0x02    /* An ephemeral table */
  1322   1297   #define TF_HasPrimaryKey   0x04    /* Table has a primary key */
  1323   1298   #define TF_Autoincrement   0x08    /* Integer primary key is autoincrement */
  1324   1299   #define TF_Virtual         0x10    /* Is a virtual table */
  1325         -#define TF_NeedMetadata    0x20    /* aCol[].zType and aCol[].pColl missing */
  1326         -
  1327   1300   
  1328   1301   
  1329   1302   /*
  1330   1303   ** Test to see whether or not a table is a virtual table.  This is
  1331   1304   ** done as a macro so that it will be optimized out when virtual
  1332   1305   ** table support is omitted from the build.
  1333   1306   */
................................................................................
  1481   1454   ** it means this is not a unique index.  Otherwise it is a unique index
  1482   1455   ** and the value of Index.onError indicate the which conflict resolution 
  1483   1456   ** algorithm to employ whenever an attempt is made to insert a non-unique
  1484   1457   ** element.
  1485   1458   */
  1486   1459   struct Index {
  1487   1460     char *zName;     /* Name of this index */
  1488         -  int nColumn;     /* Number of columns in the table used by this index */
  1489   1461     int *aiColumn;   /* Which columns are used by this index.  1st is 0 */
  1490   1462     tRowcnt *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */
  1491   1463     Table *pTable;   /* The SQL table being indexed */
  1492         -  int tnum;        /* Page containing root of this index in database file */
  1493         -  u8 onError;      /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
  1494         -  u8 autoIndex;    /* True if is automatically created (ex: by UNIQUE) */
  1495         -  u8 bUnordered;   /* Use this index for == or IN queries only */
  1496   1464     char *zColAff;   /* String defining the affinity of each column */
  1497   1465     Index *pNext;    /* The next index associated with the same table */
  1498   1466     Schema *pSchema; /* Schema containing this index */
  1499   1467     u8 *aSortOrder;  /* Array of size Index.nColumn. True==DESC, False==ASC */
  1500   1468     char **azColl;   /* Array of collation sequence names for index */
         1469  +  int nColumn;     /* Number of columns in the table used by this index */
         1470  +  int tnum;        /* Page containing root of this index in database file */
         1471  +  u8 onError;      /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
         1472  +  u8 autoIndex;    /* True if is automatically created (ex: by UNIQUE) */
         1473  +  u8 bUnordered;   /* Use this index for == or IN queries only */
  1501   1474   #ifdef SQLITE_ENABLE_STAT3
  1502   1475     int nSample;             /* Number of elements in aSample[] */
  1503   1476     tRowcnt avgEq;           /* Average nEq value for key values not in aSample */
  1504   1477     IndexSample *aSample;    /* Samples of the left-most key */
  1505   1478   #endif
  1506   1479   };
  1507   1480   
................................................................................
  1552   1525   struct AggInfo {
  1553   1526     u8 directMode;          /* Direct rendering mode means take data directly
  1554   1527                             ** from source tables rather than from accumulators */
  1555   1528     u8 useSortingIdx;       /* In direct mode, reference the sorting index rather
  1556   1529                             ** than the source table */
  1557   1530     int sortingIdx;         /* Cursor number of the sorting index */
  1558   1531     int sortingIdxPTab;     /* Cursor number of pseudo-table */
  1559         -  ExprList *pGroupBy;     /* The group by clause */
  1560   1532     int nSortingColumn;     /* Number of columns in the sorting index */
         1533  +  ExprList *pGroupBy;     /* The group by clause */
  1561   1534     struct AggInfo_col {    /* For each column used in source tables */
  1562   1535       Table *pTab;             /* Source table */
  1563   1536       int iTable;              /* Cursor number of the source table */
  1564   1537       int iColumn;             /* Column number within the source table */
  1565   1538       int iSorterColumn;       /* Column number in the sorting index */
  1566   1539       int iMem;                /* Memory location that acts as accumulator */
  1567   1540       Expr *pExpr;             /* The original expression */
................................................................................
  2056   2029   ** sequences for the ORDER BY clause.
  2057   2030   */
  2058   2031   struct Select {
  2059   2032     ExprList *pEList;      /* The fields of the result */
  2060   2033     u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
  2061   2034     char affinity;         /* MakeRecord with this affinity for SRT_Set */
  2062   2035     u16 selFlags;          /* Various SF_* values */
         2036  +  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */
         2037  +  int addrOpenEphm[3];   /* OP_OpenEphem opcodes related to this select */
         2038  +  double nSelectRow;     /* Estimated number of result rows */
  2063   2039     SrcList *pSrc;         /* The FROM clause */
  2064   2040     Expr *pWhere;          /* The WHERE clause */
  2065   2041     ExprList *pGroupBy;    /* The GROUP BY clause */
  2066   2042     Expr *pHaving;         /* The HAVING clause */
  2067   2043     ExprList *pOrderBy;    /* The ORDER BY clause */
  2068   2044     Select *pPrior;        /* Prior select in a compound select statement */
  2069   2045     Select *pNext;         /* Next select to the left in a compound */
  2070   2046     Select *pRightmost;    /* Right-most select in a compound select statement */
  2071   2047     Expr *pLimit;          /* LIMIT expression. NULL means not used. */
  2072   2048     Expr *pOffset;         /* OFFSET expression. NULL means not used. */
  2073         -  int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */
  2074         -  int addrOpenEphm[3];   /* OP_OpenEphem opcodes related to this select */
  2075         -  double nSelectRow;     /* Estimated number of result rows */
  2076   2049   };
  2077   2050   
  2078   2051   /*
  2079   2052   ** Allowed values for Select.selFlags.  The "SF" prefix stands for
  2080   2053   ** "Select Flag".
  2081   2054   */
  2082   2055   #define SF_Distinct        0x01  /* Output should be DISTINCT */
................................................................................
  2160   2133   ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
  2161   2134   ** accessed (or set to 0 for triggers fired as a result of INSERT 
  2162   2135   ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
  2163   2136   ** a mask of new.* columns used by the program.
  2164   2137   */
  2165   2138   struct TriggerPrg {
  2166   2139     Trigger *pTrigger;      /* Trigger this program was coded from */
  2167         -  int orconf;             /* Default ON CONFLICT policy */
         2140  +  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */
  2168   2141     SubProgram *pProgram;   /* Program implementing pTrigger/orconf */
         2142  +  int orconf;             /* Default ON CONFLICT policy */
  2169   2143     u32 aColmask[2];        /* Masks of old.*, new.* columns accessed */
  2170         -  TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */
  2171   2144   };
  2172   2145   
  2173   2146   /*
  2174   2147   ** The yDbMask datatype for the bitmask of all attached databases.
  2175   2148   */
  2176   2149   #if SQLITE_MAX_ATTACHED>30
  2177   2150     typedef sqlite3_uint64 yDbMask;
................................................................................
  2193   2166   ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are
  2194   2167   ** used to store the set of table-locks required by the statement being
  2195   2168   ** compiled. Function sqlite3TableLock() is used to add entries to the
  2196   2169   ** list.
  2197   2170   */
  2198   2171   struct Parse {
  2199   2172     sqlite3 *db;         /* The main database structure */
  2200         -  int rc;              /* Return code from execution */
  2201   2173     char *zErrMsg;       /* An error message */
  2202   2174     Vdbe *pVdbe;         /* An engine for executing database bytecode */
         2175  +  int rc;              /* Return code from execution */
  2203   2176     u8 colNamesSet;      /* TRUE after OP_ColumnName has been issued to pVdbe */
  2204   2177     u8 checkSchema;      /* Causes schema cookie check after an error */
  2205   2178     u8 nested;           /* Number of nested calls to the parser/code generator */
  2206   2179     u8 nTempReg;         /* Number of temporary registers in aTempReg[] */
  2207   2180     u8 nTempInUse;       /* Number of aTempReg[] currently checked out */
         2181  +  u8 nColCache;        /* Number of entries in aColCache[] */
         2182  +  u8 iColCache;        /* Next entry in aColCache[] to replace */
         2183  +  u8 isMultiWrite;     /* True if statement may modify/insert multiple rows */
         2184  +  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  2208   2185     int aTempReg[8];     /* Holding area for temporary registers */
  2209   2186     int nRangeReg;       /* Size of the temporary register block */
  2210   2187     int iRangeReg;       /* First register in temporary register block */
  2211   2188     int nErr;            /* Number of errors seen */
  2212   2189     int nTab;            /* Number of previously allocated VDBE cursors */
  2213   2190     int nMem;            /* Number of memory cells used so far */
  2214   2191     int nSet;            /* Number of sets used so far */
  2215   2192     int nOnce;           /* Number of OP_Once instructions so far */
  2216   2193     int ckBase;          /* Base register of data during check constraints */
  2217   2194     int iCacheLevel;     /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
  2218   2195     int iCacheCnt;       /* Counter used to generate aColCache[].lru values */
  2219         -  u8 nColCache;        /* Number of entries in aColCache[] */
  2220         -  u8 iColCache;        /* Next entry in aColCache[] to replace */
  2221   2196     struct yColCache {
  2222   2197       int iTable;           /* Table cursor number */
  2223   2198       int iColumn;          /* Table column number */
  2224   2199       u8 tempReg;           /* iReg is a temp register that needs to be freed */
  2225   2200       int iLevel;           /* Nesting level */
  2226   2201       int iReg;             /* Reg with value of this column. 0 means none. */
  2227   2202       int lru;              /* Least recently used entry has the smallest value */
  2228   2203     } aColCache[SQLITE_N_COLCACHE];  /* One for each column cache entry */
  2229   2204     yDbMask writeMask;   /* Start a write transaction on these databases */
  2230   2205     yDbMask cookieMask;  /* Bitmask of schema verified databases */
  2231         -  u8 isMultiWrite;     /* True if statement may affect/insert multiple rows */
  2232         -  u8 mayAbort;         /* True if statement may throw an ABORT exception */
  2233   2206     int cookieGoto;      /* Address of OP_Goto to cookie verifier subroutine */
  2234   2207     int cookieValue[SQLITE_MAX_ATTACHED+2];  /* Values of cookies to verify */
         2208  +  int regRowid;        /* Register holding rowid of CREATE TABLE entry */
         2209  +  int regRoot;         /* Register holding root page number for new objects */
         2210  +  int nMaxArg;         /* Max args passed to user function by sub-program */
  2235   2211   #ifndef SQLITE_OMIT_SHARED_CACHE
  2236   2212     int nTableLock;        /* Number of locks in aTableLock */
  2237   2213     TableLock *aTableLock; /* Required table locks for shared-cache mode */
  2238   2214   #endif
  2239         -  int regRowid;        /* Register holding rowid of CREATE TABLE entry */
  2240         -  int regRoot;         /* Register holding root page number for new objects */
  2241   2215     AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */
  2242         -  int nMaxArg;         /* Max args passed to user function by sub-program */
  2243   2216   
  2244   2217     /* Information used while coding trigger programs. */
  2245   2218     Parse *pToplevel;    /* Parse structure for main program (or NULL) */
  2246   2219     Table *pTriggerTab;  /* Table triggers are being coded for */
         2220  +  double nQueryLoop;   /* Estimated number of iterations of a query */
  2247   2221     u32 oldmask;         /* Mask of old.* columns referenced */
  2248   2222     u32 newmask;         /* Mask of new.* columns referenced */
  2249   2223     u8 eTriggerOp;       /* TK_UPDATE, TK_INSERT or TK_DELETE */
  2250   2224     u8 eOrconf;          /* Default ON CONFLICT policy for trigger steps */
  2251   2225     u8 disableTriggers;  /* True to disable triggers */
  2252         -  double nQueryLoop;   /* Estimated number of iterations of a query */
  2253   2226   
  2254   2227     /* Above is constant between recursions.  Below is reset before and after
  2255   2228     ** each recursion */
  2256   2229   
  2257         -  int nVar;            /* Number of '?' variables seen in the SQL so far */
  2258         -  int nzVar;           /* Number of available slots in azVar[] */
  2259         -  char **azVar;        /* Pointers to names of parameters */
  2260         -  Vdbe *pReprepare;    /* VM being reprepared (sqlite3Reprepare()) */
  2261         -  int nAlias;          /* Number of aliased result set columns */
  2262         -  int *aAlias;         /* Register used to hold aliased result */
  2263         -  u8 explain;          /* True if the EXPLAIN flag is found on the query */
  2264         -  Token sNameToken;    /* Token with unqualified schema object name */
  2265         -  Token sLastToken;    /* The last token parsed */
  2266         -  const char *zTail;   /* All SQL text past the last semicolon parsed */
  2267         -  Table *pNewTable;    /* A table being constructed by CREATE TABLE */
         2230  +  int nVar;                 /* Number of '?' variables seen in the SQL so far */
         2231  +  int nzVar;                /* Number of available slots in azVar[] */
         2232  +  u8 explain;               /* True if the EXPLAIN flag is found on the query */
         2233  +#ifndef SQLITE_OMIT_VIRTUALTABLE
         2234  +  u8 declareVtab;           /* True if inside sqlite3_declare_vtab() */
         2235  +  int nVtabLock;            /* Number of virtual tables to lock */
         2236  +#endif
         2237  +  int nAlias;               /* Number of aliased result set columns */
         2238  +  int nHeight;              /* Expression tree height of current sub-select */
         2239  +#ifndef SQLITE_OMIT_EXPLAIN
         2240  +  int iSelectId;            /* ID of current select for EXPLAIN output */
         2241  +  int iNextSelectId;        /* Next available select ID for EXPLAIN output */
         2242  +#endif
         2243  +  char **azVar;             /* Pointers to names of parameters */
         2244  +  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */
         2245  +  int *aAlias;              /* Register used to hold aliased result */
         2246  +  const char *zTail;        /* All SQL text past the last semicolon parsed */
         2247  +  Table *pNewTable;         /* A table being constructed by CREATE TABLE */
  2268   2248     Trigger *pNewTrigger;     /* Trigger under construct by a CREATE TRIGGER */
  2269   2249     const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
         2250  +  Token sNameToken;         /* Token with unqualified schema object name */
         2251  +  Token sLastToken;         /* The last token parsed */
  2270   2252   #ifndef SQLITE_OMIT_VIRTUALTABLE
  2271         -  Token sArg;                /* Complete text of a module argument */
  2272         -  u8 declareVtab;            /* True if inside sqlite3_declare_vtab() */
  2273         -  int nVtabLock;             /* Number of virtual tables to lock */
  2274         -  Table **apVtabLock;        /* Pointer to virtual tables needing locking */
         2253  +  Token sArg;               /* Complete text of a module argument */
         2254  +  Table **apVtabLock;       /* Pointer to virtual tables needing locking */
  2275   2255   #endif
  2276         -  int nHeight;            /* Expression tree height of current sub-select */
  2277         -  Table *pZombieTab;      /* List of Table objects to delete after code gen */
  2278         -  TriggerPrg *pTriggerPrg;    /* Linked list of coded triggers */
  2279         -
  2280         -#ifndef SQLITE_OMIT_EXPLAIN
  2281         -  int iSelectId;
  2282         -  int iNextSelectId;
  2283         -#endif
         2256  +  Table *pZombieTab;        /* List of Table objects to delete after code gen */
         2257  +  TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */
  2284   2258   };
  2285   2259   
         2260  +/*
         2261  +** Return true if currently inside an sqlite3_declare_vtab() call.
         2262  +*/
  2286   2263   #ifdef SQLITE_OMIT_VIRTUALTABLE
  2287   2264     #define IN_DECLARE_VTAB 0
  2288   2265   #else
  2289   2266     #define IN_DECLARE_VTAB (pParse->declareVtab)
  2290   2267   #endif
  2291   2268   
  2292   2269   /*
................................................................................
  2429   2406   
  2430   2407   /*
  2431   2408   ** A pointer to this structure is used to communicate information
  2432   2409   ** from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback.
  2433   2410   */
  2434   2411   typedef struct {
  2435   2412     sqlite3 *db;        /* The database being initialized */
  2436         -  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */
  2437   2413     char **pzErrMsg;    /* Error message stored here */
         2414  +  int iDb;            /* 0 for main database.  1 for TEMP, 2.. for ATTACHed */
  2438   2415     int rc;             /* Result code stored here */
  2439   2416   } InitData;
  2440   2417   
  2441   2418   /*
  2442   2419   ** Structure containing global configuration data for the SQLite library.
  2443   2420   **
  2444   2421   ** This structure also contains some state information.

Changes to src/vdbe.c.

  2849   2849   ** on the file.
  2850   2850   **
  2851   2851   ** If a write-transaction is started and the Vdbe.usesStmtJournal flag is
  2852   2852   ** true (this flag is set if the Vdbe may modify more than one row and may
  2853   2853   ** throw an ABORT exception), a statement transaction may also be opened.
  2854   2854   ** More specifically, a statement transaction is opened iff the database
  2855   2855   ** connection is currently not in autocommit mode, or if there are other
  2856         -** active statements. A statement transaction allows the affects of this
         2856  +** active statements. A statement transaction allows the changes made by this
  2857   2857   ** VDBE to be rolled back after an error without having to roll back the
  2858   2858   ** entire transaction. If no error is encountered, the statement transaction
  2859   2859   ** will automatically commit when the VDBE halts.
  2860   2860   **
  2861   2861   ** If P2 is zero, then a read-lock is obtained on the database file.
  2862   2862   */
  2863   2863   case OP_Transaction: {