/ Check-in [63fc3e4b]
Login

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

Overview
Comment:Pull in the latest changes from trunk. Update the STAT3 documentation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | stat3-trunk
Files: files | file ages | folders
SHA1: 63fc3e4bea6a7f5dc34b2af83f30458eb10b8fe0
User & Date: drh 2011-09-21 00:09:41
Context
2011-09-22
00:28
Fix an uninitialized variable and a misuse of memcpy(). check-in: ee110d5a user: drh tags: stat3-trunk
2011-09-21
00:09
Pull in the latest changes from trunk. Update the STAT3 documentation. check-in: 63fc3e4b user: drh tags: stat3-trunk
2011-09-19
20:56
Minor comment change in the description of the different memory allocator options. No changes to code. check-in: 36be31ff user: drh tags: trunk
20:36
Merge in all changes through the 3.7.8 release. check-in: 9607600b user: drh tags: stat3-trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

    19     19   **
    20     20   **    CREATE TABLE sqlite_stat1(tbl, idx, stat);
    21     21   **    CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample);
    22     22   **    CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample);
    23     23   **
    24     24   ** Additional tables might be added in future releases of SQLite.
    25     25   ** The sqlite_stat2 table is not created or used unless the SQLite version
    26         -** is between 3.6.18 and 3.7.7, inclusive, and unless SQLite is compiled
           26  +** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled
    27     27   ** with SQLITE_ENABLE_STAT2.  The sqlite_stat2 table is deprecated.
    28     28   ** The sqlite_stat2 table is superceded by sqlite_stat3, which is only
    29         -** created and used by SQLite versions after 2011-08-09 with
           29  +** created and used by SQLite versions 3.7.9 and later and with
    30     30   ** SQLITE_ENABLE_STAT3 defined.  The fucntionality of sqlite_stat3
    31     31   ** is a superset of sqlite_stat2.  
    32     32   **
    33     33   ** Format of sqlite_stat1:
    34     34   **
    35     35   ** There is normally one row per index, with the index identified by the
    36     36   ** name in the idx column.  The tbl column is the name of the table to
................................................................................
    55     55   ** column contains a single integer which is the (estimated) number of
    56     56   ** rows in the table identified by sqlite_stat1.tbl.
    57     57   **
    58     58   ** Format of sqlite_stat2:
    59     59   **
    60     60   ** The sqlite_stat2 is only created and is only used if SQLite is compiled
    61     61   ** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between
    62         -** 3.6.18 and 3.7.7.  The "stat2" table contains additional information
           62  +** 3.6.18 and 3.7.8.  The "stat2" table contains additional information
    63     63   ** about the distribution of keys within an index.  The index is identified by
    64     64   ** the "idx" column and the "tbl" column is the name of the table to which
    65     65   ** the index belongs.  There are usually 10 rows in the sqlite_stat2
    66     66   ** table for each index.
    67     67   **
    68     68   ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
    69     69   ** inclusive are samples of the left-most key value in the index taken at
................................................................................
    82     82   ** sqlite_stat3.
    83     83   **
    84     84   ** Format for sqlite_stat3:
    85     85   **
    86     86   ** The sqlite_stat3 is an enhancement to sqlite_stat2.  A new name is
    87     87   ** used to avoid compatibility problems.  
    88     88   **
    89         -** The format of the sqlite_stat3 table is similar to the format for
    90         -** the sqlite_stat2 table, with the following changes:  (1)
    91         -** The sampleno column is removed.  (2) Every sample has nEq, nLt, and nDLt
    92         -** columns which hold the approximate number of rows in the table that
    93         -** exactly match the sample, the approximate number of rows with values
    94         -** less than the sample, and the approximate number of distinct key values
    95         -** less than the sample, respectively.  (3) The number of samples can vary 
    96         -** from one table to the next; the sample count does not have to be 
    97         -** exactly 10 as it is with sqlite_stat2.
           89  +** The format of the sqlite_stat3 table is similar to the format of
           90  +** the sqlite_stat2 table.  There are multiple entries for each index.
           91  +** The idx column names the index and the tbl column is the table of the
           92  +** index.  If the idx and tbl columns are the same, then the sample is
           93  +** of the INTEGER PRIMARY KEY.  The sample column is a value taken from
           94  +** the left-most column of the index.  The nEq column is the approximate
           95  +** number of entires in the index whose left-most column exactly matches
           96  +** the sample.  nLt is the approximate number of entires whose left-most
           97  +** column is less than the same.  The nDLt column is the approximate
           98  +** number of distinct left-most entries in the index that are less than
           99  +** the same.
    98    100   **
          101  +** Future versions of SQLite might change to store a string containing
          102  +** multiple integers values in the nDLt column of sqlite_stat3.  The first
          103  +** integer will be the number of prior index entires that are distinct in
          104  +** the left-most column.  The second integer will be the number of prior index
          105  +** entries that are distinct in the first two columns.  The third integer
          106  +** will be the number of prior index entries that are distinct in the first
          107  +** three columns.  And so forth.  With that extension, the nDLt field is
          108  +** similar in function to the sqlite_stat1.stat field.
          109  +**
          110  +** There can be an arbitrary number of sqlite_stat3 entries per index.
    99    111   ** The ANALYZE command will typically generate sqlite_stat3 tables
   100    112   ** that contain between 10 and 40 samples which are distributed across
   101    113   ** the key space, though not uniformly, and which include samples with
   102    114   ** largest possible nEq values.
   103    115   */
   104    116   #ifndef SQLITE_OMIT_ANALYZE
   105    117   #include "sqliteInt.h"

Changes to src/sqliteInt.h.

   152    152   **
   153    153   ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
   154    154   ** assert() macro is enabled, each call into the Win32 native heap subsystem
   155    155   ** will cause HeapValidate to be called.  If heap validation should fail, an
   156    156   ** assertion will be triggered.
   157    157   **
   158    158   ** (Historical note:  There used to be several other options, but we've
   159         -** pared it down to just these two.)
          159  +** pared it down to just these three.)
   160    160   **
   161    161   ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
   162    162   ** the default.
   163    163   */
   164    164   #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1
   165    165   # error "At most one of the following compile-time configuration options\
   166    166    is allows: SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG"

Changes to src/where.c.

   117    117   #define TERM_COPIED     0x08   /* Has a child */
   118    118   #define TERM_ORINFO     0x10   /* Need to free the WhereTerm.u.pOrInfo object */
   119    119   #define TERM_ANDINFO    0x20   /* Need to free the WhereTerm.u.pAndInfo obj */
   120    120   #define TERM_OR_OK      0x40   /* Used during OR-clause processing */
   121    121   #ifdef SQLITE_ENABLE_STAT3
   122    122   #  define TERM_VNULL    0x80   /* Manufactured x>NULL or x<=NULL term */
   123    123   #else
   124         -#  define TERM_VNULL    0x00   /* Disabled if not using stat2 */
          124  +#  define TERM_VNULL    0x00   /* Disabled if not using stat3 */
   125    125   #endif
   126    126   
   127    127   /*
   128    128   ** An instance of the following structure holds all information about a
   129    129   ** WHERE clause.  Mostly this is a container for one or more WhereTerms.
   130    130   */
   131    131   struct WhereClause {
................................................................................
  1337   1337         pTerm->wtFlags |= TERM_COPIED;
  1338   1338         pNewTerm->prereqAll = pTerm->prereqAll;
  1339   1339       }
  1340   1340     }
  1341   1341   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  1342   1342   
  1343   1343   #ifdef SQLITE_ENABLE_STAT3
  1344         -  /* When sqlite_stat2 histogram data is available an operator of the
         1344  +  /* When sqlite_stat3 histogram data is available an operator of the
  1345   1345     ** form "x IS NOT NULL" can sometimes be evaluated more efficiently
  1346   1346     ** as "x>NULL" if x is not an INTEGER PRIMARY KEY.  So construct a
  1347   1347     ** virtual term of that form.
  1348   1348     **
  1349   1349     ** Note that the virtual term must be tagged with TERM_VNULL.  This
  1350   1350     ** TERM_VNULL tag will suppress the not-null check at the beginning
  1351   1351     ** of the loop.  Without the TERM_VNULL flag, the not-null check at