/ Check-in [a5d94eab]
Login

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

Overview
Comment:Merge the latest trunk enhancements into the sessions branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: a5d94eaba6aa12ff16d2a0af2fc752bcdb461877
User & Date: drh 2014-06-30 20:02:55
Context
2014-07-24
16:23
Merge recent trunk changes into the sessions branch. check-in: a9db017e user: drh tags: sessions
2014-06-30
20:02
Merge the latest trunk enhancements into the sessions branch. check-in: a5d94eab user: drh tags: sessions
19:28
Bump the version number to 3.8.6. check-in: f925e9ba user: drh tags: trunk
2014-06-03
20:09
Merge the 3.8.5 release candidate changes into the sessions branch. check-in: 09e75d82 user: drh tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   397    397     $(TOP)/ext/session/test_session.c
   398    398   
   399    399   # Statically linked extensions
   400    400   #
   401    401   TESTSRC += \
   402    402     $(TOP)/ext/misc/amatch.c \
   403    403     $(TOP)/ext/misc/closure.c \
          404  +  $(TOP)/ext/misc/fileio.c \
   404    405     $(TOP)/ext/misc/fuzzer.c \
   405    406     $(TOP)/ext/misc/ieee754.c \
   406    407     $(TOP)/ext/misc/nextchar.c \
   407    408     $(TOP)/ext/misc/percentile.c \
   408    409     $(TOP)/ext/misc/regexp.c \
   409    410     $(TOP)/ext/misc/spellfix.c \
   410    411     $(TOP)/ext/misc/totype.c \
................................................................................
   947    948   	echo "static const char *zMainloop = " >> $@
   948    949   	$(NAWK) -f $(TOP)/tool/tostr.awk $(TOP)/tool/spaceanal.tcl >> $@
   949    950   	echo "; return zMainloop; }" >> $@
   950    951   
   951    952   sqlite3_analyzer$(TEXE): sqlite3_analyzer.c
   952    953   	$(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS)
   953    954   
   954         -showdb$(TEXE):	$(TOP)/tool/showdb.c sqlite3.c
   955         -	$(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.c $(TLIBS)
          955  +showdb$(TEXE):	$(TOP)/tool/showdb.c sqlite3.lo
          956  +	$(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS)
          957  +
          958  +showstat4$(TEXE):	$(TOP)/tool/showstat4.c sqlite3.lo
          959  +	$(LTLINK) -o $@ $(TOP)/tool/showstat4.c sqlite3.lo $(TLIBS)
          960  +
          961  +showjournal$(TEXE):	$(TOP)/tool/showjournal.c sqlite3.lo
          962  +	$(LTLINK) -o $@ $(TOP)/tool/showjournal.c sqlite3.lo $(TLIBS)
          963  +
          964  +showwal$(TEXE):	$(TOP)/tool/showwal.c sqlite3.lo
          965  +	$(LTLINK) -o $@ $(TOP)/tool/showwal.c sqlite3.lo $(TLIBS)
          966  +
          967  +rollback-test$(TEXE):	$(TOP)/tool/rollback-test.c sqlite3.lo
          968  +	$(LTLINK) -o $@ $(TOP)/tool/rollback-test.c sqlite3.lo $(TLIBS)
          969  +
          970  +LogEst$(TEXE):	$(TOP)/tool/logest.c sqlite3.h
          971  +	$(LTLINK) -I. -o $@ $(TOP)/tool/logest.c
   956    972   
   957    973   wordcount$(TEXE):	$(TOP)/test/wordcount.c sqlite3.c
   958    974   	$(LTLINK) -o $@ $(TOP)/test/wordcount.c sqlite3.c $(TLIBS)
   959    975   
   960    976   speedtest1$(TEXE):	$(TOP)/test/wordcount.c sqlite3.lo
   961    977   	$(LTLINK) -o $@ $(TOP)/test/speedtest1.c sqlite3.lo $(TLIBS)
   962    978   

Changes to Makefile.msc.

   873    873     $(TOP)\ext\session\test_session.c
   874    874   
   875    875   # Statically linked extensions
   876    876   #
   877    877   TESTEXT = \
   878    878     $(TOP)\ext\misc\amatch.c \
   879    879     $(TOP)\ext\misc\closure.c \
          880  +  $(TOP)\ext\misc\fileio.c \
   880    881     $(TOP)\ext\misc\fuzzer.c \
   881    882     $(TOP)\ext\misc\ieee754.c \
   882    883     $(TOP)\ext\misc\nextchar.c \
   883    884     $(TOP)\ext\misc\percentile.c \
   884    885     $(TOP)\ext\misc\regexp.c \
   885    886     $(TOP)\ext\misc\spellfix.c \
   886    887     $(TOP)\ext\misc\totype.c \
................................................................................
  1458   1459   
  1459   1460   testloadext.dll: testloadext.lo
  1460   1461   	$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ testloadext.lo
  1461   1462   
  1462   1463   showdb.exe:	$(TOP)\tool\showdb.c $(SQLITE3C)
  1463   1464   	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
  1464   1465   		$(TOP)\tool\showdb.c $(SQLITE3C)
         1466  +
         1467  +showstat4.exe:	$(TOP)\tool\showstat4.c $(SQLITE3C)
         1468  +	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
         1469  +		$(TOP)\tool\showstat4.c $(SQLITE3C)
         1470  +
         1471  +showjournal.exe:	$(TOP)\tool\showjournal.c $(SQLITE3C)
         1472  +	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
         1473  +		$(TOP)\tool\showjournal.c $(SQLITE3C)
         1474  +
         1475  +showwal.exe:	$(TOP)\tool\showwal.c $(SQLITE3C)
         1476  +	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
         1477  +		$(TOP)\tool\showwal.c $(SQLITE3C)
         1478  +
         1479  +rollback-test.exe:	$(TOP)\tool\rollback-test.c $(SQLITE3C)
         1480  +	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
         1481  +		$(TOP)\tool\rollback-test.c $(SQLITE3C)
         1482  +
         1483  +LogEst.exe:	$(TOP)\tool\logest.c sqlite3.h
         1484  +	$(LTLINK) -Fe$@ $(TOP)\tool\LogEst.c
  1465   1485   
  1466   1486   wordcount.exe:	$(TOP)\test\wordcount.c $(SQLITE3C)
  1467   1487   	$(LTLINK) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \
  1468   1488   		$(TOP)\test\wordcount.c $(SQLITE3C)
  1469   1489   
  1470   1490   speedtest1.exe:	$(TOP)\test\speedtest1.c $(SQLITE3C)
  1471   1491   	$(LTLINK) -DSQLITE_OMIT_LOAD_EXTENSION -Fe$@ \

Changes to VERSION.

     1         -3.8.5
            1  +3.8.6

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.62 for sqlite 3.8.5.
            3  +# Generated by GNU Autoconf 2.62 for sqlite 3.8.6.
     4      4   #
     5      5   # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
     6      6   # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
     7      7   # This configure script is free software; the Free Software Foundation
     8      8   # gives unlimited permission to copy, distribute and modify it.
     9      9   ## --------------------- ##
    10     10   ## M4sh Initialization.  ##
................................................................................
   739    739   MFLAGS=
   740    740   MAKEFLAGS=
   741    741   SHELL=${CONFIG_SHELL-/bin/sh}
   742    742   
   743    743   # Identity of this package.
   744    744   PACKAGE_NAME='sqlite'
   745    745   PACKAGE_TARNAME='sqlite'
   746         -PACKAGE_VERSION='3.8.5'
   747         -PACKAGE_STRING='sqlite 3.8.5'
          746  +PACKAGE_VERSION='3.8.6'
          747  +PACKAGE_STRING='sqlite 3.8.6'
   748    748   PACKAGE_BUGREPORT=''
   749    749   
   750    750   # Factoring default headers for most tests.
   751    751   ac_includes_default="\
   752    752   #include <stdio.h>
   753    753   #ifdef HAVE_SYS_TYPES_H
   754    754   # include <sys/types.h>
................................................................................
  1479   1479   #
  1480   1480   # Report the --help message.
  1481   1481   #
  1482   1482   if test "$ac_init_help" = "long"; then
  1483   1483     # Omit some internal or obsolete options to make the list less imposing.
  1484   1484     # This message is too long to be a string in the A/UX 3.1 sh.
  1485   1485     cat <<_ACEOF
  1486         -\`configure' configures sqlite 3.8.5 to adapt to many kinds of systems.
         1486  +\`configure' configures sqlite 3.8.6 to adapt to many kinds of systems.
  1487   1487   
  1488   1488   Usage: $0 [OPTION]... [VAR=VALUE]...
  1489   1489   
  1490   1490   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1491   1491   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1492   1492   
  1493   1493   Defaults for the options are specified in brackets.
................................................................................
  1544   1544     --build=BUILD     configure for building on BUILD [guessed]
  1545   1545     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1546   1546   _ACEOF
  1547   1547   fi
  1548   1548   
  1549   1549   if test -n "$ac_init_help"; then
  1550   1550     case $ac_init_help in
  1551         -     short | recursive ) echo "Configuration of sqlite 3.8.5:";;
         1551  +     short | recursive ) echo "Configuration of sqlite 3.8.6:";;
  1552   1552      esac
  1553   1553     cat <<\_ACEOF
  1554   1554   
  1555   1555   Optional Features:
  1556   1556     --disable-option-checking  ignore unrecognized --enable/--with options
  1557   1557     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1558   1558     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1660   1660       cd "$ac_pwd" || { ac_status=$?; break; }
  1661   1661     done
  1662   1662   fi
  1663   1663   
  1664   1664   test -n "$ac_init_help" && exit $ac_status
  1665   1665   if $ac_init_version; then
  1666   1666     cat <<\_ACEOF
  1667         -sqlite configure 3.8.5
         1667  +sqlite configure 3.8.6
  1668   1668   generated by GNU Autoconf 2.62
  1669   1669   
  1670   1670   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
  1671   1671   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
  1672   1672   This configure script is free software; the Free Software Foundation
  1673   1673   gives unlimited permission to copy, distribute and modify it.
  1674   1674   _ACEOF
  1675   1675     exit
  1676   1676   fi
  1677   1677   cat >config.log <<_ACEOF
  1678   1678   This file contains any messages produced by compilers while
  1679   1679   running configure, to aid debugging if configure makes a mistake.
  1680   1680   
  1681         -It was created by sqlite $as_me 3.8.5, which was
         1681  +It was created by sqlite $as_me 3.8.6, which was
  1682   1682   generated by GNU Autoconf 2.62.  Invocation command line was
  1683   1683   
  1684   1684     $ $0 $@
  1685   1685   
  1686   1686   _ACEOF
  1687   1687   exec 5>>config.log
  1688   1688   {
................................................................................
 14017  14017   
 14018  14018   exec 6>&1
 14019  14019   
 14020  14020   # Save the log message, to keep $[0] and so on meaningful, and to
 14021  14021   # report actual input values of CONFIG_FILES etc. instead of their
 14022  14022   # values after options handling.
 14023  14023   ac_log="
 14024         -This file was extended by sqlite $as_me 3.8.5, which was
        14024  +This file was extended by sqlite $as_me 3.8.6, which was
 14025  14025   generated by GNU Autoconf 2.62.  Invocation command line was
 14026  14026   
 14027  14027     CONFIG_FILES    = $CONFIG_FILES
 14028  14028     CONFIG_HEADERS  = $CONFIG_HEADERS
 14029  14029     CONFIG_LINKS    = $CONFIG_LINKS
 14030  14030     CONFIG_COMMANDS = $CONFIG_COMMANDS
 14031  14031     $ $0 $@
................................................................................
 14070  14070   $config_commands
 14071  14071   
 14072  14072   Report bugs to <bug-autoconf@gnu.org>."
 14073  14073   
 14074  14074   _ACEOF
 14075  14075   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 14076  14076   ac_cs_version="\\
 14077         -sqlite config.status 3.8.5
        14077  +sqlite config.status 3.8.6
 14078  14078   configured by $0, generated by GNU Autoconf 2.62,
 14079  14079     with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 14080  14080   
 14081  14081   Copyright (C) 2008 Free Software Foundation, Inc.
 14082  14082   This config.status script is free software; the Free Software Foundation
 14083  14083   gives unlimited permission to copy, distribute and modify it."
 14084  14084   

Changes to ext/fts3/fts3_write.c.

  5170   5170   
  5171   5171       while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
  5172   5172         i64 iDocid = sqlite3_column_int64(pStmt, 0);
  5173   5173         int iLang = langidFromSelect(p, pStmt);
  5174   5174         int iCol;
  5175   5175   
  5176   5176         for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
  5177         -        const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
  5178         -        int nText = sqlite3_column_bytes(pStmt, iCol+1);
  5179         -        sqlite3_tokenizer_cursor *pT = 0;
  5180         -
  5181         -        rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
  5182         -        while( rc==SQLITE_OK ){
  5183         -          char const *zToken;       /* Buffer containing token */
  5184         -          int nToken = 0;           /* Number of bytes in token */
  5185         -          int iDum1 = 0, iDum2 = 0; /* Dummy variables */
  5186         -          int iPos = 0;             /* Position of token in zText */
  5187         -
  5188         -          rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
  5189         -          if( rc==SQLITE_OK ){
  5190         -            int i;
  5191         -            cksum2 = cksum2 ^ fts3ChecksumEntry(
  5192         -                zToken, nToken, iLang, 0, iDocid, iCol, iPos
  5193         -            );
  5194         -            for(i=1; i<p->nIndex; i++){
  5195         -              if( p->aIndex[i].nPrefix<=nToken ){
  5196         -                cksum2 = cksum2 ^ fts3ChecksumEntry(
  5197         -                  zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
  5198         -                );
         5177  +        if( p->abNotindexed[iCol]==0 ){
         5178  +          const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
         5179  +          int nText = sqlite3_column_bytes(pStmt, iCol+1);
         5180  +          sqlite3_tokenizer_cursor *pT = 0;
         5181  +
         5182  +          rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText,&pT);
         5183  +          while( rc==SQLITE_OK ){
         5184  +            char const *zToken;       /* Buffer containing token */
         5185  +            int nToken = 0;           /* Number of bytes in token */
         5186  +            int iDum1 = 0, iDum2 = 0; /* Dummy variables */
         5187  +            int iPos = 0;             /* Position of token in zText */
         5188  +
         5189  +            rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
         5190  +            if( rc==SQLITE_OK ){
         5191  +              int i;
         5192  +              cksum2 = cksum2 ^ fts3ChecksumEntry(
         5193  +                  zToken, nToken, iLang, 0, iDocid, iCol, iPos
         5194  +              );
         5195  +              for(i=1; i<p->nIndex; i++){
         5196  +                if( p->aIndex[i].nPrefix<=nToken ){
         5197  +                  cksum2 = cksum2 ^ fts3ChecksumEntry(
         5198  +                      zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
         5199  +                  );
         5200  +                }
  5199   5201                 }
  5200   5202               }
  5201   5203             }
         5204  +          if( pT ) pModule->xClose(pT);
         5205  +          if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5202   5206           }
  5203         -        if( pT ) pModule->xClose(pT);
  5204         -        if( rc==SQLITE_DONE ) rc = SQLITE_OK;
  5205   5207         }
  5206   5208       }
  5207   5209   
  5208   5210       sqlite3_finalize(pStmt);
  5209   5211     }
  5210   5212   
  5211   5213     *pbOk = (cksum1==cksum2);

Added ext/misc/compress.c.

            1  +/*
            2  +** 2014-06-13
            3  +**
            4  +** The author disclaims copyright to this source code.  In place of
            5  +** a legal notice, here is a blessing:
            6  +**
            7  +**    May you do good and not evil.
            8  +**    May you find forgiveness for yourself and forgive others.
            9  +**    May you share freely, never taking more than you give.
           10  +**
           11  +******************************************************************************
           12  +**
           13  +** This SQLite extension implements SQL compression functions
           14  +** compress() and uncompress() using ZLIB.
           15  +*/
           16  +#include "sqlite3ext.h"
           17  +SQLITE_EXTENSION_INIT1
           18  +#include <zlib.h>
           19  +
           20  +/*
           21  +** Implementation of the "compress(X)" SQL function.  The input X is
           22  +** compressed using zLib and the output is returned.
           23  +**
           24  +** The output is a BLOB that begins with a variable-length integer that
           25  +** is the input size in bytes (the size of X before compression).  The
           26  +** variable-length integer is implemented as 1 to 5 bytes.  There are
           27  +** seven bits per integer stored in the lower seven bits of each byte.
           28  +** More significant bits occur first.  The most significant bit (0x80)
           29  +** is a flag to indicate the end of the integer.
           30  +*/
           31  +static void compressFunc(
           32  +  sqlite3_context *context,
           33  +  int argc,
           34  +  sqlite3_value **argv
           35  +){
           36  +  const unsigned char *pIn;
           37  +  unsigned char *pOut;
           38  +  unsigned int nIn;
           39  +  unsigned long int nOut;
           40  +  unsigned char x[8];
           41  +  int i, j;
           42  +
           43  +  pIn = sqlite3_value_blob(argv[0]);
           44  +  nIn = sqlite3_value_bytes(argv[0]);
           45  +  nOut = 13 + nIn + (nIn+999)/1000;
           46  +  pOut = sqlite3_malloc( nOut+5 );
           47  +  for(i=4; i>=0; i--){
           48  +    x[i] = (nIn >> (7*(4-i)))&0x7f;
           49  +  }
           50  +  for(i=0; i<4 && x[i]==0; i++){}
           51  +  for(j=0; i<=4; i++, j++) pOut[j] = x[i];
           52  +  pOut[j-1] |= 0x80;
           53  +  compress(&pOut[j], &nOut, pIn, nIn);
           54  +  sqlite3_result_blob(context, pOut, nOut+j, sqlite3_free);
           55  +}
           56  +
           57  +/*
           58  +** Implementation of the "uncompress(X)" SQL function.  The argument X
           59  +** is a blob which was obtained from compress(Y).  The output will be
           60  +** the value Y.
           61  +*/
           62  +static void uncompressFunc(
           63  +  sqlite3_context *context,
           64  +  int argc,
           65  +  sqlite3_value **argv
           66  +){
           67  +  const unsigned char *pIn;
           68  +  unsigned char *pOut;
           69  +  unsigned int nIn;
           70  +  unsigned long int nOut;
           71  +  int rc;
           72  +  int i;
           73  +
           74  +  pIn = sqlite3_value_blob(argv[0]);
           75  +  nIn = sqlite3_value_bytes(argv[0]);
           76  +  nOut = 0;
           77  +  for(i=0; i<nIn && i<5; i++){
           78  +    nOut = (nOut<<7) | (pIn[i]&0x7f);
           79  +    if( (pIn[i]&0x80)!=0 ){ i++; break; }
           80  +  }
           81  +  pOut = sqlite3_malloc( nOut+1 );
           82  +  rc = uncompress(pOut, &nOut, &pIn[i], nIn-i);
           83  +  if( rc==Z_OK ){
           84  +    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
           85  +  }
           86  +}
           87  +
           88  +
           89  +#ifdef _WIN32
           90  +__declspec(dllexport)
           91  +#endif
           92  +int sqlite3_compress_init(
           93  +  sqlite3 *db, 
           94  +  char **pzErrMsg, 
           95  +  const sqlite3_api_routines *pApi
           96  +){
           97  +  int rc = SQLITE_OK;
           98  +  SQLITE_EXTENSION_INIT2(pApi);
           99  +  (void)pzErrMsg;  /* Unused parameter */
          100  +  rc = sqlite3_create_function(db, "compress", 1, SQLITE_UTF8, 0,
          101  +                               compressFunc, 0, 0);
          102  +  if( rc==SQLITE_OK ){
          103  +    rc = sqlite3_create_function(db, "uncompress", 1, SQLITE_UTF8, 0,
          104  +                                 uncompressFunc, 0, 0);
          105  +  }
          106  +  return rc;
          107  +}

Added ext/misc/fileio.c.

            1  +/*
            2  +** 2014-06-13
            3  +**
            4  +** The author disclaims copyright to this source code.  In place of
            5  +** a legal notice, here is a blessing:
            6  +**
            7  +**    May you do good and not evil.
            8  +**    May you find forgiveness for yourself and forgive others.
            9  +**    May you share freely, never taking more than you give.
           10  +**
           11  +******************************************************************************
           12  +**
           13  +** This SQLite extension implements SQL functions readfile() and
           14  +** writefile().
           15  +*/
           16  +#include "sqlite3ext.h"
           17  +SQLITE_EXTENSION_INIT1
           18  +#include <stdio.h>
           19  +
           20  +/*
           21  +** Implementation of the "readfile(X)" SQL function.  The entire content
           22  +** of the file named X is read and returned as a BLOB.  NULL is returned
           23  +** if the file does not exist or is unreadable.
           24  +*/
           25  +static void readfileFunc(
           26  +  sqlite3_context *context,
           27  +  int argc,
           28  +  sqlite3_value **argv
           29  +){
           30  +  const char *zName;
           31  +  FILE *in;
           32  +  long nIn;
           33  +  void *pBuf;
           34  +
           35  +  zName = (const char*)sqlite3_value_text(argv[0]);
           36  +  if( zName==0 ) return;
           37  +  in = fopen(zName, "rb");
           38  +  if( in==0 ) return;
           39  +  fseek(in, 0, SEEK_END);
           40  +  nIn = ftell(in);
           41  +  rewind(in);
           42  +  pBuf = sqlite3_malloc( nIn );
           43  +  if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
           44  +    sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
           45  +  }else{
           46  +    sqlite3_free(pBuf);
           47  +  }
           48  +  fclose(in);
           49  +}
           50  +
           51  +/*
           52  +** Implementation of the "writefile(X,Y)" SQL function.  The argument Y
           53  +** is written into file X.  The number of bytes written is returned.  Or
           54  +** NULL is returned if something goes wrong, such as being unable to open
           55  +** file X for writing.
           56  +*/
           57  +static void writefileFunc(
           58  +  sqlite3_context *context,
           59  +  int argc,
           60  +  sqlite3_value **argv
           61  +){
           62  +  FILE *out;
           63  +  const char *z;
           64  +  int n;
           65  +  sqlite3_int64 rc;
           66  +  const char *zFile;
           67  +
           68  +  zFile = (const char*)sqlite3_value_text(argv[0]);
           69  +  if( zFile==0 ) return;
           70  +  out = fopen(zFile, "wb");
           71  +  if( out==0 ) return;
           72  +  z = (const char*)sqlite3_value_blob(argv[1]);
           73  +  if( z==0 ){
           74  +    n = 0;
           75  +    rc = 0;
           76  +  }else{
           77  +    n = sqlite3_value_bytes(argv[1]);
           78  +    rc = fwrite(z, 1, n, out);
           79  +  }
           80  +  fclose(out);
           81  +  sqlite3_result_int64(context, rc);
           82  +}
           83  +
           84  +
           85  +#ifdef _WIN32
           86  +__declspec(dllexport)
           87  +#endif
           88  +int sqlite3_fileio_init(
           89  +  sqlite3 *db, 
           90  +  char **pzErrMsg, 
           91  +  const sqlite3_api_routines *pApi
           92  +){
           93  +  int rc = SQLITE_OK;
           94  +  SQLITE_EXTENSION_INIT2(pApi);
           95  +  (void)pzErrMsg;  /* Unused parameter */
           96  +  rc = sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
           97  +                               readfileFunc, 0, 0);
           98  +  if( rc==SQLITE_OK ){
           99  +    rc = sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
          100  +                                 writefileFunc, 0, 0);
          101  +  }
          102  +  return rc;
          103  +}

Changes to ext/rtree/rtree6.test.

    88     88   do_eqp_test rtree6.2.3 {
    89     89     SELECT * FROM t1,t2 WHERE k=ii
    90     90   } {
    91     91     0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:} 
    92     92     0 1 1 {SEARCH TABLE t2 USING INTEGER PRIMARY KEY (rowid=?)}
    93     93   }
    94     94   
    95         -do_eqp_test rtree6.2.4 {
           95  +do_eqp_test rtree6.2.4.1 {
           96  +  SELECT * FROM t1,t2 WHERE v=+ii and x1<10 and x2>10
           97  +} {
           98  +  0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0E1} 
           99  +  0 1 1 {SEARCH TABLE t2 USING AUTOMATIC COVERING INDEX (v=?)}
          100  +}
          101  +do_eqp_test rtree6.2.4.2 {
    96    102     SELECT * FROM t1,t2 WHERE v=10 and x1<10 and x2>10
    97    103   } {
    98    104     0 0 0 {SCAN TABLE t1 VIRTUAL TABLE INDEX 2:C0E1} 
    99    105     0 1 1 {SEARCH TABLE t2 USING AUTOMATIC COVERING INDEX (v=?)}
   100    106   }
   101    107   
   102    108   do_eqp_test rtree6.2.5 {

Changes to magic.txt.

    24     24   >68  belong  =0x0f055111  Fossil repository -
    25     25   >68  belong  =0x42654462  Bentley Systems BeSQLite Database -
    26     26   >68  belong  =0x42654c6e  Bentley Systems Localization File -
    27     27   >60  belong  =0x5f4d544e  Monotone source repository -
    28     28   >68  belong  =0x47504b47  OGC GeoPackage file -
    29     29   >68  belong  =0x47503130  OGC GeoPackage version 1.0 file -
    30     30   >68  belong  =0x45737269  Esri Spatially-Enabled Database -
           31  +>68  belong  =0x4d504258  MBTiles tileset -
    31     32   >0   string  =SQLite      SQLite3 database

Changes to main.mk.

   277    277     $(TOP)/src/test_wsd.c
   278    278   
   279    279   # Extensions to be statically loaded.
   280    280   #
   281    281   TESTSRC += \
   282    282     $(TOP)/ext/misc/amatch.c \
   283    283     $(TOP)/ext/misc/closure.c \
          284  +  $(TOP)/ext/misc/fileio.c \
   284    285     $(TOP)/ext/misc/fuzzer.c \
   285    286     $(TOP)/ext/misc/ieee754.c \
   286    287     $(TOP)/ext/misc/nextchar.c \
   287    288     $(TOP)/ext/misc/percentile.c \
   288    289     $(TOP)/ext/misc/regexp.c \
   289    290     $(TOP)/ext/misc/spellfix.c \
   290    291     $(TOP)/ext/misc/totype.c \
................................................................................
   634    635   TEST_EXTENSION = $(SHPREFIX)testloadext.$(SO)
   635    636   $(TEST_EXTENSION): $(TOP)/src/test_loadext.c
   636    637   	$(MKSHLIB) $(TOP)/src/test_loadext.c -o $(TEST_EXTENSION)
   637    638   
   638    639   extensiontest: testfixture$(EXE) $(TEST_EXTENSION)
   639    640   	./testfixture$(EXE) $(TOP)/test/loadext.test
   640    641   
   641         -showdb$(EXE):	$(TOP)/tool/showdb.c sqlite3.c
          642  +showdb$(EXE):	$(TOP)/tool/showdb.c sqlite3.o
   642    643   	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showdb$(EXE) \
   643         -		$(TOP)/tool/showdb.c sqlite3.c
          644  +		$(TOP)/tool/showdb.c sqlite3.o $(THREADLIB)
          645  +
          646  +showstat4$(EXE):	$(TOP)/tool/showstat4.c sqlite3.o
          647  +	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showstat4$(EXE) \
          648  +		$(TOP)/tool/showstat4.c sqlite3.o $(THREADLIB)
          649  +
          650  +showjournal$(EXE):	$(TOP)/tool/showjournal.c sqlite3.o
          651  +	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showjournal$(EXE) \
          652  +		$(TOP)/tool/showjournal.c sqlite3.o $(THREADLIB)
          653  +
          654  +showwal$(EXE):	$(TOP)/tool/showwal.c sqlite3.o
          655  +	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showwal$(EXE) \
          656  +		$(TOP)/tool/showwal.c sqlite3.o $(THREADLIB)
          657  +
          658  +rollback-test$(EXE):	$(TOP)/tool/rollback-test.c sqlite3.o
          659  +	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o rollback-test$(EXE) \
          660  +		$(TOP)/tool/rollback-test.c sqlite3.o $(THREADLIB)
          661  +
          662  +LogEst$(EXE):	$(TOP)/tool/logest.c sqlite3.h
          663  +	$(TCC) -o LogEst$(EXE) $(TOP)/tool/logest.c
   644    664   
   645    665   wordcount$(EXE):	$(TOP)/test/wordcount.c sqlite3.c
   646    666   	$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o wordcount$(EXE) \
   647    667   		$(TOP)/test/wordcount.c sqlite3.c
   648    668   
   649    669   speedtest1$(EXE):	$(TOP)/test/speedtest1.c sqlite3.o
   650    670   	$(TCC) -I. -o speedtest1$(EXE) $(TOP)/test/speedtest1.c sqlite3.o $(THREADLIB)

Changes to src/analyze.c.

   242    242     }
   243    243   
   244    244     /* Open the sqlite_stat[134] tables for writing. */
   245    245     for(i=0; aTable[i].zCols; i++){
   246    246       assert( i<ArraySize(aTable) );
   247    247       sqlite3VdbeAddOp4Int(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb, 3);
   248    248       sqlite3VdbeChangeP5(v, aCreateTbl[i]);
          249  +    VdbeComment((v, aTable[i].zName));
   249    250     }
   250    251   }
   251    252   
   252    253   /*
   253    254   ** Recommended number of samples for sqlite_stat4
   254    255   */
   255    256   #ifndef SQLITE_STAT4_SAMPLES
................................................................................
   277    278     int iCol;                       /* If !isPSample, the reason for inclusion */
   278    279     u32 iHash;                      /* Tiebreaker hash */
   279    280   #endif
   280    281   };                                                    
   281    282   struct Stat4Accum {
   282    283     tRowcnt nRow;             /* Number of rows in the entire table */
   283    284     tRowcnt nPSample;         /* How often to do a periodic sample */
   284         -  int nCol;                 /* Number of columns in index + rowid */
          285  +  int nCol;                 /* Number of columns in index + pk/rowid */
          286  +  int nKeyCol;              /* Number of index columns w/o the pk/rowid */
   285    287     int mxSample;             /* Maximum number of samples to accumulate */
   286    288     Stat4Sample current;      /* Current row as a Stat4Sample */
   287    289     u32 iPrn;                 /* Pseudo-random number used for sampling */
   288    290     Stat4Sample *aBest;       /* Array of nCol best samples */
   289    291     int iMin;                 /* Index in a[] of entry with minimum score */
   290    292     int nSample;              /* Current number of samples */
   291    293     int iGet;                 /* Index of current sample accessed by stat_get() */
................................................................................
   363    365     for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i);
   364    366     sampleClear(p->db, &p->current);
   365    367   #endif
   366    368     sqlite3DbFree(p->db, p);
   367    369   }
   368    370   
   369    371   /*
   370         -** Implementation of the stat_init(N,C) SQL function. The two parameters
   371         -** are the number of rows in the table or index (C) and the number of columns
   372         -** in the index (N).  The second argument (C) is only used for STAT3 and STAT4.
          372  +** Implementation of the stat_init(N,K,C) SQL function. The three parameters
          373  +** are:
          374  +**     N:    The number of columns in the index including the rowid/pk
          375  +**     K:    The number of columns in the index excluding the rowid/pk
          376  +**     C:    The number of rows in the index
          377  +**
          378  +** C is only used for STAT3 and STAT4.
          379  +**
          380  +** For ordinary rowid tables, N==K+1.  But for WITHOUT ROWID tables,
          381  +** N=K+P where P is the number of columns in the primary key.  For the
          382  +** covering index that implements the original WITHOUT ROWID table, N==K.
   373    383   **
   374    384   ** This routine allocates the Stat4Accum object in heap memory. The return 
   375    385   ** value is a pointer to the the Stat4Accum object encoded as a blob (i.e. 
   376    386   ** the size of the blob is sizeof(void*) bytes). 
   377    387   */
   378    388   static void statInit(
   379    389     sqlite3_context *context,
   380    390     int argc,
   381    391     sqlite3_value **argv
   382    392   ){
   383    393     Stat4Accum *p;
   384    394     int nCol;                       /* Number of columns in index being sampled */
          395  +  int nKeyCol;                    /* Number of key columns */
   385    396     int nColUp;                     /* nCol rounded up for alignment */
   386    397     int n;                          /* Bytes of space to allocate */
   387    398     sqlite3 *db;                    /* Database connection */
   388    399   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
   389    400     int mxSample = SQLITE_STAT4_SAMPLES;
   390    401   #endif
   391    402   
   392    403     /* Decode the three function arguments */
   393    404     UNUSED_PARAMETER(argc);
   394    405     nCol = sqlite3_value_int(argv[0]);
   395         -  assert( nCol>1 );               /* >1 because it includes the rowid column */
          406  +  assert( nCol>0 );
   396    407     nColUp = sizeof(tRowcnt)<8 ? (nCol+1)&~1 : nCol;
          408  +  nKeyCol = sqlite3_value_int(argv[1]);
          409  +  assert( nKeyCol<=nCol );
          410  +  assert( nKeyCol>0 );
   397    411   
   398    412     /* Allocate the space required for the Stat4Accum object */
   399    413     n = sizeof(*p) 
   400    414       + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anEq */
   401    415       + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anDLt */
   402    416   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
   403    417       + sizeof(tRowcnt)*nColUp                  /* Stat4Accum.anLt */
................................................................................
   411    425       sqlite3_result_error_nomem(context);
   412    426       return;
   413    427     }
   414    428   
   415    429     p->db = db;
   416    430     p->nRow = 0;
   417    431     p->nCol = nCol;
          432  +  p->nKeyCol = nKeyCol;
   418    433     p->current.anDLt = (tRowcnt*)&p[1];
   419    434     p->current.anEq = &p->current.anDLt[nColUp];
   420    435   
   421    436   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
   422    437     {
   423    438       u8 *pSpace;                     /* Allocated space not yet assigned */
   424    439       int i;                          /* Used to iterate through p->aSample[] */
   425    440   
   426    441       p->iGet = -1;
   427    442       p->mxSample = mxSample;
   428         -    p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1);
          443  +    p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1);
   429    444       p->current.anLt = &p->current.anEq[nColUp];
   430         -    p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[1])*0xd0944565;
          445  +    p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[2])*0xd0944565;
   431    446     
   432    447       /* Set up the Stat4Accum.a[] and aBest[] arrays */
   433    448       p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];
   434    449       p->aBest = &p->a[mxSample];
   435    450       pSpace = (u8*)(&p->a[mxSample+nCol]);
   436    451       for(i=0; i<(mxSample+nCol); i++){
   437    452         p->a[i].anEq = (tRowcnt *)pSpace; pSpace += (sizeof(tRowcnt) * nColUp);
................................................................................
   446    461     }
   447    462   #endif
   448    463   
   449    464     /* Return a pointer to the allocated object to the caller */
   450    465     sqlite3_result_blob(context, p, sizeof(p), stat4Destructor);
   451    466   }
   452    467   static const FuncDef statInitFuncdef = {
   453         -  1+IsStat34,      /* nArg */
          468  +  2+IsStat34,      /* nArg */
   454    469     SQLITE_UTF8,     /* funcFlags */
   455    470     0,               /* pUserData */
   456    471     0,               /* pNext */
   457    472     statInit,        /* xFunc */
   458    473     0,               /* xStep */
   459    474     0,               /* xFinalize */
   460    475     "stat_init",     /* zName */
................................................................................
   687    702   
   688    703     /* The three function arguments */
   689    704     Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
   690    705     int iChng = sqlite3_value_int(argv[1]);
   691    706   
   692    707     UNUSED_PARAMETER( argc );
   693    708     UNUSED_PARAMETER( context );
   694         -  assert( p->nCol>1 );        /* Includes rowid field */
          709  +  assert( p->nCol>0 );
   695    710     assert( iChng<p->nCol );
   696    711   
   697    712     if( p->nRow==0 ){
   698    713       /* This is the first call to this function. Do initialization. */
   699    714       for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
   700    715     }else{
   701    716       /* Second and subsequent calls get processed here */
................................................................................
   815    830       ** rows, then each estimate is computed as:
   816    831       **
   817    832       **        I = (K+D-1)/D
   818    833       */
   819    834       char *z;
   820    835       int i;
   821    836   
   822         -    char *zRet = sqlite3MallocZero(p->nCol * 25);
          837  +    char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 );
   823    838       if( zRet==0 ){
   824    839         sqlite3_result_error_nomem(context);
   825    840         return;
   826    841       }
   827    842   
   828    843       sqlite3_snprintf(24, zRet, "%llu", (u64)p->nRow);
   829    844       z = zRet + sqlite3Strlen30(zRet);
   830         -    for(i=0; i<(p->nCol-1); i++){
          845  +    for(i=0; i<p->nKeyCol; i++){
   831    846         u64 nDistinct = p->current.anDLt[i] + 1;
   832    847         u64 iVal = (p->nRow + nDistinct - 1) / nDistinct;
   833    848         sqlite3_snprintf(24, z, " %llu", iVal);
   834    849         z += sqlite3Strlen30(z);
   835    850         assert( p->current.anEq[i] );
   836    851       }
   837    852       assert( z[0]=='\0' && z>zRet );
................................................................................
   992   1007       int addrRewind;               /* Address of "OP_Rewind iIdxCur" */
   993   1008       int addrGotoChng0;            /* Address of "Goto addr_chng_0" */
   994   1009       int addrNextRow;              /* Address of "next_row:" */
   995   1010       const char *zIdxName;         /* Name of the index */
   996   1011   
   997   1012       if( pOnlyIdx && pOnlyIdx!=pIdx ) continue;
   998   1013       if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0;
   999         -    VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName));
  1000         -    nCol = pIdx->nKeyCol;
         1014  +    if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIdx) ){
         1015  +      nCol = pIdx->nKeyCol;
         1016  +      zIdxName = pTab->zName;
         1017  +    }else{
         1018  +      nCol = pIdx->nColumn;
         1019  +      zIdxName = pIdx->zName;
         1020  +    }
  1001   1021       aGotoChng = sqlite3DbMallocRaw(db, sizeof(int)*(nCol+1));
  1002   1022       if( aGotoChng==0 ) continue;
  1003   1023   
  1004   1024       /* Populate the register containing the index name. */
  1005         -    if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
  1006         -      zIdxName = pTab->zName;
  1007         -    }else{
  1008         -      zIdxName = pIdx->zName;
  1009         -    }
  1010   1025       sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0);
         1026  +    VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName));
  1011   1027   
  1012   1028       /*
  1013   1029       ** Pseudo-code for loop that calls stat_push():
  1014   1030       **
  1015   1031       **   Rewind csr
  1016   1032       **   if eof(csr) goto end_of_scan;
  1017   1033       **   regChng = 0
................................................................................
  1057   1073       ** 
  1058   1074       **    (1) the number of columns in the index including the rowid,
  1059   1075       **    (2) the number of rows in the index,
  1060   1076       **
  1061   1077       ** The second argument is only used for STAT3 and STAT4
  1062   1078       */
  1063   1079   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  1064         -    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+2);
         1080  +    sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat4+3);
  1065   1081   #endif
  1066         -    sqlite3VdbeAddOp2(v, OP_Integer, nCol+1, regStat4+1);
         1082  +    sqlite3VdbeAddOp2(v, OP_Integer, nCol, regStat4+1);
         1083  +    sqlite3VdbeAddOp2(v, OP_Integer, pIdx->nKeyCol, regStat4+2);
  1067   1084       sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4+1, regStat4);
  1068   1085       sqlite3VdbeChangeP4(v, -1, (char*)&statInitFuncdef, P4_FUNCDEF);
  1069         -    sqlite3VdbeChangeP5(v, 1+IsStat34);
         1086  +    sqlite3VdbeChangeP5(v, 2+IsStat34);
  1070   1087   
  1071   1088       /* Implementation of the following:
  1072   1089       **
  1073   1090       **   Rewind csr
  1074   1091       **   if eof(csr) goto end_of_scan;
  1075   1092       **   regChng = 0
  1076   1093       **   goto next_push_0;
................................................................................
  1164   1181         int regSample = regStat1+3;
  1165   1182         int regCol = regStat1+4;
  1166   1183         int regSampleRowid = regCol + nCol;
  1167   1184         int addrNext;
  1168   1185         int addrIsNull;
  1169   1186         u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
  1170   1187   
  1171         -      pParse->nMem = MAX(pParse->nMem, regCol+nCol+1);
         1188  +      pParse->nMem = MAX(pParse->nMem, regCol+nCol);
  1172   1189   
  1173   1190         addrNext = sqlite3VdbeCurrentAddr(v);
  1174   1191         callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid);
  1175   1192         addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid);
  1176   1193         VdbeCoverage(v);
  1177   1194         callStatGet(v, regStat4, STAT_GET_NEQ, regEq);
  1178   1195         callStatGet(v, regStat4, STAT_GET_NLT, regLt);
................................................................................
  1186   1203         sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, 
  1187   1204                                         pIdx->aiColumn[0], regSample);
  1188   1205   #else
  1189   1206         for(i=0; i<nCol; i++){
  1190   1207           i16 iCol = pIdx->aiColumn[i];
  1191   1208           sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i);
  1192   1209         }
  1193         -      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol+1, regSample);
         1210  +      sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample);
  1194   1211   #endif
  1195   1212         sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp);
  1196   1213         sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid);
  1197   1214         sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regTemp, regNewRowid);
  1198   1215         sqlite3VdbeAddOp2(v, OP_Goto, 1, addrNext); /* P1==1 for end-of-loop */
  1199   1216         sqlite3VdbeJumpHere(v, addrIsNull);
  1200   1217       }

Changes to src/expr.c.

    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   */
    33     33   char sqlite3ExprAffinity(Expr *pExpr){
    34     34     int op;
    35     35     pExpr = sqlite3ExprSkipCollate(pExpr);
    36         -  if( pExpr->flags & EP_Generic ) return SQLITE_AFF_NONE;
           36  +  if( pExpr->flags & EP_Generic ) return 0;
    37     37     op = pExpr->op;
    38     38     if( op==TK_SELECT ){
    39     39       assert( pExpr->flags&EP_xIsSelect );
    40     40       return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
    41     41     }
    42     42   #ifndef SQLITE_OMIT_CAST
    43     43     if( op==TK_CAST ){

Changes to src/func.c.

  1687   1687       FUNCTION(coalesce,           1, 0, 0, 0                ),
  1688   1688       FUNCTION(coalesce,           0, 0, 0, 0                ),
  1689   1689       FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),
  1690   1690       FUNCTION(hex,                1, 0, 0, hexFunc          ),
  1691   1691       FUNCTION2(ifnull,            2, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),
  1692   1692       FUNCTION2(unlikely,          1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
  1693   1693       FUNCTION2(likelihood,        2, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
         1694  +    FUNCTION2(likely,            1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
  1694   1695       VFUNCTION(random,            0, 0, 0, randomFunc       ),
  1695   1696       VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),
  1696   1697       FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
  1697   1698       FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),
  1698   1699       FUNCTION(sqlite_source_id,   0, 0, 0, sourceidFunc     ),
  1699   1700       FUNCTION(sqlite_log,         2, 0, 0, errlogFunc       ),
  1700   1701   #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS

Changes to src/main.c.

  3145   3145       ** is called immediately after installing the new callback and the return
  3146   3146       ** value from sqlite3FaultSim(0) becomes the return from
  3147   3147       ** sqlite3_test_control().
  3148   3148       */
  3149   3149       case SQLITE_TESTCTRL_FAULT_INSTALL: {
  3150   3150         /* MSVC is picky about pulling func ptrs from va lists.
  3151   3151         ** http://support.microsoft.com/kb/47961
  3152         -      ** sqlite3Config.xTestCallback = va_arg(ap, int(*)(int));
         3152  +      ** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));
  3153   3153         */
  3154   3154         typedef int(*TESTCALLBACKFUNC_t)(int);
  3155         -      sqlite3Config.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
         3155  +      sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
  3156   3156         rc = sqlite3FaultSim(0);
  3157   3157         break;
  3158   3158       }
  3159   3159   
  3160   3160       /*
  3161   3161       **  sqlite3_test_control(BENIGN_MALLOC_HOOKS, xBegin, xEnd)
  3162   3162       **

Changes to src/os_unix.c.

   441    441   
   442    442   #if HAVE_MREMAP
   443    443     { "mremap",       (sqlite3_syscall_ptr)mremap,          0 },
   444    444   #else
   445    445     { "mremap",       (sqlite3_syscall_ptr)0,               0 },
   446    446   #endif
   447    447   #define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[23].pCurrent)
   448         -#endif
   449         -
   450    448     { "getpagesize",  (sqlite3_syscall_ptr)unixGetpagesize, 0 },
   451    449   #define osGetpagesize ((int(*)(void))aSyscall[24].pCurrent)
          450  +
          451  +#endif
   452    452   
   453    453   }; /* End of the overrideable system calls */
   454    454   
   455    455   /*
   456    456   ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
   457    457   ** "unix" VFSes.  Return SQLITE_OK opon successfully updating the
   458    458   ** system call pointer, or SQLITE_NOTFOUND if there is no configurable
................................................................................
  1914   1914     if( pFile->pId ){
  1915   1915       if( pFile->ctrlFlags & UNIXFILE_DELETE ){
  1916   1916         osUnlink(pFile->pId->zCanonicalName);
  1917   1917       }
  1918   1918       vxworksReleaseFileId(pFile->pId);
  1919   1919       pFile->pId = 0;
  1920   1920     }
         1921  +#endif
         1922  +#ifdef SQLITE_UNLINK_AFTER_CLOSE
         1923  +  if( pFile->ctrlFlags & UNIXFILE_DELETE ){
         1924  +    osUnlink(pFile->zPath);
         1925  +    sqlite3_free(*(char**)&pFile->zPath);
         1926  +    pFile->zPath = 0;
         1927  +  }
  1921   1928   #endif
  1922   1929     OSTRACE(("CLOSE   %-3d\n", pFile->h));
  1923   1930     OpenCounter(-1);
  1924   1931     sqlite3_free(pFile->pUnused);
  1925   1932     memset(pFile, 0, sizeof(unixFile));
  1926   1933     return SQLITE_OK;
  1927   1934   }
................................................................................
  3953   3960   #endif
  3954   3961     if( p->ctrlFlags & UNIXFILE_PSOW ){
  3955   3962       rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
  3956   3963     }
  3957   3964     return rc;
  3958   3965   }
  3959   3966   
         3967  +#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
         3968  +
         3969  +/*
         3970  +** Return the system page size.
         3971  +**
         3972  +** This function should not be called directly by other code in this file. 
         3973  +** Instead, it should be called via macro osGetpagesize().
         3974  +*/
         3975  +static int unixGetpagesize(void){
         3976  +#if defined(_BSD_SOURCE)
         3977  +  return getpagesize();
         3978  +#else
         3979  +  return (int)sysconf(_SC_PAGESIZE);
         3980  +#endif
         3981  +}
         3982  +
         3983  +#endif /* !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 */
         3984  +
  3960   3985   #ifndef SQLITE_OMIT_WAL
  3961         -
  3962   3986   
  3963   3987   /*
  3964   3988   ** Object used to represent an shared memory buffer.  
  3965   3989   **
  3966   3990   ** When multiple threads all reference the same wal-index, each thread
  3967   3991   ** has its own unixShm object, but they all point to a single instance
  3968   3992   ** of this unixShmNode object.  In other words, each wal-index is opened
................................................................................
  4105   4129              pShmNode->sharedMask, pShmNode->exclMask));
  4106   4130     }
  4107   4131   #endif
  4108   4132   
  4109   4133     return rc;        
  4110   4134   }
  4111   4135   
  4112         -/*
  4113         -** Return the system page size.
  4114         -**
  4115         -** This function should not be called directly by other code in this file. 
  4116         -** Instead, it should be called via macro osGetpagesize().
  4117         -*/
  4118         -static int unixGetpagesize(void){
  4119         -#if defined(_BSD_SOURCE)
  4120         -  return getpagesize();
  4121         -#else
  4122         -  return (int)sysconf(_SC_PAGESIZE);
  4123         -#endif
  4124         -}
  4125         -
  4126   4136   /*
  4127   4137   ** Return the minimum number of 32KB shm regions that should be mapped at
  4128   4138   ** a time, assuming that each mapping must be an integer multiple of the
  4129   4139   ** current system page-size.
  4130   4140   **
  4131   4141   ** Usually, this is 1. The exception seems to be systems that are configured
  4132   4142   ** to use 64KB pages - in this case each mapping must cover at least two
................................................................................
  5768   5778       p->pUnused->fd = fd;
  5769   5779       p->pUnused->flags = flags;
  5770   5780     }
  5771   5781   
  5772   5782     if( isDelete ){
  5773   5783   #if OS_VXWORKS
  5774   5784       zPath = zName;
         5785  +#elif defined(SQLITE_UNLINK_AFTER_CLOSE)
         5786  +    zPath = sqlite3_mprintf("%s", zName);
         5787  +    if( zPath==0 ){
         5788  +      robust_close(p, fd, __LINE__);
         5789  +      return SQLITE_NOMEM;
         5790  +    }
  5775   5791   #else
  5776   5792       osUnlink(zName);
  5777   5793   #endif
  5778   5794     }
  5779   5795   #if SQLITE_ENABLE_LOCKING_STYLE
  5780   5796     else{
  5781   5797       p->openFlags = openFlags;

Changes to src/resolve.c.

   707    707                 pNC->nErr++;
   708    708               }
   709    709             }else{
   710    710               /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
   711    711               ** likelihood(X, 0.0625).
   712    712               ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
   713    713               ** likelihood(X,0.0625). */
   714         -            pExpr->iTable = 62;  /* TUNING:  Default 2nd arg to unlikely() is 0.0625 */
          714  +            /* TUNING: unlikely() probability is 0.0625.  likely() is 0.9375 */
          715  +            pExpr->iTable = pDef->zName[0]=='u' ? 62 : 938;
   715    716             }             
   716    717           }
   717    718         }
   718    719   #ifndef SQLITE_OMIT_AUTHORIZATION
   719    720         if( pDef ){
   720    721           auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0);
   721    722           if( auth!=SQLITE_OK ){

Changes to src/shell.c.

  1575   1575     ".bail on|off           Stop after hitting an error.  Default OFF\n"
  1576   1576     ".clone NEWDB           Clone data into NEWDB from the existing database\n"
  1577   1577     ".databases             List names and files of attached databases\n"
  1578   1578     ".dump ?TABLE? ...      Dump the database in an SQL text format\n"
  1579   1579     "                         If TABLE specified, only dump tables matching\n"
  1580   1580     "                         LIKE pattern TABLE.\n"
  1581   1581     ".echo on|off           Turn command echo on or off\n"
         1582  +  ".eqp on|off            Enable or disable automatic EXPLAIN QUERY PLAN\n"
  1582   1583     ".exit                  Exit this program\n"
  1583   1584     ".explain ?on|off?      Turn output mode suitable for EXPLAIN on or off.\n"
  1584   1585     "                         With no args, it turns EXPLAIN on.\n"
         1586  +  ".fullschema            Show schema and the content of sqlite_stat tables\n"
  1585   1587     ".headers on|off        Turn display of headers on or off\n"
  1586   1588     ".help                  Show this message\n"
  1587   1589     ".import FILE TABLE     Import data from FILE into TABLE\n"
  1588   1590     ".indices ?TABLE?       Show names of all indices\n"
  1589   1591     "                         If TABLE specified, only show indices for tables\n"
  1590   1592     "                         matching LIKE pattern TABLE.\n"
  1591   1593   #ifdef SQLITE_ENABLE_IOTRACE
................................................................................
  2406   2408       }else if (p->explainPrev.valid) {
  2407   2409         p->explainPrev.valid = 0;
  2408   2410         p->mode = p->explainPrev.mode;
  2409   2411         p->showHeader = p->explainPrev.showHeader;
  2410   2412         memcpy(p->colWidth,p->explainPrev.colWidth,sizeof(p->colWidth));
  2411   2413       }
  2412   2414     }else
         2415  +
         2416  +  if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
         2417  +    struct callback_data data;
         2418  +    char *zErrMsg = 0;
         2419  +    if( nArg!=1 ){
         2420  +      fprintf(stderr, "Usage: .fullschema\n");
         2421  +      rc = 1;
         2422  +      goto meta_command_exit;
         2423  +    }
         2424  +    open_db(p, 0);
         2425  +    memcpy(&data, p, sizeof(data));
         2426  +    data.showHeader = 0;
         2427  +    data.mode = MODE_Semi;
         2428  +    rc = sqlite3_exec(p->db,
         2429  +       "SELECT sql FROM"
         2430  +       "  (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
         2431  +       "     FROM sqlite_master UNION ALL"
         2432  +       "   SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
         2433  +       "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%'"
         2434  +       "ORDER BY rowid",
         2435  +       callback, &data, &zErrMsg
         2436  +    );
         2437  +    sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_master;'",
         2438  +                 callback, &data, &zErrMsg);
         2439  +    data.mode = MODE_Insert;
         2440  +    data.zDestTable = "sqlite_stat1";
         2441  +    shell_exec(p->db, "SELECT * FROM sqlite_stat1",
         2442  +               shell_callback, &data,&zErrMsg);
         2443  +    data.zDestTable = "sqlite_stat3";
         2444  +    shell_exec(p->db, "SELECT * FROM sqlite_stat3",
         2445  +               shell_callback, &data,&zErrMsg);
         2446  +    data.zDestTable = "sqlite_stat4";
         2447  +    shell_exec(p->db, "SELECT * FROM sqlite_stat4",
         2448  +               shell_callback, &data, &zErrMsg);
         2449  +    data.mode = MODE_Semi;
         2450  +    shell_exec(p->db, "SELECT 'ANALYZE sqlite_master;'",
         2451  +               shell_callback, &data, &zErrMsg);
         2452  +  }else
  2413   2453   
  2414   2454     if( c=='h' && strncmp(azArg[0], "headers", n)==0 ){
  2415   2455       if( nArg==2 ){
  2416   2456         p->showHeader = booleanValue(azArg[1]);
  2417   2457       }else{
  2418   2458         fprintf(stderr, "Usage: .headers on|off\n");
  2419   2459         rc = 1;
................................................................................
  2549   2589           if( z==0 && i==0 ) break;
  2550   2590           sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT);
  2551   2591           if( i<nCol-1 && sCsv.cTerm!=sCsv.cSeparator ){
  2552   2592             fprintf(stderr, "%s:%d: expected %d columns but found %d - "
  2553   2593                             "filling the rest with NULL\n",
  2554   2594                             sCsv.zFile, startLine, nCol, i+1);
  2555   2595             i++;
  2556         -          while( i<nCol ){ sqlite3_bind_null(pStmt, i); i++; }
         2596  +          while( i<=nCol ){ sqlite3_bind_null(pStmt, i); i++; }
  2557   2597           }
  2558   2598         }
  2559   2599         if( sCsv.cTerm==sCsv.cSeparator ){
  2560   2600           do{
  2561   2601             csv_read_one_field(&sCsv);
  2562   2602             i++;
  2563   2603           }while( sCsv.cTerm==sCsv.cSeparator );

Changes to src/sqliteInt.h.

  3439   3439   
  3440   3440   void sqlite3BackupRestart(sqlite3_backup *);
  3441   3441   void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
  3442   3442   
  3443   3443   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  3444   3444   void sqlite3AnalyzeFunctions(void);
  3445   3445   int sqlite3Stat4ProbeSetValue(Parse*,Index*,UnpackedRecord**,Expr*,u8,int,int*);
         3446  +int sqlite3Stat4ValueFromExpr(Parse*, Expr*, u8, sqlite3_value**);
  3446   3447   void sqlite3Stat4ProbeFree(UnpackedRecord*);
         3448  +int sqlite3Stat4Column(sqlite3*, const void*, int, int, sqlite3_value**);
  3447   3449   #endif
  3448   3450   
  3449   3451   /*
  3450   3452   ** The interface to the LEMON-generated parser
  3451   3453   */
  3452   3454   void *sqlite3ParserAlloc(void*(*)(size_t));
  3453   3455   void sqlite3ParserFree(void*, void(*)(void*));

Changes to src/test1.c.

  6277   6277     void * clientData,
  6278   6278     Tcl_Interp *interp,
  6279   6279     int objc,
  6280   6280     Tcl_Obj *CONST objv[]
  6281   6281   ){
  6282   6282     extern int sqlite3_amatch_init(sqlite3*,char**,const sqlite3_api_routines*);
  6283   6283     extern int sqlite3_closure_init(sqlite3*,char**,const sqlite3_api_routines*);
         6284  +  extern int sqlite3_fileio_init(sqlite3*,char**,const sqlite3_api_routines*);
  6284   6285     extern int sqlite3_fuzzer_init(sqlite3*,char**,const sqlite3_api_routines*);
  6285   6286     extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*);
  6286   6287     extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);
  6287   6288     extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*);
  6288   6289     extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*);
  6289   6290     extern int sqlite3_spellfix_init(sqlite3*,char**,const sqlite3_api_routines*);
  6290   6291     extern int sqlite3_totype_init(sqlite3*,char**,const sqlite3_api_routines*);
................................................................................
  6291   6292     extern int sqlite3_wholenumber_init(sqlite3*,char**,const sqlite3_api_routines*);
  6292   6293     static const struct {
  6293   6294       const char *zExtName;
  6294   6295       int (*pInit)(sqlite3*,char**,const sqlite3_api_routines*);
  6295   6296     } aExtension[] = {
  6296   6297       { "amatch",                sqlite3_amatch_init               },
  6297   6298       { "closure",               sqlite3_closure_init              },
         6299  +    { "fileio",                sqlite3_fileio_init               },
  6298   6300       { "fuzzer",                sqlite3_fuzzer_init               },
  6299   6301       { "ieee754",               sqlite3_ieee_init                 },
  6300   6302       { "nextchar",              sqlite3_nextchar_init             },
  6301   6303       { "percentile",            sqlite3_percentile_init           },
  6302   6304       { "regexp",                sqlite3_regexp_init               },
  6303   6305       { "spellfix",              sqlite3_spellfix_init             },
  6304   6306       { "totype",                sqlite3_totype_init               },

Changes to src/utf.c.

   144    144   **     0xd800 and 0xe000 then it is rendered as 0xfffd.
   145    145   **
   146    146   **  *  Bytes in the range of 0x80 through 0xbf which occur as the first
   147    147   **     byte of a character are interpreted as single-byte characters
   148    148   **     and rendered as themselves even though they are technically
   149    149   **     invalid characters.
   150    150   **
   151         -**  *  This routine accepts an infinite number of different UTF8 encodings
   152         -**     for unicode values 0x80 and greater.  It do not change over-length
          151  +**  *  This routine accepts over-length UTF8 encodings
          152  +**     for unicode values 0x80 and greater.  It does not change over-length
   153    153   **     encodings to 0xfffd as some systems recommend.
   154    154   */
   155    155   #define READ_UTF8(zIn, zTerm, c)                           \
   156    156     c = *(zIn++);                                            \
   157    157     if( c>=0xc0 ){                                           \
   158    158       c = sqlite3Utf8Trans1[c-0xc0];                         \
   159    159       while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){            \

Changes to src/vdbe.h.

   207    207   void sqlite3VdbeSwap(Vdbe*,Vdbe*);
   208    208   VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
   209    209   sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
   210    210   void sqlite3VdbeSetVarmask(Vdbe*, int);
   211    211   #ifndef SQLITE_OMIT_TRACE
   212    212     char *sqlite3VdbeExpandSql(Vdbe*, const char*);
   213    213   #endif
          214  +int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
   214    215   
   215    216   void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
   216    217   int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*,int);
   217    218   UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
   218    219   
   219    220   typedef int (*RecordCompare)(int,const void*,UnpackedRecord*,int);
   220    221   RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);

Changes to src/vdbeInt.h.

   409    409   u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
   410    410   u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
   411    411   void sqlite3VdbeDeleteAuxData(Vdbe*, int, int);
   412    412   
   413    413   int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
   414    414   int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*);
   415    415   int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *);
   416         -int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
   417    416   int sqlite3VdbeExec(Vdbe*);
   418    417   int sqlite3VdbeList(Vdbe*);
   419    418   int sqlite3VdbeHalt(Vdbe*);
   420    419   int sqlite3VdbeChangeEncoding(Mem *, int);
   421    420   int sqlite3VdbeMemTooBig(Mem*);
   422    421   int sqlite3VdbeMemCopy(Mem*, const Mem*);
   423    422   void sqlite3VdbeMemShallowCopy(Mem*, const Mem*, int);

Changes to src/vdbeaux.c.

  3587   3587     assert( mem1.zMalloc==0 );
  3588   3588   
  3589   3589     /* rc==0 here means that one or both of the keys ran out of fields and
  3590   3590     ** all the fields up to that point were equal. Return the the default_rc
  3591   3591     ** value.  */
  3592   3592     assert( CORRUPT_DB 
  3593   3593          || pPKey2->default_rc==vdbeRecordCompareDebug(nKey1, pKey1, pPKey2) 
         3594  +       || pKeyInfo->db->mallocFailed
  3594   3595     );
  3595   3596     return pPKey2->default_rc;
  3596   3597   }
  3597   3598   
  3598   3599   /*
  3599   3600   ** This function is an optimized version of sqlite3VdbeRecordCompare() 
  3600   3601   ** that (a) the first field of pPKey2 is an integer, and (b) the 
................................................................................
  3752   3753       }
  3753   3754     }
  3754   3755   
  3755   3756     assert( (res==0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)==0)
  3756   3757          || (res<0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)<0)
  3757   3758          || (res>0 && vdbeRecordCompareDebug(nKey1, pKey1, pPKey2)>0)
  3758   3759          || CORRUPT_DB
         3760  +       || pPKey2->pKeyInfo->db->mallocFailed
  3759   3761     );
  3760   3762     return res;
  3761   3763   }
  3762   3764   
  3763   3765   /*
  3764   3766   ** Return a pointer to an sqlite3VdbeRecordCompare() compatible function
  3765   3767   ** suitable for comparing serialized records to the unpacked record passed

Changes to src/vdbemem.c.

  1147   1147     int i;
  1148   1148     FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
  1149   1149     FuncDef *aFunc = (FuncDef*)&GLOBAL(FuncDef, aAnalyzeTableFuncs);
  1150   1150     for(i=0; i<ArraySize(aAnalyzeTableFuncs); i++){
  1151   1151       sqlite3FuncDefInsert(pHash, &aFunc[i]);
  1152   1152     }
  1153   1153   }
         1154  +
         1155  +/*
         1156  +** Attempt to extract a value from pExpr and use it to construct *ppVal.
         1157  +**
         1158  +** If pAlloc is not NULL, then an UnpackedRecord object is created for
         1159  +** pAlloc if one does not exist and the new value is added to the
         1160  +** UnpackedRecord object.
         1161  +**
         1162  +** A value is extracted in the following cases:
         1163  +**
         1164  +**  * (pExpr==0). In this case the value is assumed to be an SQL NULL,
         1165  +**
         1166  +**  * The expression is a bound variable, and this is a reprepare, or
         1167  +**
         1168  +**  * The expression is a literal value.
         1169  +**
         1170  +** On success, *ppVal is made to point to the extracted value.  The caller
         1171  +** is responsible for ensuring that the value is eventually freed.
         1172  +*/
         1173  +static int stat4ValueFromExpr(
         1174  +  Parse *pParse,                  /* Parse context */
         1175  +  Expr *pExpr,                    /* The expression to extract a value from */
         1176  +  u8 affinity,                    /* Affinity to use */
         1177  +  struct ValueNewStat4Ctx *pAlloc,/* How to allocate space.  Or NULL */
         1178  +  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */
         1179  +){
         1180  +  int rc = SQLITE_OK;
         1181  +  sqlite3_value *pVal = 0;
         1182  +  sqlite3 *db = pParse->db;
         1183  +
         1184  +  /* Skip over any TK_COLLATE nodes */
         1185  +  pExpr = sqlite3ExprSkipCollate(pExpr);
         1186  +
         1187  +  if( !pExpr ){
         1188  +    pVal = valueNew(db, pAlloc);
         1189  +    if( pVal ){
         1190  +      sqlite3VdbeMemSetNull((Mem*)pVal);
         1191  +    }
         1192  +  }else if( pExpr->op==TK_VARIABLE
         1193  +        || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
         1194  +  ){
         1195  +    Vdbe *v;
         1196  +    int iBindVar = pExpr->iColumn;
         1197  +    sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
         1198  +    if( (v = pParse->pReprepare)!=0 ){
         1199  +      pVal = valueNew(db, pAlloc);
         1200  +      if( pVal ){
         1201  +        rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
         1202  +        if( rc==SQLITE_OK ){
         1203  +          sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
         1204  +        }
         1205  +        pVal->db = pParse->db;
         1206  +      }
         1207  +    }
         1208  +  }else{
         1209  +    rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, pAlloc);
         1210  +  }
         1211  +
         1212  +  assert( pVal==0 || pVal->db==db );
         1213  +  *ppVal = pVal;
         1214  +  return rc;
         1215  +}
  1154   1216   
  1155   1217   /*
  1156   1218   ** This function is used to allocate and populate UnpackedRecord 
  1157   1219   ** structures intended to be compared against sample index keys stored 
  1158   1220   ** in the sqlite_stat4 table.
  1159   1221   **
  1160   1222   ** A single call to this function attempts to populates field iVal (leftmost 
................................................................................
  1187   1249     Index *pIdx,                    /* Index being probed */
  1188   1250     UnpackedRecord **ppRec,         /* IN/OUT: Probe record */
  1189   1251     Expr *pExpr,                    /* The expression to extract a value from */
  1190   1252     u8 affinity,                    /* Affinity to use */
  1191   1253     int iVal,                       /* Array element to populate */
  1192   1254     int *pbOk                       /* OUT: True if value was extracted */
  1193   1255   ){
  1194         -  int rc = SQLITE_OK;
         1256  +  int rc;
  1195   1257     sqlite3_value *pVal = 0;
  1196         -  sqlite3 *db = pParse->db;
  1197         -
  1198         -
  1199   1258     struct ValueNewStat4Ctx alloc;
         1259  +
  1200   1260     alloc.pParse = pParse;
  1201   1261     alloc.pIdx = pIdx;
  1202   1262     alloc.ppRec = ppRec;
  1203   1263     alloc.iVal = iVal;
  1204   1264   
  1205         -  /* Skip over any TK_COLLATE nodes */
  1206         -  pExpr = sqlite3ExprSkipCollate(pExpr);
         1265  +  rc = stat4ValueFromExpr(pParse, pExpr, affinity, &alloc, &pVal);
         1266  +  assert( pVal==0 || pVal->db==pParse->db );
         1267  +  *pbOk = (pVal!=0);
         1268  +  return rc;
         1269  +}
         1270  +
         1271  +/*
         1272  +** Attempt to extract a value from expression pExpr using the methods
         1273  +** as described for sqlite3Stat4ProbeSetValue() above. 
         1274  +**
         1275  +** If successful, set *ppVal to point to a new value object and return 
         1276  +** SQLITE_OK. If no value can be extracted, but no other error occurs
         1277  +** (e.g. OOM), return SQLITE_OK and set *ppVal to NULL. Or, if an error
         1278  +** does occur, return an SQLite error code. The final value of *ppVal
         1279  +** is undefined in this case.
         1280  +*/
         1281  +int sqlite3Stat4ValueFromExpr(
         1282  +  Parse *pParse,                  /* Parse context */
         1283  +  Expr *pExpr,                    /* The expression to extract a value from */
         1284  +  u8 affinity,                    /* Affinity to use */
         1285  +  sqlite3_value **ppVal           /* OUT: New value object (or NULL) */
         1286  +){
         1287  +  return stat4ValueFromExpr(pParse, pExpr, affinity, 0, ppVal);
         1288  +}
  1207   1289   
  1208         -  if( !pExpr ){
  1209         -    pVal = valueNew(db, &alloc);
  1210         -    if( pVal ){
  1211         -      sqlite3VdbeMemSetNull((Mem*)pVal);
  1212         -    }
  1213         -  }else if( pExpr->op==TK_VARIABLE
  1214         -        || NEVER(pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE)
  1215         -  ){
  1216         -    Vdbe *v;
  1217         -    int iBindVar = pExpr->iColumn;
  1218         -    sqlite3VdbeSetVarmask(pParse->pVdbe, iBindVar);
  1219         -    if( (v = pParse->pReprepare)!=0 ){
  1220         -      pVal = valueNew(db, &alloc);
  1221         -      if( pVal ){
  1222         -        rc = sqlite3VdbeMemCopy((Mem*)pVal, &v->aVar[iBindVar-1]);
  1223         -        if( rc==SQLITE_OK ){
  1224         -          sqlite3ValueApplyAffinity(pVal, affinity, ENC(db));
  1225         -        }
  1226         -        pVal->db = pParse->db;
  1227         -      }
  1228         -    }
  1229         -  }else{
  1230         -    rc = valueFromExpr(db, pExpr, ENC(db), affinity, &pVal, &alloc);
  1231         -  }
  1232         -  *pbOk = (pVal!=0);
         1290  +/*
         1291  +** Extract the iCol-th column from the nRec-byte record in pRec.  Write
         1292  +** the column value into *ppVal.  If *ppVal is initially NULL then a new
         1293  +** sqlite3_value object is allocated.
         1294  +**
         1295  +** If *ppVal is initially NULL then the caller is responsible for 
         1296  +** ensuring that the value written into *ppVal is eventually freed.
         1297  +*/
         1298  +int sqlite3Stat4Column(
         1299  +  sqlite3 *db,                    /* Database handle */
         1300  +  const void *pRec,               /* Pointer to buffer containing record */
         1301  +  int nRec,                       /* Size of buffer pRec in bytes */
         1302  +  int iCol,                       /* Column to extract */
         1303  +  sqlite3_value **ppVal           /* OUT: Extracted value */
         1304  +){
         1305  +  u32 t;                          /* a column type code */
         1306  +  int nHdr;                       /* Size of the header in the record */
         1307  +  int iHdr;                       /* Next unread header byte */
         1308  +  int iField;                     /* Next unread data byte */
         1309  +  int szField;                    /* Size of the current data field */
         1310  +  int i;                          /* Column index */
         1311  +  u8 *a = (u8*)pRec;              /* Typecast byte array */
         1312  +  Mem *pMem = *ppVal;             /* Write result into this Mem object */
  1233   1313   
  1234         -  assert( pVal==0 || pVal->db==db );
  1235         -  return rc;
         1314  +  assert( iCol>0 );
         1315  +  iHdr = getVarint32(a, nHdr);
         1316  +  if( nHdr>nRec || iHdr>=nHdr ) return SQLITE_CORRUPT_BKPT;
         1317  +  iField = nHdr;
         1318  +  for(i=0; i<=iCol; i++){
         1319  +    iHdr += getVarint32(&a[iHdr], t);
         1320  +    testcase( iHdr==nHdr );
         1321  +    testcase( iHdr==nHdr+1 );
         1322  +    if( iHdr>nHdr ) return SQLITE_CORRUPT_BKPT;
         1323  +    szField = sqlite3VdbeSerialTypeLen(t);
         1324  +    iField += szField;
         1325  +  }
         1326  +  testcase( iField==nRec );
         1327  +  testcase( iField==nRec+1 );
         1328  +  if( iField>nRec ) return SQLITE_CORRUPT_BKPT;
         1329  +  if( pMem==0 ){
         1330  +    pMem = *ppVal = sqlite3ValueNew(db);
         1331  +    if( pMem==0 ) return SQLITE_NOMEM;
         1332  +  }
         1333  +  sqlite3VdbeSerialGet(&a[iField-szField], t, pMem);
         1334  +  pMem->enc = ENC(db);
         1335  +  return SQLITE_OK;
  1236   1336   }
  1237   1337   
  1238   1338   /*
  1239   1339   ** Unless it is NULL, the argument must be an UnpackedRecord object returned
  1240   1340   ** by an earlier call to sqlite3Stat4ProbeSetValue(). This call deletes
  1241   1341   ** the object.
  1242   1342   */

Changes to src/wal.c.

  2092   2092     ** during the few nanoseconds that it is holding the lock.  In that case,
  2093   2093     ** it might take longer than normal for the lock to free.
  2094   2094     **
  2095   2095     ** After 5 RETRYs, we begin calling sqlite3OsSleep().  The first few
  2096   2096     ** calls to sqlite3OsSleep() have a delay of 1 microsecond.  Really this
  2097   2097     ** is more of a scheduler yield than an actual delay.  But on the 10th
  2098   2098     ** an subsequent retries, the delays start becoming longer and longer, 
  2099         -  ** so that on the 100th (and last) RETRY we delay for 21 milliseconds.
  2100         -  ** The total delay time before giving up is less than 1 second.
         2099  +  ** so that on the 100th (and last) RETRY we delay for 323 milliseconds.
         2100  +  ** The total delay time before giving up is less than 10 seconds.
  2101   2101     */
  2102   2102     if( cnt>5 ){
  2103   2103       int nDelay = 1;                      /* Pause time in microseconds */
  2104   2104       if( cnt>100 ){
  2105   2105         VVA_ONLY( pWal->lockError = 1; )
  2106   2106         return SQLITE_PROTOCOL;
  2107   2107       }
  2108         -    if( cnt>=10 ) nDelay = (cnt-9)*238;  /* Max delay 21ms. Total delay 996ms */
         2108  +    if( cnt>=10 ) nDelay = (cnt-9)*(cnt-9)*39;
  2109   2109       sqlite3OsSleep(pWal->pVfs, nDelay);
  2110   2110     }
  2111   2111   
  2112   2112     if( !useWal ){
  2113   2113       rc = walIndexReadHdr(pWal, pChanged);
  2114   2114       if( rc==SQLITE_BUSY ){
  2115   2115         /* If there is not a recovery running in another thread or process

Changes to src/where.c.

   540    540   
   541    541     /* memset(pScan, 0, sizeof(*pScan)); */
   542    542     pScan->pOrigWC = pWC;
   543    543     pScan->pWC = pWC;
   544    544     if( pIdx && iColumn>=0 ){
   545    545       pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
   546    546       for(j=0; pIdx->aiColumn[j]!=iColumn; j++){
   547         -      if( NEVER(j>=pIdx->nKeyCol) ) return 0;
          547  +      if( NEVER(j>pIdx->nColumn) ) return 0;
   548    548       }
   549    549       pScan->zCollName = pIdx->azColl[j];
   550    550     }else{
   551    551       pScan->idxaff = 0;
   552    552       pScan->zCollName = 0;
   553    553     }
   554    554     pScan->opMask = opMask;
................................................................................
  1490   1490   }
  1491   1491   
  1492   1492   
  1493   1493   /*
  1494   1494   ** Estimate the logarithm of the input value to base 2.
  1495   1495   */
  1496   1496   static LogEst estLog(LogEst N){
  1497         -  LogEst x = sqlite3LogEst(N);
  1498         -  return x>33 ? x - 33 : 0;
         1497  +  return N<=10 ? 0 : sqlite3LogEst(N) - 33;
  1499   1498   }
  1500   1499   
  1501   1500   /*
  1502   1501   ** Two routines for printing the content of an sqlite3_index_info
  1503   1502   ** structure.  Used for testing and debugging only.  If neither
  1504   1503   ** SQLITE_TEST or SQLITE_DEBUG are defined, then these routines
  1505   1504   ** are no-ops.
................................................................................
  1995   1994       }else if( (pTerm->wtFlags & TERM_VNULL)==0 ){
  1996   1995         nRet -= 20;        assert( 20==sqlite3LogEst(4) );
  1997   1996       }
  1998   1997     }
  1999   1998     return nRet;
  2000   1999   }
  2001   2000   
         2001  +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
         2002  +/* 
         2003  +** This function is called to estimate the number of rows visited by a
         2004  +** range-scan on a skip-scan index. For example:
         2005  +**
         2006  +**   CREATE INDEX i1 ON t1(a, b, c);
         2007  +**   SELECT * FROM t1 WHERE a=? AND c BETWEEN ? AND ?;
         2008  +**
         2009  +** Value pLoop->nOut is currently set to the estimated number of rows 
         2010  +** visited for scanning (a=? AND b=?). This function reduces that estimate 
         2011  +** by some factor to account for the (c BETWEEN ? AND ?) expression based
         2012  +** on the stat4 data for the index. this scan will be peformed multiple 
         2013  +** times (once for each (a,b) combination that matches a=?) is dealt with 
         2014  +** by the caller.
         2015  +**
         2016  +** It does this by scanning through all stat4 samples, comparing values
         2017  +** extracted from pLower and pUpper with the corresponding column in each
         2018  +** sample. If L and U are the number of samples found to be less than or
         2019  +** equal to the values extracted from pLower and pUpper respectively, and
         2020  +** N is the total number of samples, the pLoop->nOut value is adjusted
         2021  +** as follows:
         2022  +**
         2023  +**   nOut = nOut * ( min(U - L, 1) / N )
         2024  +**
         2025  +** If pLower is NULL, or a value cannot be extracted from the term, L is
         2026  +** set to zero. If pUpper is NULL, or a value cannot be extracted from it,
         2027  +** U is set to N.
         2028  +**
         2029  +** Normally, this function sets *pbDone to 1 before returning. However,
         2030  +** if no value can be extracted from either pLower or pUpper (and so the
         2031  +** estimate of the number of rows delivered remains unchanged), *pbDone
         2032  +** is left as is.
         2033  +**
         2034  +** If an error occurs, an SQLite error code is returned. Otherwise, 
         2035  +** SQLITE_OK.
         2036  +*/
         2037  +static int whereRangeSkipScanEst(
         2038  +  Parse *pParse,       /* Parsing & code generating context */
         2039  +  WhereTerm *pLower,   /* Lower bound on the range. ex: "x>123" Might be NULL */
         2040  +  WhereTerm *pUpper,   /* Upper bound on the range. ex: "x<455" Might be NULL */
         2041  +  WhereLoop *pLoop,    /* Update the .nOut value of this loop */
         2042  +  int *pbDone          /* Set to true if at least one expr. value extracted */
         2043  +){
         2044  +  Index *p = pLoop->u.btree.pIndex;
         2045  +  int nEq = pLoop->u.btree.nEq;
         2046  +  sqlite3 *db = pParse->db;
         2047  +  int nLower = -1;
         2048  +  int nUpper = p->nSample+1;
         2049  +  int rc = SQLITE_OK;
         2050  +  u8 aff = p->pTable->aCol[ p->aiColumn[nEq] ].affinity;
         2051  +  CollSeq *pColl;
         2052  +  
         2053  +  sqlite3_value *p1 = 0;          /* Value extracted from pLower */
         2054  +  sqlite3_value *p2 = 0;          /* Value extracted from pUpper */
         2055  +  sqlite3_value *pVal = 0;        /* Value extracted from record */
         2056  +
         2057  +  pColl = sqlite3LocateCollSeq(pParse, p->azColl[nEq]);
         2058  +  if( pLower ){
         2059  +    rc = sqlite3Stat4ValueFromExpr(pParse, pLower->pExpr->pRight, aff, &p1);
         2060  +    nLower = 0;
         2061  +  }
         2062  +  if( pUpper && rc==SQLITE_OK ){
         2063  +    rc = sqlite3Stat4ValueFromExpr(pParse, pUpper->pExpr->pRight, aff, &p2);
         2064  +    nUpper = p2 ? 0 : p->nSample;
         2065  +  }
         2066  +
         2067  +  if( p1 || p2 ){
         2068  +    int i;
         2069  +    int nDiff;
         2070  +    for(i=0; rc==SQLITE_OK && i<p->nSample; i++){
         2071  +      rc = sqlite3Stat4Column(db, p->aSample[i].p, p->aSample[i].n, nEq, &pVal);
         2072  +      if( rc==SQLITE_OK && p1 ){
         2073  +        int res = sqlite3MemCompare(p1, pVal, pColl);
         2074  +        if( res>=0 ) nLower++;
         2075  +      }
         2076  +      if( rc==SQLITE_OK && p2 ){
         2077  +        int res = sqlite3MemCompare(p2, pVal, pColl);
         2078  +        if( res>=0 ) nUpper++;
         2079  +      }
         2080  +    }
         2081  +    nDiff = (nUpper - nLower);
         2082  +    if( nDiff<=0 ) nDiff = 1;
         2083  +
         2084  +    /* If there is both an upper and lower bound specified, and the 
         2085  +    ** comparisons indicate that they are close together, use the fallback
         2086  +    ** method (assume that the scan visits 1/64 of the rows) for estimating
         2087  +    ** the number of rows visited. Otherwise, estimate the number of rows
         2088  +    ** using the method described in the header comment for this function. */
         2089  +    if( nDiff!=1 || pUpper==0 || pLower==0 ){
         2090  +      int nAdjust = (sqlite3LogEst(p->nSample) - sqlite3LogEst(nDiff));
         2091  +      pLoop->nOut -= nAdjust;
         2092  +      *pbDone = 1;
         2093  +      WHERETRACE(0x10, ("range skip-scan regions: %u..%u  adjust=%d est=%d\n",
         2094  +                           nLower, nUpper, nAdjust*-1, pLoop->nOut));
         2095  +    }
         2096  +
         2097  +  }else{
         2098  +    assert( *pbDone==0 );
         2099  +  }
         2100  +
         2101  +  sqlite3ValueFree(p1);
         2102  +  sqlite3ValueFree(p2);
         2103  +  sqlite3ValueFree(pVal);
         2104  +
         2105  +  return rc;
         2106  +}
         2107  +#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
         2108  +
  2002   2109   /*
  2003   2110   ** This function is used to estimate the number of rows that will be visited
  2004   2111   ** by scanning an index for a range of values. The range may have an upper
  2005   2112   ** bound, a lower bound, or both. The WHERE clause terms that set the upper
  2006   2113   ** and lower bounds are represented by pLower and pUpper respectively. For
  2007   2114   ** example, assuming that index p is on t1(a):
  2008   2115   **
................................................................................
  2031   2138   ** When this function is called, *pnOut is set to the sqlite3LogEst() of the
  2032   2139   ** number of rows that the index scan is expected to visit without 
  2033   2140   ** considering the range constraints. If nEq is 0, this is the number of 
  2034   2141   ** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)
  2035   2142   ** to account for the range contraints pLower and pUpper.
  2036   2143   ** 
  2037   2144   ** In the absence of sqlite_stat4 ANALYZE data, or if such data cannot be
  2038         -** used, each range inequality reduces the search space by a factor of 4. 
  2039         -** Hence a pair of constraints (x>? AND x<?) reduces the expected number of
  2040         -** rows visited by a factor of 16.
         2145  +** used, a single range inequality reduces the search space by a factor of 4. 
         2146  +** and a pair of constraints (x>? AND x<?) reduces the expected number of
         2147  +** rows visited by a factor of 64.
  2041   2148   */
  2042   2149   static int whereRangeScanEst(
  2043   2150     Parse *pParse,       /* Parsing & code generating context */
  2044   2151     WhereLoopBuilder *pBuilder,
  2045   2152     WhereTerm *pLower,   /* Lower bound on the range. ex: "x>123" Might be NULL */
  2046   2153     WhereTerm *pUpper,   /* Upper bound on the range. ex: "x<455" Might be NULL */
  2047   2154     WhereLoop *pLoop     /* Modify the .nOut and maybe .rRun fields */
................................................................................
  2051   2158     LogEst nNew;
  2052   2159   
  2053   2160   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  2054   2161     Index *p = pLoop->u.btree.pIndex;
  2055   2162     int nEq = pLoop->u.btree.nEq;
  2056   2163   
  2057   2164     if( p->nSample>0
  2058         -   && nEq==pBuilder->nRecValid
  2059   2165      && nEq<p->nSampleCol
  2060   2166      && OptimizationEnabled(pParse->db, SQLITE_Stat3) 
  2061   2167     ){
  2062         -    UnpackedRecord *pRec = pBuilder->pRec;
  2063         -    tRowcnt a[2];
  2064         -    u8 aff;
  2065         -
  2066         -    /* Variable iLower will be set to the estimate of the number of rows in 
  2067         -    ** the index that are less than the lower bound of the range query. The
  2068         -    ** lower bound being the concatenation of $P and $L, where $P is the
  2069         -    ** key-prefix formed by the nEq values matched against the nEq left-most
  2070         -    ** columns of the index, and $L is the value in pLower.
  2071         -    **
  2072         -    ** Or, if pLower is NULL or $L cannot be extracted from it (because it
  2073         -    ** is not a simple variable or literal value), the lower bound of the
  2074         -    ** range is $P. Due to a quirk in the way whereKeyStats() works, even
  2075         -    ** if $L is available, whereKeyStats() is called for both ($P) and 
  2076         -    ** ($P:$L) and the larger of the two returned values used.
  2077         -    **
  2078         -    ** Similarly, iUpper is to be set to the estimate of the number of rows
  2079         -    ** less than the upper bound of the range query. Where the upper bound
  2080         -    ** is either ($P) or ($P:$U). Again, even if $U is available, both values
  2081         -    ** of iUpper are requested of whereKeyStats() and the smaller used.
  2082         -    */
  2083         -    tRowcnt iLower;
  2084         -    tRowcnt iUpper;
  2085         -
  2086         -    if( nEq==p->nKeyCol ){
  2087         -      aff = SQLITE_AFF_INTEGER;
  2088         -    }else{
  2089         -      aff = p->pTable->aCol[p->aiColumn[nEq]].affinity;
  2090         -    }
  2091         -    /* Determine iLower and iUpper using ($P) only. */
  2092         -    if( nEq==0 ){
  2093         -      iLower = 0;
  2094         -      iUpper = sqlite3LogEstToInt(p->aiRowLogEst[0]);
  2095         -    }else{
  2096         -      /* Note: this call could be optimized away - since the same values must 
  2097         -      ** have been requested when testing key $P in whereEqualScanEst().  */
  2098         -      whereKeyStats(pParse, p, pRec, 0, a);
  2099         -      iLower = a[0];
  2100         -      iUpper = a[0] + a[1];
  2101         -    }
  2102         -
  2103         -    /* If possible, improve on the iLower estimate using ($P:$L). */
  2104         -    if( pLower ){
  2105         -      int bOk;                    /* True if value is extracted from pExpr */
  2106         -      Expr *pExpr = pLower->pExpr->pRight;
  2107         -      assert( (pLower->eOperator & (WO_GT|WO_GE))!=0 );
  2108         -      rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
  2109         -      if( rc==SQLITE_OK && bOk ){
  2110         -        tRowcnt iNew;
         2168  +    if( nEq==pBuilder->nRecValid ){
         2169  +      UnpackedRecord *pRec = pBuilder->pRec;
         2170  +      tRowcnt a[2];
         2171  +      u8 aff;
         2172  +
         2173  +      /* Variable iLower will be set to the estimate of the number of rows in 
         2174  +      ** the index that are less than the lower bound of the range query. The
         2175  +      ** lower bound being the concatenation of $P and $L, where $P is the
         2176  +      ** key-prefix formed by the nEq values matched against the nEq left-most
         2177  +      ** columns of the index, and $L is the value in pLower.
         2178  +      **
         2179  +      ** Or, if pLower is NULL or $L cannot be extracted from it (because it
         2180  +      ** is not a simple variable or literal value), the lower bound of the
         2181  +      ** range is $P. Due to a quirk in the way whereKeyStats() works, even
         2182  +      ** if $L is available, whereKeyStats() is called for both ($P) and 
         2183  +      ** ($P:$L) and the larger of the two returned values used.
         2184  +      **
         2185  +      ** Similarly, iUpper is to be set to the estimate of the number of rows
         2186  +      ** less than the upper bound of the range query. Where the upper bound
         2187  +      ** is either ($P) or ($P:$U). Again, even if $U is available, both values
         2188  +      ** of iUpper are requested of whereKeyStats() and the smaller used.
         2189  +      */
         2190  +      tRowcnt iLower;
         2191  +      tRowcnt iUpper;
         2192  +
         2193  +      if( nEq==p->nKeyCol ){
         2194  +        aff = SQLITE_AFF_INTEGER;
         2195  +      }else{
         2196  +        aff = p->pTable->aCol[p->aiColumn[nEq]].affinity;
         2197  +      }
         2198  +      /* Determine iLower and iUpper using ($P) only. */
         2199  +      if( nEq==0 ){
         2200  +        iLower = 0;
         2201  +        iUpper = sqlite3LogEstToInt(p->aiRowLogEst[0]);
         2202  +      }else{
         2203  +        /* Note: this call could be optimized away - since the same values must 
         2204  +        ** have been requested when testing key $P in whereEqualScanEst().  */
  2111   2205           whereKeyStats(pParse, p, pRec, 0, a);
  2112         -        iNew = a[0] + ((pLower->eOperator & WO_GT) ? a[1] : 0);
  2113         -        if( iNew>iLower ) iLower = iNew;
  2114         -        nOut--;
  2115         -      }
  2116         -    }
  2117         -
  2118         -    /* If possible, improve on the iUpper estimate using ($P:$U). */
  2119         -    if( pUpper ){
  2120         -      int bOk;                    /* True if value is extracted from pExpr */
  2121         -      Expr *pExpr = pUpper->pExpr->pRight;
  2122         -      assert( (pUpper->eOperator & (WO_LT|WO_LE))!=0 );
  2123         -      rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
  2124         -      if( rc==SQLITE_OK && bOk ){
  2125         -        tRowcnt iNew;
  2126         -        whereKeyStats(pParse, p, pRec, 1, a);
  2127         -        iNew = a[0] + ((pUpper->eOperator & WO_LE) ? a[1] : 0);
  2128         -        if( iNew<iUpper ) iUpper = iNew;
  2129         -        nOut--;
  2130         -      }
  2131         -    }
  2132         -
  2133         -    pBuilder->pRec = pRec;
  2134         -    if( rc==SQLITE_OK ){
  2135         -      if( iUpper>iLower ){
  2136         -        nNew = sqlite3LogEst(iUpper - iLower);
  2137         -      }else{
  2138         -        nNew = 10;        assert( 10==sqlite3LogEst(2) );
  2139         -      }
  2140         -      if( nNew<nOut ){
  2141         -        nOut = nNew;
  2142         -      }
  2143         -      pLoop->nOut = (LogEst)nOut;
  2144         -      WHERETRACE(0x10, ("range scan regions: %u..%u  est=%d\n",
  2145         -                         (u32)iLower, (u32)iUpper, nOut));
  2146         -      return SQLITE_OK;
         2206  +        iLower = a[0];
         2207  +        iUpper = a[0] + a[1];
         2208  +      }
         2209  +
         2210  +      /* If possible, improve on the iLower estimate using ($P:$L). */
         2211  +      if( pLower ){
         2212  +        int bOk;                    /* True if value is extracted from pExpr */
         2213  +        Expr *pExpr = pLower->pExpr->pRight;
         2214  +        assert( (pLower->eOperator & (WO_GT|WO_GE))!=0 );
         2215  +        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
         2216  +        if( rc==SQLITE_OK && bOk ){
         2217  +          tRowcnt iNew;
         2218  +          whereKeyStats(pParse, p, pRec, 0, a);
         2219  +          iNew = a[0] + ((pLower->eOperator & WO_GT) ? a[1] : 0);
         2220  +          if( iNew>iLower ) iLower = iNew;
         2221  +          nOut--;
         2222  +        }
         2223  +      }
         2224  +
         2225  +      /* If possible, improve on the iUpper estimate using ($P:$U). */
         2226  +      if( pUpper ){
         2227  +        int bOk;                    /* True if value is extracted from pExpr */
         2228  +        Expr *pExpr = pUpper->pExpr->pRight;
         2229  +        assert( (pUpper->eOperator & (WO_LT|WO_LE))!=0 );
         2230  +        rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
         2231  +        if( rc==SQLITE_OK && bOk ){
         2232  +          tRowcnt iNew;
         2233  +          whereKeyStats(pParse, p, pRec, 1, a);
         2234  +          iNew = a[0] + ((pUpper->eOperator & WO_LE) ? a[1] : 0);
         2235  +          if( iNew<iUpper ) iUpper = iNew;
         2236  +          nOut--;
         2237  +        }
         2238  +      }
         2239  +
         2240  +      pBuilder->pRec = pRec;
         2241  +      if( rc==SQLITE_OK ){
         2242  +        if( iUpper>iLower ){
         2243  +          nNew = sqlite3LogEst(iUpper - iLower);
         2244  +        }else{
         2245  +          nNew = 10;        assert( 10==sqlite3LogEst(2) );
         2246  +        }
         2247  +        if( nNew<nOut ){
         2248  +          nOut = nNew;
         2249  +        }
         2250  +        pLoop->nOut = (LogEst)nOut;
         2251  +        WHERETRACE(0x10, ("range scan regions: %u..%u  est=%d\n",
         2252  +                           (u32)iLower, (u32)iUpper, nOut));
         2253  +        return SQLITE_OK;
         2254  +      }
         2255  +    }else{
         2256  +      int bDone = 0;
         2257  +      rc = whereRangeSkipScanEst(pParse, pLower, pUpper, pLoop, &bDone);
         2258  +      if( bDone ) return rc;
  2147   2259       }
  2148   2260     }
  2149   2261   #else
  2150   2262     UNUSED_PARAMETER(pParse);
  2151   2263     UNUSED_PARAMETER(pBuilder);
  2152   2264   #endif
  2153   2265     assert( pLower || pUpper );
................................................................................
  2198   2310     UnpackedRecord *pRec = pBuilder->pRec;
  2199   2311     u8 aff;                   /* Column affinity */
  2200   2312     int rc;                   /* Subfunction return code */
  2201   2313     tRowcnt a[2];             /* Statistics */
  2202   2314     int bOk;
  2203   2315   
  2204   2316     assert( nEq>=1 );
  2205         -  assert( nEq<=(p->nKeyCol+1) );
         2317  +  assert( nEq<=p->nColumn );
  2206   2318     assert( p->aSample!=0 );
  2207   2319     assert( p->nSample>0 );
  2208   2320     assert( pBuilder->nRecValid<nEq );
  2209   2321   
  2210   2322     /* If values are not available for all fields of the index to the left
  2211   2323     ** of this one, no estimate can be made. Return SQLITE_NOTFOUND. */
  2212   2324     if( pBuilder->nRecValid<(nEq-1) ){
  2213   2325       return SQLITE_NOTFOUND;
  2214   2326     }
  2215   2327   
  2216   2328     /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue()
  2217   2329     ** below would return the same value.  */
  2218         -  if( nEq>p->nKeyCol ){
         2330  +  if( nEq>=p->nColumn ){
  2219   2331       *pnRow = 1;
  2220   2332       return SQLITE_OK;
  2221   2333     }
  2222   2334   
  2223   2335     aff = p->pTable->aCol[p->aiColumn[nEq-1]].affinity;
  2224   2336     rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq-1, &bOk);
  2225   2337     pBuilder->pRec = pRec;
................................................................................
  2642   2754     if( nEq==0 && (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ){
  2643   2755       return 0;
  2644   2756     }
  2645   2757     sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH);
  2646   2758     txt.db = db;
  2647   2759     sqlite3StrAccumAppend(&txt, " (", 2);
  2648   2760     for(i=0; i<nEq; i++){
  2649         -    char *z = (i==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName;
         2761  +    char *z = aiColumn[i] < 0 ? "rowid" : aCol[aiColumn[i]].zName;
  2650   2762       if( i>=nSkip ){
  2651   2763         explainAppendTerm(&txt, i, z, "=");
  2652   2764       }else{
  2653   2765         if( i ) sqlite3StrAccumAppend(&txt, " AND ", 5);
  2654   2766         sqlite3StrAccumAppend(&txt, "ANY(", 4);
  2655   2767         sqlite3StrAccumAppendAll(&txt, z);
  2656   2768         sqlite3StrAccumAppend(&txt, ")", 1);
  2657   2769       }
  2658   2770     }
  2659   2771   
  2660   2772     j = i;
  2661   2773     if( pLoop->wsFlags&WHERE_BTM_LIMIT ){
  2662         -    char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName;
         2774  +    char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName;
  2663   2775       explainAppendTerm(&txt, i++, z, ">");
  2664   2776     }
  2665   2777     if( pLoop->wsFlags&WHERE_TOP_LIMIT ){
  2666         -    char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName;
         2778  +    char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName;
  2667   2779       explainAppendTerm(&txt, i, z, "<");
  2668   2780     }
  2669   2781     sqlite3StrAccumAppend(&txt, ")", 1);
  2670   2782     return sqlite3StrAccumFinish(&txt);
  2671   2783   }
  2672   2784   
  2673   2785   /*
................................................................................
  3683   3795                   p->u.vtab.idxNum, p->u.vtab.idxStr, p->u.vtab.omitMask);
  3684   3796       }else{
  3685   3797         z = sqlite3_mprintf("(%d,%x)", p->u.vtab.idxNum, p->u.vtab.omitMask);
  3686   3798       }
  3687   3799       sqlite3DebugPrintf(" %-19s", z);
  3688   3800       sqlite3_free(z);
  3689   3801     }
  3690         -  sqlite3DebugPrintf(" f %04x N %d", p->wsFlags, p->nLTerm);
         3802  +  sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
  3691   3803     sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
  3692   3804   #ifdef SQLITE_ENABLE_TREE_EXPLAIN
  3693   3805     /* If the 0x100 bit of wheretracing is set, then show all of the constraint
  3694   3806     ** expressions in the WhereLoop.aLTerm[] array.
  3695   3807     */
  3696   3808     if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){  /* WHERETRACE 0x100 */
  3697   3809       int i;
................................................................................
  3919   4031       assert( p->rSetup==0 || pTemplate->rSetup==0 
  3920   4032                    || p->rSetup==pTemplate->rSetup );
  3921   4033   
  3922   4034       /* whereLoopAddBtree() always generates and inserts the automatic index
  3923   4035       ** case first.  Hence compatible candidate WhereLoops never have a larger
  3924   4036       ** rSetup. Call this SETUP-INVARIANT */
  3925   4037       assert( p->rSetup>=pTemplate->rSetup );
         4038  +
         4039  +    /* Any loop using an appliation-defined index (or PRIMARY KEY or
         4040  +    ** UNIQUE constraint) with one or more == constraints is better
         4041  +    ** than an automatic index. */
         4042  +    if( (p->wsFlags & WHERE_AUTO_INDEX)!=0
         4043  +     && (pTemplate->wsFlags & WHERE_INDEXED)!=0
         4044  +     && (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0
         4045  +     && (p->prereq & pTemplate->prereq)==pTemplate->prereq
         4046  +    ){
         4047  +      break;
         4048  +    }
  3926   4049   
  3927   4050       /* If existing WhereLoop p is better than pTemplate, pTemplate can be
  3928   4051       ** discarded.  WhereLoop p is better if:
  3929   4052       **   (1)  p has no more dependencies than pTemplate, and
  3930   4053       **   (2)  p has an equal or lower cost than pTemplate
  3931   4054       */
  3932   4055       if( (p->prereq & pTemplate->prereq)==p->prereq    /* (1)  */
................................................................................
  4044   4167       /* We will be overwriting WhereLoop p[].  But before we do, first
  4045   4168       ** go through the rest of the list and delete any other entries besides
  4046   4169       ** p[] that are also supplated by pTemplate */
  4047   4170       WhereLoop **ppTail = &p->pNextLoop;
  4048   4171       WhereLoop *pToDel;
  4049   4172       while( *ppTail ){
  4050   4173         ppTail = whereLoopFindLesser(ppTail, pTemplate);
  4051         -      if( NEVER(ppTail==0) ) break;
         4174  +      if( ppTail==0 ) break;
  4052   4175         pToDel = *ppTail;
  4053   4176         if( pToDel==0 ) break;
  4054   4177         *ppTail = pToDel->pNextLoop;
  4055   4178   #if WHERETRACE_ENABLED /* 0x8 */
  4056   4179         if( sqlite3WhereTrace & 0x8 ){
  4057         -        sqlite3DebugPrintf("ins-del: ");
         4180  +        sqlite3DebugPrintf("ins-del:  ");
  4058   4181           whereLoopPrint(pToDel, pBuilder->pWC);
  4059   4182         }
  4060   4183   #endif
  4061   4184         whereLoopDelete(db, pToDel);
  4062   4185       }
  4063   4186     }
  4064   4187     whereLoopXfer(db, p, pTemplate);
................................................................................
  4150   4273     }else if( pProbe->tnum<=0 || (pSrc->jointype & JT_LEFT)!=0 ){
  4151   4274       opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE;
  4152   4275     }else{
  4153   4276       opMask = WO_EQ|WO_IN|WO_ISNULL|WO_GT|WO_GE|WO_LT|WO_LE;
  4154   4277     }
  4155   4278     if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
  4156   4279   
  4157         -  assert( pNew->u.btree.nEq<=pProbe->nKeyCol );
  4158         -  if( pNew->u.btree.nEq < pProbe->nKeyCol ){
  4159         -    iCol = pProbe->aiColumn[pNew->u.btree.nEq];
  4160         -  }else{
  4161         -    iCol = -1;
  4162         -  }
         4280  +  assert( pNew->u.btree.nEq<pProbe->nColumn );
         4281  +  iCol = pProbe->aiColumn[pNew->u.btree.nEq];
         4282  +
  4163   4283     pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
  4164   4284                           opMask, pProbe);
  4165   4285     saved_nEq = pNew->u.btree.nEq;
  4166   4286     saved_nSkip = pNew->u.btree.nSkip;
  4167   4287     saved_nLTerm = pNew->nLTerm;
  4168   4288     saved_wsFlags = pNew->wsFlags;
  4169   4289     saved_prereq = pNew->prereq;
................................................................................
  4345   4465       if( pNew->wsFlags & WHERE_COLUMN_RANGE ){
  4346   4466         pNew->nOut = saved_nOut;
  4347   4467       }else{
  4348   4468         pNew->nOut = nOutUnadjusted;
  4349   4469       }
  4350   4470   
  4351   4471       if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
  4352         -     && pNew->u.btree.nEq<(pProbe->nKeyCol + (pProbe->zName!=0))
         4472  +     && pNew->u.btree.nEq<pProbe->nColumn
  4353   4473       ){
  4354   4474         whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
  4355   4475       }
  4356   4476       pNew->nOut = saved_nOut;
  4357   4477   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
  4358   4478       pBuilder->nRecValid = nRecValid;
  4359   4479   #endif
................................................................................
  4492   4612       /* There is no INDEXED BY clause.  Create a fake Index object in local
  4493   4613       ** variable sPk to represent the rowid primary key index.  Make this
  4494   4614       ** fake index the first in a chain of Index objects with all of the real
  4495   4615       ** indices to follow */
  4496   4616       Index *pFirst;                  /* First of real indices on the table */
  4497   4617       memset(&sPk, 0, sizeof(Index));
  4498   4618       sPk.nKeyCol = 1;
         4619  +    sPk.nColumn = 1;
  4499   4620       sPk.aiColumn = &aiColumnPk;
  4500   4621       sPk.aiRowLogEst = aiRowEstPk;
  4501   4622       sPk.onError = OE_Replace;
  4502   4623       sPk.pTable = pTab;
  4503   4624       sPk.szIdxRow = pTab->szTabRow;
  4504   4625       aiRowEstPk[0] = pTab->nRowLogEst;
  4505   4626       aiRowEstPk[1] = 0;
................................................................................
  5275   5396     int iLoop;                /* Loop counter over the terms of the join */
  5276   5397     int ii, jj;               /* Loop counters */
  5277   5398     int mxI = 0;              /* Index of next entry to replace */
  5278   5399     int nOrderBy;             /* Number of ORDER BY clause terms */
  5279   5400     LogEst rCost;             /* Cost of a path */
  5280   5401     LogEst nOut;              /* Number of outputs */
  5281   5402     LogEst mxCost = 0;        /* Maximum cost of a set of paths */
  5282         -  LogEst mxOut = 0;         /* Maximum nOut value on the set of paths */
  5283   5403     int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */
  5284   5404     WherePath *aFrom;         /* All nFrom paths at the previous level */
  5285   5405     WherePath *aTo;           /* The nTo best paths at the current level */
  5286   5406     WherePath *pFrom;         /* An element of aFrom[] that we are working on */
  5287   5407     WherePath *pTo;           /* An element of aTo[] that we are working on */
  5288   5408     WhereLoop *pWLoop;        /* One of the WhereLoop objects */
  5289   5409     WhereLoop **pX;           /* Used to divy up the pSpace memory */
................................................................................
  5385   5505           }else{
  5386   5506             revMask = pFrom->revLoop;
  5387   5507           }
  5388   5508           /* Check to see if pWLoop should be added to the mxChoice best so far */
  5389   5509           for(jj=0, pTo=aTo; jj<nTo; jj++, pTo++){
  5390   5510             if( pTo->maskLoop==maskNew
  5391   5511              && ((pTo->isOrdered^isOrdered)&80)==0
  5392         -           && ((pTo->rCost<=rCost && pTo->nRow<=nOut) ||
  5393         -                (pTo->rCost>=rCost && pTo->nRow>=nOut))
  5394   5512             ){
  5395   5513               testcase( jj==nTo-1 );
  5396   5514               break;
  5397   5515             }
  5398   5516           }
  5399   5517           if( jj>=nTo ){
  5400   5518             if( nTo>=mxChoice && rCost>=mxCost ){
................................................................................
  5420   5538             if( sqlite3WhereTrace&0x4 ){
  5421   5539               sqlite3DebugPrintf("New    %s cost=%-3d,%3d order=%c\n",
  5422   5540                   wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
  5423   5541                   isOrdered>=0 ? isOrdered+'0' : '?');
  5424   5542             }
  5425   5543   #endif
  5426   5544           }else{
  5427         -          if( pTo->rCost<=rCost && pTo->nRow<=nOut ){
         5545  +          if( pTo->rCost<=rCost ){
  5428   5546   #ifdef WHERETRACE_ENABLED /* 0x4 */
  5429   5547               if( sqlite3WhereTrace&0x4 ){
  5430   5548                 sqlite3DebugPrintf(
  5431   5549                     "Skip   %s cost=%-3d,%3d order=%c",
  5432   5550                     wherePathName(pFrom, iLoop, pWLoop), rCost, nOut,
  5433   5551                     isOrdered>=0 ? isOrdered+'0' : '?');
  5434   5552                 sqlite3DebugPrintf("   vs %s cost=%-3d,%d order=%c\n",
................................................................................
  5460   5578           pTo->rCost = rCost;
  5461   5579           pTo->isOrdered = isOrdered;
  5462   5580           memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
  5463   5581           pTo->aLoop[iLoop] = pWLoop;
  5464   5582           if( nTo>=mxChoice ){
  5465   5583             mxI = 0;
  5466   5584             mxCost = aTo[0].rCost;
  5467         -          mxOut = aTo[0].nRow;
  5468   5585             for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
  5469         -            if( pTo->rCost>mxCost || (pTo->rCost==mxCost && pTo->nRow>mxOut) ){
         5586  +            if( pTo->rCost>mxCost ){
  5470   5587                 mxCost = pTo->rCost;
  5471         -              mxOut = pTo->nRow;
  5472   5588                 mxI = jj;
  5473   5589               }
  5474   5590             }
  5475   5591           }
  5476   5592         }
  5477   5593       }
  5478   5594   

Changes to test/analyze9.test.

   948    948   for {set i 0} {$i<16} {incr i} {
   949    949       set val "$i $i $i $i"
   950    950       do_execsql_test 20.3.$i {
   951    951         SELECT count(*) FROM sqlite_stat4 
   952    952         WHERE lrange(test_decode(sample), 0, 3)=$val
   953    953       } {1}
   954    954   }
          955  +
          956  +#-------------------------------------------------------------------------
          957  +#
          958  +reset_db
          959  +
          960  +do_execsql_test 21.0 {
          961  +  CREATE TABLE t2(a, b);
          962  +  CREATE INDEX i2 ON t2(a);
          963  +}
          964  +
          965  +do_test 21.1 {
          966  +  for {set i 1} {$i < 100} {incr i} {
          967  +    execsql { 
          968  +      INSERT INTO t2 VALUES(CASE WHEN $i < 80 THEN 'one' ELSE 'two' END, $i) 
          969  +    }
          970  +  }
          971  +  execsql ANALYZE
          972  +} {}
          973  +
          974  +# Condition (a='one') matches 80% of the table. (rowid<10) reduces this to
          975  +# 10%, but (rowid<50) only reduces it to 50%. So in the first case below
          976  +# the index is used. In the second, it is not. 
          977  +#
          978  +do_eqp_test 21.2 {
          979  +  SELECT * FROM t2 WHERE a='one' AND rowid < 10
          980  +} {/*USING INDEX i2 (a=? AND rowid<?)*/}
          981  +do_eqp_test 21.3 {
          982  +  SELECT * FROM t2 WHERE a='one' AND rowid < 50
          983  +} {/*USING INTEGER PRIMARY KEY*/}
          984  +
          985  +#-------------------------------------------------------------------------
          986  +#
          987  +reset_db
          988  +do_execsql_test 22.0 {
          989  +  CREATE TABLE t3(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;
          990  +}
          991  +do_execsql_test 22.1 {
          992  +  WITH r(x) AS (
          993  +    SELECT 1
          994  +    UNION ALL
          995  +    SELECT x+1 FROM r WHERE x<=100
          996  +  )
          997  +
          998  +  INSERT INTO t3 SELECT
          999  +    CASE WHEN (x>45 AND x<96) THEN 'B' ELSE 'A' END,  /* Column "a" */
         1000  +    x,                                                /* Column "b" */
         1001  +    CASE WHEN (x<51) THEN 'one' ELSE 'two' END,       /* Column "c" */
         1002  +    x                                                 /* Column "d" */
         1003  +  FROM r;
         1004  +
         1005  +  CREATE INDEX i3 ON t3(c);
         1006  +  CREATE INDEX i4 ON t3(d);
         1007  +  ANALYZE;
         1008  +}
         1009  +
         1010  +# Expression (c='one' AND a='B') matches 5 table rows. But (c='one' AND a=A')
         1011  +# matches 45. Expression (d<?) matches 20. Neither index is a covering index.
         1012  +#
         1013  +# Therefore, with stat4 data, SQLite prefers (c='one' AND a='B') over (d<20),
         1014  +# and (d<20) over (c='one' AND a='A').
         1015  +foreach {tn where res} {
         1016  +  1 "c='one' AND a='B' AND d < 20"   {/*INDEX i3 (c=? AND a=?)*/}
         1017  +  2 "c='one' AND a='A' AND d < 20"   {/*INDEX i4 (d<?)*/}
         1018  +} {
         1019  +  do_eqp_test 22.2.$tn "SELECT * FROM t3 WHERE $where" $res
         1020  +}
   955   1021   
   956   1022   finish_test
         1023  +
         1024  +

Added test/autoindex2.test.

            1  +# 2014-06-17
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +#
           12  +# This file implements regression tests for SQLite library.  The
           13  +# focus of this script is testing automatic index creation logic.
           14  +#
           15  +# This file contains a single real-world test case that was giving
           16  +# suboptimal performance because of over-use of automatic indexes.
           17  +#
           18  +
           19  +set testdir [file dirname $argv0]
           20  +source $testdir/tester.tcl
           21  +
           22  +
           23  +do_execsql_test autoindex2-100 {
           24  +  CREATE TABLE t1(
           25  +    t1_id largeint,
           26  +    did char(9),
           27  +    ptime largeint,
           28  +    exbyte char(4),
           29  +    pe_id int,
           30  +    field_id int,
           31  +    mass float,
           32  +    param10 float,
           33  +    param11 float,
           34  +    exmass float,
           35  +    deviation float,
           36  +    trange float,
           37  +    vstatus int,
           38  +    commit_status int,
           39  +    formula char(329),
           40  +    tier int DEFAULT 2,
           41  +    ssid int DEFAULT 0,
           42  +    last_operation largeint DEFAULT 0,
           43  +    admin_uuid int DEFAULT 0,
           44  +    previous_value float,
           45  +    job_id largeint,
           46  +    last_t1 largeint DEFAULT 0,
           47  +    data_t1 int,
           48  +    previous_date largeint DEFAULT 0,
           49  +    flg8 int DEFAULT 1,
           50  +    failed_fields char(100)
           51  +  );
           52  +  CREATE INDEX t1x0 on t1 (t1_id);
           53  +  CREATE INDEX t1x1 on t1 (ptime, vstatus);
           54  +  CREATE INDEX t1x2 on t1 (did, ssid, ptime, vstatus, exbyte, t1_id);
           55  +  CREATE INDEX t1x3 on t1 (job_id);
           56  +  
           57  +  CREATE TABLE t2(
           58  +    did char(9),
           59  +    client_did char(30),
           60  +    description char(49),
           61  +    uid int,
           62  +    tzid int,
           63  +    privilege int,
           64  +    param2 int,
           65  +    type char(30),
           66  +    subtype char(32),
           67  +    dparam1 char(7) DEFAULT '',
           68  +    param5 char(3) DEFAULT '',
           69  +    notional float DEFAULT 0.000000,
           70  +    create_time largeint,
           71  +    sample_time largeint DEFAULT 0,
           72  +    param6 largeint,
           73  +    frequency int,
           74  +    expiration largeint,
           75  +    uw_status int,
           76  +    next_sample largeint,
           77  +    last_sample largeint,
           78  +    reserve1 char(29) DEFAULT '',
           79  +    reserve2 char(29) DEFAULT '',
           80  +    reserve3 char(29) DEFAULT '',
           81  +    bxcdr char(19) DEFAULT 'XY',
           82  +    ssid int DEFAULT 1,
           83  +    last_t1_id largeint,
           84  +    reserve4 char(29) DEFAULT '',
           85  +    reserve5 char(29) DEFAULT '',
           86  +    param12 int DEFAULT 0,
           87  +    long_did char(100) DEFAULT '',
           88  +    gr_code int DEFAULT 0,
           89  +    drx char(100) DEFAULT '',
           90  +    parent_id char(9) DEFAULT '',
           91  +    param13 int DEFAULT 0,
           92  +    position float DEFAULT 1.000000,
           93  +    client_did3 char(100) DEFAULT '',
           94  +    client_did4 char(100) DEFAULT '',
           95  +    dlib_id char(9) DEFAULT ''
           96  +  );
           97  +  CREATE INDEX t2x0 on t2 (did);
           98  +  CREATE INDEX t2x1 on t2 (client_did);
           99  +  CREATE INDEX t2x2 on t2 (long_did);
          100  +  CREATE INDEX t2x3 on t2 (uid);
          101  +  CREATE INDEX t2x4 on t2 (param2);
          102  +  CREATE INDEX t2x5 on t2 (type);
          103  +  CREATE INDEX t2x6 on t2 (subtype);
          104  +  CREATE INDEX t2x7 on t2 (last_sample);
          105  +  CREATE INDEX t2x8 on t2 (param6);
          106  +  CREATE INDEX t2x9 on t2 (frequency);
          107  +  CREATE INDEX t2x10 on t2 (privilege);
          108  +  CREATE INDEX t2x11 on t2 (sample_time);
          109  +  CREATE INDEX t2x12 on t2 (notional);
          110  +  CREATE INDEX t2x13 on t2 (tzid);
          111  +  CREATE INDEX t2x14 on t2 (gr_code);
          112  +  CREATE INDEX t2x15 on t2 (parent_id);
          113  +  
          114  +  CREATE TABLE t3(
          115  +    uid int,
          116  +    param3 int,
          117  +    uuid int,
          118  +    acc_id int,
          119  +    cust_num int,
          120  +    numerix_id int,
          121  +    pfy char(29),
          122  +    param4 char(29),
          123  +    param15 int DEFAULT 0,
          124  +    flg7 int DEFAULT 0,
          125  +    param21 int DEFAULT 0,
          126  +    bxcdr char(2) DEFAULT 'PC',
          127  +    c31 int DEFAULT 0,
          128  +    c33 int DEFAULT 0,
          129  +    c35 int DEFAULT 0,
          130  +    c37 int,
          131  +    mgr_uuid int,
          132  +    back_up_uuid int,
          133  +    priv_mars int DEFAULT 0,
          134  +    is_qc int DEFAULT 0,
          135  +    c41 int DEFAULT 0,
          136  +    deleted int DEFAULT 0,
          137  +    c47 int DEFAULT 1
          138  +  );
          139  +  CREATE INDEX t3x0 on t3 (uid);
          140  +  CREATE INDEX t3x1 on t3 (param3);
          141  +  CREATE INDEX t3x2 on t3 (uuid);
          142  +  CREATE INDEX t3x3 on t3 (acc_id);
          143  +  CREATE INDEX t3x4 on t3 (param4);
          144  +  CREATE INDEX t3x5 on t3 (pfy);
          145  +  CREATE INDEX t3x6 on t3 (is_qc);
          146  +  SELECT count(*) FROM sqlite_master;
          147  +} {30}
          148  +do_execsql_test autoindex2-110 {
          149  +  ANALYZE sqlite_master;
          150  +  INSERT INTO sqlite_stat1 VALUES('t1','t1x3','10747267 260');
          151  +  INSERT INTO sqlite_stat1 VALUES('t1','t1x2','10747267 121 113 2 2 2 1');
          152  +  INSERT INTO sqlite_stat1 VALUES('t1','t1x1','10747267 50 40');
          153  +  INSERT INTO sqlite_stat1 VALUES('t1','t1x0','10747267 1');
          154  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x15','39667 253');
          155  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x14','39667 19834');
          156  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x13','39667 13223');
          157  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x12','39667 7');
          158  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x11','39667 17');
          159  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x10','39667 19834');
          160  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x9','39667 7934');
          161  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x8','39667 11');
          162  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x7','39667 5');
          163  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x6','39667 242');
          164  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x5','39667 1984');
          165  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x4','39667 4408');
          166  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x3','39667 81');
          167  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x2','39667 551');
          168  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x1','39667 2');
          169  +  INSERT INTO sqlite_stat1 VALUES('t2','t2x0','39667 1');
          170  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x6','569 285');
          171  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x5','569 2');
          172  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x4','569 2');
          173  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x3','569 5');
          174  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x2','569 3');
          175  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x1','569 6');
          176  +  INSERT INTO sqlite_stat1 VALUES('t3','t3x0','569 1');
          177  +  ANALYZE sqlite_master;
          178  +} {}
          179  +do_execsql_test autoindex2-120 {
          180  +  EXPLAIN QUERY PLAN
          181  +  SELECT
          182  +     t1_id,
          183  +     t1.did,
          184  +     param2,
          185  +     param3,
          186  +     t1.ptime,
          187  +     t1.trange,
          188  +     t1.exmass,
          189  +     t1.mass,
          190  +     t1.vstatus,
          191  +     type,
          192  +     subtype,
          193  +     t1.deviation,
          194  +     t1.formula,
          195  +     dparam1,
          196  +     reserve1,
          197  +     reserve2,
          198  +     param4,
          199  +     t1.last_operation,
          200  +     t1.admin_uuid,
          201  +     t1.previous_value,
          202  +     t1.job_id,
          203  +     client_did, 
          204  +     t1.last_t1,
          205  +     t1.data_t1,
          206  +     t1.previous_date,
          207  +     param5,
          208  +     param6,
          209  +     mgr_uuid
          210  +  FROM
          211  +     t1,
          212  +     t2,
          213  +     t3
          214  +  WHERE
          215  +     t1.ptime > 1393520400
          216  +     AND param3<>9001
          217  +     AND t3.flg7 = 1
          218  +     AND t1.did = t2.did
          219  +     AND t2.uid = t3.uid
          220  +  ORDER BY t1.ptime desc LIMIT 500;
          221  +} {0 0 0 {SEARCH TABLE t1 USING INDEX t1x1 (ptime>?)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2x0 (did=?)} 0 2 2 {SEARCH TABLE t3 USING INDEX t3x0 (uid=?)}}
          222  +#
          223  +# ^^^--- Before being fixed, the above was using an automatic covering
          224  +# on t3 and reordering the tables so that t3 was in the outer loop and
          225  +# implementing the ORDER BY clause using a B-Tree.
          226  +
          227  +do_execsql_test autoindex2-120 {
          228  +  EXPLAIN QUERY PLAN
          229  +  SELECT
          230  +     t1_id,
          231  +     t1.did,
          232  +     param2,
          233  +     param3,
          234  +     t1.ptime,
          235  +     t1.trange,
          236  +     t1.exmass,
          237  +     t1.mass,
          238  +     t1.vstatus,
          239  +     type,
          240  +     subtype,
          241  +     t1.deviation,
          242  +     t1.formula,
          243  +     dparam1,
          244  +     reserve1,
          245  +     reserve2,
          246  +     param4,
          247  +     t1.last_operation,
          248  +     t1.admin_uuid,
          249  +     t1.previous_value,
          250  +     t1.job_id,
          251  +     client_did, 
          252  +     t1.last_t1,
          253  +     t1.data_t1,
          254  +     t1.previous_date,
          255  +     param5,
          256  +     param6,
          257  +     mgr_uuid
          258  +  FROM
          259  +     t3,
          260  +     t2,
          261  +     t1
          262  +  WHERE
          263  +     t1.ptime > 1393520400
          264  +     AND param3<>9001
          265  +     AND t3.flg7 = 1
          266  +     AND t1.did = t2.did
          267  +     AND t2.uid = t3.uid
          268  +  ORDER BY t1.ptime desc LIMIT 500;
          269  +} {0 0 2 {SEARCH TABLE t1 USING INDEX t1x1 (ptime>?)} 0 1 1 {SEARCH TABLE t2 USING INDEX t2x0 (did=?)} 0 2 0 {SEARCH TABLE t3 USING INDEX t3x0 (uid=?)}}
          270  +
          271  +finish_test

Added test/autoindex3.test.

            1  +# 2014-06-17
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#*************************************************************************
           11  +#
           12  +# This file implements regression tests for SQLite library.  The
           13  +# focus of this script is testing automatic index creation logic,
           14  +# and specifically that an automatic index will not be created that
           15  +# shadows a declared index.
           16  +#
           17  +
           18  +set testdir [file dirname $argv0]
           19  +source $testdir/tester.tcl
           20  +
           21  +# The t1b and t2d indexes are not very selective.  It used to be that
           22  +# the autoindex mechanism would create automatic indexes on t1(b) or
           23  +# t2(d), make assumptions that they were reasonably selective, and use
           24  +# them instead of t1b or t2d.  But that would be cheating, because the
           25  +# automatic index cannot be any more selective than the real index.
           26  +#
           27  +# This test verifies that the cheat is no longer allowed.
           28  +#
           29  +do_execsql_test autoindex3-100 {
           30  +  CREATE TABLE t1(a,b,x);
           31  +  CREATE TABLE t2(c,d,y);
           32  +  CREATE INDEX t1b ON t1(b);
           33  +  CREATE INDEX t2d ON t2(d);
           34  +  ANALYZE sqlite_master;
           35  +  INSERT INTO sqlite_stat1 VALUES('t1','t1b','10000 500');
           36  +  INSERT INTO sqlite_stat1 VALUES('t2','t2d','10000 500');
           37  +  ANALYZE sqlite_master;
           38  +  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d=b;
           39  +} {~/AUTO/}
           40  +
           41  +# Automatic indexes can still be used if existing indexes do not
           42  +# participate in == constraints.
           43  +#
           44  +do_execsql_test autoindex3-110 {
           45  +  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d>b AND x=y;
           46  +} {/AUTO/}
           47  +do_execsql_test autoindex3-120 {
           48  +  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d<b AND x=y;
           49  +} {/AUTO/}
           50  +do_execsql_test autoindex3-130 {
           51  +  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IS NULL AND x=y;
           52  +} {/AUTO/}
           53  +do_execsql_test autoindex3-140 {
           54  +  EXPLAIN QUERY PLAN SELECT * FROM t1, t2 WHERE d IN (5,b) AND x=y;
           55  +} {/AUTO/}
           56  +
           57  +
           58  +finish_test

Added test/extension01.test.

            1  +# 2014-06-16
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# 
           12  +# This file implements tests for various small extensions.
           13  +#
           14  +
           15  +set testdir [file dirname $argv0]
           16  +source $testdir/tester.tcl
           17  +set ::testprefix extension01
           18  +
           19  +load_static_extension db fileio
           20  +do_test 1.0 {
           21  +  forcedelete file1.txt
           22  +  set out [open ./file1.txt wb]
           23  +  puts -nonewline $out "This is a text file without a line ending"
           24  +  close $out
           25  +  db eval {
           26  +    CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT);
           27  +    INSERT INTO t1 VALUES(1, readfile('./file1.txt'));
           28  +    SELECT * FROM t1;
           29  +  }
           30  +} {1 {This is a text file without a line ending}}
           31  +do_test 1.1 {
           32  +  forcedelete file2.txt
           33  +  db nullvalue nil
           34  +  db eval {
           35  +    DELETE FROM t1;
           36  +    INSERT INTO t1 VALUES(2, readfile(NULL)),(3, readfile('file2.txt'));
           37  +    SELECT a, b, typeof(b) FROM t1;
           38  +  }
           39  +} {2 nil null 3 nil null}
           40  +
           41  +do_test 1.2 {
           42  +  db eval {
           43  +    SELECT writefile('./file2.txt', 'A second test line');
           44  +  }
           45  +} {18}
           46  +do_test 1.3 {
           47  +  set in [open ./file2.txt rb]
           48  +  set x [read $in]
           49  +  close $in
           50  +  list $x [file size file2.txt]
           51  +} {{A second test line} 18}
           52  +
           53  +do_test 1.4 {
           54  +  db eval {
           55  +    SELECT writefile('./file2.txt', NULL);
           56  +  }
           57  +} {0}
           58  +do_test 1.5 {
           59  +  file size ./file2.txt
           60  +} {0}
           61  +
           62  +do_test 1.6 {
           63  +  if {$::tcl_platform(platform)=="unix"} {
           64  +    file attributes ./file2.txt -permissions r--r--r--
           65  +  } else {
           66  +    file attributes ./file2.txt -readonly 1
           67  +  }
           68  +  db eval {
           69  +    SELECT writefile('./file2.txt', 'Another test');
           70  +  }
           71  +} {nil}
           72  +do_test 1.7 {
           73  +  if {$::tcl_platform(platform)=="unix"} {
           74  +    file attributes ./file2.txt -permissions rw-r--r--
           75  +  } else {
           76  +    file attributes ./file2.txt -readonly 0
           77  +  }
           78  +  db eval {
           79  +    SELECT writefile(NULL, 'Another test');
           80  +  }
           81  +} {nil}
           82  +
           83  +finish_test

Changes to test/fts4check.test.

   147    147   } {
   148    148     do_execsql_test  3.2.1.$tn "BEGIN; $disruption"
   149    149     do_catchsql_test 3.2.2.$tn {
   150    150       INSERT INTO t3 (t3) VALUES('integrity-check')
   151    151     } {1 {database disk image is malformed}}
   152    152     do_execsql_test  3.2.3.$tn "ROLLBACK"
   153    153   }
          154  +
          155  +#--------------------------------------------------------------------------
          156  +# Test case 4.*
          157  +#
          158  +# Test that the integrity-check works if there are "notindexed" columns.
          159  +#
          160  +do_execsql_test 4.0 {
          161  +  CREATE VIRTUAL TABLE t4 USING fts4(a, b, c, notindexed=b);
          162  +  INSERT INTO t4 VALUES('text one', 'text two', 'text three');
          163  +  INSERT INTO t4(t4) VALUES('integrity-check');
          164  +}
          165  +
          166  +do_execsql_test 4.1 {
          167  +  PRAGMA writable_schema = 1;
          168  +  UPDATE sqlite_master 
          169  +    SET sql = 'CREATE VIRTUAL TABLE t4 USING fts4(a, b, c)' 
          170  +    WHERE name = 't4';
          171  +}
          172  +
          173  +do_test 4.2 {
          174  +  db close
          175  +  sqlite3 db test.db
          176  +  catchsql {
          177  +    INSERT INTO t4(t4) VALUES('integrity-check');
          178  +  }
          179  +} {1 {database disk image is malformed}}
          180  +reset_db
   154    181   
   155    182   finish_test
          183  +

Changes to test/func3.test.

   145    145     SELECT quote(unlikely(x'010203000405'));
   146    146   } {X'010203000405'}
   147    147   
   148    148   # EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that
   149    149   # the code generator optimizes away so that it consumes no CPU cycles at
   150    150   # run-time (that is, during calls to sqlite3_step()).
   151    151   #
   152         -do_test func3-5.40 {
          152  +do_test func3-5.39 {
   153    153     db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}
   154    154   } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
          155  +
          156  +do_execsql_test func3-5.40 {
          157  +  SELECT likely(9223372036854775807);
          158  +} {9223372036854775807}
          159  +do_execsql_test func3-5.41 {
          160  +  SELECT likely(-9223372036854775808);
          161  +} {-9223372036854775808}
          162  +do_execsql_test func3-5.42 {
          163  +  SELECT likely(14.125);
          164  +} {14.125}
          165  +do_execsql_test func3-5.43 {
          166  +  SELECT likely(NULL);
          167  +} {{}}
          168  +do_execsql_test func3-5.44 {
          169  +  SELECT likely('test-string');
          170  +} {test-string}
          171  +do_execsql_test func3-5.45 {
          172  +  SELECT quote(likely(x'010203000405'));
          173  +} {X'010203000405'}
          174  +do_test func3-5.49 {
          175  +  db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))}
          176  +} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
          177  +
          178  +
   155    179   
   156    180   finish_test

Changes to test/mallocK.test.

    12     12   # This test script checks malloc failures in WHERE clause analysis.
    13     13   # 
    14     14   # $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   source $testdir/malloc_common.tcl
           19  +set testprefix mallocK
    19     20   
    20     21   set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
    21     22   for {set x 1} {$x<5} {incr x} {
    22     23     append sql " AND b=y"
    23     24     do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {
    24     25       CREATE TABLE t1(a,b);
    25     26       CREATE TABLE t2(x,y);
................................................................................
    64     65           CREATE TABLE t1(a,b);
    65     66           CREATE VIRTUAL TABLE t2 USING echo(t1);
    66     67         }
    67     68       }
    68     69     }
    69     70   }
    70     71   
           72  +#-------------------------------------------------------------------------
           73  +# Test that OOM errors are correctly handled by the code that uses stat4
           74  +# data to estimate the number of rows visited by a skip-scan range query.
           75  +#
           76  +add_alignment_test_collations db
           77  +do_execsql_test 6.0 {
           78  +  CREATE TABLE t3(a TEXT, b TEXT COLLATE utf16_aligned, c);
           79  +  INSERT INTO t3 VALUES('one', '.....', 0);
           80  +  INSERT INTO t3 VALUES('one', '....x', 1);
           81  +  INSERT INTO t3 VALUES('one', '...x.', 2);
           82  +  INSERT INTO t3 VALUES('one', '...xx', 3);
           83  +  INSERT INTO t3 VALUES('one', '..x..', 4);
           84  +  INSERT INTO t3 VALUES('one', '..x.x', 5);
           85  +  INSERT INTO t3 VALUES('one', '..xx.', 6);
           86  +  INSERT INTO t3 VALUES('one', '..xxx', 7);
           87  +  INSERT INTO t3 VALUES('one', '.x...', 8);
           88  +  INSERT INTO t3 VALUES('one', '.x..x', 9);
           89  +  INSERT INTO t3 VALUES('one', '.x.x.', 10);
           90  +  INSERT INTO t3 VALUES('one', '.x.xx', 11);
           91  +  INSERT INTO t3 VALUES('one', '.xx..', 12);
           92  +  INSERT INTO t3 VALUES('one', '.xx.x', 13);
           93  +  INSERT INTO t3 VALUES('one', '.xxx.', 14);
           94  +  INSERT INTO t3 VALUES('one', '.xxxx', 15);
           95  +
           96  +  INSERT INTO t3 VALUES('two', 'x....', 16);
           97  +  INSERT INTO t3 VALUES('two', 'x...x', 17);
           98  +  INSERT INTO t3 VALUES('two', 'x..x.', 18);
           99  +  INSERT INTO t3 VALUES('two', 'x..xx', 19);
          100  +  INSERT INTO t3 VALUES('two', 'x.x..', 20);
          101  +  INSERT INTO t3 VALUES('two', 'x.x.x', 21);
          102  +  INSERT INTO t3 VALUES('two', 'x.xx.', 22);
          103  +  INSERT INTO t3 VALUES('two', 'x.xxx', 23);
          104  +  INSERT INTO t3 VALUES('two', 'xx...', 24);
          105  +  INSERT INTO t3 VALUES('two', 'xx..x', 25);
          106  +  INSERT INTO t3 VALUES('two', 'xx.x.', 26);
          107  +  INSERT INTO t3 VALUES('two', 'xx.xx', 27);
          108  +  INSERT INTO t3 VALUES('two', 'xxx..', 28);
          109  +  INSERT INTO t3 VALUES('two', 'xxx.x', 29);
          110  +  INSERT INTO t3 VALUES('two', 'xxxx.', 30);
          111  +  INSERT INTO t3 VALUES('two', 'xxxxx', 31);
          112  +
          113  +  INSERT INTO t3 SELECT * FROM t3;
          114  +
          115  +  CREATE INDEX i3 ON t3(a, b);
          116  +  ANALYZE;
          117  +
          118  +  SELECT 'x' > '.';
          119  +} {1}
          120  +
          121  +ifcapable stat4 {
          122  +  do_eqp_test 6.1 {
          123  +    SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx';
          124  +  } {
          125  +    0 0 0 {SEARCH TABLE t3 USING INDEX i3 (ANY(a) AND b>? AND b<?)} 
          126  +    0 0 0 {USE TEMP B-TREE FOR DISTINCT}
          127  +  }
          128  +}
          129  +
          130  +do_faultsim_test 6 -faults oom* -body {
          131  +  db cache flush
          132  +  db eval { SELECT DISTINCT c FROM t3 WHERE b BETWEEN '.xx..' AND '.xxxx' }
          133  +} -test {
          134  +  faultsim_test_result {0 {12 13 14 15}} 
          135  +}
    71    136   
    72    137   finish_test
          138  +

Changes to test/shell5.test.

   352    352   .mode csv
   353    353   CREATE TABLE t4(a, b);
   354    354   .import shell5.csv t4
   355    355     }]
   356    356     db eval { SELECT * FROM t4 }
   357    357   } {xy\" hello}
   358    358   
          359  +do_test shell5-2.5 {
          360  +  set fd [open shell5.csv w]
          361  +  puts $fd {"one","2"}
          362  +  puts $fd {}
          363  +  close $fd
          364  +  catchcmd test.db [string trim {
          365  +.mode csv
          366  +CREATE TABLE t4(a, b);
          367  +.import shell5.csv t4
          368  +  }]
          369  +  db eval { SELECT * FROM t4 }
          370  +} {xy\" hello one 2 {} {}}
   359    371   
   360    372   
   361    373   finish_test

Added test/skipscan5.test.

            1  +# 2013-11-13
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# This file implements tests of the "skip-scan" query strategy. In 
           13  +# particular it tests that stat4 data can be used by a range query
           14  +# that uses the skip-scan approach.
           15  +#
           16  +
           17  +set testdir [file dirname $argv0]
           18  +source $testdir/tester.tcl
           19  +set testprefix skipscan5
           20  +
           21  +ifcapable !stat4 {
           22  +  finish_test
           23  +  return
           24  +}
           25  +
           26  +do_execsql_test 1.1 {
           27  +  CREATE TABLE t1(a INT, b INT, c INT);
           28  +  CREATE INDEX i1 ON t1(a, b);
           29  +} {}
           30  +
           31  +expr srand(4)
           32  +do_test 1.2 {
           33  +  for {set i 0} {$i < 100} {incr i} {
           34  +    set a [expr int(rand()*4.0) + 1]
           35  +    set b [expr int(rand()*20.0) + 1]
           36  +    execsql { INSERT INTO t1 VALUES($a, $b, NULL) }
           37  +  }
           38  +  execsql ANALYZE
           39  +} {}
           40  +
           41  +foreach {tn q res} {
           42  +  1  "b = 5"                   {/*ANY(a) AND b=?*/}
           43  +  2  "b > 12 AND b < 16"       {/*ANY(a) AND b>? AND b<?*/}
           44  +  3  "b > 2 AND b < 16"        {/*SCAN TABLE t1*/}
           45  +  4  "b > 18 AND b < 25"       {/*ANY(a) AND b>? AND b<?*/}
           46  +  5  "b > 15"                  {/*ANY(a) AND b>?*/}
           47  +  6  "b > 5"                   {/*SCAN TABLE t1*/}
           48  +  7  "b < 15"                  {/*SCAN TABLE t1*/}
           49  +  8  "b < 5"                   {/*ANY(a) AND b<?*/}
           50  +  9  "5 > b"                   {/*ANY(a) AND b<?*/}
           51  +  10 "b = '5'"                 {/*ANY(a) AND b=?*/}
           52  +  11 "b > '12' AND b < '16'"   {/*ANY(a) AND b>? AND b<?*/}
           53  +  12 "b > '2' AND b < '16'"    {/*SCAN TABLE t1*/}
           54  +  13 "b > '18' AND b < '25'"   {/*ANY(a) AND b>? AND b<?*/}
           55  +  14 "b > '15'"                {/*ANY(a) AND b>?*/}
           56  +  15 "b > '5'"                 {/*SCAN TABLE t1*/}
           57  +  16 "b < '15'"                {/*SCAN TABLE t1*/}
           58  +  17 "b < '5'"                 {/*ANY(a) AND b<?*/}
           59  +  18 "'5' > b"                 {/*ANY(a) AND b<?*/}
           60  +} {
           61  +  set sql "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE $q"
           62  +  do_execsql_test 1.3.$tn $sql $res
           63  +}
           64  +
           65  +
           66  +#-------------------------------------------------------------------------
           67  +# Test that range-query/skip-scan estimation works with text values.
           68  +# And on UTF-16 databases when there is no UTF-16 collation sequence
           69  +# available.
           70  +#
           71  +
           72  +proc test_collate {enc lhs rhs} {
           73  +  string compare $lhs $rhs
           74  +}
           75  +
           76  +foreach {tn dbenc coll} {
           77  +  1 UTF-8   { add_test_collate db 0 0 1 }
           78  +  2 UTF-16  { add_test_collate db 1 0 0 }
           79  +  3 UTF-8   { add_test_collate db 0 1 0 }
           80  +} {
           81  +  reset_db
           82  +  eval $coll
           83  +
           84  +  do_execsql_test 2.$tn.1 " PRAGMA encoding = '$dbenc' "
           85  +  do_execsql_test 2.$tn.2 {
           86  +    CREATE TABLE t2(a TEXT, b TEXT, c TEXT COLLATE test_collate, d TEXT);
           87  +    CREATE INDEX i2 ON t2(a, b, c);
           88  +  }
           89  +
           90  +  set vocab(d) { :) }
           91  +  set vocab(c) { a b c d e f g h i j k l m n o p q r s t }
           92  +  set vocab(b) { one two three }
           93  +  set vocab(a) { sql }
           94  +
           95  +  do_test 2.$tn.3 {
           96  +    for {set i 0} {$i < 100} {incr i} {
           97  +      foreach var {a b c d} { 
           98  +        set $var [lindex $vocab($var) [expr $i % [llength $vocab($var)]]]
           99  +      }
          100  +      execsql { INSERT INTO t2 VALUES($a, $b, $c, $d) }
          101  +    }
          102  +    execsql ANALYZE
          103  +  } {}
          104  +
          105  +  foreach {tn2 q res} {
          106  +    1 { c BETWEEN 'd' AND 'e' }       {/*ANY(a) AND ANY(b) AND c>? AND c<?*/}
          107  +    2 { c BETWEEN 'b' AND 'r' }       {/*SCAN TABLE t2*/}
          108  +    3 { c > 'q' }                     {/*ANY(a) AND ANY(b) AND c>?*/}
          109  +    4 { c > 'e' }                     {/*SCAN TABLE t2*/}
          110  +    5 { c < 'q' }                     {/*SCAN TABLE t2*/}
          111  +    4 { c < 'e' }                     {/*ANY(a) AND ANY(b) AND c<?*/}
          112  +  } {
          113  +    set sql "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE $q" 
          114  +    do_execsql_test 2.$tn.$tn2 $sql $res
          115  +  }
          116  +
          117  +}
          118  +
          119  +#-------------------------------------------------------------------------
          120  +# Test that range-query/skip-scan estimation works on columns that contain
          121  +# a variety of types.
          122  +#
          123  +
          124  +reset_db
          125  +do_execsql_test 3.1 {
          126  +  CREATE TABLE t3(a, b, c);
          127  +  CREATE INDEX i3 ON t3(a, b);
          128  +}
          129  +
          130  +set values {
          131  +    NULL NULL NULL
          132  +    NULL -9567 -9240
          133  +    -8725 -8659 -8248.340244520614
          134  +    -8208 -7939 -7746.985758536954
          135  +    -7057 -6550 -5916
          136  +    -5363 -4935.781822975623 -4935.063633571875
          137  +    -3518.4554911770183 -2537 -2026
          138  +    -1511.2603881914456 -1510.4195994839156 -1435
          139  +    -1127.4210136045804 -1045 99
          140  +    1353 1457 1563.2908193223611
          141  +    2245 2286 2552
          142  +    2745.18831295203 2866.279926554429 3075.0468527316334
          143  +    3447 3867 4237.892420141907
          144  +    4335 5052.9775000424015 5232.178240656935
          145  +    5541.784919585003 5749.725576373621 5758
          146  +    6005 6431 7263.477992854769
          147  +    7441 7541 8667.279760663994
          148  +    8857 9199.638673662972 'dl'
          149  +    'dro' 'h' 'igprfq'
          150  +    'jnbd' 'k' 'kordee'
          151  +    'lhwcv' 'mzlb' 'nbjked'
          152  +    'nufpo' 'nxqkdq' 'shelln'
          153  +    'tvzn' 'wpnt' 'wylf'
          154  +    'ydkgu' 'zdb' X''
          155  +    X'0a' X'203f6429f1f33f' X'23858e324545e0362b'
          156  +    X'3f9f8a' X'516f7ddd4b' X'68f1df0930ac6b'
          157  +    X'9ea60d' X'a06f' X'aefd342a39ce36df'
          158  +    X'afaa020fe2' X'be201c' X'c47d97b209601e45'
          159  +}
          160  +
          161  +do_test 3.2 {
          162  +  set c 0
          163  +  foreach v $values {
          164  +    execsql "INSERT INTO t3 VALUES($c % 2, $v, $c)"
          165  +    incr c
          166  +  }
          167  +  execsql ANALYZE
          168  +} {}
          169  +
          170  +foreach {tn q res} {
          171  +  1 "b BETWEEN -10000 AND -8000"       {/*ANY(a) AND b>? AND b<?*/}
          172  +  2 "b BETWEEN -10000 AND 'qqq'"       {/*SCAN TABLE t3*/}
          173  +  3 "b < X'5555'"                      {/*SCAN TABLE t3*/}
          174  +  4 "b > X'5555'"                      {/*ANY(a) AND b>?*/}
          175  +  5 "b > 'zzz'"                        {/*ANY(a) AND b>?*/}
          176  +  6 "b < 'zzz'"                        {/*SCAN TABLE t3*/}
          177  +} {
          178  +  set sql "EXPLAIN QUERY PLAN SELECT * FROM t3 WHERE $q" 
          179  +  do_execsql_test 3.3.$tn $sql $res
          180  +}
          181  +
          182  +finish_test
          183  +
          184  +
          185  +
          186  +

Added test/tkt-9a8b09f8e6.test.

            1  +# 2014 June 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.
           12  +#
           13  +# This file implements tests to verify that ticket [9a8b09f8e6] has been
           14  +# fixed.
           15  +#
           16  +
           17  +set testdir [file dirname $argv0]
           18  +source $testdir/tester.tcl
           19  +set testprefix tkt-9a8b09f8e6
           20  +
           21  +do_test 1.1 {
           22  +  execsql {
           23  +    CREATE TABLE t1(x TEXT);
           24  +    INSERT INTO t1 VALUES('1');
           25  +  }
           26  +} {}
           27  +
           28  +do_test 1.2 {
           29  +  execsql {
           30  +    CREATE TABLE t2(x INTEGER);
           31  +    INSERT INTO t2 VALUES(1);
           32  +  }
           33  +} {}
           34  +
           35  +do_test 1.3 {
           36  +  execsql {
           37  +    CREATE TABLE t3(x REAL);
           38  +    INSERT INTO t3 VALUES(1.0);
           39  +  }
           40  +} {}
           41  +
           42  +do_test 1.4 {
           43  +  execsql {
           44  +    CREATE TABLE t4(x REAL);
           45  +    INSERT INTO t4 VALUES(1.11);
           46  +  }
           47  +} {}
           48  +
           49  +do_test 1.5 {
           50  +  execsql {
           51  +    CREATE TABLE t5(x, y);
           52  +    INSERT INTO t5 VALUES('1', 'one');
           53  +    INSERT INTO t5 VALUES(1, 'two');
           54  +    INSERT INTO t5 VALUES('1.0', 'three');
           55  +    INSERT INTO t5 VALUES(1.0, 'four');
           56  +  }
           57  +} {}
           58  +
           59  +do_test 2.1 {
           60  +  execsql {
           61  +    SELECT x FROM t1 WHERE x IN (1);
           62  +  }
           63  +} {1}
           64  +
           65  +do_test 2.2 {
           66  +  execsql {
           67  +    SELECT x FROM t1 WHERE x IN (1.0);
           68  +  }
           69  +} {}
           70  +
           71  +do_test 2.3 {
           72  +  execsql {
           73  +    SELECT x FROM t1 WHERE x IN ('1');
           74  +  }
           75  +} {1}
           76  +
           77  +do_test 2.4 {
           78  +  execsql {
           79  +    SELECT x FROM t1 WHERE x IN ('1.0');
           80  +  }
           81  +} {}
           82  +
           83  +do_test 2.5 {
           84  +  execsql {
           85  +    SELECT x FROM t1 WHERE 1 IN (x);
           86  +  }
           87  +} {}
           88  +
           89  +do_test 2.6 {
           90  +  execsql {
           91  +    SELECT x FROM t1 WHERE 1.0 IN (x);
           92  +  }
           93  +} {}
           94  +
           95  +do_test 2.7 {
           96  +  execsql {
           97  +    SELECT x FROM t1 WHERE '1' IN (x);
           98  +  }
           99  +} {1}
          100  +
          101  +do_test 2.8 {
          102  +  execsql {
          103  +    SELECT x FROM t1 WHERE '1.0' IN (x);
          104  +  }
          105  +} {}
          106  +
          107  +do_test 3.1 {
          108  +  execsql {
          109  +    SELECT x FROM t2 WHERE x IN (1);
          110  +  }
          111  +} {1}
          112  +
          113  +do_test 3.2 {
          114  +  execsql {
          115  +    SELECT x FROM t2 WHERE x IN (1.0);
          116  +  }
          117  +} {1}
          118  +
          119  +do_test 3.3 {
          120  +  execsql {
          121  +    SELECT x FROM t2 WHERE x IN ('1');
          122  +  }
          123  +} {1}
          124  +
          125  +do_test 3.4 {
          126  +  execsql {
          127  +    SELECT x FROM t2 WHERE x IN ('1.0');
          128  +  }
          129  +} {1}
          130  +
          131  +do_test 3.5 {
          132  +  execsql {
          133  +    SELECT x FROM t2 WHERE 1 IN (x);
          134  +  }
          135  +} {1}
          136  +
          137  +do_test 3.6 {
          138  +  execsql {
          139  +    SELECT x FROM t2 WHERE 1.0 IN (x);
          140  +  }
          141  +} {1}
          142  +
          143  +do_test 3.7 {
          144  +  execsql {
          145  +    SELECT x FROM t2 WHERE '1' IN (x);
          146  +  }
          147  +} {}
          148  +
          149  +do_test 3.8 {
          150  +  execsql {
          151  +    SELECT x FROM t2 WHERE '1.0' IN (x);
          152  +  }
          153  +} {}
          154  +
          155  +do_test 4.1 {
          156  +  execsql {
          157  +    SELECT x FROM t3 WHERE x IN (1);
          158  +  }
          159  +} {1.0}
          160  +
          161  +do_test 4.2 {
          162  +  execsql {
          163  +    SELECT x FROM t3 WHERE x IN (1.0);
          164  +  }
          165  +} {1.0}
          166  +
          167  +do_test 4.3 {
          168  +  execsql {
          169  +    SELECT x FROM t3 WHERE x IN ('1');
          170  +  }
          171  +} {1.0}
          172  +
          173  +do_test 4.4 {
          174  +  execsql {
          175  +    SELECT x FROM t3 WHERE x IN ('1.0');
          176  +  }
          177  +} {1.0}
          178  +
          179  +do_test 4.5 {
          180  +  execsql {
          181  +    SELECT x FROM t3 WHERE 1 IN (x);
          182  +  }
          183  +} {1.0}
          184  +
          185  +do_test 4.6 {
          186  +  execsql {
          187  +    SELECT x FROM t3 WHERE 1.0 IN (x);
          188  +  }
          189  +} {1.0}
          190  +
          191  +do_test 4.7 {
          192  +  execsql {
          193  +    SELECT x FROM t3 WHERE '1' IN (x);
          194  +  }
          195  +} {}
          196  +
          197  +do_test 4.8 {
          198  +  execsql {
          199  +    SELECT x FROM t3 WHERE '1.0' IN (x);
          200  +  }
          201  +} {}
          202  +
          203  +do_test 5.1 {
          204  +  execsql {
          205  +    SELECT x FROM t4 WHERE x IN (1);
          206  +  }
          207  +} {}
          208  +
          209  +do_test 5.2 {
          210  +  execsql {
          211  +    SELECT x FROM t4 WHERE x IN (1.0);
          212  +  }
          213  +} {}
          214  +
          215  +do_test 5.3 {
          216  +  execsql {
          217  +    SELECT x FROM t4 WHERE x IN ('1');
          218  +  }
          219  +} {}
          220  +
          221  +do_test 5.4 {
          222  +  execsql {
          223  +    SELECT x FROM t4 WHERE x IN ('1.0');
          224  +  }
          225  +} {}
          226  +
          227  +do_test 5.5 {
          228  +  execsql {
          229  +    SELECT x FROM t4 WHERE x IN (1.11);
          230  +  }
          231  +} {1.11}
          232  +
          233  +do_test 5.6 {
          234  +  execsql {
          235  +    SELECT x FROM t4 WHERE x IN ('1.11');
          236  +  }
          237  +} {1.11}
          238  +
          239  +do_test 5.7 {
          240  +  execsql {
          241  +    SELECT x FROM t4 WHERE 1 IN (x);
          242  +  }
          243  +} {}
          244  +
          245  +do_test 5.8 {
          246  +  execsql {
          247  +    SELECT x FROM t4 WHERE 1.0 IN (x);
          248  +  }
          249  +} {}
          250  +
          251  +do_test 5.9 {
          252  +  execsql {
          253  +    SELECT x FROM t4 WHERE '1' IN (x);
          254  +  }
          255  +} {}
          256  +
          257  +do_test 5.10 {
          258  +  execsql {
          259  +    SELECT x FROM t4 WHERE '1.0' IN (x);
          260  +  }
          261  +} {}
          262  +
          263  +do_test 5.11 {
          264  +  execsql {
          265  +    SELECT x FROM t4 WHERE 1.11 IN (x);
          266  +  }
          267  +} {1.11}
          268  +
          269  +do_test 5.12 {
          270  +  execsql {
          271  +    SELECT x FROM t4 WHERE '1.11' IN (x);
          272  +  }
          273  +} {}
          274  +
          275  +do_test 6.1 {
          276  +  execsql {
          277  +    SELECT x, y FROM t5 WHERE x IN (1);
          278  +  }
          279  +} {1 two 1.0 four}
          280  +
          281  +do_test 6.2 {
          282  +  execsql {
          283  +    SELECT x, y FROM t5 WHERE x IN (1.0);
          284  +  }
          285  +} {1 two 1.0 four}
          286  +
          287  +do_test 6.3 {
          288  +  execsql {
          289  +    SELECT x, y FROM t5 WHERE x IN ('1');
          290  +  }
          291  +} {1 one}
          292  +
          293  +do_test 6.4 {
          294  +  execsql {
          295  +    SELECT x, y FROM t5 WHERE x IN ('1.0');
          296  +  }
          297  +} {1.0 three}
          298  +
          299  +do_test 6.5 {
          300  +  execsql {
          301  +    SELECT x, y FROM t5 WHERE 1 IN (x);
          302  +  }
          303  +} {1 two 1.0 four}
          304  +
          305  +do_test 6.6 {
          306  +  execsql {
          307  +    SELECT x, y FROM t5 WHERE 1.0 IN (x);
          308  +  }
          309  +} {1 two 1.0 four}
          310  +
          311  +do_test 6.7 {
          312  +  execsql {
          313  +    SELECT x, y FROM t5 WHERE '1' IN (x);
          314  +  }
          315  +} {1 one}
          316  +
          317  +do_test 6.8 {
          318  +  execsql {
          319  +    SELECT x, y FROM t5 WHERE '1.0' IN (x);
          320  +  }
          321  +} {1.0 three}
          322  +
          323  +finish_test

Changes to test/tpch01.test.

   164    164                  o_year
   165    165          order by
   166    166                  o_year;}]
   167    167     set ::eqpres
   168    168   } {/0 0 0 {SEARCH TABLE part USING INDEX bootleg_pti .P_TYPE=..} 0 1 2 {SEARCH TABLE lineitem USING INDEX lpki2 .L_PARTKEY=..}.*/}
   169    169   do_test tpch01-1.1b {
   170    170     set ::eqpres
   171         -} {/.* customer .* nation AS n1 .* nation AS n2 .*/}
          171  +} {/.* customer .* nation AS n1 .*/}
          172  +do_test tpch01-1.1c {
          173  +  set ::eqpres
          174  +} {/.* supplier .* nation AS n2 .*/}
   172    175   
   173    176   do_eqp_test tpch01-1.2 {
   174    177   select
   175    178       c_custkey,    c_name,    sum(l_extendedprice * (1 - l_discount)) as revenue,
   176    179       c_acctbal,    n_name,    c_address,    c_phone,    c_comment
   177    180   from
   178    181       customer,    orders,    lineitem,    nation
................................................................................
   181    184       and o_orderdate >=  '1994-08-01'    and o_orderdate < date('1994-08-01', '+3 month')
   182    185       and l_returnflag = 'R'    and c_nationkey = n_nationkey
   183    186   group by
   184    187       c_custkey,    c_name,    c_acctbal,    c_phone,    n_name, c_address,    c_comment
   185    188   order by
   186    189       revenue desc;
   187    190   } {0 0 1 {SEARCH TABLE orders USING INDEX odi (O_ORDERDATE>? AND O_ORDERDATE<?)} 0 1 0 {SEARCH TABLE customer USING INDEX cpki (C_CUSTKEY=?)} 0 2 3 {SEARCH TABLE nation USING INDEX npki (N_NATIONKEY=?)} 0 3 2 {SEARCH TABLE lineitem USING INDEX lpki (L_ORDERKEY=?)} 0 0 0 {USE TEMP B-TREE FOR GROUP BY} 0 0 0 {USE TEMP B-TREE FOR ORDER BY}}
          191  +
          192  +finish_test

Changes to test/whereG.test.

     5      5   #
     6      6   #    May you do good and not evil.
     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # 
    12         -# Test cases for query planning decisions and the unlikely() and
           12  +# Test cases for query planning decisions and the likely(), unlikely(), and
    13     13   # likelihood() functions.
    14     14   
    15     15   set testdir [file dirname $argv0]
    16     16   source $testdir/tester.tcl
    17     17   set testprefix whereG
    18     18   
    19     19   do_execsql_test whereG-1.0 {
................................................................................
   195    195   }
   196    196   do_eqp_test 5.1.2 {
   197    197     SELECT * FROM t1 WHERE a>?
   198    198   } {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a>?)}}
   199    199   do_eqp_test 5.1.3 {
   200    200     SELECT * FROM t1 WHERE likelihood(a>?, 0.9)
   201    201   } {0 0 0 {SCAN TABLE t1}}
          202  +do_eqp_test 5.1.4 {
          203  +  SELECT * FROM t1 WHERE likely(a>?)
          204  +} {0 0 0 {SCAN TABLE t1}}
   202    205   
   203    206   do_test 5.2 {
   204    207     for {set i 0} {$i < 100} {incr i} {
   205    208       execsql { INSERT INTO t1 VALUES('abc', $i, $i); }
   206    209     }
   207    210     execsql { INSERT INTO t1 SELECT 'def', b, c FROM t1; }
   208    211     execsql { ANALYZE }
................................................................................
   209    212   } {}
   210    213   do_eqp_test 5.2.2 {
   211    214     SELECT * FROM t1 WHERE likelihood(b>?, 0.01)
   212    215   } {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (ANY(a) AND b>?)}}
   213    216   do_eqp_test 5.2.3 {
   214    217     SELECT * FROM t1 WHERE likelihood(b>?, 0.9)
   215    218   } {0 0 0 {SCAN TABLE t1}}
          219  +do_eqp_test 5.2.4 {
          220  +  SELECT * FROM t1 WHERE likely(b>?)
          221  +} {0 0 0 {SCAN TABLE t1}}
   216    222   
   217    223   do_eqp_test 5.3.1 {
   218    224     SELECT * FROM t1 WHERE a=?
   219    225   } {0 0 0 {SEARCH TABLE t1 USING INDEX i1 (a=?)}}
   220    226   do_eqp_test 5.3.2 {
   221    227     SELECT * FROM t1 WHERE likelihood(a=?, 0.9)
   222    228   } {0 0 0 {SCAN TABLE t1}}
          229  +do_eqp_test 5.3.3 {
          230  +  SELECT * FROM t1 WHERE likely(a=?)
          231  +} {0 0 0 {SCAN TABLE t1}}
   223    232   
   224    233   finish_test
   225         -

Added test/whereJ.test.

            1  +# 2014-06-06
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# 
           12  +# This file implements a single regression test for a complex
           13  +# query planning case.
           14  +#
           15  +
           16  +set testdir [file dirname $argv0]
           17  +source $testdir/tester.tcl
           18  +set ::testprefix whereJ
           19  +
           20  +ifcapable !stat4 {
           21  +  finish_test
           22  +  return
           23  +}
           24  +
           25  +do_execsql_test whereJ-1.0 {
           26  +  CREATE TABLE tx1 (
           27  +    est,
           28  +    cid,
           29  +    sid,	
           30  +    fid,
           31  +    aid,
           32  +    edate,
           33  +    rstat,
           34  +    ftype,
           35  +    cx,
           36  +    fyear,
           37  +    fp,
           38  +    acode,
           39  +    a1,
           40  +    curx,
           41  +    tdate,
           42  +    gstat,
           43  +    trgtpx,
           44  +    effdate,
           45  +    adate,
           46  +    ytime,
           47  +    mstat
           48  +  );
           49  +  CREATE INDEX ix0 on tx1(a1,curx,aid,cid,sid,ftype,fp,fyear DESC,edate DESC,fid);
           50  +  CREATE INDEX ix1 on tx1(a1,curx,aid,ftype,fp,fyear DESC,fid,edate DESC,cid,sid);
           51  +  CREATE INDEX ix2 on tx1(a1,curx,cid,sid,ftype,fp,fyear DESC,edate DESC,aid,fid);
           52  +  CREATE INDEX ix3 on tx1(a1,curx,fid,ftype,fp,fyear DESC,cid,sid,aid,edate DESC);
           53  +  CREATE INDEX ix4 on tx1(a1,curx,ftype,cid,sid,aid,edate DESC,fid,fp,fyear DESC);
           54  +  CREATE INDEX ix5 on tx1(a1,curx,ftype,aid,fid,cid,sid,edate DESC,fp,fyear DESC);
           55  +  CREATE INDEX ix6 on tx1(ftype,fp,fyear DESC,cid,sid,edate DESC,a1,fid,aid,curx,est,rstat,cx,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);
           56  +  CREATE INDEX ix7 on tx1(cid,a1,curx,sid,ftype,est,fid,aid,edate,rstat,cx,fyear,fp,acode,tdate,gstat,trgtpx,effdate,adate,ytime,mstat);
           57  +  CREATE INDEX ix8 on tx1(cid,sid,edate DESC,aid,est);
           58  +  CREATE INDEX ix9 on tx1(aid,edate DESC,a1,curx);
           59  +} {}
           60  +do_execsql_test whereJ-1.1 {
           61  +  ANALYZE sqlite_master;
           62  +  DELETE FROM sqlite_stat1;
           63  +  DELETE FROM sqlite_stat4;
           64  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix9','11680827 289 2 2 2');
           65  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix8','11680827 286 250 2 2 2');
           66  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix7','11680827 286 194 98 88 83 18 7 6 2 2 2 2 2 2 2 2 2 2 2 2 2');
           67  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix6','11680827 5840414 5840414 5840414 240 212 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2');
           68  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix5','11680827 5840414 2920207 1668690 114 90 8 8 2 2 2');
           69  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix4','11680827 5840414 2920207 1668690 92 83 9 2 2 2 2');
           70  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix3','11680827 5840414 2920207 2048 1835 1835 1835 12 11 8 2');
           71  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix2','11680827 5840414 2920207 98 88 83 83 83 2 2 2');
           72  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix1','11680827 5840414 2920207 117 114 114 114 90 2 2 2');
           73  +  INSERT INTO sqlite_stat1 VALUES('tx1','ix0','11680827 5840414 2920207 117 9 9 9 9 9 2 2');
           74  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6736 21 21 21 1','29210 29404 29404 29404 29424','44 12184 13020 13079 29424',X'06030409080416C1150133512800B01FCA');
           75  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6658 24 21 21 1','452220 453273 453276 453276 453296','622 226258 235279 236774 453296',X'06030409080416F34501332ADC00AA1BD3');
           76  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','820 2 2 2 1','1297771 1297869 1297869 1297869 1297869','1964 681724 711020 715822 1297869',X'06030409080317875501332C6C55AF4D');
           77  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','26985 2216 2216 2216 1','1797607 1797782 1797782 1797782 1799997','3162 970307 1008879 1016089 1799997',X'0603040809041A08040132401A0099A334');
           78  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','10434 19 17 17 1','2118117 2120403 2120405 2120405 2120421','3815 1136110 1181459 1190207 2120421',X'0603040908041AD36901332CD000861A2F');
           79  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','437 1 1 1 1','2595414 2595739 2595739 2595739 2595739','5005 1409452 1464066 1475163 2595739',X'0603040808031CE7FD01317FD46BFBCC');
           80  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','12619 38 38 38 1','2595957 2600212 2600212 2600212 2600249','5007 1410347 1464961 1476068 2600249',X'0603040808041CE87E01328F61008CE96A');
           81  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7534 23 18 18 1','3329985 3334890 3334895 3334895 3334912','6901 1834013 1902216 1917268 3334912',X'060304090804244E1901328F59008CAA39');
           82  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','5693 1 1 1 1','3891665 3893609 3893609 3893609 3893609','8357 2164400 2245393 2263185 3893609',X'0603040808043063B70132B66800A28A43');
           83  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','44405 2588 2223 1527 1','4220255 4221633 4221998 4222694 4224220','9221 2354858 2441973 2461511 4224220',X'0603040909043377630133517A00B0DE4F');
           84  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6883 32 28 28 1','4423918 4429926 4429930 4429930 4429957','9690 2452276 2543443 2563995 4429957',X'06030409080434F46801328F5C008CC3DA');
           85  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6974 27 26 26 1','5048404 5051129 5051130 5051130 5051155','11703 2817010 2920184 2944013 5051155',X'0603040908043C1C5C0132DEA5009F7473');
           86  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','476 2 2 2 1','5191322 5191479 5191479 5191479 5191479','12242 2901130 3006663 3031222 5191479',X'0603040908033DC6080132DEA478849A');
           87  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','627 4 4 4 1','6488823 6489349 6489349 6489349 6489349','16423 3644815 3778857 3809866 6489349',X'0603040808035AA00E0131F4AE342150');
           88  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','145 2 2 1 1','7787091 7787218 7787218 7787219 7787219','20223 4343720 4510110 4547961 7787219',X'0603040809037254890132189C703706');
           89  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','20 1 1 1 1','9085074 9085089 9085089 9085089 9085089','25315 5033102 5230788 5275692 9085089',X'06040408080300EAE6CA01326657620652');
           90  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','229621 6135 5934 5934 1','9507353 9572696 9572696 9572696 9576801','27189 5255584 5463962 5511784 9576801',X'06040408080300F2FA440132DF1A7D1A60');
           91  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','6376 24 22 22 1','10381524 10382938 10382940 10382940 10382959','30519 5581705 5804515 5856651 10382959',X'06040409080400F9DBF3013305AC00A688A4');
           92  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','7761 45 9 9 1','10569039 10572476 10572512 10572512 10572520','31455 5661599 5888691 5941811 10572520',X'06040409080400FB31560132DDD800A05DF5');
           93  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','8382 37 37 37 1','10866664 10867565 10867565 10867565 10867601','33475 5809193 6042611 6097741 10867601',X'06040409080400FFA4A701332A0E00A93957');
           94  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','76136 4099 3018 3018 1','11283107 11308143 11309224 11309224 11312241','37001 6022861 6264510 6322923 11312241',X'060404090804010B0A5C0133517200B0E8E0');
           95  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','23472 2188 2188 2181 1','11365285 11380281 11380281 11380288 11382468','37055 6026680 6268909 6327509 11382468',X'060404080904010B3C6701332B2E00AA4374');
           96  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','59591 4087 4073 4 1','11415316 11448759 11448773 11452842 11452845','37350 6040743 6283483 6342389 11452845',X'060404090904010BFA810133512800B010AE');
           97  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix9','43891 3029 3021 4 1','11598477 11622881 11622889 11625906 11625909','39110 6107644 6353109 6413914 11625909',X'0604040909040113B9960133512800B01235');
           98  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7340 4977 19 1 1 1','206533 206533 208739 208757 208757 208757','125 164 111403 207397 207399 208757',X'070308040407030187840132B54B0101A0D1401C0000000000004C87E5');
           99  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8877 8788 45 1 1 1','1221375 1221375 1224509 1224553 1224553 1224553','931 1117 679933 1216705 1216722 1224553',X'07030804040703018D3F0133023D010B9B67401C0000000000007A99EF');
          100  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7204 7204 39 1 1 1','1240162 1240162 1242572 1242610 1242610 1242610','942 1131 688420 1234655 1234672 1242610',X'07030804040703018D4F0132DB820105D324401C0000000000007EC569');
          101  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9608 9608 44 1 1 1','1264939 1264939 1266529 1266572 1266572 1266572','952 1145 699518 1258423 1258440 1266572',X'07030804040704018D61013305B9010D3CEB406E8000000000000081E17A');
          102  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','6636 6636 1 1 1 1','1294580 1294580 1297869 1297869 1297869 1297869','964 1159 713121 1289522 1289540 1297869',X'07030804030704018D7801328F693482A2403400000000000000A26728');
          103  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7822 6629 26 1 1 1','2375708 2375708 2381333 2381358 2381358 2381358','3423 3833 1371902 2366527 2366559 2381358',X'0703080403070301B1F501317F16403B7B403F00000000000060D67A');
          104  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1403 1303 5 1 1 1','2594767 2594767 2595737 2595739 2595739 2595739','3914 4427 1512042 2580073 2580114 2595739',X'0703080403070301B6480131CC18558082407120000000000029CC12');
          105  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7901 6067 26 1 1 1','3424107 3424107 3425939 3425964 3425964 3425964','5872 6630 2032411 3406550 3406594 3425964',X'0703080404070401C3F90132B7A100FDCC04403E00000000000000A014CE');
          106  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7483 6161 22 1 1 1','3549446 3549446 3555223 3555244 3555244 3555244','5932 6752 2099309 3535259 3535304 3555244',X'0703080403070301C4490131573F4104F8403400000000000067FD1E');
          107  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','12076 8263 37 1 1 1','3558079 3558079 3560036 3560072 3560072 3560072','5935 6758 2101989 3540078 3540123 3560072',X'0703080404070301C44E0132DD0901076DA9404200000000000076F994');
          108  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1123 1113 1 1 1 1','3892913 3892913 3893609 3893609 3893609 3893609','6594 7611 2305483 3871711 3871770 3893609',X'0703080403070301CA280131CA1C215083401C00000000000071F6B2');
          109  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9344 7315 41 1 1 1','4213510 4213510 4219434 4219474 4219474 4219474','7200 8390 2503024 4196141 4196204 4219474',X'0703080404070301CE8C01317DE800FE4E8B4034000000000000458317');
          110  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8062 3291 1 1 1 1','5037060 5037060 5040350 5040350 5040350 5040350','10201 11915 3045602 5012912 5012997 5040350',X'070308040307030213B20130B83A16DF86403600000000000028F8CD');
          111  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','9125 2926 1 1 1 1','5046490 5052665 5055590 5055590 5055590 5055590','10203 11926 3055524 5028097 5028182 5055590',X'070302040307030213B5232A013107F01745AF40330000000000002B57DE');
          112  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','591 591 1 1 1 1','5190991 5190991 5191479 5191479 5191479 5191479','10649 12426 3145181 5163206 5163296 5191479',X'070308040307030244AD0131315217C1CD401C00000000000003BC32');
          113  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 4689 1 1 1 1','6112248 6112248 6116936 6116936 6116936 6116936','13780 16308 3748958 6083681 6083797 6116936',X'0703080403070402A9D1013108B531A21C401C0000000000000092F5C6');
          114  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7569 7381 28 1 1 1','6280084 6280084 6281842 6281869 6281869 6281869','14559 17217 3856803 6247722 6247841 6281869',X'0703080404070302C14C0132DBF101044CC7401C00000000000074FB16');
          115  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','8289 7047 28 1 1 1','6290764 6290764 6296854 6296881 6296881 6296881','14569 17229 3863206 6262658 6262777 6296881',X'0703080403070302C16401317CC348B670401C0000000000006824BB');
          116  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2209 2209 1 1 1 1','6489075 6489075 6489349 6489349 6489349 6489349','15377 18147 3986912 6454194 6454318 6489349',X'0703080403070402EA5901332A656C6F5E401C00000000000000AE7C03');
          117  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7381 6799 1 1 1 1','7314420 7314420 7321218 7321218 7321218 7321218','18403 21722 4532963 7281695 7281847 7321218',X'07030804030703049EE501310667176DC940438000000000005ED2B5');
          118  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','7163 7001 31 1 1 1','7652849 7652849 7658600 7658630 7658630 7658630','19462 22956 4750159 7617449 7617608 7658630',X'070308040407030503EB01317DEF010ADD3F402800000000000061C3EF');
          119  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','1433 1433 2 1 1 1','7785842 7785842 7787219 7787219 7787219 7787219','20001 23575 4834605 7745315 7745477 7787219',X'07030804030703055010013156D81B11AC404380000000000004A313');
          120  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','2247 2247 1 1 1 1','9083272 9083272 9085089 9085089 9085089 9085089','24940 29143 5668423 9036693 9036887 9085089',X'070308040307031A620A01323EEB5CE39C406FE000000000006F8177');
          121  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix8','107 107 5 1 1 1','10382912 10382912 10382957 10382959 10382959 10382959','31251 36297 6541362 10329764 10330008 10382959',X'0704080403070400955501013350516AA9D0406060000000000000884648');
          122  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7340 4770 4527 3331 3331 970 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','206533 206533 206533 206533 206533 206596 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565 207565','125 202 402 512 560 6209 20696 25885 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 206260 207565',X'1703080808080704030408030808010308070808080803018784401C000000000000024FD353493F8801317E4700FFFF0F00FFFFC0F869E0000000002642C5');
          123  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8877 4669 71 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1221375 1225583 1230181 1230249 1230249 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251 1230251','931 1504 2992 3495 3751 39629 120561 147424 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1222711 1230251',X'1703090902080704030408090808010108070404040804018D3F03E8405680000000000000822B981EB823013351F00F0C4086E00000000000013351F0013351F053870D7500B22A8C');
          124  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7204 4801 193 193 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1240162 1240162 1244770 1244770 1244959 1244961 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962 1244962','942 1520 3024 3531 3791 40098 122274 149540 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1237296 1244962',X'1703080908010703030408030808010308070408040803018D4F07406FE000000000000602CF16DE05013303C300FFFF0300FFFFC0F869E000000000013303C3008000004BD756');
          125  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9608 6098 5910 5910 5910 2149 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1264939 1264939 1264939 1264939 1264939 1265217 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365 1267365','952 1536 3055 3576 3841 40616 124132 151876 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1259547 1267365',X'1703080808080704030408090808010101070404040803018D61401C0000000000000131374D1726AB0132DD780F0C0540390000000000000132DD780132DD784E2789C6190CA9');
          126  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','6636 4411 4237 4237 4237 33 8 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','1294580 1294580 1294580 1294580 1294580 1297842 1297862 1297862 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','964 1557 3097 3622 3888 41246 126538 154868 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1289863 1297869',X'1703080808080703030408090808010308070808080803018D7840420000000000007332F1227B5901321AF80800FFFF40260000000000006D0CEB');
          127  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7822 4817 260 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2375708 2375708 2380265 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524 2380524','3423 5117 10120 11184 11775 86237 242937 294878 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2366404 2380524',X'170308090308070304040803080801030807040408080401B1F501831C405C40000000000077646800EAD44C0132697000FFFF0300FFFFC0F869E0000000000132696F0132696F0094935E');
          128  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1403 1022 82 74 74 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','2594767 2594767 2595707 2595707 2595707 2595708 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','3914 5817 11518 12879 13613 98100 278304 342850 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2580971 2595739',X'170308090808070303040803080801030807080808080301B648405C400000000000038EAC243F770131A6F700FFFF0E00FFFFC0F869E0000000005C8664');
          129  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7901 5298 291 55 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3424107 3424107 3429114 3429350 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404 3429404','5872 8944 17727 19769 20846 145206 401995 498360 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3411279 3429404',X'170308090201070404040803080801030807040808080401C3F9232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083157B');
          130  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7483 5407 230 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3549446 3549446 3554623 3554845 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852 3554852','5932 9041 17921 20139 21264 149060 417718 520064 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3536268 3554852',X'170308090201070404040803080801030807040808080401C449232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329460083162A');
          131  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','12076 8365 7981 5546 5546 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3558079 3558079 3558079 3558079 3558079 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624 3563624','5935 9046 17930 20154 21279 149235 418443 521109 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3544970 3563624',X'170308080808070303040803080801030107040408080301C44E4074300000000000029EB13BB98E01328EFE00FFFF0E00FFFF0AC0F869E00000000001328F0001328F0071D802');
          132  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1123 916 875 875 875 93 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1','3892913 3892913 3892913 3892913 3892913 3893531 3893602 3893602 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','6594 10057 19942 22653 23964 165533 468498 587524 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3873325 3893609',X'170308080808070403040802080801030107040404080301CA28403F00000000000000832DC71933330132DB8800FC0F00FFFF054050C000000000000132DB870132DB8A4D5E35A2107205');
          133  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9344 6359 6022 9 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','4213510 4213510 4213510 4219523 4219523 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531 4219531','7200 11025 21872 25036 26543 181203 517345 652858 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4198057 4219531',X'170308080308070303040803080801030807080808080301CE8C0186A0403F00000000000002C2142F19870131554100FFFF0F00FFFFC0F869E0000000000687F7');
          134  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8062 4993 241 53 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5037060 5037060 5041812 5042000 5042051 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052 5042052','10201 15484 30736 35196 37326 231854 654010 829510 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5017193 5042052',X'17030809020107030404080308080103080704080808030213B2245407406FE0000000000002C0AA00F6ABA101332A7E00FFFF0300FFFFC0F869E00000000001332A7E5287C0');
          135  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','9125 5761 264 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5046490 5046490 5051987 5052246 5052246 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250 5052250','10203 15488 30744 35230 37365 232178 654964 830718 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5027358 5052250',X'17030809030807030304080308080103080708080808030213B501831F406FE00000000000029E627136F901328DD500FFFF0300FFFFC0F869E000000000290DD6');
          136  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','591 591 566 566 566 27 18 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','5190991 5190991 5190991 5190991 5190991 5191461 5191464 5191474 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','10649 16115 31973 36593 38793 239550 673441 853755 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5165855 5191479',X'17030808080807030404080108080101080708080808040244AD4045800000000000029E6200EAE8740132690D0A0F0C402E00000000000000941EAF');
          137  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 3728 83 16 16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6112248 6115901 6119546 6119613 6119613 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628 6119628','13780 20707 41067 47538 50438 296473 834203 1056686 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6089878 6119628',X'170309090208070304040809080801010807040404080402A9D12328407360000000000002172300EABCFF0133517F0F0C404AA6665E02EA960133517F01335239538BC5C1008B5EC9');
          138  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7569 5785 274 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6280084 6280084 6285595 6285867 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868 6285868','14559 21811 43240 50020 53057 307264 862871 1092992 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6255378 6285868',X'170308090301070404040803080801030807040808080302C14C01832707405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E000000000013329461E5109');
          139  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','8289 5734 266 33 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6290764 6290764 6296232 6296465 6296495 6296495 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497 6296497','14569 21827 43272 50056 53096 307563 864043 1094585 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6265950 6296497',X'170308090201070404040803080801030807040808080402C164232807405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600A90415');
          140  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2209 1450 1369 1369 1369 597 13 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1','6489075 6489075 6489075 6489075 6489075 6489139 6489344 6489344 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','15377 22998 45584 52641 55837 319564 895653 1134252 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6458046 6489349',X'170308080808070303040802080801030807040404080302EA59401C0000000000000D4B201AD8B30132DF0400FC0600FFFF40180000000000000132DF040132DF054EBA338714FBBA');
          141  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7381 5446 171 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7314420 7314420 7319695 7319855 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865 7319865','18403 27319 54152 62541 66337 369851 1032180 1306261 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7284923 7319865',X'1703080902010703030408030808010308070408080804049EE503E907405C400000000000029EC32E97BE0133061F00FFFF0300FFFFC0F869E0000000000133061F00A9ECEF');
          142  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','7163 4782 209 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7652849 7652849 7657422 7657626 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630 7657630','19462 28830 57147 65962 69945 388539 1084446 1372423 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7621247 7657630',X'17030809020107040404080308080103080704080808040503EB03EA07405C40000000000000FF559400F2FA440133294600FFFF0300FFFFC0F869E0000000000133294600831554');
          143  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','1433 582 571 571 571 15 15 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1','7785842 7786693 7786693 7786693 7786693 7787208 7787208 7787208 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','20001 29582 58632 67649 71736 396840 1107204 1400830 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7750264 7787219',X'1703090808080703040408090808010108070404040804055010406E80000000000001C7A600FC429201332D890F0C402C00000000000001332D890133505352D7248A008775D8');
          144  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','2247 682 657 657 657 117 45 45 1 1 1 1 1 1 1 1 1 1 1 1 1 1','9083272 9084837 9084837 9084837 9084837 9085088 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','24940 36384 72113 82665 87632 474987 1318830 1664527 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9042708 9085089',X'17030908080807030304080208080103010704040408031A620A403E00000000000001C3D332CF850132DE9D00FC0200FFFF054050E000000000000132DE9D0132DE9D4E8C092E790553');
          145  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix7','107 77 69 69 69 11 5 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1','10382912 10382942 10382942 10382942 10382942 10382952 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','31251 45639 90416 102896 109225 567280 1544395 1943661 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10337289 10382959',X'170409080808070303040809080801010807040404080300955501403E000000000000029E686E250B01332D220F0C402E00000000000001332D220133504E52CFCF4F21CD7F');
          146  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7337 4975 19 19 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 206462 206462 210789 210789 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807 210807','0 0 0 125 164 112407 128579 207456 209489 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 209490 210807',X'170808080308040804030807080301030807080808080301878401317F26024FD3531E2DAF404200000000000000FFFF0200FFFFC0F869E0000000002642C4');
          147  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8874 8785 45 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1221012 1221012 1224145 1224165 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189 1224189','0 0 0 931 1117 679896 773861 1207582 1216653 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1216673 1224189',X'1708080803080409040408070809010308070404040803018D3F0133023D01940C420106B14D40420000000000000F00FFFF4070E000000000000133023D0133023D4F2053654AE525');
          148  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7200 7200 39 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1239793 1239793 1242199 1242223 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237 1242237','0 0 0 942 1131 688381 783660 1225441 1234602 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1234622 1242237',X'1708080803080409040308070809010301070404040804018D4F0132DB820113FAB92F19C5401C0000000000000F00FFFF0F403A0000000000000132DB820132DB824D542A4F009B5C72');
          149  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9606 9606 44 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1264560 1264560 1266149 1266168 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192 1266192','0 0 0 952 1145 699479 796008 1249062 1258369 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1258391 1266192',X'1708080803080409040308070809010101070404040803018D61013305B9017CDF4916F8B140280000000000000F0C0A403600000000000001330557013305B9507EA8DD212E79');
          150  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 6635 6635 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 1294199 1294199 1297868 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869 1297869','0 0 0 964 1159 713241 812408 1280435 1289849 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1289871 1297869',X'1708080803080409030308070803010308070808080803018D78013267DC0EF747387106403F00000000000000FFFF0F00FFFFC0F869E00000000006B968');
          151  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7815 6624 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2374939 2374939 2380559 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584 2380584','0 0 0 3423 3833 1371803 1539928 2350493 2366415 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2366460 2380584',X'170808080308040903030807080301030807080808080301B1F501317F160DDEA51C46AB405280000000000000FFFF0F00FFFFC0F869E0000000006ADDA9');
          152  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3595 3459 10 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 2595336 2595336 2595734 2595737 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739 2595739','0 0 0 3918 4433 1512586 1693312 2557025 2580917 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2580967 2595739',X'170808080308040903030807080101010107040404080301B64F01332ACC029E833D19084028000000000000320F0C054074A0000000000001332A0901332ACC518A316F1F30D6');
          153  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7894 6061 26 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3422592 3422592 3424418 3424434 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443 3424443','0 0 0 5872 6630 2032185 2267240 3366727 3406294 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3406363 3424443',X'170808080308040904030807080101030807040404080401C3F90132B7A100D6FD7F6CE97F4070500000000000100F00FFFF40560000000000000132B7310132DB2D4D3F72D9009AE8EE');
          154  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7479 6158 22 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3547845 3547845 3553619 3553619 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640 3553640','0 0 0 5932 6752 2099067 2343370 3491679 3534981 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3535053 3553640',X'170808080308040804030807080301030807080808080301C4490131573F008E7AC03077E0403E00000000000000FFFF0F00FFFFC0F869E00000000065B45A');
          155  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 12068 8257 37 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3556474 3556474 3558426 3558446 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462 3558462','0 0 0 5935 6758 2101744 2346448 3496404 3539797 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3539869 3558462',X'170808080308040904030807080201010107040404080301C44E0132DD09016891C11788EB404200000000000000FC0F0C0F400199999999999A0132DD090132DD094DE5DCE3763299');
          156  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1510 1497 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 3892149 3892149 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609 3893609','0 0 0 6596 7614 2306358 2572095 3823194 3873232 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3873319 3893609',X'170808080308040803030807080301030807080808080301CA2E01312E3A038EE6257265400000000000000000FFFF0600FFFFC0F869E00000000032518F');
          157  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9341 7313 41 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 4211282 4211282 4217204 4217243 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244 4217244','0 0 0 7200 8390 2502650 2792131 4139620 4195704 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4195798 4217244',X'170808080308040903030807080301030807080808080301CE8C01317DE8029E9D3B6D23403E00000000000000FFFF0F00FFFFC0F869E00000000008EF7D');
          158  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8055 3290 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5033936 5033936 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225 5037225','0 0 0 10201 11915 3045026 3383481 4941323 5012256 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5012369 5037225',X'17080808030804090303080708030803080708080808030213B20130B83A018A7516DF86403600000000000000FFFF00FFFFC0F869E00000000028F8CD');
          159  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 9117 2923 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5043358 5049528 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450 5052450','0 0 0 10203 11926 3054947 3394812 4956408 5027439 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5027552 5052450',X'17080808030204080303080708030103080708080808030213B5232A013107F00217231745AF403300000000000000FFFF0200FFFFC0F869E0000000002B57DE');
          160  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 333 333 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 5191271 5191271 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479 5191479','0 0 0 10672 12452 3147059 3494842 5093162 5165710 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5165827 5191479',X'17080808030804080303080708030103080708080808030244F00131CB4201C1C917188E403F00000000000000FFFF0800FFFFC0F869E00000000001C5CB');
          161  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7374 4684 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6107894 6107894 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577 6112577','0 0 0 13780 16308 3748117 4153600 5995776 6082692 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6082834 6112577',X'170808080308040803030807080301030807080808080402A9D1013108B5029E6831A21C401C00000000000000FFFF0200FFFFC0F869E0000000000092F5C6');
          162  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7562 7376 28 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6275521 6275521 6277274 6277291 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301 6277301','0 0 0 14559 17217 3855913 4271255 6156622 6246677 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6246823 6277301',X'170808080308040904030807080201030107040404080302C14C0132DBF100832DC739FF53403F00000000000000FC0F00FFFF05402C0000000000000132DBF10132DBF34D89B7AA1114CB');
          163  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 8282 7043 28 28 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6286191 6286191 6292277 6292277 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304 6292304','0 0 0 14569 17229 3862314 4278722 6171137 6261611 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6261757 6292304',X'170808080308040804030807080301030807080808080302C16401317CC301B5AA4A1AB270405680000000000000FFFF0F00FFFFC0F869E00000000048FD4C');
          164  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 3101 3101 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 6486495 6486495 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 15379 18149 3988504 4417216 6363796 6457879 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6458036 6489349',X'170808080308040803030807080301030807080808080302EA6601317F7301C3EB17C4CE401C00000000000000FFFF0F00FFFFC0F869E000000000398198');
          165  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 7379 6798 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7308682 7308682 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479 7315479','0 0 0 18403 21722 4531809 5008068 7172304 7280343 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7280536 7315479',X'1708080803080408040308070803010308070808080803049EE501310667008390D0176DC9404380000000000000FFFF0500FFFFC0F869E0000000005ED2B5');
          166  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 211 211 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 7787150 7787150 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 0 0 20027 23602 4837427 5341824 7634169 7750020 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7750224 7787219',X'17080808030804080303080708090103080704040808030550B30132B73501A79C17C3D840340000000000000F00FFFF40140000000000000132B6D00132B7400D1DB9');
          167  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 26 26 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 9085083 9085083 9085088 9085088 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089 9085089','0 0 0 24964 29171 5671673 6246216 8904392 9042441 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9042684 9085089',X'17080808030804080303080708030103080708080808031AA25C0131CA197A6D831B1D84401C00000000000000FFFF0F00FFFFC0F869E00000000071E307');
          168  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','11668540 11668540 11668540 1261 1261 9 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','0 0 0 10381872 10381872 10382956 10382956 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959 10382959','0 0 0 31297 36344 6545140 7198586 10180602 10336983 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10337266 10382959',X'17080808040804080303080708010101080708080808030095A4C401321BB603010141073C401C000000000000080F0C40308000000000007E55BE');
          169  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix6','12287 12287 12287 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1','11668540 11668540 11668540 11672111 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127 11672127','1 1 1 43128 49243 7431284 8170740 11452355 11624787 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11625093 11672127',X'1701080803020408040409070803010308070408040804070267C127130133041E00AB540900E64074405C40000000000000FFFF0300FFFFC0F869E0000000000133041E0080000000A3EE16');
          170  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24157 24157 29 29 1 1 1 1','0 0 0 1236590 1236590 1251799 1251799 1251827 1251827 1251827 1251827','0 0 0 3120 4771 71527 72755 1238782 1238782 1238782 1251827',X'0C08080803040308040808031A080400FF5594029BB30131CD372B1368');
          171  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 1209 1209 129 129 1 1 1 1','0 0 0 1296873 1296873 1297744 1297744 1297869 1297869 1297869 1297869','0 0 0 3203 4902 74577 75831 1284645 1284645 1284645 1297869',X'0C08080803030308040808041A215F04C9D901B0A30131066F0087162A');
          172  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 12129 9261 428 428 1 1 1 1','0 0 0 1790076 1790076 1790076 1790076 1790503 1790503 1790503 1790503','0 0 0 4938 7561 108783 110860 1774402 1774402 1774402 1790503',X'0C08080803030308040808031CE87E029E6B018700013219C1373BA8');
          173  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 273 273 5 5 1 1 1 1','0 0 0 2595625 2595625 2595738 2595738 2595739 2595739 2595739 2595739','0 0 0 7863 12132 166423 169877 2575172 2575172 2575172 2595739',X'0C08080803030308040808042F020502DA0E02C73A0133049700A711F8');
          174  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 7735 7735 29 29 1 1 1 1','0 0 0 2924165 2924165 2929754 2929754 2929782 2929782 2929782 2929782','0 0 0 9123 14045 191316 195293 2907742 2907742 2907742 2929782',X'0C080808030403080408080333776300FF559475928D013329435A824F');
          175  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 360 229 27 27 1 1 1 1','0 0 0 3893374 3893505 3893605 3893605 3893609 3893609 3893609 3893609','0 0 0 13912 21124 273265 278784 3866425 3866425 3866425 3893609',X'0C08080803030308040808044717710E070B01E88F0131A5B80098D0A5');
          176  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 683 671 32 32 1 1 1 1','0 0 0 5191447 5191459 5191477 5191477 5191479 5191479 5191479 5191479','0 0 0 20361 30776 381171 389104 5158962 5158962 5158962 5191479',X'0C08080803030308040808037370D10F00290188450132B537354C5E');
          177  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 213354 213354 113 113 1 1 1 1','0 0 0 6102233 6102233 6155183 6155183 6155295 6155295 6155295 6155295','0 0 0 26812 39489 472780 483115 6119281 6119281 6119281 6155295',X'0C080808040403080408080300F2FA4400FF5594019B6D01324067714AE8');
          178  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 3675 3675 241 241 1 1 1 1','0 0 0 6486701 6486701 6489287 6489287 6489349 6489349 6489349 6489349','0 0 0 28380 41383 502486 513750 6452691 6452691 6452691 6489349',X'0C080808040304080408080300F6ABAC6C967D009F84B60132DBDD155A2A');
          179  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 24063 24063 38 38 1 1 1 1','0 0 0 7080911 7080911 7102380 7102380 7102417 7102417 7102417 7102417','0 0 0 35724 49844 582928 595393 7065320 7065320 7065320 7102417',X'0C0808080404040804080803010B0A5C00FF559400CCD3EE0133294559DDCD');
          180  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 7173953 7173950 20284 20284 38 38 1 1 1 1','0 0 0 7107237 7107237 7126606 7126606 7126643 7126643 7126643 7126643','0 0 0 35764 49885 586473 599030 7089546 7089546 7089546 7126643',X'0C0808080404040804080803010B3C6700FF55940114CE73013329432225CC');
          181  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 11855 11855 3 1 1 1 1 1','0 7173953 7173953 7665258 7665258 7672559 7672561 7672561 7672561 7672561 7672561','0 1 2 64320 91213 1077048 1100563 7630436 7630436 7630436 7672561',X'0C080908040403020408080400F2FA4400FF559405DD0A23280132DD75009F3468');
          182  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 618063 4 4 1 1 1 1 1 1','0 7173953 7173953 7787218 7787218 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74034 102405 1189484 1215034 7745001 7745001 7745001 7787219',X'0C0809080403040804080803010DDABE0368B700FEBFF60133068F22D1E5');
          183  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','7804279 630326 12263 1433 1433 1 1 1 1 1 1','0 7173953 7792016 7797877 7797877 7799309 7799309 7799309 7799309 7799309 7799309','0 1 3 76213 104626 1201397 1227113 7757087 7757087 7757087 7799309',X'0C08090104040408040808030700F2FA4400FF559401C3969E013329461E5052');
          184  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8657 8657 605 605 1 1 1 1','7804279 7804279 7804279 8360485 8360485 8364643 8364643 8365247 8365247 8365247 8365247','1 2 4 77865 106290 1217527 1243460 8321843 8321843 8321843 8365247',X'0C09080803030308040808031AD369021FFC0DC36E01328E2F3D9128');
          185  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 33421 33421 57 26 1 1 1 1','7804279 7804279 7804279 8873934 8873934 8891008 8891039 8891064 8891064 8891064 8891064','1 2 4 78914 107340 1231432 1257622 8846644 8846644 8846644 8891064',X'0C090808030403020408080433776300FF55940CE166232801332A1800836DFB');
          186  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 2182 2182 94 94 1 1 1 1','7804279 7804279 7804279 9083187 9083187 9085006 9085006 9085089 9085089 9085089 9085089','1 2 4 79307 107733 1237174 1263453 9040316 9040316 9040316 9085089',X'0C09080803030308040808033AC92C021FFC04AF670132B5FC38DBD0');
          187  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 6023 6023 50 50 1 1 1 1','7804279 7804279 7804279 9393480 9393480 9395815 9395815 9395864 9395864 9395864 9395864','1 2 4 79973 108402 1245294 1271679 9350536 9350536 9350536 9395864',X'0C09080803030308040808034CDD9A7E1C2301C30D0132908703CC11');
          188  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 79 79 6 6 1 1 1 1','7804279 7804279 7804279 10382946 10382946 10382956 10382956 10382959 10382959 10382959 10382959','1 2 4 82501 110947 1276304 1303221 10336296 10336296 10336296 10382959',X'0C090808040303080408080400E9A10A0CC31602A47201332C6C00ABCD60');
          189  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 8251 8251 280 280 1 1 1 1','7804279 7804279 7804279 11067468 11067468 11072690 11072690 11072969 11072969 11072969 11072969','1 2 4 85529 113989 1307763 1335183 11025935 11025935 11025935 11072969',X'0C090808040404080408080300FFA4A7008A66AD0089DBDD0132B5FF6AE2B8');
          190  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 44772 44772 58 58 1 1 1 1','7804279 7804279 7804279 11268036 11268036 11269261 11269261 11269318 11269318 11269318 11269318','1 2 4 87132 115597 1321101 1348736 11222284 11222284 11222284 11269318',X'0C0908080404030804080804010B0A5C00FF5594018ACD0133294300B0E291');
          191  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 53775 53775 37 19 1 1 1 1','7804279 7804279 7804279 11330929 11330929 11355027 11355045 11355063 11355063 11355063 11355063','1 2 4 87335 115800 1327560 1355328 11308029 11308029 11308029 11355063',X'0C0908080404030204080803010BFA8100FF5594026C24232801332B2E1F8BB5');
          192  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 3718791 3718791 39430 39430 39 39 1 1 1 1','7804279 7804279 7804279 11458789 11458789 11476757 11476757 11476795 11476795 11476795 11476795','1 2 4 88502 116970 1340484 1368500 11429761 11429761 11429761 11476795',X'0C09080804040308040808030113B99600FF559402F6AF01332B2E1F8A54');
          193  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix5','3876548 157757 157736 5317 5317 1 1 1 1 1 1','7804279 11523070 11523070 11652823 11652823 11658139 11658139 11658139 11658139 11658139 11658139','1 3 5 100045 128561 1480184 1510648 11611105 11611105 11611105 11658139',X'0C0909080404040204080803010BFA8100FF559402594CCB2328013351E85B0F5D');
          194  +} {}
          195  +do_execsql_test whereJ-1.3 {
          196  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4748 4629 308 1 1 1 1 1','0 0 0 634880 634880 639119 639426 639426 639426 639426 639426','0 0 0 779 907 26900 633919 633920 633920 633920 639426',X'0C0808080308040403080803018C4A00F450A80132671F029EAC271DA5');
          197  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4608 4608 246 1 1 1 1 1','0 0 0 752580 752580 755578 755823 755823 755823 755823 755823','0 0 0 936 1089 31876 749384 749385 749385 749385 755823',X'0C0808080308030403080804018D4F347FD20131547D018A7500936FE2');
          198  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4776 4776 240 1 1 1 1 1','0 0 0 762070 762070 764545 764784 764784 764784 764784 764784','0 0 0 940 1097 32187 758274 758275 758275 758275 764784',X'0C0808080308030403080804018D562E0EAB0131A68F029E9300994D36');
          199  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5910 5910 257 1 1 1 1 1','0 0 0 771353 771353 772646 772902 772902 772902 772902 772902','0 0 0 946 1103 32460 766333 766334 766334 766334 772902',X'0C0808080308030404080803018D611726F40130E13C00822B980302A0');
          200  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 1834 1834 46 1 1 1 1 1','0 0 0 1296866 1296866 1297832 1297869 1297869 1297869 1297869 1297869','0 0 0 2621 2842 56932 1287063 1287064 1287064 1287064 1297869',X'0C080808030803040308080301A6E33010BC01317F2005516E3932DB');
          201  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5007 3959 317 1 1 1 1 1','0 0 0 2152400 2152400 2153781 2154097 2154097 2154097 2154097 2154097','0 0 0 5683 6304 111431 2139450 2139457 2139457 2139457 2154097',X'0C080808030803040308080301C3F91E114001315549029F74635F36');
          202  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4768 4609 397 1 1 1 1 1','0 0 0 2200466 2200466 2200700 2201096 2201096 2201096 2201096 2201096','0 0 0 5714 6370 114266 2186220 2186227 2186227 2186227 2201096',X'0C080808030803040308080401C42217887E01312D72036D5B009AF3F8');
          203  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5177 4669 264 1 1 1 1 1','0 0 0 2234078 2234078 2235865 2236128 2236128 2236128 2236128 2236128','0 0 0 5743 6422 116499 2221108 2221115 2221115 2221115 2236128',X'0C080808030803040308080401C4491EF49D013155450D4B200091BFB3');
          204  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 7981 5546 272 1 1 1 1 1','0 0 0 2239923 2239923 2242583 2242854 2242854 2242854 2242854 2242854','0 0 0 5746 6428 116800 2227775 2227782 2227782 2227782 2242854',X'0C080808030803040308080301C44E2EFF35013109E67764687E36D6');
          205  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 351 336 15 1 1 1 1 1','0 0 0 2595725 2595725 2595725 2595739 2595739 2595739 2595739 2595739','0 0 0 6747 7717 144364 2578697 2578708 2578708 2578708 2595739',X'0C080808030803040308080401CCC91782C20131CC1902D7C0008E7A4F');
          206  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 6022 4942 304 1 1 1 1 1','0 0 0 2648510 2648510 2648849 2649152 2649152 2649152 2649152 2649152','0 0 0 6934 7959 149030 2631886 2631900 2631900 2631900 2649152',X'0C080808030803040308080301CE8C17887E01312D6E036D5B424939');
          207  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 4752 1965 5 1 1 1 1 1','0 0 0 3161780 3161780 3163740 3163744 3163744 3163744 3163744 3163744','0 0 0 9707 11219 194477 3143873 3143896 3143896 3143896 3163744',X'0C08080803080404030808030213B20116290C01332B9D0270102494C2');
          208  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5497 1880 3 1 1 1 1 1','0 0 0 3167643 3167643 3169520 3169522 3169522 3169522 3169522 3169522','0 0 0 9709 11226 194760 3149632 3149655 3149655 3149655 3169522',X'0C08080803080404040808030213B5010B0A5C0133294500FF55941DCA72');
          209  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 2185 2126 134 1 1 1 1 1','0 0 0 3891669 3891669 3893607 3893609 3893609 3893609 3893609 3893609','0 0 0 13596 15952 257364 3869701 3869733 3869733 3869733 3893609',X'0C080808030804040308080302BD5F01010F13013350517B8BF356D913');
          210  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5511 5355 345 1 1 1 1 1','0 0 0 3931849 3931849 3931954 3932298 3932298 3932298 3932298 3932298','0 0 0 13793 16188 260160 3908172 3908206 3908206 3908206 3932298',X'0C080808030803040308080402C14C17887E01312D75036D5B009AF4B1');
          211  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5468 5115 310 1 1 1 1 1','0 0 0 3939090 3939090 3939894 3940203 3940203 3940203 3940203 3940203','0 0 0 13803 16200 260571 3916034 3916068 3916068 3916068 3940203',X'0C080808030803040308080302C164191E7F0131A4FC0606F30CE25A');
          212  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 5275 4792 252 1 1 1 1 1','0 0 0 4590216 4590216 4591340 4591591 4591591 4591591 4591591 4591591','0 0 0 17456 20455 315887 4563939 4563981 4563981 4563981 4591591',X'0C0808080308030403080804049EE51EB67B01317C5204C9D900AE08CD');
          213  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 339 339 20 1 1 1 1 1','0 0 0 5191257 5191257 5191475 5191479 5191479 5191479 5191479 5191479','0 0 0 20754 24230 366257 5160652 5160701 5160701 5160701 5191479',X'0C08080803080404030808030CEE9300E50D8D013242BE018A755F6BC3');
          214  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 7173953 7173950 13 13 1 1 1 1 1 1','0 0 0 6489337 6489337 6489349 6489349 6489349 6489349 6489349 6489349','0 0 0 29449 33987 481632 6453309 6453378 6453378 6453378 6489349',X'0C08080804080304030808030091B3AB600E9801323F54029F7403EF0C');
          215  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 618063 10 9 1 1 1 1 1 1','0 7173953 7173953 7787217 7787217 7787219 7787219 7787219 7787219 7787219 7787219','0 1 2 74978 85458 1107555 7744920 7744997 7744997 7744997 7787219',X'0C0809080408030403080804014F459B48960801332ADC01C7A600AA1BA3');
          216  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','7804279 630326 12263 17 1 1 1 1 1 1 1','0 7173953 7792016 7795570 7795586 7795586 7795586 7795586 7795586 7795586 7795586','0 1 3 78329 89057 1115864 7753287 7753364 7753364 7753364 7795586',X'0C0809010302040404080804070267C1271300E640740133041E00AB540900A3EE16');
          217  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 397 397 46 1 1 1 1 1','7804279 7804279 7804279 9084892 9084892 9085088 9085089 9085089 9085089 9085089 9085089','1 2 4 87584 99143 1159195 9040539 9040616 9040616 9040616 9085089',X'0C090808030804040308080301CBAF00E5C288013351810C390F26671E');
          218  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 3718791 3718791 141 141 20 1 1 1 1 1','7804279 7804279 7804279 10382921 10382921 10382951 10382959 10382959 10382959 10382959 10382959','1 2 4 95054 107437 1210217 10336699 10336776 10336776 10336776 10382959',X'0C09080803080304030808030DB5C14114E301332A7E018A751F17C1');
          219  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix4','3876548 157757 157736 83 16 1 1 1 1 1 1','7804279 11523070 11523070 11587733 11587800 11587815 11587815 11587815 11587815 11587815 11587815','1 3 5 112412 126326 1332792 11540704 11540781 11540781 11540781 11587815',X'0C090908030204040308080402A9D12328010B92880133517F029E9D008B5B23');
          220  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 213279 213279 213279 213279 376 212 101 1 1','0 0 12394 12394 12394 12394 18421 18421 18421 18424 18424','0 0 3 3 3 3 810 1027 1949 18324 18424',X'0C0808030808080308030403018A75018788178574013265FC611E2A');
          221  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 86515 86515 86515 86515 377 377 377 1 1','0 0 271240 271240 271240 271240 274521 274521 274521 274780 274780','0 0 8 8 8 8 9766 10762 19602 273178 274780',X'0C080803080808030803040401A79C01886F174AEF0132678B00A4AEFF');
          222  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 193482 193482 193482 193482 444 444 444 1 1','0 0 542802 542802 542802 542802 575453 575453 575453 575505 575505','0 0 27 27 27 27 24310 25597 43165 571774 575505',X'0C080803080808030803040401C3EB018CCE55312F013305B700AF487C');
          223  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 126108 126108 126108 126108 200 200 28 1 1','0 0 747801 747801 747801 747801 762121 762121 762293 762320 762320','0 0 33 33 33 33 30770 32410 56629 757315 762320',X'0C080803080808030803040301C7A6018A9D6AB1100131F17D04364A');
          224  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 149712 149712 149712 149712 216 216 5 1 1','0 0 1107747 1107747 1107747 1107747 1147090 1147090 1147301 1147305 1147305','0 0 98 98 98 98 51603 53785 94043 1139967 1147305',X'0C080803080808030803040302172301B84D2E828501317B95651924');
          225  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 87289 87289 87289 87289 27 27 12 1 1','0 0 1257751 1257751 1257751 1257751 1297850 1297850 1297865 1297869 1297869','0 0 100 100 100 100 57625 60123 107069 1289807 1297869',X'0C0808030808080308040403021FFC02554D00E643C7013242692A9BBC');
          226  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 192597 192597 192597 192597 291 291 3 1 1','0 0 1464077 1464077 1464077 1464077 1512946 1512946 1513234 1513236 1513236','0 0 134 134 134 134 67476 70262 123260 1502886 1513236',X'0C0808030808080308040404029E6201B94000F8341701330419008B74DA');
          227  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 196917 196917 196917 196917 326 326 12 1 1','0 0 1677739 1677739 1677739 1677739 1797333 1797333 1797647 1797658 1797658','0 0 136 136 136 136 76717 80026 143308 1785522 1797658',X'0C0808030808080308040404029E6802B7DC0108ACBA0132DD7B0087795F');
          228  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 140297 140297 140297 140297 206 188 90 1 1','0 0 1951850 1951850 1951850 1951850 2020506 2020524 2020622 2020711 2020711','0 0 146 146 146 146 85439 89181 160816 2006993 2020711',X'0C0808030808080302040403029E8102171603E800FA82B20132B5AD384ECD');
          229  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 132041 132041 132041 132041 173 173 20 1 1','0 0 2415706 2415706 2415706 2415706 2428962 2428962 2429115 2429134 2429134','0 0 163 163 163 163 100984 105182 186071 2412732 2429134',X'0C0808030808080308030403029EB1018BF55020D60131A3D23BB156');
          230  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 6830 6830 6830 6830 35 35 35 1 1','0 0 2595444 2595444 2595444 2595444 2595711 2595711 2595711 2595739 2595739','0 0 169 169 169 169 108584 113037 199947 2578183 2595739',X'0C0808030808080308030403029EC001878C17A7520131A43A6E513C');
          231  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 101615 101615 101615 101615 244 33 33 1 1','0 0 2999185 2999185 2999185 2999185 3019255 3019466 3019466 3019498 3019498','0 0 213 213 213 213 131035 136293 237357 2999333 3019498',X'0C080803080808030203040302D7C001B93E03F041A96D013303017C72B6');
          232  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 26914 26914 26914 26914 87 87 73 1 1','0 0 3868553 3868553 3868553 3868553 3893568 3893568 3893582 3893609 3893609','0 0 387 387 387 387 172456 180121 311050 3869040 3893609',X'0C08080308080803080304040498C86B7EF347CC5A0132B678008A4646');
          233  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 97492 97492 97492 97492 410 410 44 1 1','0 0 4948831 4948831 4948831 4948831 5009456 5009456 5009822 5009865 5009865','0 0 751 751 751 751 226745 236274 399260 4980988 5009865',X'0C08080308080803080404030E565F03686C00F89CD001332A115479DC');
          234  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 1782 1782 1782 1782 52 52 52 1 1','0 0 5190938 5190938 5190938 5190938 5191434 5191434 5191434 5191479 5191479','0 0 800 800 800 800 236362 246237 414618 5161779 5191479',X'0C08080308080803080304040EBD0F0268E064A6DB013242CB00875BAF');
          235  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 4645 4645 4645 4645 17 17 17 1 1','0 0 6485214 6485214 6485214 6485214 6489339 6489339 6489339 6489349 6489349','0 0 1396 1396 1396 1396 317293 329836 538486 6453712 6489349',X'0C080804080808040803040300ABD9B000A69D33737CBB01328F6B0F6298');
          236  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 7173953 290196 290196 290196 290196 138 138 26 1 1','0 0 6734628 6734628 6734628 6734628 6744872 6744872 6744984 6745009 6745009','0 0 1641 1641 1641 1641 338986 352099 569319 6708651 6745009',X'0C080804080808030804040400FF5594018819010B3C670133294300B1674C');
          237  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','7804279 630326 24310 1435 1435 1435 1 1 1 1 1','0 7173953 7763625 7786500 7786500 7786500 7787219 7787219 7787219 7787219 7787219','0 1 3518 4119 4119 4119 726018 753845 1215054 7745002 7787219',X'0C080904010808030204040400FF5594070357AB232800F2FA440133294600A90441');
          238  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 114188 114188 114188 114188 463 61 61 1 1','7804279 7804279 7809377 7809377 7809377 7809377 7864755 7865157 7865157 7865217 7865217','1 2 3751 4413 4413 4413 740133 768607 1233927 7822883 7865217',X'0C0908030808080302030403018A750213B2245416DF860131CB3A2879CC');
          239  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 86108 86108 86108 86108 605 605 605 1 1','7804279 7804279 8403815 8403815 8403815 8403815 8463845 8463845 8463845 8464449 8464449','1 2 3805 4467 4467 4467 760796 789718 1255047 8421249 8464449',X'0C0908030808080308030403021FFC0DC36E1AD36901328E2F3D9128');
          240  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 60490 60490 60490 60490 44 44 44 1 1','7804279 7804279 9062901 9062901 9062901 9062901 9085056 9085056 9085056 9085089 9085089','1 2 3845 4507 4507 4507 778931 808217 1273550 9040805 9085089',X'0C0908030808080308040403029EB101C30B00E889140132697F092505');
          241  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 57304 57304 57304 57304 2 2 2 1 1','7804279 7804279 10328144 10328144 10328144 10328144 10382958 10382958 10382958 10382959 10382959','1 2 4106 4768 4768 4768 823966 853934 1319290 10336860 10382959',X'0C09080308080804080404040E565F00CE8C3100E7F68D0133517900B0B4CE');
          242  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 3718791 174377 174377 174377 174377 81 81 66 1 1','7804279 7804279 11246252 11246252 11246252 11246252 11358749 11358749 11358764 11358829 11358829','1 2 4517 5179 5179 5179 867595 898252 1363807 11311829 11358829',X'0C090804080808030804040300FF55940E584300F2FA44013240670E2E89');
          243  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix3','3876548 157757 15066 15066 15066 15066 1 1 1 1 1','7804279 11523070 11657249 11657249 11657249 11657249 11672314 11672314 11672314 11672314 11672314','1 3 5503 6167 6167 6167 1025351 1059076 1524822 11625280 11672314',X'0C090904080808040203040300FF5594025D19032328337763013351F2277A3E');
          244  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4748 4629 4629 4629 4629 17 1 1 1','0 0 634880 634880 634880 634880 634880 639175 639191 639191 639191','0 0 779 907 907 907 907 415429 633684 633685 639191',X'0C0808030808080804030303018C4A013157983CE7FE05E54B6BB7FB');
          245  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4608 4608 4608 4608 4608 33 1 1 1','0 0 752580 752580 752580 752580 752580 755506 755538 755538 755538','0 0 936 1089 1089 1089 1089 491324 749126 749127 755538',X'0C0808030808080804030303018D4F0131A682512ECF029E6A70A9E9');
          246  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4776 4776 4776 4776 4776 27 1 1 1','0 0 762070 762070 762070 762070 762070 763357 763383 763383 763383','0 0 940 1097 1097 1097 1097 495628 756890 756891 763383',X'0C0808030808080804040303018D560132DB8800F3416D029EA654D9AC');
          247  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5910 5910 5910 5910 5910 37 2 2 1','0 0 771353 771353 771353 771353 771353 775562 775597 775597 775598','0 0 946 1103 1103 1103 1103 501111 769013 769014 775598',X'0C0808030808080804030303018D610131CADE4C6E2D01D5860141A9');
          248  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 1834 1834 1834 1834 1834 6 1 1 1','0 0 1296866 1296866 1296866 1296866 1296866 1297867 1297869 1297869 1297869','0 0 2621 2842 2842 2842 2842 857867 1287063 1287064 1297869',X'0C080803080808080403030301A6E30132419A1E1B7F0567EE2880C0');
          249  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5007 3959 3959 3959 3959 25 1 1 1','0 0 2152400 2152400 2152400 2152400 2152400 2155551 2155575 2155575 2155575','0 0 5683 6304 6304 6304 6304 1442790 2140930 2140937 2155575',X'0C080803080808080404030301C3F901317CC701044CC7029E6834F7E2');
          250  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4768 4609 4609 4609 4609 26 1 1 1','0 0 2200466 2200466 2200466 2200466 2200466 2204364 2204389 2204389 2204389','0 0 5714 6370 6370 6370 6370 1470393 2189496 2189503 2204389',X'0C080803080808080403030301C4220131586B3EB735018A7567CE9E');
          251  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5177 4669 4669 4669 4669 22 1 1 1','0 0 2234078 2234078 2234078 2234078 2234078 2238366 2238387 2238387 2238387','0 0 5743 6422 6422 6422 6422 1490145 2223355 2223362 2238387',X'0C080803080808080403030301C4490131573F4104F802D9CA67FD1E');
          252  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 7981 5546 5546 5546 5546 32 1 1 1','0 0 2239923 2239923 2239923 2239923 2239923 2243388 2243419 2243419 2243419','0 0 5746 6428 6428 6428 6428 1492784 2228358 2228365 2243419',X'0C080803080808080404030301C44E0131A4FE00FDCC04029E8175076B');
          253  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 351 336 336 336 336 1 1 1 1','0 0 2595725 2595725 2595725 2595725 2595725 2595739 2595739 2595739 2595739','0 0 6747 7717 7717 7717 7717 1732397 2578697 2578708 2595739',X'0C080803080808080404030301CCC901332A7700F17E5D0E5D6F523B01');
          254  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 6022 4942 4942 4942 4942 38 1 1 1','0 0 2648510 2648510 2648510 2648510 2648510 2652126 2652163 2652163 2652163','0 0 6934 7959 7959 7959 7959 1770411 2634884 2634898 2652163',X'0C080803080808080404030301CE8C01317DE800FE4E8B029E81458317');
          255  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 4752 1965 1965 1965 1965 1 1 1 1','0 0 3161780 3161780 3161780 3161780 3161780 3163744 3163744 3163744 3163744','0 0 9707 11219 11219 11219 11219 2143797 3143873 3143896 3163744',X'0C08080308080808040303030213B20130BC9216F939029E815B86EE');
          256  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5497 1880 1880 1880 1880 1 1 1 1','0 0 3167643 3167643 3167643 3167643 3167643 3169522 3169522 3169522 3169522','0 0 9709 11226 11226 11226 11226 2148088 3149632 3149655 3169522',X'0C08080308080808040303030213B50130BBC616FC6501C7A62A1BB2');
          257  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 2185 2126 2126 2126 2126 4 1 1 1','0 0 3891670 3891670 3891670 3891670 3891670 3893609 3893609 3893609 3893609','0 0 13596 15952 15953 15953 15953 2677069 3869700 3869732 3893609',X'0C080803080808080403030302BD5F01317CC81782F704C9D95EFF0C');
          258  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5511 5355 5355 5355 5355 21 1 1 1','0 0 3931850 3931850 3931850 3931850 3931850 3936206 3936226 3936226 3936226','0 0 13793 16188 16189 16189 16189 2705655 3912091 3912125 3936226',X'0C080803080808080403030302C14C01317C514010FA01B64235E688');
          259  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5468 5115 5115 5115 5115 27 1 1 1','0 0 3939091 3939091 3939091 3939091 3939091 3943255 3943281 3943281 3943281','0 0 13803 16200 16201 16201 16201 2709082 3919099 3919133 3943281',X'0C080803080808080403030302C16401317CC348B67001C3EB6824BB');
          260  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 5275 4792 4792 4792 4792 31 1 1 1','0 0 4590217 4590217 4590217 4590217 4590217 4591639 4591669 4591669 4591669','0 0 17456 20455 20456 20456 20456 3175906 4564022 4564064 4591669',X'0C0808030808080804040403049EE50132915200FA2F9300EA0DC50554E0');
          261  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 339 339 339 339 339 2 1 1 1','0 0 5191258 5191258 5191258 5191258 5191258 5191478 5191479 5191479 5191479','0 0 20754 24230 24231 24231 24231 3601696 5160652 5160701 5191479',X'0C08080308080808040303030CEE930132671A1B8AFF01B6426386D0');
          262  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 7173953 13 13 13 13 13 1 1 1 1','0 0 6489339 6489339 6489339 6489339 6489339 6489349 6489349 6489349 6489349','0 0 29449 33987 33989 33989 33989 4540005 6453309 6453378 6489349',X'0C08080408080808040303030091B3AB01321B5A4F26F2018A750B6686');
          263  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','7804279 630326 19 19 18 18 18 1 1 1 1','0 7173953 7787203 7787203 7787203 7787203 7787203 7787219 7787219 7787219 7787219','0 1 73522 83967 91688 91688 91688 5643606 7744920 7744997 7787219',X'0C080904080808080404030300FF69210132DB2900FB0715029EB573EB9F');
          264  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 4598 4512 4512 4512 4512 38 1 1 1','7804279 7804279 8237877 8237877 8237877 8237877 8237877 8238986 8239023 8239023 8239023','1 2 76726 87349 95641 95641 95641 5923145 8195880 8195957 8239023',X'0C0908030808080804040404018D3F01332A780111068001FB6F840083BEF9');
          265  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 397 397 397 397 397 2 1 1 1','7804279 7804279 9084892 9084892 9084892 9084892 9084892 9085089 9085089 9085089 9085089','1 2 79826 90851 99143 99143 99143 6505397 9040540 9040617 9085089',X'0C090803080808080403030301CBAF0133028A4E35BE715A2A49098C');
          266  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 3718791 141 141 141 141 141 2 1 1 1','7804279 7804279 10382921 10382921 10382921 10382921 10382921 10382958 10382959 10382959 10382959','1 2 87296 99145 107437 107437 107437 7432077 10336699 10336776 10382959',X'0C09080308080808040403030DB5C101332BF7010E37310EB97420BFF6');
          267  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix2','3876548 157757 83 16 16 16 16 1 1 1 1','7804279 11523070 11587750 11587817 11587817 11587817 11587817 11587832 11587832 11587832 11587832','1 3 104655 118035 126343 126343 126343 8311754 11540721 11540798 11587832',X'0C090903020808080404030402A9D1232801332CC300EB7D35029E83008581B1');
          268  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24157 24157 24157 24157 24157 133 1 1 1','0 0 1236590 1236590 1236590 1236590 1236590 1241150 1241282 1241282 1241282','0 0 3120 3120 3120 3120 4771 741878 1223262 1228239 1241282',X'0C08080308080804040408031A080400FF559401321BC20099C49F3BE84C');
          269  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 1209 1209 1209 1209 1209 2 1 1 1','0 0 1296873 1296873 1296873 1296873 1296873 1297868 1297869 1297869 1297869','0 0 3203 3203 3203 3203 4902 763298 1279554 1284645 1297869',X'0C08080308080803040308031A215F04C9D901317D1501B0A355A290');
          270  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 12129 12129 12129 12129 9261 38 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1791737 1791774 1791774 1791774','0 0 4938 4938 4938 4938 7561 1075153 1767990 1775629 1791774',X'0C08080308080803040408031CE87E029E6B01328F6100B473FD5BE552');
          271  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 273 273 273 273 273 1 1 1 1','0 0 2595625 2595625 2595625 2595625 2595625 2595739 2595739 2595739 2595739','0 0 7863 7863 7863 7863 12132 1580849 2562484 2575172 2595739',X'0C08080308080803040308032F020502DA0E013241A16B73DE01E021');
          272  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 7735 7735 7735 7735 7735 503 1 1 1','0 0 2924165 2924165 2924165 2924165 2924165 2931394 2931896 2931896 2931896','0 0 9123 9123 9123 9123 14045 1794002 2895440 2909856 2931896',X'0C080803080808040404080433776300FF55940133294301C56631008BCB5A');
          273  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 360 360 360 360 229 1 1 1 1','0 0 3893374 3893374 3893374 3893374 3893505 3893609 3893609 3893609 3893609','0 0 13912 13912 13912 13912 21124 2420346 3846830 3866425 3893609',X'0C08080308080803040308034717710E070B01317F7102C73A396CE1');
          274  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 683 683 683 683 671 2 1 1 1','0 0 5191447 5191447 5191447 5191447 5191459 5191479 5191479 5191479 5191479','0 0 20361 20361 20361 20361 30776 3226670 5127525 5158962 5191479',X'0C08080308080803040308037370D10F00290132B59A018F7A694C9B');
          275  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 213354 213354 213354 213354 213354 5934 1 1 1','0 0 6102233 6102233 6102233 6102233 6102233 6154276 6155650 6155650 6155650','0 0 26812 26812 26812 26812 39489 3770219 6079715 6119855 6155650',X'0C080804080808040403080300F2FA4400FF55940132DF1A01C0C115D4D4');
          276  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 3675 3675 3675 3675 3675 14 1 1 1','0 0 6486701 6486701 6486701 6486701 6486701 6489347 6489349 6489349 6489349','0 0 28380 28380 28380 28380 41383 3868787 6409451 6452691 6489349',X'0C080804080808030403020300F6ABAC6C967D0132B672026C8D03E8155844');
          277  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 24063 24063 24063 24063 24063 1799 1 1 1','0 0 7080914 7080914 7080914 7080914 7080914 7103178 7104976 7104976 7104976','0 0 35724 35725 35725 35725 49845 4189282 7019641 7067879 7104976',X'0C0808040808080404040804010B0A5C00FF55940133294301D2C35700A877B5');
          278  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 7173953 20284 20284 20284 20284 20284 1518 1 1 1','0 0 7107240 7107240 7107240 7107240 7107240 7124584 7126101 7126101 7126101','0 0 35764 35765 35765 35765 49886 4191089 7040717 7089004 7126101',X'0C0808040808080404040803010B3C6700FF55940133294501F0A829511573');
          279  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 13288 11855 11855 11855 11855 5449 1 1 1','0 7173953 7671119 7671119 7671119 7671119 7671119 7676514 7676526 7676526 7676526','0 1 64320 65543 65543 65543 92453 4431581 7580039 7634401 7676526',X'0C080904080808040403080400F2FA4400FF5594013329430186CB00A866E4');
          280  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','7804279 630326 61 61 61 61 61 14 1 1 1','0 7173953 7787172 7787172 7787172 7787172 7787172 7787217 7787219 7787219 7787219','0 1 73272 75274 75274 75274 103642 4468650 7689369 7745002 7787219',X'0C0809040808080304030803010ABA910DD2420133068F05DE6223042F');
          281  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8657 8657 8657 8657 8657 18 1 1 1','7804279 7804279 8360485 8360485 8360485 8360485 8360485 8360977 8360994 8360994 8360994','1 2 75785 77865 77865 77865 106290 4756698 8258979 8317590 8360994',X'0C09080308080803040408031AD369021FFC0133517F01B017F259F6C3');
          282  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 33421 33421 33421 33421 33421 2221 1 1 1','7804279 7804279 8873934 8873934 8873934 8873934 8873934 8874868 8877088 8877088 8877088','1 2 76834 78914 78914 78914 107340 5041847 8770182 8832668 8877088',X'0C090803080808040404020333776300FF5594013351790241FEE4232825FB3D');
          283  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 2182 2182 2182 2182 2182 20 1 1 1','7804279 7804279 9083187 9083187 9083187 9083187 9083187 9085087 9085089 9085089 9085089','1 2 77227 79307 79307 79307 107733 5141706 8974619 9040316 9085089',X'0C09080308080803040308043AC92C021FFC0132B668018BAB00964778');
          284  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6008 6008 6008 6008 6008 26 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9128286 9128311 9128311 9128311','1 2 77300 79380 79380 79380 107806 5160088 9016921 9083451 9128311',X'0C09080308080804040408033C1C5C00F024880132DB2100B88E8A420C1B');
          285  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 6023 6023 6023 6023 6023 91 1 1 1','7804279 7804279 9393480 9393480 9393480 9393480 9393480 9396519 9396609 9396609 9396609','1 2 77893 79973 79973 79973 108402 5311949 9282988 9351281 9396609',X'0C09080308080803040408044CDD9A7E1C230132DE4200D105C800A087F7');
          286  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 79 79 79 79 79 1 1 1 1','7804279 7804279 10382946 10382946 10382946 10382946 10382946 10382959 10382959 10382959 10382959','1 2 80421 82501 82501 82501 110947 5821380 10258569 10336296 10382959',X'0C090804080808030403080300E9A10A0CC3160133505F0D25365733C6');
          287  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 8251 8251 8251 8251 8251 37 1 1 1','7804279 7804279 11067468 11067468 11067468 11067468 11067468 11068084 11068120 11068120 11068120','1 2 83449 85529 85529 85529 113989 6177561 10936213 11021086 11068120',X'0C090804080808040404080400FFA4A7008A66AD01332AD10170A8B10084054A');
          288  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 44772 44772 44772 44772 44772 3018 1 1 1','7804279 7804279 11268036 11268036 11268036 11268036 11268036 11282829 11285846 11285846 11285846','1 2 85052 87132 87132 87132 115597 6281979 11151347 11238812 11285846',X'0C0908040808080404040804010B0A5C00FF5594013351720249087400B0523C');
          289  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 53775 53775 53775 53775 53775 4069 1 1 1','7804279 7804279 11330929 11330929 11330929 11330929 11330929 11359035 11363103 11363103 11363103','1 2 85255 87335 87335 87335 115800 6292285 11227544 11316069 11363103',X'0C0908040808080404040804010BFA8100FF5594013351280252F8A000B01818');
          290  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 3718791 39430 39430 39430 39430 39430 3018 1 1 1','7804279 7804279 11458789 11458789 11458789 11458789 11458789 11468188 11471205 11471205 11471205','1 2 86422 88502 88502 88502 116970 6333877 11333316 11424171 11471205',X'0C09080408080804040408040113B99600FF559401335174024530C4008AC82C');
          291  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix1','3876548 157757 5317 5317 5317 5317 5317 12 1 1 1','7804279 11523070 11652844 11652844 11652844 11652844 11652844 11658149 11658160 11658160 11658160','1 3 97969 100051 100051 100051 128567 6429914 11517744 11611126 11658160',X'0C0909040808080404040804010BFA8100FF559401332B2E01521E0B008447F4');
          292  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24157 29 29 29 29 29 1 1 1','0 0 1236590 1251799 1251799 1251799 1251799 1251799 1251827 1251827 1251827','0 0 3120 62451 63798 63798 63798 63798 1238772 1238782 1251827',X'0C08080303080808080404031A0804029BB30131CD3700FF55942B1368');
          293  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 1209 129 129 129 129 129 1 1 1','0 0 1296873 1297744 1297744 1297744 1297744 1297744 1297869 1297869 1297869','0 0 3203 65280 66657 66657 66657 66657 1284635 1284645 1297869',X'0C08080303080808080403041A215F01B0A30131066F04C9D90087162A');
          294  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 12129 604 604 604 604 604 1 1 1','0 0 1790076 1790076 1790076 1790076 1790076 1790076 1790679 1790679 1790679','0 0 4938 95334 97612 97612 97612 97612 1774566 1774578 1790679',X'0C08080303080808080403031CE87E01870001317C4D0CED622FE2E8');
          295  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 273 5 5 5 5 5 1 1 1','0 0 2595625 2595738 2595738 2595738 2595738 2595738 2595739 2595739 2595739','0 0 7863 145612 149427 149427 149427 149427 2575145 2575172 2595739',X'0C08080303080808080403042F020502C73A0133049702DA0E00A711F8');
          296  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 7735 29 29 29 29 29 1 1 1','0 0 2924165 2929754 2929754 2929754 2929754 2929754 2929782 2929782 2929782','0 0 9123 167852 172269 172269 172269 172269 2907715 2907742 2929782',X'0C080803030808080804040333776375928D0133294300FF55945A824F');
          297  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 360 6 6 6 6 6 1 1 1','0 0 3893374 3893607 3893607 3893607 3893607 3893607 3893609 3893609 3893609','0 0 13912 240908 247109 247109 247109 247109 3866384 3866425 3893609',X'0C080803030808080804030347177104AF8701317D220E070B687905');
          298  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 683 32 32 32 32 32 2 2 1','0 0 5191447 5191465 5191465 5191465 5191465 5191465 5191479 5191479 5191479','0 0 20361 336764 345696 345696 345696 345696 5158907 5158962 5191479',X'0C08080303080808080403037370D101884501328F690F002900A69C');
          299  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 213354 113 113 113 113 113 1 1 1','0 0 6102233 6155183 6155183 6155183 6155183 6155183 6155295 6155295 6155295','0 0 26812 421693 433202 433202 433202 433202 6119212 6119281 6155295',X'0C080804030808080804040300F2FA44019B6D0132406700FF5594714AE8');
          300  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 3675 241 241 241 241 241 1 1 1','0 0 6486701 6489287 6489287 6489287 6489287 6489287 6489349 6489349 6489349','0 0 28380 450494 462953 462953 462953 462953 6452616 6452691 6489349',X'0C080804040808080804030300F6ABAC009F84B60132DBDD6C967D155A2A');
          301  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 24063 38 38 38 38 38 1 1 1','0 0 7080914 7102383 7102383 7102383 7102383 7102383 7102420 7102420 7102420','0 0 35724 528136 541855 541858 541858 541858 7065247 7065323 7102420',X'0C0808040408080808040403010B0A5C00CCD3EE0133294500FF559459DDCD');
          302  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 7173953 20284 38 38 38 38 38 1 1 1','0 0 7107240 7126609 7126609 7126609 7126609 7126609 7126646 7126646 7126646','0 0 35764 531673 545484 545487 545487 545487 7089473 7089549 7126646',X'0C0808040408080808040403010B3C670114CE730133294300FF55942225CC');
          303  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 13288 5 1 1 1 1 1 1 1','0 7173953 7671119 7675167 7675171 7675171 7675171 7675171 7675171 7675171 7675171','0 1 64320 967583 993386 999414 999414 999414 7632969 7633046 7675171',X'0C080904030308080804040400F2FA4401D16F0183350132DEFE00FF5594009FA501');
          304  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','7804279 630326 61 1 1 1 1 1 1 1 1','0 7173953 7787172 7787219 7787219 7787219 7787219 7787219 7787219 7787219 7787219','0 1 73272 1068631 1096442 1107608 1107608 1107608 7744925 7745002 7787219',X'0C0809040408080808040304010ABA9100AA4C1F013351DB0DD242008BFFEF');
          305  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8657 605 605 605 605 605 1 1 1','7804279 7804279 8360485 8364643 8364643 8364643 8364643 8364643 8365247 8365247 8365247','1 2 75785 1096159 1124446 1135923 1135923 1135923 8321766 8321843 8365247',X'0C09080303080808080403031AD3690DC36E01328E2F021FFC3D9128');
          306  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 33421 57 26 26 26 26 1 1 1','7804279 7804279 8873934 8891008 8891039 8891039 8891039 8891039 8891064 8891064 8891064','1 2 76834 1110063 1138607 1150084 1150084 1150084 8846567 8846644 8891064',X'0C09080303020808080404043377630CE166232801332A1800FF559400836DFB');
          307  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 2182 94 94 94 94 94 1 1 1','7804279 7804279 9083187 9085006 9085006 9085006 9085006 9085006 9085089 9085089 9085089','1 2 77227 1115805 1144438 1155915 1155915 1155915 9040239 9040316 9085089',X'0C09080303080808080403033AC92C04AF670132B5FC021FFC38DBD0');
          308  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6008 277 277 277 277 277 1 1 1','7804279 7804279 9124662 9124662 9124662 9124662 9124662 9124662 9124938 9124938 9124938','1 2 77300 1116652 1145304 1156781 1156781 1156781 9080000 9080077 9124938',X'0C09080303080808080404033C1C5C01B49901328DDA00F024883D6052');
          309  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 6023 50 50 50 50 50 1 1 1','7804279 7804279 9393480 9395815 9395815 9395815 9395815 9395815 9395864 9395864 9395864','1 2 77893 1123924 1152663 1164140 1164140 1164140 9350459 9350536 9395864',X'0C09080303080808080403034CDD9A01C30D013290877E1C2303CC11');
          310  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 79 6 6 6 6 6 1 1 1','7804279 7804279 10382946 10382956 10382956 10382956 10382956 10382956 10382959 10382959 10382959','1 2 80421 1154920 1184197 1195674 1195674 1195674 10336219 10336296 10382959',X'0C090804030808080804030400E9A10A02A47201332C6C0CC31600ABCD60');
          311  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 8251 280 280 280 280 280 1 1 1','7804279 7804279 11067468 11072690 11072690 11072690 11072690 11072690 11072969 11072969 11072969','1 2 83449 1186373 1216159 1227636 1227636 1227636 11025858 11025935 11072969',X'0C090804040808080804040300FFA4A70089DBDD0132B5FF008A66AD6AE2B8');
          312  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 44772 58 58 58 58 58 1 1 1','7804279 7804279 11268036 11269261 11269261 11269261 11269261 11269261 11269318 11269318 11269318','1 2 85052 1199706 1229712 1241189 1241189 1241189 11222207 11222284 11269318',X'0C0908040308080808040404010B0A5C018ACD0133294300FF559400B0E291');
          313  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 53775 37 19 19 19 19 1 1 1','7804279 7804279 11330929 11355027 11355045 11355045 11355045 11355045 11355063 11355063 11355063','1 2 85255 1206165 1236304 1247781 1247781 1247781 11307952 11308029 11355063',X'0C0908040302080808040403010BFA81026C24232801332B2E00FF55941F8BB5');
          314  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 3718791 39430 39 39 39 39 39 1 1 1','7804279 7804279 11458789 11476757 11476757 11476757 11476757 11476757 11476795 11476795 11476795','1 2 86422 1219089 1249476 1260953 1260953 1260953 11429684 11429761 11476795',X'0C09080403080808080404030113B99602F6AF01332B2E00FF55941F8A54');
          315  +  INSERT INTO sqlite_stat4 VALUES('tx1','ix0','3876548 157757 5317 1 1 1 1 1 1 1 1','7804279 11523070 11652844 11658160 11658160 11658160 11658160 11658160 11658160 11658160 11658160','1 3 97969 1358780 1391643 1403122 1403122 1403122 11611049 11611126 11658160',X'0C0909040402080808040403010BFA8102594CCB2328013351E800FF55945B0F5D');
          316  +  ANALYZE sqlite_master;
          317  +} {}
          318  +
          319  +# Ensure that the query planner implements the GROUP BY using a separate sort
          320  +#
          321  +do_execsql_test whereJ-1.4 {
          322  +  EXPLAIN QUERY PLAN
          323  +  SELECT aid, sid, MAX(edate) edate
          324  +    FROM tx1
          325  +   WHERE cid = 115790
          326  +     AND sid = 9100
          327  +     AND edate <= 20140430 AND edate >= 20120429
          328  +   GROUP BY aid;
          329  +} {/B-TREE/}
          330  +
          331  +finish_test

Changes to test/without_rowid1.test.

   209    209     CREATE TABLE t42(x);
   210    210     INSERT INTO t42 VALUES('xyz');
   211    211     SELECT t42.rowid FROM t41, t42;
   212    212   } {1}
   213    213   do_execsql_test 4.2 {
   214    214     SELECT t42.rowid FROM t42, t41;
   215    215   } {1}
          216  +
          217  +
          218  +#--------------------------------------------------------------------------
          219  +# The following tests verify that the trailing PK fields added to each
          220  +# entry in an index on a WITHOUT ROWID table are used correctly.
          221  +#
          222  +do_execsql_test 5.0 {
          223  +  CREATE TABLE t45(a PRIMARY KEY, b, c) WITHOUT ROWID;
          224  +  CREATE INDEX i45 ON t45(b);
          225  +
          226  +  INSERT INTO t45 VALUES(2, 'one', 'x');
          227  +  INSERT INTO t45 VALUES(4, 'one', 'x');
          228  +  INSERT INTO t45 VALUES(6, 'one', 'x');
          229  +  INSERT INTO t45 VALUES(8, 'one', 'x');
          230  +  INSERT INTO t45 VALUES(10, 'one', 'x');
          231  +
          232  +  INSERT INTO t45 VALUES(1, 'two', 'x');
          233  +  INSERT INTO t45 VALUES(3, 'two', 'x');
          234  +  INSERT INTO t45 VALUES(5, 'two', 'x');
          235  +  INSERT INTO t45 VALUES(7, 'two', 'x');
          236  +  INSERT INTO t45 VALUES(9, 'two', 'x');
          237  +}
          238  +
          239  +do_eqp_test 5.1 {
          240  +  SELECT * FROM t45 WHERE b=? AND a>?
          241  +} {/*USING INDEX i45 (b=? AND a>?)*/}
          242  +
          243  +do_execsql_test 5.2 {
          244  +  SELECT * FROM t45 WHERE b='two' AND a>4
          245  +} {5 two x 7 two x 9 two x}
          246  +
          247  +do_execsql_test 5.3 {
          248  +  SELECT * FROM t45 WHERE b='one' AND a<8
          249  +} { 2 one x 4 one x 6 one x }
          250  +
          251  +do_execsql_test 5.4 {
          252  +  CREATE TABLE t46(a, b, c, d, PRIMARY KEY(a, b)) WITHOUT ROWID;
          253  +  WITH r(x) AS (
          254  +    SELECT 1 UNION ALL SELECT x+1 FROM r WHERE x<100
          255  +  )
          256  +  INSERT INTO t46 SELECT x / 20, x % 20, x % 10, x FROM r;
          257  +}
          258  +
          259  +set queries {
          260  +  1    2    "c = 5 AND a = 1"          {/*i46 (c=? AND a=?)*/}
          261  +  2    6    "c = 4 AND a < 3"          {/*i46 (c=? AND a<?)*/}
          262  +  3    4    "c = 2 AND a >= 3"         {/*i46 (c=? AND a>?)*/}
          263  +  4    1    "c = 2 AND a = 1 AND b<10" {/*i46 (c=? AND a=? AND b<?)*/}
          264  +  5    1    "c = 0 AND a = 0 AND b>5"  {/*i46 (c=? AND a=? AND b>?)*/}
          265  +}
          266  +
          267  +foreach {tn cnt where eqp} $queries {
          268  +  do_execsql_test 5.5.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt
          269  +}
          270  +
          271  +do_execsql_test 5.6 {
          272  +  CREATE INDEX i46 ON t46(c);
          273  +}
          274  +
          275  +foreach {tn cnt where eqp} $queries {
          276  +  do_execsql_test 5.7.$tn.1 "SELECT count(*) FROM t46 WHERE $where" $cnt
          277  +  do_eqp_test 5.7.$tn.2  "SELECT count(*) FROM t46 WHERE $where" $eqp
          278  +}
          279  +
   216    280     
   217    281   finish_test

Changes to tool/lemon.c.

  1179   1179         apx->type = SH_RESOLVED;
  1180   1180       }else if( spx->prec==spy->prec && spx->assoc==RIGHT ){ /* Use operator */
  1181   1181         apy->type = RD_RESOLVED;                             /* associativity */
  1182   1182       }else if( spx->prec==spy->prec && spx->assoc==LEFT ){  /* to break tie */
  1183   1183         apx->type = SH_RESOLVED;
  1184   1184       }else{
  1185   1185         assert( spx->prec==spy->prec && spx->assoc==NONE );
  1186         -      apy->type = SRCONFLICT;
  1187         -      errcnt++;
         1186  +      apx->type = ERROR;
  1188   1187       }
  1189   1188     }else if( apx->type==REDUCE && apy->type==REDUCE ){
  1190   1189       spx = apx->x.rp->precsym;
  1191   1190       spy = apy->x.rp->precsym;
  1192   1191       if( spx==0 || spy==0 || spx->prec<0 ||
  1193   1192       spy->prec<0 || spx->prec==spy->prec ){
  1194   1193         apy->type = RRCONFLICT;

Changes to tool/showdb.c.

    62     62   */
    63     63   static unsigned char *getContent(int ofst, int nByte){
    64     64     unsigned char *aData;
    65     65     aData = malloc(nByte+32);
    66     66     if( aData==0 ) out_of_memory();
    67     67     memset(aData, 0, nByte+32);
    68     68     lseek(db, ofst, SEEK_SET);
    69         -  read(db, aData, nByte);
           69  +  if( read(db, aData, nByte)<nByte ) memset(aData, 0, nByte);
    70     70     return aData;
    71     71   }
    72     72   
    73     73   /*
    74     74   ** Print a range of bytes as hex and as ascii.
    75     75   */
    76     76   static unsigned char *print_byte_range(
................................................................................
   124    124     unsigned char *aData;
   125    125     iStart = (iPg-1)*pagesize;
   126    126     fprintf(stdout, "Page %d:   (offsets 0x%x..0x%x)\n",
   127    127             iPg, iStart, iStart+pagesize-1);
   128    128     aData = print_byte_range(iStart, pagesize, 0);
   129    129     free(aData);
   130    130   }
          131  +
   131    132   
   132    133   /* Print a line of decode output showing a 4-byte integer.
   133    134   */
   134    135   static void print_decode_line(
   135    136     unsigned char *aData,      /* Content being decoded */
   136    137     int ofst, int nByte,       /* Start and size of decode */
   137    138     const char *zMsg           /* Message to append */
................................................................................
   336    337     }
   337    338     if( showCellContent && cType!=5 ){
   338    339       nDesc += describeContent(a, nLocal, &zDesc[nDesc-1]);
   339    340     }
   340    341     *pzDesc = zDesc;
   341    342     return nLocal+n;
   342    343   }
          344  +
          345  +/* Print an offset followed by nByte bytes.  Add extra white-space
          346  +** at the end so that subsequent text is aligned.
          347  +*/
          348  +static void printBytes(
          349  +  unsigned char *aData,      /* Content being decoded */
          350  +  unsigned char *aStart,     /* Start of content to be printed */
          351  +  int nByte                  /* Number of bytes to print */
          352  +){
          353  +  int j;
          354  +  printf(" %03x: ", (int)(aStart-aData));
          355  +  for(j=0; j<9; j++){
          356  +    if( j>=nByte ){
          357  +      printf("   ");
          358  +    }else{
          359  +      printf("%02x ", aStart[j]);
          360  +    }
          361  +  }
          362  +}
          363  +
          364  +
          365  +/*
          366  +** Write a full decode on stdout for the cell at a[ofst].
          367  +** Assume the page contains a header of size szPgHdr bytes.
          368  +*/
          369  +static void decodeCell(
          370  +  unsigned char *a,       /* Page content (without the page-1 header) */
          371  +  unsigned pgno,          /* Page number */
          372  +  int iCell,              /* Cell index */
          373  +  int szPgHdr,            /* Size of the page header.  0 or 100 */
          374  +  int ofst                /* Cell begins at a[ofst] */
          375  +){
          376  +  int i, j, k;
          377  +  int leftChild;
          378  +  i64 nPayload;
          379  +  i64 rowid;
          380  +  i64 nHdr;
          381  +  i64 iType;
          382  +  int nLocal;
          383  +  unsigned char *x = a + ofst;
          384  +  unsigned char *end;
          385  +  unsigned char cType = a[0];
          386  +  int nCol = 0;
          387  +  int szCol[2000];
          388  +  int ofstCol[2000];
          389  +  int typeCol[2000];
          390  +
          391  +  printf("Cell[%d]:\n", iCell);
          392  +  if( cType<=5 ){
          393  +    leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3];
          394  +    printBytes(a, x, 4);
          395  +    printf("left child page:: %d\n", leftChild);
          396  +    x += 4;
          397  +  }
          398  +  if( cType!=5 ){
          399  +    i = decodeVarint(x, &nPayload);
          400  +    printBytes(a, x, i);
          401  +    nLocal = localPayload(nPayload, cType);
          402  +    if( nLocal==nPayload ){
          403  +      printf("payload-size: %d\n", (int)nPayload);
          404  +    }else{
          405  +      printf("payload-size: %d (%d local, %d overflow)\n",
          406  +             (int)nPayload, nLocal, (int)(nPayload-nLocal));
          407  +    }
          408  +    x += i;
          409  +  }else{
          410  +    nPayload = nLocal = 0;
          411  +  }
          412  +  end = x + nLocal;
          413  +  if( cType==5 || cType==13 ){
          414  +    i = decodeVarint(x, &rowid);
          415  +    printBytes(a, x, i);
          416  +    printf("rowid: %lld\n", rowid);
          417  +    x += i;
          418  +  }
          419  +  if( nLocal>0 ){
          420  +    i = decodeVarint(x, &nHdr);
          421  +    printBytes(a, x, i);
          422  +    printf("record-header-size: %d\n", (int)nHdr);
          423  +    j = i;
          424  +    nCol = 0;
          425  +    k = nHdr;
          426  +    while( x+j<end && j<nHdr ){
          427  +       const char *zTypeName;
          428  +       int sz = 0;
          429  +       char zNm[30];
          430  +       i = decodeVarint(x+j, &iType);
          431  +       printBytes(a, x+j, i);
          432  +       printf("typecode[%d]: %d - ", nCol, (int)iType);
          433  +       switch( iType ){
          434  +         case 0:  zTypeName = "NULL";    sz = 0;  break;
          435  +         case 1:  zTypeName = "int8";    sz = 1;  break;
          436  +         case 2:  zTypeName = "int16";   sz = 2;  break;
          437  +         case 3:  zTypeName = "int24";   sz = 3;  break;
          438  +         case 4:  zTypeName = "int32";   sz = 4;  break;
          439  +         case 5:  zTypeName = "int48";   sz = 6;  break;
          440  +         case 6:  zTypeName = "int64";   sz = 8;  break;
          441  +         case 7:  zTypeName = "double";  sz = 8;  break;
          442  +         case 8:  zTypeName = "zero";    sz = 0;  break;
          443  +         case 9:  zTypeName = "one";     sz = 0;  break;
          444  +         case 10:
          445  +         case 11: zTypeName = "error";   sz = 0;  break;
          446  +         default: {
          447  +           sz = (int)(iType-12)/2;
          448  +           sprintf(zNm, (iType&1)==0 ? "blob(%d)" : "text(%d)", sz);
          449  +           zTypeName = zNm;
          450  +           break;
          451  +         }
          452  +       }
          453  +       printf("%s\n", zTypeName);
          454  +       szCol[nCol] = sz;
          455  +       ofstCol[nCol] = k;
          456  +       typeCol[nCol] = (int)iType;
          457  +       k += sz;
          458  +       nCol++;
          459  +       j += i;
          460  +    }
          461  +    for(i=0; i<nCol && ofstCol[i]+szCol[i]<=nLocal; i++){
          462  +       int s = ofstCol[i];
          463  +       i64 v;
          464  +       const unsigned char *pData;
          465  +       if( szCol[i]==0 ) continue;
          466  +       printBytes(a, x+s, szCol[i]);
          467  +       printf("data[%d]: ", i);
          468  +       pData = x+s;
          469  +       if( typeCol[i]<=7 ){
          470  +         v = (signed char)pData[0];
          471  +         for(k=1; k<szCol[i]; k++){
          472  +           v = (v<<8) + pData[k];
          473  +         }
          474  +         if( typeCol[i]==7 ){
          475  +           double r;
          476  +           memcpy(&r, &v, sizeof(r));
          477  +           printf("%#g\n", r);
          478  +         }else{
          479  +           printf("%lld\n", v);
          480  +         }
          481  +       }else{
          482  +         int ii, jj;
          483  +         char zConst[32];
          484  +         if( (typeCol[i]&1)==0 ){
          485  +           zConst[0] = 'x';
          486  +           zConst[1] = '\'';
          487  +           for(ii=2, jj=0; jj<szCol[i] && ii<24; jj++, ii+=2){
          488  +             sprintf(zConst+ii, "%02x", pData[jj]);
          489  +           }
          490  +         }else{
          491  +           zConst[0] = '\'';
          492  +           for(ii=1, jj=0; jj<szCol[i] && ii<24; jj++, ii++){
          493  +             zConst[ii] = isprint(pData[jj]) ? pData[jj] : '.';
          494  +           }
          495  +           zConst[ii] = 0;
          496  +         }
          497  +         if( jj<szCol[i] ){
          498  +           memcpy(zConst+ii, "...'", 5);
          499  +         }else{
          500  +           memcpy(zConst+ii, "'", 2);
          501  +         }
          502  +         printf("%s\n", zConst);
          503  +       }
          504  +       j = ofstCol[i] + szCol[i];
          505  +    }
          506  +  }
          507  +  if( j<nLocal ){
          508  +    printBytes(a, x+j, 0);
          509  +    printf("... %d bytes of content ...\n", nLocal-j);
          510  +  }
          511  +  if( nLocal<nPayload ){
          512  +    printBytes(a, x+nLocal, 4);
          513  +    printf("overflow-page: %d\n", decodeInt32(x+nLocal));
          514  +  }
          515  +}
          516  +
   343    517   
   344    518   /*
   345    519   ** Decode a btree page
   346    520   */
   347    521   static void decode_btree_page(
   348    522     unsigned char *a,   /* Page content */
   349    523     int pgno,           /* Page number */
................................................................................
   352    526   ){
   353    527     const char *zType = "unknown";
   354    528     int nCell;
   355    529     int i, j;
   356    530     int iCellPtr;
   357    531     int showCellContent = 0;
   358    532     int showMap = 0;
          533  +  int cellToDecode = -2;
   359    534     char *zMap = 0;
   360    535     switch( a[0] ){
   361    536       case 2:  zType = "index interior node";  break;
   362    537       case 5:  zType = "table interior node";  break;
   363    538       case 10: zType = "index leaf";           break;
   364    539       case 13: zType = "table leaf";           break;
   365    540     }
   366    541     while( zArgs[0] ){
   367    542       switch( zArgs[0] ){
   368    543         case 'c': showCellContent = 1;  break;
   369    544         case 'm': showMap = 1;          break;
          545  +      case 'd': {
          546  +        if( !isdigit(zArgs[1]) ){
          547  +          cellToDecode = -1;
          548  +        }else{
          549  +          cellToDecode = 0;
          550  +          while( isdigit(zArgs[1]) ){
          551  +            zArgs++;
          552  +            cellToDecode = cellToDecode*10 + zArgs[0] - '0';
          553  +          }
          554  +        }
          555  +        break;
          556  +      }
   370    557       }
   371    558       zArgs++;
   372    559     }
   373         -  printf("Decode of btree page %d:\n", pgno);
          560  +  nCell = a[3]*256 + a[4];
          561  +  iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8;
          562  +  if( cellToDecode>=nCell ){
          563  +    printf("Page %d has only %d cells\n", pgno, nCell);
          564  +    return;
          565  +  }
          566  +  printf("Header on btree page %d:\n", pgno);
   374    567     print_decode_line(a, 0, 1, zType);
   375    568     print_decode_line(a, 1, 2, "Offset to first freeblock");
   376    569     print_decode_line(a, 3, 2, "Number of cells on this page");
   377         -  nCell = a[3]*256 + a[4];
   378    570     print_decode_line(a, 5, 2, "Offset to cell content area");
   379    571     print_decode_line(a, 7, 1, "Fragmented byte count");
   380    572     if( a[0]==2 || a[0]==5 ){
   381    573       print_decode_line(a, 8, 4, "Right child");
   382         -    iCellPtr = 12;
   383         -  }else{
   384         -    iCellPtr = 8;
   385    574     }
   386         -  if( nCell>0 ){
          575  +  if( cellToDecode==(-2) && nCell>0 ){
   387    576       printf(" key: lx=left-child n=payload-size r=rowid\n");
   388    577     }
   389    578     if( showMap ){
   390    579       zMap = malloc(pagesize);
   391    580       memset(zMap, '.', pagesize);
   392    581       memset(zMap, '1', hdrSize);
   393    582       memset(&zMap[hdrSize], 'H', iCellPtr);
................................................................................
   405    594         memset(&zMap[cofst], '*', n);
   406    595         zMap[cofst] = '[';
   407    596         zMap[cofst+n-1] = ']';
   408    597         sprintf(zBuf, "%d", i);
   409    598         j = strlen(zBuf);
   410    599         if( j<=n-2 ) memcpy(&zMap[cofst+1], zBuf, j);
   411    600       }
   412         -    printf(" %03x: cell[%d] %s\n", cofst, i, zDesc);
          601  +    if( cellToDecode==(-2) ){
          602  +      printf(" %03x: cell[%d] %s\n", cofst, i, zDesc);
          603  +    }else if( cellToDecode==(-1) || cellToDecode==i ){
          604  +      decodeCell(a, pgno, i, hdrSize, cofst-hdrSize);
          605  +    }
   413    606     }
   414    607     if( showMap ){
          608  +    printf("Page map:  (H=header P=cell-index 1=page-1-header .=free-space)\n");
   415    609       for(i=0; i<pagesize; i+=64){
   416    610         printf(" %03x: %.64s\n", i, &zMap[i]);
   417    611       }
   418    612       free(zMap);
   419         -  }  
          613  +  }
   420    614   }
   421    615   
   422    616   /*
   423    617   ** Decode a freelist trunk page.
   424    618   */
   425    619   static void decode_trunk_page(
   426    620     int pgno,             /* The page number */
................................................................................
   753    947       "    pgidx           Index of how each page is used\n"
   754    948       "    ptrmap          Show all PTRMAP page content\n"
   755    949       "    NNN..MMM        Show hex of pages NNN through MMM\n"
   756    950       "    NNN..end        Show hex of pages NNN through end of file\n"
   757    951       "    NNNb            Decode btree page NNN\n"
   758    952       "    NNNbc           Decode btree page NNN and show content\n"
   759    953       "    NNNbm           Decode btree page NNN and show a layout map\n"
          954  +    "    NNNbdCCC        Decode cell CCC on btree page NNN\n"
   760    955       "    NNNt            Decode freelist trunk page NNN\n"
   761    956       "    NNNtd           Show leaf freelist pages on the decode\n"
   762    957       "    NNNtr           Recurisvely decode freelist starting at NNN\n"
   763    958     );
   764    959   }
   765    960   
   766    961   int main(int argc, char **argv){
................................................................................
   774    969     if( db<0 ){
   775    970       fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]);
   776    971       exit(1);
   777    972     }
   778    973     zPgSz[0] = 0;
   779    974     zPgSz[1] = 0;
   780    975     lseek(db, 16, SEEK_SET);
   781         -  read(db, zPgSz, 2);
          976  +  if( read(db, zPgSz, 2)<2 ) memset(zPgSz, 0, 2);
   782    977     pagesize = zPgSz[0]*256 + zPgSz[1]*65536;
   783    978     if( pagesize==0 ) pagesize = 1024;
   784    979     printf("Pagesize: %d\n", pagesize);
   785    980     fstat(db, &sbuf);
   786    981     mxPage = sbuf.st_size/pagesize;
   787    982     printf("Available pages: 1..%d\n", mxPage);
   788    983     if( argc==2 ){

Changes to tool/showjournal.c.

     8      8   
     9      9   /*
    10     10   ** state information
    11     11   */
    12     12   static int pageSize = 1024;
    13     13   static int sectorSize = 512;
    14     14   static FILE *db = 0;
    15         -static int showPageContent = 0;
    16     15   static int fileSize = 0;
    17     16   static unsigned cksumNonce = 0;
    18     17   
    19     18   /* Report a memory allocation error */
    20     19   static void out_of_memory(void){
    21     20     fprintf(stderr,"Out of memory...\n");
    22     21     exit(1);
    23     22   }
    24     23   
    25     24   /*
    26     25   ** Read N bytes of memory starting at iOfst into space obtained
    27     26   ** from malloc().
    28     27   */
    29         -static char *read_content(int N, int iOfst){
           28  +static unsigned char *read_content(int N, int iOfst){
    30     29     int got;
    31         -  char *pBuf = malloc(N);
           30  +  unsigned char *pBuf = malloc(N);
    32     31     if( pBuf==0 ) out_of_memory();
    33     32     fseek(db, iOfst, SEEK_SET);
    34     33     got = fread(pBuf, 1, N, db);
    35     34     if( got<0 ){
    36     35       fprintf(stderr, "I/O error reading %d bytes from %d\n", N, iOfst);
    37     36       memset(pBuf, 0, N);
    38     37     }else if( got<N ){
................................................................................
    42     41     }
    43     42     return pBuf;
    44     43   }
    45     44   
    46     45   /* Print a line of decode output showing a 4-byte integer.
    47     46   */
    48     47   static unsigned print_decode_line(
    49         -  unsigned char *aData,      /* Content being decoded */
    50         -  int ofst, int nByte,       /* Start and size of decode */
    51         -  const char *zMsg           /* Message to append */
           48  +  const unsigned char *aData,  /* Content being decoded */
           49  +  int ofst, int nByte,         /* Start and size of decode */
           50  +  const char *zMsg             /* Message to append */
    52     51   ){
    53     52     int i, j;
    54     53     unsigned val = aData[ofst];
    55     54     char zBuf[100];
    56         -  sprintf(zBuf, " %03x: %02x", ofst, aData[ofst]);
           55  +  sprintf(zBuf, " %05x: %02x", ofst, aData[ofst]);
    57     56     i = strlen(zBuf);
    58     57     for(j=1; j<4; j++){
    59     58       if( j>=nByte ){
    60     59         sprintf(&zBuf[i], "   ");
    61     60       }else{
    62     61         sprintf(&zBuf[i], " %02x", aData[ofst+j]);
    63     62         val = val*256 + aData[ofst+j];
................................................................................
    70     69   }
    71     70   
    72     71   /*
    73     72   ** Read and print a journal header.  Store key information (page size, etc)
    74     73   ** in global variables.
    75     74   */
    76     75   static unsigned decode_journal_header(int iOfst){
    77         -  char *pHdr = read_content(64, iOfst);
           76  +  unsigned char *pHdr = read_content(64, iOfst);
    78     77     unsigned nPage;
    79     78     printf("Header at offset %d:\n", iOfst);
    80     79     print_decode_line(pHdr, 0, 4, "Header part 1 (3654616569)");
    81     80     print_decode_line(pHdr, 4, 4, "Header part 2 (547447767)");
    82     81     nPage =
    83     82     print_decode_line(pHdr, 8, 4, "page count");
    84     83     cksumNonce =
................................................................................
    97     96   }
    98     97   
    99     98   static void print_page(int iOfst){
   100     99     unsigned char *aData;
   101    100     char zTitle[50];
   102    101     aData = read_content(pageSize+8, iOfst);
   103    102     sprintf(zTitle, "page number for page at offset %d", iOfst);
   104         -  print_decode_line(aData, 0, 4, zTitle);
          103  +  print_decode_line(aData-iOfst, iOfst, 4, zTitle);
   105    104     free(aData);
   106    105   }
   107    106   
   108    107   int main(int argc, char **argv){
   109         -  int rc;
   110    108     int nPage, cnt;
   111    109     int iOfst;
   112    110     if( argc!=2 ){
   113    111       fprintf(stderr,"Usage: %s FILENAME\n", argv[0]);
   114    112       exit(1);
   115    113     }
   116    114     db = fopen(argv[1], "rb");
................................................................................
   132    130       while( cnt && iOfst<fileSize ){
   133    131         print_page(iOfst);
   134    132         iOfst += pageSize+8;
   135    133       }
   136    134       iOfst = (iOfst/sectorSize + 1)*sectorSize;
   137    135     }
   138    136     fclose(db);
          137  +  return 0;
   139    138   }

Added tool/showstat4.c.

            1  +/*
            2  +** This utility program decodes and displays the content of the
            3  +** sqlite_stat4 table in the database file named on the command
            4  +** line.
            5  +*/
            6  +#include <stdio.h>
            7  +#include <string.h>
            8  +#include <stdlib.h>
            9  +#include <ctype.h>
           10  +#include "sqlite3.h"
           11  +
           12  +typedef sqlite3_int64 i64;   /* 64-bit signed integer type */
           13  +
           14  +
           15  +/*
           16  +** Convert the var-int format into i64.  Return the number of bytes
           17  +** in the var-int.  Write the var-int value into *pVal.
           18  +*/
           19  +static int decodeVarint(const unsigned char *z, i64 *pVal){
           20  +  i64 v = 0;
           21  +  int i;
           22  +  for(i=0; i<8; i++){
           23  +    v = (v<<7) + (z[i]&0x7f);
           24  +    if( (z[i]&0x80)==0 ){ *pVal = v; return i+1; }
           25  +  }
           26  +  v = (v<<8) + (z[i]&0xff);
           27  +  *pVal = v;
           28  +  return 9;
           29  +}
           30  +
           31  +
           32  +
           33  +int main(int argc, char **argv){
           34  +  sqlite3 *db;
           35  +  sqlite3_stmt *pStmt;
           36  +  char *zIdx = 0;
           37  +  int rc, j, x, y, mxHdr;
           38  +  const unsigned char *aSample;
           39  +  int nSample;
           40  +  i64 iVal;
           41  +  const char *zSep;
           42  +
           43  +  if( argc!=2 ){
           44  +    fprintf(stderr, "Usage: %s DATABASE-FILE\n", argv[0]);
           45  +    exit(1);
           46  +  }
           47  +  rc = sqlite3_open(argv[1], &db);
           48  +  if( rc!=SQLITE_OK || db==0 ){
           49  +    fprintf(stderr, "Cannot open database file [%s]\n", argv[1]);
           50  +    exit(1);
           51  +  }
           52  +  rc = sqlite3_prepare_v2(db,
           53  +        "SELECT tbl||'.'||idx, nEq, nLT, nDLt, sample "
           54  +        "FROM sqlite_stat4 ORDER BY 1", -1,
           55  +        &pStmt, 0);
           56  +  if( rc!=SQLITE_OK || pStmt==0 ){
           57  +    fprintf(stderr, "%s\n", sqlite3_errmsg(db));
           58  +    sqlite3_close(db);
           59  +    exit(1);
           60  +  }
           61  +  while( SQLITE_ROW==sqlite3_step(pStmt) ){
           62  +    if( zIdx==0 || strcmp(zIdx, (const char*)sqlite3_column_text(pStmt,0))!=0 ){
           63  +      if( zIdx ) printf("\n");
           64  +      sqlite3_free(zIdx);
           65  +      zIdx = sqlite3_mprintf("%s", sqlite3_column_text(pStmt,0));
           66  +      printf("%s:\n", zIdx);
           67  +    }else{
           68  +      printf("  -----------------------------------------------------------\n");
           69  +    }
           70  +    printf("  nEq    = %s\n", sqlite3_column_text(pStmt,1));
           71  +    printf("  nLt    = %s\n", sqlite3_column_text(pStmt,2));
           72  +    printf("  nDLt   = %s\n", sqlite3_column_text(pStmt,3));
           73  +    printf("  sample = x'");
           74  +    aSample = sqlite3_column_blob(pStmt,4);
           75  +    nSample = sqlite3_column_bytes(pStmt,4);
           76  +    for(j=0; j<nSample; j++) printf("%02x", aSample[j]);
           77  +    printf("'\n          ");
           78  +    zSep = " ";
           79  +    x = decodeVarint(aSample, &iVal);
           80  +    if( iVal<x || iVal>nSample ){
           81  +      printf(" <error>\n");
           82  +      continue;
           83  +    }
           84  +    y = mxHdr = (int)iVal;
           85  +    while( x<mxHdr ){
           86  +      int sz;
           87  +      i64 v;
           88  +      x += decodeVarint(aSample+x, &iVal);
           89  +      if( x>mxHdr ) break;
           90  +      if( iVal<0 ) break;
           91  +      switch( iVal ){
           92  +        case 0:  sz = 0;  break;
           93  +        case 1:  sz = 1;  break;
           94  +        case 2:  sz = 2;  break;
           95  +        case 3:  sz = 3;  break;
           96  +        case 4:  sz = 4;  break;
           97  +        case 5:  sz = 6;  break;
           98  +        case 6:  sz = 8;  break;
           99  +        case 7:  sz = 8;  break;
          100  +        case 8:  sz = 0;  break;
          101  +        case 9:  sz = 0;  break;
          102  +        case 10:
          103  +        case 11: sz = 0;  break;
          104  +        default: sz = (int)(iVal-12)/2;  break;
          105  +      }
          106  +      if( y+sz>nSample ) break;
          107  +      if( iVal==0 ){
          108  +        printf("%sNULL", zSep);
          109  +      }else if( iVal==8 || iVal==9 ){
          110  +        printf("%s%d", zSep, ((int)iVal)-8);
          111  +      }else if( iVal<=7 ){
          112  +        v = (signed char)aSample[y];
          113  +        for(j=1; j<sz; j++){
          114  +          v = (v<<8) + aSample[y+j];
          115  +        }
          116  +        if( iVal==7 ){
          117  +          double r;
          118  +          memcpy(&r, &v, sizeof(r));
          119  +          printf("%s%#g", zSep, r);
          120  +        }else{
          121  +          printf("%s%lld", zSep, v);
          122  +        }
          123  +      }else if( (iVal&1)==0 ){
          124  +        printf("%sx'", zSep);
          125  +        for(j=0; j<sz; j++){
          126  +          printf("%02x", aSample[y+j]);
          127  +        }
          128  +        printf("'");
          129  +      }else{
          130  +        printf("%s\"", zSep);
          131  +        for(j=0; j<sz; j++){
          132  +          char c = (char)aSample[y+j];
          133  +          if( isprint(c) ){
          134  +            if( c=='"' || c=='\\' ) putchar('\\');
          135  +            putchar(c);
          136  +          }else if( c=='\n' ){
          137  +            printf("\\n");
          138  +          }else if( c=='\t' ){
          139  +            printf("\\t");
          140  +          }else if( c=='\r' ){
          141  +            printf("\\r");
          142  +          }else{
          143  +            printf("\\%03o", c);
          144  +          }
          145  +        }
          146  +        printf("\"");
          147  +      }
          148  +      zSep = ",";
          149  +      y += sz;
          150  +    }
          151  +    printf("\n");
          152  +  }
          153  +  sqlite3_free(zIdx);
          154  +  sqlite3_finalize(pStmt);
          155  +  sqlite3_close(db);
          156  +  return 0;
          157  +}