Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
sqlite update to 3.49.0
Baptiste Daroussin committed 1 year ago
commit 2c007a009bf7eca05acfffb83d2cf1dda7ef3b5f
parent 0af5fe5
4 files changed +4237 -2741
modified external/sqlite/Makefile.autosetup
@@ -6,7 +6,7 @@ SRCS= sqlite3.c \
LOCAL_CFLAGS=	-I$(top_srcdir)/external/linenoise \
		-I$(top_builddir)/external/sqlite \
		-D_HAVE_SQLITE_CONFIG_H \
-
		-DHAVE_LINENOISE \
+
		-DHAVE_LINENOISE=2 \
		-Wno-unused-variable \
		-Wno-unused-function \
		-Wno-strict-aliasing \
modified external/sqlite/shell.c
@@ -122,9 +122,6 @@ typedef unsigned short int u16;
typedef sqlite3_int64 i64;
typedef sqlite3_uint64 u64;
typedef unsigned char u8;
-
#if SQLITE_USER_AUTHENTICATION
-
# include "sqlite3userauth.h"
-
#endif
#include <ctype.h>
#include <stdarg.h>

@@ -360,6 +357,11 @@ void sqlite3_fsetmode(FILE *stream, int mode);
** use O_U8TEXT when writing to the Windows console (or anything
** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
** for all other output channels.
+
**
+
** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available.  If
+
** defined, it forces the use of Win32 APIs for all console I/O, both
+
** input and output.  This is necessary for some non-Microsoft run-times
+
** that implement stdio differently from Microsoft/Visual-Studio.
*/
#if defined(SQLITE_U8TEXT_ONLY)
# define UseWtextForOutput(fd) 1
@@ -410,8 +412,8 @@ FILE *sqlite3_fopen(const char *zFilename, const char *zMode){

  sz1 = (int)strlen(zFilename);
  sz2 = (int)strlen(zMode);
-
  b1 = malloc( (sz1+1)*sizeof(b1[0]) );
-
  b2 = malloc( (sz2+1)*sizeof(b1[0]) );
+
  b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
+
  b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
  if( b1 && b2 ){
    sz1 = MultiByteToWideChar(CP_UTF8, 0, zFilename, sz1, b1, sz1);
    b1[sz1] = 0;
@@ -419,8 +421,8 @@ FILE *sqlite3_fopen(const char *zFilename, const char *zMode){
    b2[sz2] = 0;
    fp = _wfopen(b1, b2);
  }
-
  free(b1);
-
  free(b2);
+
  sqlite3_free(b1);
+
  sqlite3_free(b2);
  simBinaryOther = 0;
  return fp;
}
@@ -436,8 +438,8 @@ FILE *sqlite3_popen(const char *zCommand, const char *zMode){

  sz1 = (int)strlen(zCommand);
  sz2 = (int)strlen(zMode);
-
  b1 = malloc( (sz1+1)*sizeof(b1[0]) );
-
  b2 = malloc( (sz2+1)*sizeof(b1[0]) );
+
  b1 = sqlite3_malloc( (sz1+1)*sizeof(b1[0]) );
+
  b2 = sqlite3_malloc( (sz2+1)*sizeof(b1[0]) );
  if( b1 && b2 ){
    sz1 = MultiByteToWideChar(CP_UTF8, 0, zCommand, sz1, b1, sz1);
    b1[sz1] = 0;
@@ -445,8 +447,8 @@ FILE *sqlite3_popen(const char *zCommand, const char *zMode){
    b2[sz2] = 0;
    fp = _wpopen(b1, b2);
  }
-
  free(b1);
-
  free(b2);
+
  sqlite3_free(b1);
+
  sqlite3_free(b2);
  return fp;
}

@@ -460,12 +462,22 @@ char *sqlite3_fgets(char *buf, int sz, FILE *in){
    ** that into UTF-8.  Otherwise, non-ASCII characters all get translated
    ** into '?'.
    */
-
    wchar_t *b1 = malloc( sz*sizeof(wchar_t) );
+
    wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
    if( b1==0 ) return 0;
-
    _setmode(_fileno(in), IsConsole(in) ? _O_WTEXT : _O_U8TEXT);
-
    if( fgetws(b1, sz/4, in)==0 ){
-
      sqlite3_free(b1);
-
      return 0;
+
#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
+
    DWORD nRead = 0;
+
    if( IsConsole(in)
+
     && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
+
    ){
+
      b1[nRead] = 0;
+
    }else
+
#endif
+
    {
+
      _setmode(_fileno(in), IsConsole(in) ? _O_WTEXT : _O_U8TEXT);
+
      if( fgetws(b1, sz/4, in)==0 ){
+
        sqlite3_free(b1);
+
        return 0;
+
      }
    }
    WideCharToMultiByte(CP_UTF8, 0, b1, -1, buf, sz, 0, 0);
    sqlite3_free(b1);
@@ -521,20 +533,34 @@ int sqlite3_fputs(const char *z, FILE *out){
    ** any translation. */
    return fputs(z, out);
  }else{
-
    /* When writing to the command-prompt in Windows, it is necessary
-
    ** to use O_U8TEXT to render Unicode U+0080 and greater.  Go ahead
-
    ** use O_U8TEXT for everything in text mode.
+
    /* One must use UTF16 in order to get unicode support when writing
+
    ** to the console on Windows. 
    */
    int sz = (int)strlen(z);
-
    wchar_t *b1 = malloc( (sz+1)*sizeof(wchar_t) );
+
    wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
    if( b1==0 ) return 0;
    sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
    b1[sz] = 0;
-
    _setmode(_fileno(out), _O_U8TEXT);
-
    if( UseBinaryWText(out) ){
-
      piecemealOutput(b1, sz, out);
-
    }else{
-
      fputws(b1, out);
+

+
#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
+
    DWORD nWr = 0;
+
    if( IsConsole(out)
+
      && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
+
    ){
+
      /* If writing to the console, then the WriteConsoleW() is all we
+
      ** need to do. */
+
    }else
+
#endif
+
    {
+
      /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for
+
      ** non-console I/O even if that macro is defined, write using the
+
      ** standard library. */
+
      _setmode(_fileno(out), _O_U8TEXT);
+
      if( UseBinaryWText(out) ){
+
        piecemealOutput(b1, sz, out);
+
      }else{
+
        fputws(b1, out);
+
      }
    }
    sqlite3_free(b1);
    return 0;
@@ -2349,7 +2375,7 @@ int sqlite3PcacheTraceDeactivate(void){
**
** This SQLite extension implements functions that compute SHA3 hashes
** in the way described by the (U.S.) NIST FIPS 202 SHA-3 Standard.
-
** Two SQL functions are implemented:
+
** Three SQL functions are implemented:
**
**     sha3(X,SIZE)
**     sha3_agg(Y,SIZE)
@@ -5072,10 +5098,10 @@ int sqlite3_percentile_init(
){
  int rc = SQLITE_OK;
  unsigned int i;
-
#if defined(SQLITE3_H) || defined(SQLITE_STATIC_PERCENTILE)
-
  (void)pApi;      /* Unused parameter */
-
#else
+
#ifdef SQLITE3EXT_H
  SQLITE_EXTENSION_INIT2(pApi);
+
#else
+
  (void)pApi;      /* Unused parameter */
#endif
  (void)pzErrMsg;  /* Unused parameter */
  for(i=0; i<sizeof(aPercentFunc)/sizeof(aPercentFunc[0]); i++){
@@ -5271,15 +5297,15 @@ static u8* fromBase64( char *pIn, int ncIn, u8 *pOut ){
      case ND:
        /*  Treat dark non-digits as pad, but they terminate decode too. */
        ncIn = 0;
-
        deliberate_fall_through;
+
        deliberate_fall_through; /* FALLTHRU */
      case WS:
        /* Treat whitespace as pad and terminate this group.*/
        nti = nac;
-
        deliberate_fall_through;
+
        deliberate_fall_through; /* FALLTHRU */
      case PC:
        bdp = 0;
        --nbo;
-
        deliberate_fall_through;
+
        deliberate_fall_through; /* FALLTHRU */
      default: /* bdp is the digit value. */
        qv = qv<<6 | bdp;
        break;
@@ -5288,10 +5314,13 @@ static u8* fromBase64( char *pIn, int ncIn, u8 *pOut ){
    switch( nbo ){
    case 3:
      pOut[2] = (qv) & 0xff;
+
      deliberate_fall_through; /* FALLTHRU */
    case 2:
      pOut[1] = (qv>>8) & 0xff;
+
      deliberate_fall_through; /* FALLTHRU */
    case 1:
      pOut[0] = (qv>>16) & 0xff;
+
      break;
    }
    pOut += nbo;
  }
@@ -5626,12 +5655,16 @@ static u8* fromBase85( char *pIn, int ncIn, u8 *pOut ){
    switch( nbo ){
    case 4:
      *pOut++ = (qv >> 24)&0xff;
+
      /* FALLTHRU */
    case 3:
      *pOut++ = (qv >> 16)&0xff;
+
      /* FALLTHRU */
    case 2:
      *pOut++ = (qv >> 8)&0xff;
+
      /* FALLTHRU */
    case 1:
      *pOut++ = qv&0xff;
+
      /* FALLTHRU */
    case 0:
      break;
    }
@@ -6833,7 +6866,7 @@ static int seriesBestIndex(
      continue;
    }
    if( pConstraint->iColumn<SERIES_COLUMN_START ){
-
      if( pConstraint->iColumn==SERIES_COLUMN_VALUE ){
+
      if( pConstraint->iColumn==SERIES_COLUMN_VALUE && pConstraint->usable ){
        switch( op ){
          case SQLITE_INDEX_CONSTRAINT_EQ:
          case SQLITE_INDEX_CONSTRAINT_IS: {
@@ -6841,7 +6874,9 @@ static int seriesBestIndex(
            idxNum &= ~0x3300;
            aIdx[5] = i;
            aIdx[6] = -1;
+
#ifndef ZERO_ARGUMENT_GENERATE_SERIES
            bStartSeen = 1;
+
#endif
            break;
          }
          case SQLITE_INDEX_CONSTRAINT_GE: {
@@ -6849,7 +6884,9 @@ static int seriesBestIndex(
            idxNum |=  0x0100;
            idxNum &= ~0x0200;
            aIdx[5] = i;
+
#ifndef ZERO_ARGUMENT_GENERATE_SERIES
            bStartSeen = 1;
+
#endif
            break;
          }
          case SQLITE_INDEX_CONSTRAINT_GT: {
@@ -6857,7 +6894,9 @@ static int seriesBestIndex(
            idxNum |=  0x0200;
            idxNum &= ~0x0100;
            aIdx[5] = i;
+
#ifndef ZERO_ARGUMENT_GENERATE_SERIES
            bStartSeen = 1;
+
#endif
            break;
          }
          case SQLITE_INDEX_CONSTRAINT_LE: {
@@ -7668,7 +7707,8 @@ static const char *re_subcompile_string(ReCompiled *p){
** regular expression.  Applications should invoke this routine once
** for every call to re_compile() to avoid memory leaks.
*/
-
static void re_free(ReCompiled *pRe){
+
static void re_free(void *p){
+
  ReCompiled *pRe = (ReCompiled*)p;
  if( pRe ){
    sqlite3_free(pRe->aOp);
    sqlite3_free(pRe->aArg);
@@ -8334,7 +8374,7 @@ static int writeFile(

    GetSystemTime(&currentTime);
    SystemTimeToFileTime(&currentTime, &lastAccess);
-
    intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
+
    intervals = (mtime*10000000) + 116444736000000000;
    lastWrite.dwLowDateTime = (DWORD)intervals;
    lastWrite.dwHighDateTime = intervals >> 32;
    zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);
@@ -14169,7 +14209,7 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
    }else{
      IdxTable *pTab;
      rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
-
      if( rc==SQLITE_OK ){
+
      if( rc==SQLITE_OK && ALWAYS(pTab!=0) ){
        int i;
        char *zInner = 0;
        char *zOuter = 0;
@@ -16237,7 +16277,27 @@ int sqlite3_stmtrand_init(
** invariants are (1) you must have -DSQLITE_ENABLE_VFSTRACE so that
** the shell.c source file will know to include the -vfstrace command-line
** option and (2) you must compile and link the three source files
-
** shell,c, test_vfstrace.c, and sqlite3.c.  
+
** shell,c, test_vfstrace.c, and sqlite3.c.
+
**
+
** RUNTIME CONTROL OF VFSTRACE OUTPUT
+
**
+
** The application can use the "vfstrace" pragma to control which VFS
+
** APIs are traced.  To disable all output:
+
**
+
**    PRAGMA vfstrace('-all');
+
**
+
** To enable all output (which is the default setting):
+
**
+
**    PRAGMA vfstrace('+all');
+
**
+
** Individual APIs can be enabled or disabled by name, with or without
+
** the initial "x" character.  For example, to set up for tracing lock
+
** primatives only:
+
**
+
**    PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
+
**
+
** The argument to the vfstrace pragma ignores capitalization and any
+
** characters other than alphabetics, '+', and '-'.
*/
#include <stdlib.h>
#include <string.h>
@@ -16251,6 +16311,8 @@ typedef struct vfstrace_info vfstrace_info;
struct vfstrace_info {
  sqlite3_vfs *pRootVfs;              /* The underlying real VFS */
  int (*xOut)(const char*, void*);    /* Send output here */
+
  unsigned int mTrace;                /* Mask of interfaces to trace */
+
  u8 bOn;                             /* Tracing on/off */
  void *pOutArg;                      /* First argument to xOut */
  const char *zVfsName;               /* Name of this trace-VFS */
  sqlite3_vfs *pTraceVfs;             /* Pointer back to the trace VFS */
@@ -16268,6 +16330,39 @@ struct vfstrace_file {
};

/*
+
** Bit values for vfstrace_info.mTrace.
+
*/
+
#define VTR_CLOSE           0x00000001
+
#define VTR_READ            0x00000002
+
#define VTR_WRITE           0x00000004
+
#define VTR_TRUNC           0x00000008
+
#define VTR_SYNC            0x00000010
+
#define VTR_FSIZE           0x00000020
+
#define VTR_LOCK            0x00000040
+
#define VTR_UNLOCK          0x00000080
+
#define VTR_CRL             0x00000100
+
#define VTR_FCTRL           0x00000200
+
#define VTR_SECSZ           0x00000400
+
#define VTR_DEVCHAR         0x00000800
+
#define VTR_SHMLOCK         0x00001000
+
#define VTR_SHMMAP          0x00002000
+
#define VTR_SHMBAR          0x00004000
+
#define VTR_SHMUNMAP        0x00008000
+
#define VTR_OPEN            0x00010000
+
#define VTR_DELETE          0x00020000
+
#define VTR_ACCESS          0x00040000
+
#define VTR_FULLPATH        0x00080000
+
#define VTR_DLOPEN          0x00100000
+
#define VTR_DLERR           0x00200000
+
#define VTR_DLSYM           0x00400000
+
#define VTR_DLCLOSE         0x00800000
+
#define VTR_RAND            0x01000000
+
#define VTR_SLEEP           0x02000000
+
#define VTR_CURTIME         0x04000000
+
#define VTR_LASTERR         0x08000000
+
#define VTR_FETCH           0x10000000   /* Also coverse xUnfetch */
+

+
/*
** Method declarations for vfstrace_file.
*/
static int vfstraceClose(sqlite3_file*);
@@ -16331,11 +16426,13 @@ static void vfstrace_printf(
){
  va_list ap;
  char *zMsg;
-
  va_start(ap, zFormat);
-
  zMsg = sqlite3_vmprintf(zFormat, ap);
-
  va_end(ap);
-
  pInfo->xOut(zMsg, pInfo->pOutArg);
-
  sqlite3_free(zMsg);
+
  if( pInfo->bOn ){
+
    va_start(ap, zFormat);
+
    zMsg = sqlite3_vmprintf(zFormat, ap);
+
    va_end(ap);
+
    pInfo->xOut(zMsg, pInfo->pOutArg);
+
    sqlite3_free(zMsg);
+
  }
}

/*
@@ -16435,12 +16532,20 @@ static void strappend(char *z, int *pI, const char *zAppend){
}

/*
+
** Turn tracing output on or off according to mMask.
+
*/
+
static void vfstraceOnOff(vfstrace_info *pInfo, unsigned int mMask){
+
  pInfo->bOn = (pInfo->mTrace & mMask)!=0;
+
}
+

+
/*
** Close an vfstrace-file.
*/
static int vfstraceClose(sqlite3_file *pFile){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_CLOSE);
  vfstrace_printf(pInfo, "%s.xClose(%s)", pInfo->zVfsName, p->zFName);
  rc = p->pReal->pMethods->xClose(p->pReal);
  vfstrace_print_errcode(pInfo, " -> %s\n", rc);
@@ -16463,6 +16568,7 @@ static int vfstraceRead(
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_READ);
  vfstrace_printf(pInfo, "%s.xRead(%s,n=%d,ofst=%lld)",
                  pInfo->zVfsName, p->zFName, iAmt, iOfst);
  rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst);
@@ -16482,6 +16588,7 @@ static int vfstraceWrite(
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_WRITE);
  vfstrace_printf(pInfo, "%s.xWrite(%s,n=%d,ofst=%lld)",
                  pInfo->zVfsName, p->zFName, iAmt, iOfst);
  rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst);
@@ -16496,6 +16603,7 @@ static int vfstraceTruncate(sqlite3_file *pFile, sqlite_int64 size){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_TRUNC);
  vfstrace_printf(pInfo, "%s.xTruncate(%s,%lld)", pInfo->zVfsName, p->zFName,
                  size);
  rc = p->pReal->pMethods->xTruncate(p->pReal, size);
@@ -16520,6 +16628,7 @@ static int vfstraceSync(sqlite3_file *pFile, int flags){
  if( flags & ~(SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY) ){
    sqlite3_snprintf(sizeof(zBuf)-i, &zBuf[i], "|0x%x", flags);
  }
+
  vfstraceOnOff(pInfo, VTR_SYNC);
  vfstrace_printf(pInfo, "%s.xSync(%s,%s)", pInfo->zVfsName, p->zFName,
                  &zBuf[1]);
  rc = p->pReal->pMethods->xSync(p->pReal, flags);
@@ -16534,6 +16643,7 @@ static int vfstraceFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_FSIZE);
  vfstrace_printf(pInfo, "%s.xFileSize(%s)", pInfo->zVfsName, p->zFName);
  rc = p->pReal->pMethods->xFileSize(p->pReal, pSize);
  vfstrace_print_errcode(pInfo, " -> %s,", rc);
@@ -16562,6 +16672,7 @@ static int vfstraceLock(sqlite3_file *pFile, int eLock){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_LOCK);
  vfstrace_printf(pInfo, "%s.xLock(%s,%s)", pInfo->zVfsName, p->zFName,
                  lockName(eLock));
  rc = p->pReal->pMethods->xLock(p->pReal, eLock);
@@ -16576,6 +16687,7 @@ static int vfstraceUnlock(sqlite3_file *pFile, int eLock){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_UNLOCK);
  vfstrace_printf(pInfo, "%s.xUnlock(%s,%s)", pInfo->zVfsName, p->zFName,
                  lockName(eLock));
  rc = p->pReal->pMethods->xUnlock(p->pReal, eLock);
@@ -16590,6 +16702,7 @@ static int vfstraceCheckReservedLock(sqlite3_file *pFile, int *pResOut){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_CRL);
  vfstrace_printf(pInfo, "%s.xCheckReservedLock(%s,%d)", 
                  pInfo->zVfsName, p->zFName);
  rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut);
@@ -16609,6 +16722,7 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
  char zBuf2[100];
  char *zOp;
  char *zRVal = 0;
+
  vfstraceOnOff(pInfo, VTR_FCTRL);
  switch( op ){
    case SQLITE_FCNTL_LOCKSTATE:           zOp = "LOCKSTATE";           break;
    case SQLITE_GET_LOCKPROXYFILE:         zOp = "GET_LOCKPROXYFILE";   break;
@@ -16637,6 +16751,80 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
    case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
    case SQLITE_FCNTL_PRAGMA: {
      const char *const* a = (const char*const*)pArg;
+
      if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
+
        const u8 *zArg = (const u8*)a[2];
+
        if( zArg[0]>='0' && zArg[0]<=9 ){
+
          pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
+
        }else{
+
          static const struct {
+
            const char *z;
+
            unsigned int m;
+
          } aKw[] = {
+
            { "all",                   0xffffffff   },
+
            { "close",                 VTR_CLOSE    },
+
            { "read",                  VTR_READ     },
+
            { "write",                 VTR_WRITE    },
+
            { "truncate",              VTR_TRUNC    },
+
            { "sync",                  VTR_SYNC     },
+
            { "filesize",              VTR_FSIZE    },
+
            { "lock",                  VTR_LOCK     },
+
            { "unlock",                VTR_UNLOCK   },
+
            { "checkreservedlock",     VTR_CRL      },
+
            { "filecontrol",           VTR_FCTRL    },
+
            { "sectorsize",            VTR_SECSZ    },
+
            { "devicecharacteristics", VTR_DEVCHAR  },
+
            { "shmlock",               VTR_SHMLOCK  },
+
            { "shmmap",                VTR_SHMMAP   },
+
            { "shmummap",              VTR_SHMUNMAP },
+
            { "shmbarrier",            VTR_SHMBAR   },
+
            { "open",                  VTR_OPEN     },
+
            { "delete",                VTR_DELETE   },
+
            { "access",                VTR_ACCESS   },
+
            { "fullpathname",          VTR_FULLPATH },
+
            { "dlopen",                VTR_DLOPEN   },
+
            { "dlerror",               VTR_DLERR    },
+
            { "dlsym",                 VTR_DLSYM    },
+
            { "dlclose",               VTR_DLCLOSE  },
+
            { "randomness",            VTR_RAND     },
+
            { "sleep",                 VTR_SLEEP    },
+
            { "currenttime",           VTR_CURTIME  },
+
            { "currenttimeint64",      VTR_CURTIME  },
+
            { "getlasterror",          VTR_LASTERR  },
+
            { "fetch",                 VTR_FETCH    },
+
          };
+
          int onOff = 1;
+
          while( zArg[0] ){
+
            int jj, n;
+
            while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
+
                   && !isalpha(zArg[0]) ) zArg++;
+
            if( zArg[0]==0 ) break;
+
            if( zArg[0]=='-' ){
+
              onOff = 0;
+
              zArg++;
+
            }else if( zArg[0]=='+' ){
+
              onOff = 1;
+
              zArg++;
+
            }
+
            while( !isalpha(zArg[0]) ){
+
              if( zArg[0]==0 ) break;
+
              zArg++;
+
            }
+
            if( zArg[0]=='x' && isalpha(zArg[1]) ) zArg++;
+
            for(n=0; isalpha(zArg[n]); n++){}
+
            for(jj=0; jj<(int)(sizeof(aKw)/sizeof(aKw[0])); jj++){
+
              if( sqlite3_strnicmp(aKw[jj].z,(const char*)zArg,n)==0 ){
+
                if( onOff ){
+
                  pInfo->mTrace |= aKw[jj].m;
+
                }else{
+
                  pInfo->mTrace &= ~aKw[jj].m;
+
                }
+
                break;
+
              }
+
            }
+
            zArg += n;
+
          }
+
        }
+
      }
      sqlite3_snprintf(sizeof(zBuf), zBuf, "PRAGMA,[%s,%s]",a[1],a[2]);
      zOp = zBuf;
      break;
@@ -16732,6 +16920,7 @@ static int vfstraceSectorSize(sqlite3_file *pFile){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_SECSZ);
  vfstrace_printf(pInfo, "%s.xSectorSize(%s)", pInfo->zVfsName, p->zFName);
  rc = p->pReal->pMethods->xSectorSize(p->pReal);
  vfstrace_printf(pInfo, " -> %d\n", rc);
@@ -16745,6 +16934,7 @@ static int vfstraceDeviceCharacteristics(sqlite3_file *pFile){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_DEVCHAR);
  vfstrace_printf(pInfo, "%s.xDeviceCharacteristics(%s)",
                  pInfo->zVfsName, p->zFName);
  rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal);
@@ -16756,11 +16946,22 @@ static int vfstraceDeviceCharacteristics(sqlite3_file *pFile){
** Shared-memory operations.
*/
static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){
+
  static const char *azLockName[] = {
+
     "WRITE",
+
     "CKPT",
+
     "RECOVER",
+
     "READ0",
+
     "READ1",
+
     "READ2",
+
     "READ3",
+
     "READ4",
+
  };
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
  char zLck[100];
  int i = 0;
+
  vfstraceOnOff(pInfo, VTR_SHMLOCK);
  memcpy(zLck, "|0", 3);
  if( flags & SQLITE_SHM_UNLOCK )    strappend(zLck, &i, "|UNLOCK");
  if( flags & SQLITE_SHM_LOCK )      strappend(zLck, &i, "|LOCK");
@@ -16769,8 +16970,15 @@ static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){
  if( flags & ~(0xf) ){
     sqlite3_snprintf(sizeof(zLck)-i, &zLck[i], "|0x%x", flags);
  }
-
  vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=%d,n=%d,%s)",
-
                  pInfo->zVfsName, p->zFName, ofst, n, &zLck[1]);
+
  if( ofst>=0 && ofst<(int)(sizeof(azLockName)/sizeof(azLockName[0])) ){
+
    vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=%d(%s),n=%d,%s)",
+
                  pInfo->zVfsName, p->zFName, ofst, azLockName[ofst],
+
                  n, &zLck[1]);
+
  }else{
+
    vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=5d,n=%d,%s)",
+
                  pInfo->zVfsName, p->zFName, ofst,
+
                  n, &zLck[1]);
+
  }
  rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags);
  vfstrace_print_errcode(pInfo, " -> %s\n", rc);
  return rc;
@@ -16785,6 +16993,7 @@ static int vfstraceShmMap(
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_SHMMAP);
  vfstrace_printf(pInfo, "%s.xShmMap(%s,iRegion=%d,szRegion=%d,isWrite=%d,*)",
                  pInfo->zVfsName, p->zFName, iRegion, szRegion, isWrite);
  rc = p->pReal->pMethods->xShmMap(p->pReal, iRegion, szRegion, isWrite, pp);
@@ -16794,6 +17003,7 @@ static int vfstraceShmMap(
static void vfstraceShmBarrier(sqlite3_file *pFile){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
+
  vfstraceOnOff(pInfo, VTR_SHMBAR);
  vfstrace_printf(pInfo, "%s.xShmBarrier(%s)\n", pInfo->zVfsName, p->zFName);
  p->pReal->pMethods->xShmBarrier(p->pReal);
}
@@ -16801,13 +17011,35 @@ static int vfstraceShmUnmap(sqlite3_file *pFile, int delFlag){
  vfstrace_file *p = (vfstrace_file *)pFile;
  vfstrace_info *pInfo = p->pInfo;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_SHMUNMAP);
  vfstrace_printf(pInfo, "%s.xShmUnmap(%s,delFlag=%d)",
                  pInfo->zVfsName, p->zFName, delFlag);
  rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
  vfstrace_print_errcode(pInfo, " -> %s\n", rc);
  return rc;
}
-

+
static int vfstraceFetch(sqlite3_file *pFile, i64 iOff, int nAmt, void **pptr){
+
  vfstrace_file *p = (vfstrace_file *)pFile;
+
  vfstrace_info *pInfo = p->pInfo;
+
  int rc;
+
  vfstraceOnOff(pInfo, VTR_FETCH);
+
  vfstrace_printf(pInfo, "%s.xFetch(%s,iOff=%lld,nAmt=%d,p=%p)",
+
                  pInfo->zVfsName, p->zFName, iOff, nAmt, *pptr);
+
  rc = p->pReal->pMethods->xFetch(p->pReal, iOff, nAmt, pptr);
+
  vfstrace_print_errcode(pInfo, " -> %s\n", rc);
+
  return rc;
+
}
+
static int vfstraceUnfetch(sqlite3_file *pFile, i64 iOff, void *ptr){
+
  vfstrace_file *p = (vfstrace_file *)pFile;
+
  vfstrace_info *pInfo = p->pInfo;
+
  int rc;
+
  vfstraceOnOff(pInfo, VTR_FETCH);
+
  vfstrace_printf(pInfo, "%s.xUnfetch(%s,iOff=%lld,p=%p)",
+
                  pInfo->zVfsName, p->zFName, iOff, ptr);
+
  rc = p->pReal->pMethods->xUnfetch(p->pReal, iOff, ptr);
+
  vfstrace_print_errcode(pInfo, " -> %s\n", rc);
+
  return rc;
+
}


/*
@@ -16828,6 +17060,7 @@ static int vfstraceOpen(
  p->zFName = zName ? fileTail(zName) : "<temp>";
  p->pReal = (sqlite3_file *)&p[1];
  rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags);
+
  vfstraceOnOff(pInfo, VTR_OPEN);
  vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)",
                  pInfo->zVfsName, p->zFName, flags);
  if( p->pReal->pMethods ){
@@ -16853,6 +17086,10 @@ static int vfstraceOpen(
      pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;
      pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;
    }
+
    if( pNew->iVersion>=3 ){
+
      pNew->xFetch = pSub->xFetch ? vfstraceFetch : 0;
+
      pNew->xUnfetch = pSub->xUnfetch ? vfstraceUnfetch : 0;
+
    }
    pFile->pMethods = pNew;
  }
  vfstrace_print_errcode(pInfo, " -> %s", rc);
@@ -16873,6 +17110,7 @@ static int vfstraceDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_DELETE);
  vfstrace_printf(pInfo, "%s.xDelete(\"%s\",%d)",
                  pInfo->zVfsName, zPath, dirSync);
  rc = pRoot->xDelete(pRoot, zPath, dirSync);
@@ -16893,6 +17131,7 @@ static int vfstraceAccess(
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_ACCESS);
  vfstrace_printf(pInfo, "%s.xAccess(\"%s\",%d)",
                  pInfo->zVfsName, zPath, flags);
  rc = pRoot->xAccess(pRoot, zPath, flags, pResOut);
@@ -16915,6 +17154,7 @@ static int vfstraceFullPathname(
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
  int rc;
+
  vfstraceOnOff(pInfo, VTR_FULLPATH);
  vfstrace_printf(pInfo, "%s.xFullPathname(\"%s\")",
                  pInfo->zVfsName, zPath);
  rc = pRoot->xFullPathname(pRoot, zPath, nOut, zOut);
@@ -16929,6 +17169,7 @@ static int vfstraceFullPathname(
static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
+
  vfstraceOnOff(pInfo, VTR_DLOPEN);
  vfstrace_printf(pInfo, "%s.xDlOpen(\"%s\")\n", pInfo->zVfsName, zPath);
  return pRoot->xDlOpen(pRoot, zPath);
}
@@ -16941,6 +17182,7 @@ static void *vfstraceDlOpen(sqlite3_vfs *pVfs, const char *zPath){
static void vfstraceDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
+
  vfstraceOnOff(pInfo, VTR_DLERR);
  vfstrace_printf(pInfo, "%s.xDlError(%d)", pInfo->zVfsName, nByte);
  pRoot->xDlError(pRoot, nByte, zErrMsg);
  vfstrace_printf(pInfo, " -> \"%s\"", zErrMsg);
@@ -16962,7 +17204,8 @@ static void (*vfstraceDlSym(sqlite3_vfs *pVfs,void *p,const char *zSym))(void){
static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
-
  vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName);
+
  vfstraceOnOff(pInfo, VTR_DLCLOSE);
+
  vfstrace_printf(pInfo, "%s.xDlClose()\n", pInfo->zVfsName);
  pRoot->xDlClose(pRoot, pHandle);
}

@@ -16973,6 +17216,7 @@ static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
+
  vfstraceOnOff(pInfo, VTR_RAND);
  vfstrace_printf(pInfo, "%s.xRandomness(%d)\n", pInfo->zVfsName, nByte);
  return pRoot->xRandomness(pRoot, nByte, zBufOut);
}
@@ -16984,6 +17228,8 @@ static int vfstraceRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){
static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
+
  vfstraceOnOff(pInfo, VTR_SLEEP);
+
  vfstrace_printf(pInfo, "%s.xSleep(%d)\n", pInfo->zVfsName, nMicro);
  return pRoot->xSleep(pRoot, nMicro);
}

@@ -16993,21 +17239,37 @@ static int vfstraceSleep(sqlite3_vfs *pVfs, int nMicro){
static int vfstraceCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
-
  return pRoot->xCurrentTime(pRoot, pTimeOut);
+
  int rc;
+
  vfstraceOnOff(pInfo, VTR_CURTIME);
+
  vfstrace_printf(pInfo, "%s.xCurrentTime()", pInfo->zVfsName);
+
  rc = pRoot->xCurrentTime(pRoot, pTimeOut);
+
  vfstrace_printf(pInfo, " -> %.17g\n", *pTimeOut);
+
  return rc;
}
static int vfstraceCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *pTimeOut){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
-
  return pRoot->xCurrentTimeInt64(pRoot, pTimeOut);
+
  int rc;
+
  vfstraceOnOff(pInfo, VTR_CURTIME);
+
  vfstrace_printf(pInfo, "%s.xCurrentTimeInt64()", pInfo->zVfsName);
+
  rc = pRoot->xCurrentTimeInt64(pRoot, pTimeOut);
+
  vfstrace_printf(pInfo, " -> %lld\n", *pTimeOut);
+
  return rc;
}

/*
-
** Return th3 most recent error code and message
+
** Return the most recent error code and message
*/
-
static int vfstraceGetLastError(sqlite3_vfs *pVfs, int iErr, char *zErr){
+
static int vfstraceGetLastError(sqlite3_vfs *pVfs, int nErr, char *zErr){
  vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
  sqlite3_vfs *pRoot = pInfo->pRootVfs;
-
  return pRoot->xGetLastError(pRoot, iErr, zErr);
+
  int rc;
+
  vfstraceOnOff(pInfo, VTR_LASTERR);
+
  vfstrace_printf(pInfo, "%s.xGetLastError(%d,zBuf)", pInfo->zVfsName, nErr);
+
  if( nErr ) zErr[0] = 0;
+
  rc = pRoot->xGetLastError(pRoot, nErr, zErr);
+
  vfstrace_printf(pInfo, " -> zBuf[] = \"%s\", rc = %d\n", nErr?zErr:"", rc);
+
  return rc;
}

/*
@@ -17101,6 +17363,8 @@ int vfstrace_register(
  pInfo->pOutArg = pOutArg;
  pInfo->zVfsName = pNew->zName;
  pInfo->pTraceVfs = pNew;
+
  pInfo->mTrace = 0xffffffff;
+
  pInfo->bOn = 1;
  vfstrace_printf(pInfo, "%s.enabled_for(\"%s\")\n",
       pInfo->zVfsName, pRoot->zName);
  return sqlite3_vfs_register(pNew, makeDefault);
@@ -20230,6 +20494,8 @@ static int recoverWriteDataStep(sqlite3_recover *p){
          recoverError(p, SQLITE_NOMEM, 0);
        }
        p1->nVal = iField+1;
+
      }else if( pTab->nCol==0 ){
+
        p1->nVal = pTab->nCol;
      }
      p1->iPrevCell = iCell;
      p1->iPrevPage = iPage;
@@ -21937,8 +22203,8 @@ const char *zSkipValidUtf8(const char *z, int nAccept, long ccm){
  const char *pcLimit = (nAccept>=0)? z+nAccept : 0;
  assert(z!=0);
  while( (pcLimit)? (z<pcLimit) : (ng-- != 0) ){
-
    char c = *z;
-
    if( (c & 0x80) == 0 ){
+
    unsigned char c = *(u8*)z;
+
    if( c<0x7f ){
      if( ccm != 0L && c < 0x20 && ((1L<<c) & ccm) != 0 ) return z;
      ++z; /* ASCII */
    }else if( (c & 0xC0) != 0xC0 ) return z; /* not a lead byte */
@@ -22006,10 +22272,10 @@ static void output_c_string(FILE *out, const char *z){
}

/*
-
** Output the given string as a quoted according to JSON quoting rules.
+
** Output the given string as quoted according to JSON quoting rules.
*/
static void output_json_string(FILE *out, const char *z, i64 n){
-
  char c;
+
  unsigned char c;
  static const char *zq = "\"";
  static long ctrlMask = ~0L;
  static const char *zDQBS = "\"\\";
@@ -22029,7 +22295,7 @@ static void output_json_string(FILE *out, const char *z, i64 n){
      z = pcEnd;
    }
    if( z >= pcLimit ) break;
-
    c = *(z++);
+
    c = (unsigned char)*(z++);
    switch( c ){
    case '"': case '\\':
      cbsSay = (char)c;
@@ -22044,8 +22310,8 @@ static void output_json_string(FILE *out, const char *z, i64 n){
    if( cbsSay ){
      ace[1] = cbsSay;
      sqlite3_fputs(ace, out);
-
    }else if( c<=0x1f ){
-
      sqlite3_fprintf(out, "u%04x", c);
+
    }else if( c<=0x1f || c>=0x7f ){
+
      sqlite3_fprintf(out, "\\u%04x", c);
    }else{
      ace[1] = (char)c;
      sqlite3_fputs(ace+1, out);
@@ -24786,9 +25052,9 @@ static int run_schema_dump_query(
    }else{
      rc = SQLITE_CORRUPT;
    }
-
    sqlite3_free(zErr);
    free(zQ2);
  }
+
  sqlite3_free(zErr);
  return rc;
}

@@ -24851,6 +25117,7 @@ static const char *(azHelp[]) = {
#if SQLITE_SHELL_HAVE_RECOVER
  ".dbinfo ?DB?             Show status information about the database",
#endif
+
  ".dbtotxt                 Hex dump of the database file",
  ".dump ?OBJECTS?          Render database content as SQL",
  "   Options:",
  "     --data-only            Output only INSERT statements",
@@ -25656,7 +25923,8 @@ void close_db(sqlite3 *db){
  }
}

-
#if HAVE_READLINE || HAVE_EDITLINE
+
#if (HAVE_READLINE || HAVE_EDITLINE) \
+
  && !defined(SQLITE_OMIT_READLINE_COMPLETION)
/*
** Readline completion callbacks
*/
@@ -25694,15 +25962,22 @@ static char **readline_completion(const char *zText, int iStart, int iEnd){
** Linenoise completion callback. Note that the 3rd argument is from
** the "msteveb" version of linenoise, not the "antirez" version.
*/
-
static void linenoise_completion(const char *zLine, linenoiseCompletions *lc,
-
                                 void *pUserData){
+
static void linenoise_completion(
+
  const char *zLine,
+
  linenoiseCompletions *lc
+
#if HAVE_LINENOISE==2
+
  ,void *pUserData
+
#endif
+
){
  i64 nLine = strlen(zLine);
  i64 i, iStart;
  sqlite3_stmt *pStmt = 0;
  char *zSql;
  char zBuf[1000];

+
#if HAVE_LINENOISE==2
  UNUSED_PARAMETER(pUserData);
+
#endif
  if( nLine>(i64)sizeof(zBuf)-30 ) return;
  if( zLine[0]=='.' || zLine[0]=='#') return;
  for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
@@ -26392,14 +26667,20 @@ static void output_reset(ShellState *p){
/*
** Run an SQL command and return the single integer result.
*/
-
static int db_int(sqlite3 *db, const char *zSql){
+
static int db_int(sqlite3 *db, const char *zSql, ...){
  sqlite3_stmt *pStmt;
  int res = 0;
-
  sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
+
  char *z;
+
  va_list ap;
+
  va_start(ap, zSql);
+
  z = sqlite3_vmprintf(zSql, ap);
+
  va_end(ap);
+
  sqlite3_prepare_v2(db, z, -1, &pStmt, 0);
  if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
    res = sqlite3_column_int(pStmt,0);
  }
  sqlite3_finalize(pStmt);
+
  sqlite3_free(z);
  return res;
}

@@ -26502,9 +26783,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
    zSchemaTab = sqlite3_mprintf("\"%w\".sqlite_schema", zDb);
  }
  for(i=0; i<ArraySize(aQuery); i++){
-
    char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
-
    int val = db_int(p->db, zSql);
-
    sqlite3_free(zSql);
+
    int val = db_int(p->db, aQuery[i].zSql, zSchemaTab);
    sqlite3_fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
  }
  sqlite3_free(zSchemaTab);
@@ -26515,6 +26794,99 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
#endif /* SQLITE_SHELL_HAVE_RECOVER */

/*
+
** Implementation of the ".dbtotxt" command.
+
**
+
** Return 1 on error, 2 to exit, and 0 otherwise.
+
*/
+
static int shell_dbtotxt_command(ShellState *p, int nArg, char **azArg){
+
  sqlite3_stmt *pStmt = 0;
+
  sqlite3_int64 nPage = 0;
+
  int pgSz = 0;
+
  const char *zTail;
+
  char *zName = 0;
+
  int rc, i, j;
+
  unsigned char bShow[256];   /* Characters ok to display */
+

+
  UNUSED_PARAMETER(nArg);
+
  UNUSED_PARAMETER(azArg);
+
  memset(bShow, '.', sizeof(bShow));
+
  for(i=' '; i<='~'; i++){
+
    if( i!='{' && i!='}' && i!='"' && i!='\\' ) bShow[i] = (unsigned char)i;
+
  }
+
  rc = sqlite3_prepare_v2(p->db, "PRAGMA page_size", -1, &pStmt, 0);
+
  if( rc ) goto dbtotxt_error;
+
  rc = 0;
+
  if( sqlite3_step(pStmt)!=SQLITE_ROW ) goto dbtotxt_error;
+
  pgSz = sqlite3_column_int(pStmt, 0);
+
  sqlite3_finalize(pStmt);
+
  pStmt = 0;
+
  if( pgSz<512 || pgSz>65536 || (pgSz&(pgSz-1))!=0 ) goto dbtotxt_error;
+
  rc = sqlite3_prepare_v2(p->db, "PRAGMA page_count", -1, &pStmt, 0);
+
  if( rc ) goto dbtotxt_error;
+
  rc = 0;
+
  if( sqlite3_step(pStmt)!=SQLITE_ROW ) goto dbtotxt_error;
+
  nPage = sqlite3_column_int64(pStmt, 0);
+
  sqlite3_finalize(pStmt);
+
  pStmt = 0;
+
  if( nPage<1 ) goto dbtotxt_error;
+
  rc = sqlite3_prepare_v2(p->db, "PRAGMA databases", -1, &pStmt, 0);
+
  if( rc ) goto dbtotxt_error;
+
  if( sqlite3_step(pStmt)!=SQLITE_ROW ){
+
    zTail = "unk.db";
+
  }else{
+
    const char *zFilename = (const char*)sqlite3_column_text(pStmt, 2);
+
    if( zFilename==0 || zFilename[0]==0 ) zFilename = "unk.db";
+
    zTail = strrchr(zFilename, '/');
+
#if defined(_WIN32)
+
    if( zTail==0 ) zTail = strrchr(zFilename, '\\');
+
#endif
+
  }
+
  zName = strdup(zTail);
+
  shell_check_oom(zName);
+
  sqlite3_fprintf(p->out, "| size %lld pagesize %d filename %s\n",
+
                  nPage*pgSz, pgSz, zName);
+
  sqlite3_finalize(pStmt);
+
  pStmt = 0;
+
  rc = sqlite3_prepare_v2(p->db,
+
           "SELECT pgno, data FROM sqlite_dbpage ORDER BY pgno", -1, &pStmt, 0);
+
  if( rc ) goto dbtotxt_error;
+
  while( sqlite3_step(pStmt)==SQLITE_ROW ){
+
    sqlite3_int64 pgno = sqlite3_column_int64(pStmt, 0);
+
    const u8 *aData = sqlite3_column_blob(pStmt, 1);
+
    int seenPageLabel = 0;
+
    for(i=0; i<pgSz; i+=16){
+
      const u8 *aLine = aData+i;
+
      for(j=0; j<16 && aLine[j]==0; j++){}
+
      if( j==16 ) continue;
+
      if( !seenPageLabel ){
+
        sqlite3_fprintf(p->out, "| page %lld offset %lld\n", pgno, pgno*pgSz);
+
        seenPageLabel = 1;
+
      }
+
      sqlite3_fprintf(p->out, "|  %5d:", i);
+
      for(j=0; j<16; j++) sqlite3_fprintf(p->out, " %02x", aLine[j]);
+
      sqlite3_fprintf(p->out, "   ");
+
      for(j=0; j<16; j++){
+
        unsigned char c = (unsigned char)aLine[j];
+
        sqlite3_fprintf(p->out, "%c", bShow[c]);
+
      }
+
      sqlite3_fprintf(p->out, "\n");
+
    }
+
  }
+
  sqlite3_finalize(pStmt);
+
  sqlite3_fprintf(p->out, "| end %s\n", zName);
+
  free(zName);
+
  return 0;
+

+
dbtotxt_error:
+
  if( rc ){
+
    sqlite3_fprintf(stderr, "ERROR: %s\n", sqlite3_errmsg(p->db));
+
  }
+
  sqlite3_finalize(pStmt);
+
  free(zName);
+
  return 1;
+
}
+

+
/*
** Print the given string as an error message.
*/
static void shellEmitError(const char *zErr){
@@ -27131,7 +27503,7 @@ static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){
      break;
    case AR_SWITCH_APPEND:
      pAr->bAppend = 1;
-
      deliberate_fall_through;
+
      deliberate_fall_through; /* FALLTHRU */
    case AR_SWITCH_FILE:
      pAr->zFile = zArg;
      break;
@@ -28069,8 +28441,8 @@ FROM (\
  }else{
    /* Formulate the columns spec, close the DB, zero *pDb. */
    char *zColsSpec = 0;
-
    int hasDupes = db_int(*pDb, zHasDupes);
-
    int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
+
    int hasDupes = db_int(*pDb, "%s", zHasDupes);
+
    int nDigits = (hasDupes)? db_int(*pDb, "%s", zColDigits) : 0;
    if( hasDupes ){
#ifdef SHELL_COLUMN_RENAME_CLEAN
      rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
@@ -28085,7 +28457,7 @@ FROM (\
      sqlite3_finalize(pStmt);
      if( rc!=SQLITE_DONE ) rc_err_oom_die(SQLITE_NOMEM);
    }
-
    assert(db_int(*pDb, zHasDupes)==0); /* Consider: remove this */
+
    assert(db_int(*pDb, "%s", zHasDupes)==0); /* Consider: remove this */
    rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
    rc_err_oom_die(rc);
    rc = sqlite3_step(pStmt);
@@ -28519,6 +28891,9 @@ static int do_meta_command(char *zLine, ShellState *p){
      const char *zName;
      int op;
    } aDbConfig[] = {
+
        { "attach_create",      SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE  },
+
        { "attach_write",       SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE   },
+
        { "comments",           SQLITE_DBCONFIG_ENABLE_COMMENTS       },
        { "defensive",          SQLITE_DBCONFIG_DEFENSIVE             },
        { "dqs_ddl",            SQLITE_DBCONFIG_DQS_DDL               },
        { "dqs_dml",            SQLITE_DBCONFIG_DQS_DML               },
@@ -28691,6 +29066,10 @@ static int do_meta_command(char *zLine, ShellState *p){
    }
  }else

+
  if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbtotxt", n)==0 ){
+
    rc = shell_dbtotxt_command(p, nArg, azArg);
+
  }else
+

  if( c=='e' && cli_strncmp(azArg[0], "eqp", n)==0 ){
    if( nArg==2 ){
      p->autoEQPtest = 0;
@@ -29131,7 +29510,11 @@ static int do_meta_command(char *zLine, ShellState *p){
      while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
    }
    import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */
-
    if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0) ){
+
    if( sqlite3_table_column_metadata(p->db, zSchema, zTable,0,0,0,0,0,0) 
+
     && 0==db_int(p->db, "SELECT count(*) FROM \"%w\".sqlite_schema"
+
                         " WHERE name=%Q AND type='view'",
+
                         zSchema ? zSchema : "main", zTable)
+
    ){
      /* Table does not exist.  Create it. */
      sqlite3 *dbCols = 0;
      char *zRenames = 0;
@@ -29865,6 +30248,7 @@ static int do_meta_command(char *zLine, ShellState *p){
    if( zFile==0 ){
      zFile = sqlite3_mprintf("stdout");
    }
+
    shell_check_oom(zFile);
    if( bOnce ){
      p->outCount = 2;
    }else{
@@ -29907,6 +30291,7 @@ static int do_meta_command(char *zLine, ShellState *p){
#else
      FILE *pfPipe = sqlite3_popen(zFile + 1, "w");
      if( pfPipe==0 ){
+
        assert( stderr!=NULL );
        sqlite3_fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
        rc = 1;
      }else{
@@ -29919,7 +30304,8 @@ static int do_meta_command(char *zLine, ShellState *p){
      FILE *pfFile = output_file_open(zFile);
      if( pfFile==0 ){
        if( cli_strcmp(zFile,"off")!=0 ){
-
          sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
+
         assert( stderr!=NULL );
+
         sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
        }
        rc = 1;
      } else {
@@ -30023,6 +30409,7 @@ static int do_meta_command(char *zLine, ShellState *p){
          rc = 1;
        }
      }
+
      bind_prepared_stmt(p, pStmt);
      sqlite3_step(pStmt);
      sqlite3_finalize(pStmt);
    }else
@@ -30203,7 +30590,10 @@ static int do_meta_command(char *zLine, ShellState *p){
  }else
#endif /* !defined(SQLITE_SHELL_FIDDLE) */

-
  if( c=='s' && cli_strncmp(azArg[0], "scanstats", n)==0 ){
+
  if( c=='s' &&
+
     (cli_strncmp(azArg[0], "scanstats",  n)==0 ||
+
      cli_strncmp(azArg[0], "scanstatus", n)==0)
+
  ){
    if( nArg==2 ){
      if( cli_strcmp(azArg[1], "vm")==0 ){
        p->scanstatsOn = 3;
@@ -31254,11 +31644,14 @@ static int do_meta_command(char *zLine, ShellState *p){
            { 0x04000000, 1, "NullUnusedCols" },
            { 0x08000000, 1, "OnePass" },
            { 0x10000000, 1, "OrderBySubq" },
+
            { 0x20000000, 1, "StarQuery" },
            { 0xffffffff, 0, "All" },
          };
          unsigned int curOpt;
          unsigned int newOpt;
+
          unsigned int m;
          int ii;
+
          int nOff;
          sqlite3_test_control(SQLITE_TESTCTRL_GETOPT, p->db, &curOpt);
          newOpt = curOpt;
          for(ii=2; ii<nArg; ii++){
@@ -31299,24 +31692,28 @@ static int do_meta_command(char *zLine, ShellState *p){
          }
          if( curOpt!=newOpt ){
            sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,p->db,newOpt);
-
          }else if( nArg<3 ){
-
            curOpt = ~newOpt;
          }
-
          if( newOpt==0 ){
-
            sqlite3_fputs("+All\n", p->out);
-
          }else if( newOpt==0xffffffff ){
-
            sqlite3_fputs("-All\n", p->out);
+
          for(ii=nOff=0, m=1; ii<32; ii++, m <<= 1){
+
            if( m & newOpt ) nOff++;
+
          }
+
          if( nOff<12 ){
+
            sqlite3_fputs("+All", p->out);
+
            for(ii=0; ii<ArraySize(aLabel); ii++){
+
              if( !aLabel[ii].bDsply  ) continue;
+
              if( (newOpt & aLabel[ii].mask)!=0 ){
+
                sqlite3_fprintf(p->out, " -%s", aLabel[ii].zLabel);
+
              }
+
            }
          }else{
-
            int jj;
-
            for(jj=0; jj<ArraySize(aLabel); jj++){
-
              unsigned int m = aLabel[jj].mask;
-
              if( !aLabel[jj].bDsply  ) continue;
-
              if( (curOpt&m)!=(newOpt&m) ){
-
                sqlite3_fprintf(p->out, "%c%s\n", (newOpt & m)==0 ? '+' : '-',
-
                      aLabel[jj].zLabel);
+
            sqlite3_fputs("-All", p->out);
+
            for(ii=0; ii<ArraySize(aLabel); ii++){
+
              if( !aLabel[ii].bDsply  ) continue;
+
              if( (newOpt & aLabel[ii].mask)==0 ){
+
                sqlite3_fprintf(p->out, " +%s", aLabel[ii].zLabel);
              }
            }
          }
+
          sqlite3_fputs("\n", p->out);
          rc2 = isOk = 3;
          break;
        }
@@ -31654,69 +32051,6 @@ static int do_meta_command(char *zLine, ShellState *p){
  }else
#endif

-
#if SQLITE_USER_AUTHENTICATION
-
  if( c=='u' && cli_strncmp(azArg[0], "user", n)==0 ){
-
    if( nArg<2 ){
-
      eputz("Usage: .user SUBCOMMAND ...\n");
-
      rc = 1;
-
      goto meta_command_exit;
-
    }
-
    open_db(p, 0);
-
    if( cli_strcmp(azArg[1],"login")==0 ){
-
      if( nArg!=4 ){
-
        eputz("Usage: .user login USER PASSWORD\n");
-
        rc = 1;
-
        goto meta_command_exit;
-
      }
-
      rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
-
                                     strlen30(azArg[3]));
-
      if( rc ){
-
        sqlite3_fprintf(stderr,"Authentication failed for user %s\n", azArg[2]);
-
        rc = 1;
-
      }
-
    }else if( cli_strcmp(azArg[1],"add")==0 ){
-
      if( nArg!=5 ){
-
        eputz("Usage: .user add USER PASSWORD ISADMIN\n");
-
        rc = 1;
-
        goto meta_command_exit;
-
      }
-
      rc = sqlite3_user_add(p->db, azArg[2], azArg[3], strlen30(azArg[3]),
-
                            booleanValue(azArg[4]));
-
      if( rc ){
-
        sqlite3_fprintf(stderr,"User-Add failed: %d\n", rc);
-
        rc = 1;
-
      }
-
    }else if( cli_strcmp(azArg[1],"edit")==0 ){
-
      if( nArg!=5 ){
-
        eputz("Usage: .user edit USER PASSWORD ISADMIN\n");
-
        rc = 1;
-
        goto meta_command_exit;
-
      }
-
      rc = sqlite3_user_change(p->db, azArg[2], azArg[3], strlen30(azArg[3]),
-
                              booleanValue(azArg[4]));
-
      if( rc ){
-
        sqlite3_fprintf(stderr,"User-Edit failed: %d\n", rc);
-
        rc = 1;
-
      }
-
    }else if( cli_strcmp(azArg[1],"delete")==0 ){
-
      if( nArg!=3 ){
-
        eputz("Usage: .user delete USER\n");
-
        rc = 1;
-
        goto meta_command_exit;
-
      }
-
      rc = sqlite3_user_delete(p->db, azArg[2]);
-
      if( rc ){
-
        sqlite3_fprintf(stderr,"User-Delete failed: %d\n", rc);
-
        rc = 1;
-
      }
-
    }else{
-
      eputz("Usage: .user login|add|edit|delete ...\n");
-
      rc = 1;
-
      goto meta_command_exit;
-
    }
-
  }else
-
#endif /* SQLITE_USER_AUTHENTICATION */
-

  if( c=='v' && cli_strncmp(azArg[0], "version", n)==0 ){
    char *zPtrSz = sizeof(void*)==8 ? "64-bit" : "32-bit";
    sqlite3_fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
@@ -31840,7 +32174,6 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss,
  char cWait = (char)qss; /* intentional narrowing loss */
  if( cWait==0 ){
  PlainScan:
-
    assert( cWait==0 );
    while( (cin = *zLine++)!=0 ){
      if( IsSpace(cin) )
        continue;
@@ -31866,7 +32199,7 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss,
        break;
      case '[':
        cin = ']';
-
        deliberate_fall_through;
+
        deliberate_fall_through; /* FALLTHRU */
      case '`': case '\'': case '"':
        cWait = cin;
        qss = QSS_HasDark | cWait;
@@ -31892,7 +32225,6 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss,
          if( *zLine != '/' )
            continue;
          ++zLine;
-
          cWait = 0;
          CONTINUE_PROMPT_AWAITC(pst, 0);
          qss = QSS_SETV(qss, 0);
          goto PlainScan;
@@ -31902,9 +32234,8 @@ static QuickScanState quickscan(char *zLine, QuickScanState qss,
            ++zLine;
            continue;
          }
-
          deliberate_fall_through;
+
          deliberate_fall_through; /* FALLTHRU */
        case ']':
-
          cWait = 0;
          CONTINUE_PROMPT_AWAITC(pst, 0);
          qss = QSS_SETV(qss, 0);
          goto PlainScan;
@@ -32092,7 +32423,10 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
}

static void echo_group_input(ShellState *p, const char *zDo){
-
  if( ShellHasFlag(p, SHFLG_Echo) ) sqlite3_fprintf(p->out, "%s\n", zDo);
+
  if( ShellHasFlag(p, SHFLG_Echo) ){
+
    sqlite3_fprintf(p->out, "%s\n", zDo);
+
    fflush(p->out);
+
  }
}

#ifdef SQLITE_SHELL_FIDDLE
@@ -32553,6 +32887,15 @@ static void sayAbnormalExit(void){
  if( seenInterrupt ) eputz("Program interrupted.\n");
}

+
/* Routine to output from vfstrace
+
*/
+
static int vfstraceOut(const char *z, void *pArg){
+
  ShellState *p = (ShellState*)pArg;
+
  sqlite3_fputs(z, p->out);
+
  fflush(p->out);
+
  return 1;
+
}
+

#ifndef SQLITE_SHELL_IS_UTF8
#  if (defined(_WIN32) || defined(WIN32)) \
   && (defined(_MSC_VER) || (defined(UNICODE) && defined(__GNUC__)))
@@ -32789,8 +33132,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
         default: sqlite3_config(SQLITE_CONFIG_SERIALIZED);    break;
      }
    }else if( cli_strcmp(z,"-vfstrace")==0 ){
-
      vfstrace_register("trace",0,(int(*)(const char*,void*))sqlite3_fputs,
-
                        stderr,1);
      bEnableVfstrace = 1;
#ifdef SQLITE_ENABLE_MULTIPLEX
    }else if( cli_strcmp(z,"-multiplex")==0 ){
@@ -32887,6 +33228,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#endif
  }
  data.out = stdout;
+
  if( bEnableVfstrace ){
+
    vfstrace_register("trace",0,vfstraceOut, &data, 1);
+
  }
#ifndef SQLITE_SHELL_FIDDLE
  sqlite3_appendvfs_init(0,0,0);
#endif
@@ -33131,15 +33475,10 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
      char *zHome;
      char *zHistory;
      int nHistory;
-
#if CIO_WIN_WC_XLATE
-
# define SHELL_CIO_CHAR_SET (stdout_is_console? " (UTF-16 console I/O)" : "")
-
#else
-
# define SHELL_CIO_CHAR_SET ""
-
#endif
      sqlite3_fprintf(stdout,
-
            "SQLite version %s %.19s%s\n" /*extra-version-info*/
+
            "SQLite version %s %.19s\n" /*extra-version-info*/
            "Enter \".help\" for usage hints.\n",
-
            sqlite3_libversion(), sqlite3_sourceid(), SHELL_CIO_CHAR_SET);
+
            sqlite3_libversion(), sqlite3_sourceid());
      if( warnInmemoryDb ){
        sputz(stdout, "Connected to a ");
        printBold("transient in-memory database");
@@ -33156,9 +33495,11 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
        }
      }
      if( zHistory ){ shell_read_history(zHistory); }
-
#if HAVE_READLINE || HAVE_EDITLINE
+
#if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION)
      rl_attempted_completion_function = readline_completion;
-
#elif HAVE_LINENOISE
+
#elif HAVE_LINENOISE==1
+
      linenoiseSetCompletionCallback(linenoise_completion);
+
#elif HAVE_LINENOISE==2
      linenoiseSetCompletionCallback(linenoise_completion, NULL);
#endif
      data.in = 0;
modified external/sqlite/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-
** version 3.47.0.  By combining all the individual C code files into this
+
** version 3.49.0.  By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit.  This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately.  Performance improvements
@@ -18,8 +18,11 @@
** separate file. This file contains only code for the core SQLite library.
**
** The content in this amalgamation comes from Fossil check-in
-
** 03a9703e27c44437c39363d0baf82db4ebc9.
+
** 4a7dd425dc2a0e5082a9049c9b4a9d4f199a with changes in files:
+
**
+
**    
*/
+
#ifndef SQLITE_AMALGAMATION
#define SQLITE_CORE 1
#define SQLITE_AMALGAMATION 1
#ifndef SQLITE_PRIVATE
@@ -462,9 +465,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-
#define SQLITE_VERSION        "3.47.0"
-
#define SQLITE_VERSION_NUMBER 3047000
-
#define SQLITE_SOURCE_ID      "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e"
+
#define SQLITE_VERSION        "3.49.0"
+
#define SQLITE_VERSION_NUMBER 3049000
+
#define SQLITE_SOURCE_ID      "2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde"

/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -968,6 +971,13 @@ SQLITE_API int sqlite3_exec(
** filesystem supports doing multiple write operations atomically when those
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
+
**
+
** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
+
** from the database file in amounts that are not a multiple of the
+
** page size and that do not begin at a page boundary.  Without this
+
** property, SQLite is careful to only do full-page reads and write
+
** on aligned pages, with the one exception that it will do a sub-page
+
** read of the first page to access the database header.
*/
#define SQLITE_IOCAP_ATOMIC                 0x00000001
#define SQLITE_IOCAP_ATOMIC512              0x00000002
@@ -984,6 +994,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000
#define SQLITE_IOCAP_IMMUTABLE              0x00002000
#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000
+
#define SQLITE_IOCAP_SUBPAGE_READ           0x00008000

/*
** CAPI3REF: File Locking Levels
@@ -1130,6 +1141,7 @@ struct sqlite3_file {
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
** <li> [SQLITE_IOCAP_IMMUTABLE]
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
+
** <li> [SQLITE_IOCAP_SUBPAGE_READ]
** </ul>
**
** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -1407,6 +1419,11 @@ struct sqlite3_io_methods {
** pointed to by the pArg argument.  This capability is used during testing
** and only needs to be supported when SQLITE_TEST is defined.
**
+
** <li>[[SQLITE_FCNTL_NULL_IO]]
+
** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor
+
** or file handle for the [sqlite3_file] object such that it will no longer
+
** read or write to the database file.
+
**
** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
** be advantageous to block on the next WAL lock if the lock is not immediately
@@ -1560,6 +1577,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_EXTERNAL_READER        40
#define SQLITE_FCNTL_CKSM_FILE              41
#define SQLITE_FCNTL_RESET_CACHE            42
+
#define SQLITE_FCNTL_NULL_IO                43

/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -2512,7 +2530,15 @@ struct sqlite3_mem_methods {
** CAPI3REF: Database Connection Configuration Options
**
** These constants are the available integer configuration options that
-
** can be passed as the second argument to the [sqlite3_db_config()] interface.
+
** can be passed as the second parameter to the [sqlite3_db_config()] interface.
+
**
+
** The [sqlite3_db_config()] interface is a var-args functions.  It takes a
+
** variable number of parameters, though always at least two.  The number of
+
** parameters passed into sqlite3_db_config() depends on which of these
+
** constants is given as the second parameter.  This documentation page
+
** refers to parameters beyond the second as "arguments".  Thus, when this
+
** page says "the N-th argument" it means "the N-th parameter past the
+
** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
**
** New configuration options may be added in future releases of SQLite.
** Existing configuration options might be discontinued.  Applications
@@ -2524,8 +2550,14 @@ struct sqlite3_mem_methods {
** <dl>
** [[SQLITE_DBCONFIG_LOOKASIDE]]
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
-
** <dd> ^This option takes three additional arguments that determine the
-
** [lookaside memory allocator] configuration for the [database connection].
+
** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
+
** configuration of the lookaside memory allocator within a database
+
** connection.
+
** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
+
** in the [DBCONFIG arguments|usual format].
+
** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
+
** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
+
** should have a total of five parameters.
** ^The first argument (the third parameter to [sqlite3_db_config()] is a
** pointer to a memory buffer to use for lookaside memory.
** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
@@ -2548,7 +2580,8 @@ struct sqlite3_mem_methods {
** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
** <dd> ^This option is used to enable or disable the enforcement of
-
** [foreign key constraints].  There should be two additional arguments.
+
** [foreign key constraints].  This is the same setting that is
+
** enabled or disabled by the [PRAGMA foreign_keys] statement.
** The first argument is an integer which is 0 to disable FK enforcement,
** positive to enable FK enforcement or negative to leave FK enforcement
** unchanged.  The second parameter is a pointer to an integer into which
@@ -2570,13 +2603,13 @@ struct sqlite3_mem_methods {
** <p>Originally this option disabled all triggers.  ^(However, since
** SQLite version 3.35.0, TEMP triggers are still allowed even if
** this option is off.  So, in other words, this option now only disables
-
** triggers in the main database schema or in the schemas of ATTACH-ed
+
** triggers in the main database schema or in the schemas of [ATTACH]-ed
** databases.)^ </dd>
**
** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** The first argument is an integer which is 0 to disable views,
** positive to enable views or negative to leave the setting unchanged.
** The second parameter is a pointer to an integer into which
@@ -2595,7 +2628,7 @@ struct sqlite3_mem_methods {
** <dd> ^This option is used to enable or disable the
** [fts3_tokenizer()] function which is part of the
** [FTS3] full-text search engine extension.
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
** positive to enable fts3_tokenizer() or negative to leave the setting
** unchanged.
@@ -2610,7 +2643,7 @@ struct sqlite3_mem_methods {
** interface independently of the [load_extension()] SQL function.
** The [sqlite3_enable_load_extension()] API enables or disables both the
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** When the first argument to this interface is 1, then only the C-API is
** enabled and the SQL function remains disabled.  If the first argument to
** this interface is 0, then both the C-API and the SQL function are disabled.
@@ -2624,23 +2657,30 @@ struct sqlite3_mem_methods {
**
** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
** <dd> ^This option is used to change the name of the "main" database
-
** schema.  ^The sole argument is a pointer to a constant UTF8 string
-
** which will become the new schema name in place of "main".  ^SQLite
-
** does not make a copy of the new main schema name string, so the application
-
** must ensure that the argument passed into this DBCONFIG option is unchanged
-
** until after the database connection closes.
+
** schema.  This option does not follow the
+
** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
+
** This option takes exactly one additional argument so that the
+
** [sqlite3_db_config()] call has a total of three parameters.  The
+
** extra argument must be a pointer to a constant UTF8 string which
+
** will become the new schema name in place of "main".  ^SQLite does
+
** not make a copy of the new main schema name string, so the application
+
** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
+
** is unchanged until after the database connection closes.
** </dd>
**
** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
-
** <dd> Usually, when a database in wal mode is closed or detached from a
-
** database handle, SQLite checks if this will mean that there are now no
-
** connections at all to the database. If so, it performs a checkpoint
-
** operation before closing the connection. This option may be used to
-
** override this behavior. The first parameter passed to this operation
-
** is an integer - positive to disable checkpoints-on-close, or zero (the
-
** default) to enable them, and negative to leave the setting unchanged.
-
** The second parameter is a pointer to an integer
+
** <dd> Usually, when a database in [WAL mode] is closed or detached from a
+
** database handle, SQLite checks if if there are other connections to the
+
** same database, and if there are no other database connection (if the
+
** connection being closed is the last open connection to the database),
+
** then SQLite performs a [checkpoint] before closing the connection and
+
** deletes the WAL file.  The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
+
** be used to override that behavior. The first argument passed to this
+
** operation (the third parameter to [sqlite3_db_config()]) is an integer
+
** which is positive to disable checkpoints-on-close, or zero (the default)
+
** to enable them, and negative to leave the setting unchanged.
+
** The second argument (the fourth parameter) is a pointer to an integer
** into which is written 0 or 1 to indicate whether checkpoints-on-close
** have been disabled - 0 if they are not disabled, 1 if they are.
** </dd>
@@ -2801,7 +2841,7 @@ struct sqlite3_mem_methods {
** statistics. For statistics to be collected, the flag must be set on
** the database handle both when the SQL statement is prepared and when it
** is stepped. The flag is set (collection of statistics is enabled)
-
** by default.  This option takes two arguments: an integer and a pointer to
+
** by default. <p>This option takes two arguments: an integer and a pointer to
** an integer..  The first argument is 1, 0, or -1 to enable, disable, or
** leave unchanged the statement scanstatus option.  If the second argument
** is not NULL, then the value of the statement scanstatus setting after
@@ -2815,7 +2855,7 @@ struct sqlite3_mem_methods {
** in which tables and indexes are scanned so that the scans start at the end
** and work toward the beginning rather than starting at the beginning and
** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
-
** same as setting [PRAGMA reverse_unordered_selects].  This option takes
+
** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
** two arguments which are an integer and a pointer to an integer.  The first
** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
** reverse scan order flag, respectively.  If the second argument is not NULL,
@@ -2824,7 +2864,76 @@ struct sqlite3_mem_methods {
** first argument.
** </dd>
**
+
** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
+
** the ability of the [ATTACH DATABASE] SQL command to create a new database
+
** file if the database filed named in the ATTACH command does not already
+
** exist.  This ability of ATTACH to create a new database is enabled by
+
** default.  Applications can disable or reenable the ability for ATTACH to
+
** create new database files using this DBCONFIG option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the attach-create flag, respectively.  If the second
+
** argument is not NULL, then 0 or 1 is written into the integer that the
+
** second argument points to depending on if the attach-create flag is set
+
** after processing the first argument.
+
** </dd>
+
**
+
** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
+
** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
+
** This capability is enabled by default.  Applications can disable or
+
** reenable this capability using the current DBCONFIG option.  If the
+
** the this capability is disabled, the [ATTACH] command will still work,
+
** but the database will be opened read-only.  If this option is disabled,
+
** then the ability to create a new database using [ATTACH] is also disabled,
+
** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
+
** option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the ability to ATTACH another database for writing,
+
** respectively.  If the second argument is not NULL, then 0 or 1 is written
+
** into the integer to which the second argument points, depending on whether
+
** the ability to ATTACH a read/write database is enabled or disabled
+
** after processing the first argument.
+
** </dd>
+
**
+
** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
+
** ability to include comments in SQL text.  Comments are enabled by default.
+
** An application can disable or reenable comments in SQL text using this
+
** DBCONFIG option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the ability to use comments in SQL text,
+
** respectively.  If the second argument is not NULL, then 0 or 1 is written
+
** into the integer that the second argument points to depending on if
+
** comments are allowed in SQL text after processing the first argument.
+
** </dd>
+
**
** </dl>
+
**
+
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
+
**
+
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
+
** overall call to [sqlite3_db_config()] has a total of four parameters.
+
** The first argument (the third parameter to sqlite3_db_config()) is a integer.
+
** The second argument is a pointer to an integer.  If the first argument is 1,
+
** then the option becomes enabled.  If the first integer argument is 0, then the
+
** option is disabled.  If the first argument is -1, then the option setting
+
** is unchanged.  The second argument, the pointer to an integer, may be NULL.
+
** If the second argument is not NULL, then a value of 0 or 1 is written into
+
** the integer to which the second argument points, depending on whether the
+
** setting is disabled or enabled after applying any changes specified by
+
** the first argument.
+
**
+
** <p>While most SQLITE_DBCONFIG options use the argument format
+
** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
+
** and [SQLITE_DBCONFIG_LOOKASIDE] options are different.  See the
+
** documentation of those exceptional options for details.
*/
#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
@@ -2846,7 +2955,10 @@ struct sqlite3_mem_methods {
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA        1017 /* int int* */
#define SQLITE_DBCONFIG_STMT_SCANSTATUS       1018 /* int int* */
#define SQLITE_DBCONFIG_REVERSE_SCANORDER     1019 /* int int* */
-
#define SQLITE_DBCONFIG_MAX                   1019 /* Largest DBCONFIG */
+
#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE  1020 /* int int* */
+
#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE   1021 /* int int* */
+
#define SQLITE_DBCONFIG_ENABLE_COMMENTS       1022 /* int int* */
+
#define SQLITE_DBCONFIG_MAX                   1022 /* Largest DBCONFIG */

/*
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -2938,10 +3050,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
** deleted by the most recently completed INSERT, UPDATE or DELETE
** statement on the database connection specified by the only parameter.
** The two functions are identical except for the type of the return value
-
** and that if the number of rows modified by the most recent INSERT, UPDATE
+
** and that if the number of rows modified by the most recent INSERT, UPDATE,
** or DELETE is greater than the maximum value supported by type "int", then
** the return value of sqlite3_changes() is undefined. ^Executing any other
** type of SQL statement does not modify the value returned by these functions.
+
** For the purposes of this interface, a CREATE TABLE AS SELECT statement
+
** does not count as an INSERT, UPDATE or DELETE statement and hence the rows
+
** added to the new table by the CREATE TABLE AS SELECT statement are not
+
** counted.
**
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
@@ -4501,11 +4617,22 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
** to return an error (error code SQLITE_ERROR) if the statement uses
** any virtual tables.
+
**
+
** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt>
+
** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler
+
** errors from being sent to the error log defined by
+
** [SQLITE_CONFIG_LOG].  This can be used, for example, to do test
+
** compiles to see if some SQL syntax is well-formed, without generating
+
** messages on the global error log when it is not.  If the test compile
+
** fails, the sqlite3_prepare_v3() call returns the same error indications
+
** with or without this flag; it just omits the call to [sqlite3_log()] that
+
** logs the error.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT              0x01
#define SQLITE_PREPARE_NORMALIZE               0x02
#define SQLITE_PREPARE_NO_VTAB                 0x04
+
#define SQLITE_PREPARE_DONT_LOG                0x10

/*
** CAPI3REF: Compiling An SQL Statement
@@ -11034,8 +11161,9 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
/*
** CAPI3REF: Serialize a database
**
-
** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
-
** that is a serialization of the S database on [database connection] D.
+
** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
+
** memory that is a serialization of the S database on
+
** [database connection] D.  If S is a NULL pointer, the main database is used.
** If P is not a NULL pointer, then the size of the database in bytes
** is written into *P.
**
@@ -11196,7 +11324,7 @@ SQLITE_API int sqlite3_deserialize(
#if 0
}  /* End of the 'extern "C"' block */
#endif
-
#endif /* SQLITE3_H */
+
/* #endif for SQLITE3_H will be added by mksqlite3.tcl */

/******** Begin file sqlite3rtree.h *********/
/*
@@ -13447,14 +13575,29 @@ struct Fts5PhraseIter {
**   value returned by xInstCount(), SQLITE_RANGE is returned.  Otherwise,
**   output variable (*ppToken) is set to point to a buffer containing the
**   matching document token, and (*pnToken) to the size of that buffer in
-
**   bytes. This API is not available if the specified token matches a
-
**   prefix query term. In that case both output variables are always set
-
**   to 0.
+
**   bytes.
**
**   The output text is not a copy of the document text that was tokenized.
**   It is the output of the tokenizer module. For tokendata=1 tables, this
**   includes any embedded 0x00 and trailing data.
**
+
**   This API may be slow in some cases if the token identified by parameters
+
**   iIdx and iToken matched a prefix token in the query. In most cases, the
+
**   first call to this API for each prefix token in the query is forced
+
**   to scan the portion of the full-text index that matches the prefix
+
**   token to collect the extra data required by this API. If the prefix
+
**   token matches a large number of token instances in the document set,
+
**   this may be a performance problem.
+
**
+
**   If the user knows in advance that a query may use this API for a
+
**   prefix token, FTS5 may be configured to collect all required data as part
+
**   of the initial querying of the full-text index, avoiding the second scan
+
**   entirely. This also causes prefix queries that do not use this API to
+
**   run more slowly and use more memory. FTS5 may be configured in this way
+
**   either on a per-table basis using the [FTS5 insttoken | 'insttoken']
+
**   option, or on a per-query basis using the
+
**   [fts5_insttoken | fts5_insttoken()] user function.
+
**
**   This API can be quite slow if used with an FTS5 table created with the
**   "detail=none" or "detail=column" option.
**
@@ -13888,6 +14031,7 @@ struct fts5_api {
#endif /* _FTS5_H */

/******** End of fts5.h *********/
+
#endif /* SQLITE3_H */

/************** End of sqlite3.h *********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -13933,6 +14077,7 @@ struct fts5_api {
#ifndef SQLITE_MAX_LENGTH
# define SQLITE_MAX_LENGTH 1000000000
#endif
+
#define SQLITE_MIN_LENGTH 30   /* Minimum value for the length limit */

/*
** This is the maximum number of
@@ -13998,9 +14143,13 @@ struct fts5_api {

/*
** The maximum number of arguments to an SQL function.
+
**
+
** This value has a hard upper limit of 32767 due to storage
+
** constraints (it needs to fit inside a i16).  We keep it
+
** lower than that to prevent abuse.
*/
#ifndef SQLITE_MAX_FUNCTION_ARG
-
# define SQLITE_MAX_FUNCTION_ARG 127
+
# define SQLITE_MAX_FUNCTION_ARG 1000
#endif

/*
@@ -14823,7 +14972,8 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
#define TK_ERROR                          182
#define TK_QNUMBER                        183
#define TK_SPACE                          184
-
#define TK_ILLEGAL                        185
+
#define TK_COMMENT                        185
+
#define TK_ILLEGAL                        186

/************** End of parse.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -15075,6 +15225,8 @@ typedef u64 tRowcnt;
**    0.5 -> -10           0.1 -> -33        0.0625 -> -40
*/
typedef INT16_TYPE LogEst;
+
#define LOGEST_MIN (-32768)
+
#define LOGEST_MAX (32767)

/*
** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
@@ -15345,7 +15497,7 @@ SQLITE_PRIVATE u32 sqlite3WhereTrace;
** 0xFFFF----   Low-level debug messages
**
** 0x00000001   Code generation
-
** 0x00000002   Solver
+
** 0x00000002   Solver (Use 0x40000 for less detail)
** 0x00000004   Solver costs
** 0x00000008   WhereLoop inserts
**
@@ -15364,6 +15516,8 @@ SQLITE_PRIVATE u32 sqlite3WhereTrace;
**
** 0x00010000   Show more detail when printing WHERE terms
** 0x00020000   Show WHERE terms returned from whereScanNext()
+
** 0x00040000   Solver overview messages
+
** 0x00080000   Star-query heuristic
*/


@@ -16002,6 +16156,22 @@ typedef struct PgHdr DbPage;
#define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */
#define PAGER_JOURNALMODE_WAL         5   /* Use write-ahead logging */

+
#define isWalMode(x) ((x)==PAGER_JOURNALMODE_WAL)
+

+
/*
+
** The argument to this macro is a file descriptor (type sqlite3_file*).
+
** Return 0 if it is not open, or non-zero (but not 1) if it is.
+
**
+
** This is so that expressions can be written as:
+
**
+
**   if( isOpen(pPager->jfd) ){ ...
+
**
+
** instead of
+
**
+
**   if( pPager->jfd->pMethods ){ ...
+
*/
+
#define isOpen(pFd) ((pFd)->pMethods!=0)
+

/*
** Flags that make up the mask passed to sqlite3PagerGet().
*/
@@ -16640,6 +16810,7 @@ typedef struct SubrtnSig SubrtnSig;
*/
struct SubrtnSig {
  int selId;          /* SELECT-id for the SELECT statement on the RHS */
+
  u8 bComplete;       /* True if fully coded and available for reusable */
  char *zAff;         /* Affinity of the overall IN expression */
  int iTable;         /* Ephemeral table generated by the subroutine */
  int iAddr;          /* Subroutine entry address */
@@ -17027,7 +17198,7 @@ typedef struct VdbeOpList VdbeOpList;
** Additional non-public SQLITE_PREPARE_* flags
*/
#define SQLITE_PREPARE_SAVESQL  0x80  /* Preserve SQL text */
-
#define SQLITE_PREPARE_MASK     0x0f  /* Mask of public flags */
+
#define SQLITE_PREPARE_MASK     0x1f  /* Mask of public flags */

/*
** Prototypes for the VDBE interface.  See comments on the implementation
@@ -17742,47 +17913,11 @@ struct FuncDefHash {
};
#define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ)

-
#if defined(SQLITE_USER_AUTHENTICATION)
-
# warning  "The SQLITE_USER_AUTHENTICATION extension is deprecated. \
-
 See ext/userauth/user-auth.txt for details."
-
#endif
-
#ifdef SQLITE_USER_AUTHENTICATION
-
/*
-
** Information held in the "sqlite3" database connection object and used
-
** to manage user authentication.
-
*/
-
typedef struct sqlite3_userauth sqlite3_userauth;
-
struct sqlite3_userauth {
-
  u8 authLevel;                 /* Current authentication level */
-
  int nAuthPW;                  /* Size of the zAuthPW in bytes */
-
  char *zAuthPW;                /* Password used to authenticate */
-
  char *zAuthUser;              /* User name used to authenticate */
-
};
-

-
/* Allowed values for sqlite3_userauth.authLevel */
-
#define UAUTH_Unknown     0     /* Authentication not yet checked */
-
#define UAUTH_Fail        1     /* User authentication failed */
-
#define UAUTH_User        2     /* Authenticated as a normal user */
-
#define UAUTH_Admin       3     /* Authenticated as an administrator */
-

-
/* Functions used only by user authorization logic */
-
SQLITE_PRIVATE int sqlite3UserAuthTable(const char*);
-
SQLITE_PRIVATE int sqlite3UserAuthCheckLogin(sqlite3*,const char*,u8*);
-
SQLITE_PRIVATE void sqlite3UserAuthInit(sqlite3*);
-
SQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
-

-
#endif /* SQLITE_USER_AUTHENTICATION */
-

/*
** typedef for the authorization callback function.
*/
-
#ifdef SQLITE_USER_AUTHENTICATION
-
  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
-
                               const char*, const char*);
-
#else
-
  typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
-
                               const char*);
-
#endif
+
typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*,
+
                             const char*);

#ifndef SQLITE_OMIT_DEPRECATED
/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
@@ -17943,9 +18078,6 @@ struct sqlite3 {
  void (*xUnlockNotify)(void **, int);  /* Unlock notify callback */
  sqlite3 *pNextBlocked;        /* Next in list of all blocked connections */
#endif
-
#ifdef SQLITE_USER_AUTHENTICATION
-
  sqlite3_userauth auth;        /* User authentication information */
-
#endif
};

/*
@@ -18009,6 +18141,9 @@ struct sqlite3 {
#define SQLITE_CorruptRdOnly  HI(0x00002) /* Prohibit writes due to error */
#define SQLITE_ReadUncommit   HI(0x00004) /* READ UNCOMMITTED in shared-cache */
#define SQLITE_FkNoAction     HI(0x00008) /* Treat all FK as NO ACTION */
+
#define SQLITE_AttachCreate   HI(0x00010) /* ATTACH allowed to create new dbs */
+
#define SQLITE_AttachWrite    HI(0x00020) /* ATTACH allowed to open for write */
+
#define SQLITE_Comments       HI(0x00040) /* Enable SQL comments */

/* Flags used only if debugging */
#ifdef SQLITE_DEBUG
@@ -18068,6 +18203,7 @@ struct sqlite3 {
#define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
#define SQLITE_OnePass        0x08000000 /* Single-pass DELETE and UPDATE */
#define SQLITE_OrderBySubq    0x10000000 /* ORDER BY in subquery helps outer */
+
#define SQLITE_StarQuery      0x20000000 /* Heurists for star queries */
#define SQLITE_AllOpts        0xffffffff /* All optimizations */

/*
@@ -18104,7 +18240,7 @@ struct sqlite3 {
** field is used by per-connection app-def functions.
*/
struct FuncDef {
-
  i8 nArg;             /* Number of arguments.  -1 means unlimited */
+
  i16 nArg;            /* Number of arguments.  -1 means unlimited */
  u32 funcFlags;       /* Some combination of SQLITE_FUNC_* */
  void *pUserData;     /* User data parameter */
  FuncDef *pNext;      /* Next function with same name */
@@ -19397,13 +19533,8 @@ struct ExprList {
*/
struct IdList {
  int nId;         /* Number of identifiers on the list */
-
  u8 eU4;          /* Which element of a.u4 is valid */
  struct IdList_item {
    char *zName;      /* Name of the identifier */
-
    union {
-
      int idx;          /* Index in some Table.aCol[] of a column named zName */
-
      Expr *pExpr;      /* Expr to implement a USING variable -- NOT USED */
-
    } u4;
  } a[1];
};

@@ -20090,9 +20221,7 @@ struct Parse {
  int nVtabLock;            /* Number of virtual tables to lock */
#endif
  int nHeight;              /* Expression tree height of current sub-select */
-
#ifndef SQLITE_OMIT_EXPLAIN
  int addrExplain;          /* Address of current OP_Explain opcode */
-
#endif
  VList *pVList;            /* Mapping between variable names and numbers */
  Vdbe *pReprepare;         /* VM being reprepared (sqlite3Reprepare()) */
  const char *zTail;        /* All SQL text past the last semicolon parsed */
@@ -22852,9 +22981,6 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_UNTESTABLE
  "UNTESTABLE",
#endif
-
#ifdef SQLITE_USER_AUTHENTICATION
-
  "USER_AUTHENTICATION",
-
#endif
#ifdef SQLITE_USE_ALLOCA
  "USE_ALLOCA",
#endif
@@ -23553,6 +23679,7 @@ struct sqlite3_value {
#ifdef SQLITE_DEBUG
  Mem *pScopyFrom;    /* This Mem is a shallow copy of pScopyFrom */
  u16 mScopyFlags;    /* flags value immediately after the shallow copy */
+
  u8  bScopy;         /* The pScopyFrom of some other Mem *might* point here */
#endif
};

@@ -23702,7 +23829,7 @@ struct sqlite3_context {
  int isError;            /* Error code returned by the function. */
  u8 enc;                 /* Encoding to use for results */
  u8 skipFlag;            /* Skip accumulator loading if true */
-
  u8 argc;                /* Number of arguments */
+
  u16 argc;               /* Number of arguments */
  sqlite3_value *argv[1]; /* Argument set */
};

@@ -23849,6 +23976,7 @@ struct PreUpdate {
  int iBlobWrite;                 /* Value returned by preupdate_blobwrite() */
  i64 iKey1;                      /* First key value passed to hook */
  i64 iKey2;                      /* Second key value passed to hook */
+
  Mem oldipk;                     /* Memory cell holding "old" IPK value */
  Mem *aNew;                      /* Array of new.* values */
  Table *pTab;                    /* Schema object being updated */
  Index *pPk;                     /* PK index if pTab is WITHOUT ROWID */
@@ -24650,6 +24778,9 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
        zDate++;
      }
      ms /= rScale;
+
      /* Truncate to avoid problems with sub-milliseconds
+
      ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */
+
      if( ms>0.999 ) ms = 0.999;
    }
  }else{
    s = 0;
@@ -25857,7 +25988,7 @@ static void strftimeFunc(
      }
      case 'f': {  /* Fractional seconds.  (Non-standard) */
        double s = x.s;
-
        if( s>59.999 ) s = 59.999;
+
        if( NEVER(s>59.999) ) s = 59.999;
        sqlite3_str_appendf(&sRes, "%06.3f", s);
        break;
      }
@@ -32298,6 +32429,7 @@ SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExp
    pExpr = pExpr->pLeft;
  }
  if( pExpr==0 ) return;
+
  if( ExprHasProperty(pExpr, EP_FromDDL) ) return;
  db->errByteOffset = pExpr->w.iOfst;
}

@@ -33024,10 +33156,13 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc)
      sqlite3_str_appendf(&x, " DDL");
    }
    if( pItem->fg.isCte ){
-
      sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
+
      static const char *aMat[] = {",MAT", "", ",NO-MAT"};
+
      sqlite3_str_appendf(&x, " CteUse=%d%s",
+
                          pItem->u2.pCteUse->nUse,
+
                          aMat[pItem->u2.pCteUse->eM10d]);
    }
    if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
-
      sqlite3_str_appendf(&x, " ON");
+
      sqlite3_str_appendf(&x, " isOn");
    }
    if( pItem->fg.isTabFunc )      sqlite3_str_appendf(&x, " isTabFunc");
    if( pItem->fg.isCorrelated )   sqlite3_str_appendf(&x, " isCorrelated");
@@ -33055,9 +33190,6 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc)
        sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
      }
      assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) );
-
      sqlite3TreeViewPush(&pView, 0);
-
      sqlite3TreeViewLine(pView, "SUBQUERY");
-
      sqlite3TreeViewPop(&pView);
      sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, 0);
    }
    if( pItem->fg.isTabFunc ){
@@ -33787,21 +33919,7 @@ SQLITE_PRIVATE void sqlite3TreeViewBareIdList(
      if( zName==0 ) zName = "(null)";
      sqlite3TreeViewPush(&pView, moreToFollow);
      sqlite3TreeViewLine(pView, 0);
-
      if( pList->eU4==EU4_NONE ){
-
        fprintf(stdout, "%s\n", zName);
-
      }else if( pList->eU4==EU4_IDX ){
-
        fprintf(stdout, "%s (%d)\n", zName, pList->a[i].u4.idx);
-
      }else{
-
        assert( pList->eU4==EU4_EXPR );
-
        if( pList->a[i].u4.pExpr==0 ){
-
          fprintf(stdout, "%s (pExpr=NULL)\n", zName);
-
        }else{
-
          fprintf(stdout, "%s\n", zName);
-
          sqlite3TreeViewPush(&pView, i<pList->nId-1);
-
          sqlite3TreeViewExpr(pView, pList->a[i].u4.pExpr, 0);
-
          sqlite3TreeViewPop(&pView);
-
        }
-
      }
+
      fprintf(stdout, "%s\n", zName);
      sqlite3TreeViewPop(&pView);
    }
  }
@@ -34111,6 +34229,10 @@ SQLITE_PRIVATE void sqlite3TreeViewTrigger(
** accessible to the debugging, and to avoid warnings about unused
** functions.  But these routines only exist in debugging builds, so they
** do not contaminate the interface.
+
**
+
** See Also:
+
**
+
**     sqlite3ShowWhereTerm() in where.c
*/
SQLITE_PRIVATE void sqlite3ShowExpr(const Expr *p){ sqlite3TreeViewExpr(0,p,0); }
SQLITE_PRIVATE void sqlite3ShowExprList(const ExprList *p){ sqlite3TreeViewExprList(0,p,0,0);}
@@ -35687,8 +35809,8 @@ SQLITE_PRIVATE int sqlite3AtoF(const char *z, double *pResult, int length, u8 en
  int eValid = 1;  /* True exponent is either not used or is well-formed */
  int nDigit = 0;  /* Number of digits processed */
  int eType = 1;   /* 1: pure integer,  2+: fractional  -1 or less: bad UTF16 */
+
  u64 s2;          /* round-tripped significand */
  double rr[2];
-
  u64 s2;

  assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
  *pResult = 0.0;   /* Default return value, in case of an error */
@@ -35791,7 +35913,7 @@ do_atof_calc:
  e = (e*esign) + d;

  /* Try to adjust the exponent to make it smaller */
-
  while( e>0 && s<(LARGEST_UINT64/10) ){
+
  while( e>0 && s<((LARGEST_UINT64-0x7ff)/10) ){
    s *= 10;
    e--;
  }
@@ -35801,11 +35923,22 @@ do_atof_calc:
  }

  rr[0] = (double)s;
-
  s2 = (u64)rr[0];
-
#if defined(_MSC_VER) && _MSC_VER<1700
-
  if( s2==0x8000000000000000LL ){ s2 = 2*(u64)(0.5*rr[0]); }
+
  assert( sizeof(s2)==sizeof(rr[0]) );
+
#ifdef SQLITE_DEBUG
+
  rr[1] = 18446744073709549568.0;
+
  memcpy(&s2, &rr[1], sizeof(s2));
+
  assert( s2==0x43efffffffffffffLL );
#endif
-
  rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
+
  /* Largest double that can be safely converted to u64
+
  **         vvvvvvvvvvvvvvvvvvvvvv   */
+
  if( rr[0]<=18446744073709549568.0 ){
+
    s2 = (u64)rr[0];
+
    rr[1] = s>=s2 ? (double)(s - s2) : -(double)(s2 - s);
+
  }else{
+
    rr[1] = 0.0;
+
  }
+
  assert( rr[1]<=1.0e-10*rr[0] );  /* Equal only when rr[0]==0.0 */
+

  if( e>0 ){
    while( e>=100  ){
      e -= 100;
@@ -38676,7 +38809,7 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
# endif
#else /* !SQLITE_WASI */
# ifndef HAVE_FCHMOD
-
#  define HAVE_FCHMOD
+
#  define HAVE_FCHMOD 1
# endif
#endif /* SQLITE_WASI */

@@ -40127,7 +40260,7 @@ static int unixFileLock(unixFile *pFile, struct flock *pLock){
  if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
    if( pInode->bProcessLock==0 ){
      struct flock lock;
-
      assert( pInode->nLock==0 );
+
      /* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */
      lock.l_whence = SEEK_SET;
      lock.l_start = SHARED_FIRST;
      lock.l_len = SHARED_SIZE;
@@ -42450,6 +42583,11 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
    }
#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */

+
    case SQLITE_FCNTL_NULL_IO: {
+
      osClose(pFile->h);
+
      pFile->h = -1;
+
      return SQLITE_OK;
+
    }
    case SQLITE_FCNTL_LOCKSTATE: {
      *(int*)pArg = pFile->eFileLock;
      return SQLITE_OK;
@@ -42591,6 +42729,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
    if( pFd->ctrlFlags & UNIXFILE_PSOW ){
      pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
    }
+
    pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ;

    pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
  }
@@ -50330,6 +50469,11 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
      return SQLITE_OK;
    }
#endif
+
    case SQLITE_FCNTL_NULL_IO: {
+
      (void)osCloseHandle(pFile->h);
+
      pFile->h = NULL;
+
      return SQLITE_OK;
+
    }
    case SQLITE_FCNTL_TEMPFILENAME: {
      char *zTFile = 0;
      int rc = winGetTempname(pFile->pVfs, &zTFile);
@@ -50391,7 +50535,7 @@ static int winSectorSize(sqlite3_file *id){
*/
static int winDeviceCharacteristics(sqlite3_file *id){
  winFile *p = (winFile*)id;
-
  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
+
  return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_SUBPAGE_READ |
         ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
}

@@ -51779,7 +51923,7 @@ static int winOpen(

  int rc = SQLITE_OK;            /* Function Return Code */
#if !defined(NDEBUG) || SQLITE_OS_WINCE
-
  int eType = flags&0xFFFFFF00;  /* Type of file to open */
+
  int eType = flags&0x0FFF00;  /* Type of file to open */
#endif

  int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);
@@ -57980,39 +58124,33 @@ static const unsigned char aJournalMagic[] = {
# define USEFETCH(x) 0
#endif

-
/*
-
** The argument to this macro is a file descriptor (type sqlite3_file*).
-
** Return 0 if it is not open, or non-zero (but not 1) if it is.
-
**
-
** This is so that expressions can be written as:
-
**
-
**   if( isOpen(pPager->jfd) ){ ...
-
**
-
** instead of
-
**
-
**   if( pPager->jfd->pMethods ){ ...
-
*/
-
#define isOpen(pFd) ((pFd)->pMethods!=0)
-

#ifdef SQLITE_DIRECT_OVERFLOW_READ
/*
** Return true if page pgno can be read directly from the database file
** by the b-tree layer. This is the case if:
**
-
**   * the database file is open,
-
**   * there are no dirty pages in the cache, and
-
**   * the desired page is not currently in the wal file.
+
**   (1)  the database file is open
+
**   (2)  the VFS for the database is able to do unaligned sub-page reads
+
**   (3)  there are no dirty pages in the cache, and
+
**   (4)  the desired page is not currently in the wal file.
*/
SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){
-
  if( pPager->fd->pMethods==0 ) return 0;
-
  if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
+
  assert( pPager!=0 );
+
  assert( pPager->fd!=0 );
+
  if( pPager->fd->pMethods==0 ) return 0;  /* Case (1) */
+
  if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
#ifndef SQLITE_OMIT_WAL
  if( pPager->pWal ){
    u32 iRead = 0;
    (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
-
    return iRead==0;
+
    if( iRead ) return 0;  /* Case (4) */
  }
#endif
+
  assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
+
  if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
+
        & SQLITE_IOCAP_SUBPAGE_READ)==0 ){
+
    return 0; /* Case (2) */
+
  }
  return 1;
}
#endif
@@ -59271,7 +59409,7 @@ static int pager_end_transaction(Pager *pPager, int hasSuper, int bCommit){
      }
      pPager->journalOff = 0;
    }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
-
      || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)
+
      || (pPager->exclusiveMode && pPager->journalMode<PAGER_JOURNALMODE_WAL)
    ){
      rc = zeroJournalHdr(pPager, hasSuper||pPager->tempFile);
      pPager->journalOff = 0;
@@ -67981,11 +68119,7 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
*/
static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
  volatile WalCkptInfo *pInfo;    /* Checkpoint information in wal-index */
-
  u32 mxReadMark;                 /* Largest aReadMark[] value */
-
  int mxI;                        /* Index of largest aReadMark[] value */
-
  int i;                          /* Loop counter */
  int rc = SQLITE_OK;             /* Return code  */
-
  u32 mxFrame;                    /* Wal frame to lock to */
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
  int nBlockTmout = 0;
#endif
@@ -68091,141 +68225,147 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
  assert( pWal->apWiData[0]!=0 );
  pInfo = walCkptInfo(pWal);
  SEH_INJECT_FAULT;
-
  if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
+
  {
+
    u32 mxReadMark;               /* Largest aReadMark[] value */
+
    int mxI;                      /* Index of largest aReadMark[] value */
+
    int i;                        /* Loop counter */
+
    u32 mxFrame;                  /* Wal frame to lock to */
+
    if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
#ifdef SQLITE_ENABLE_SNAPSHOT
-
   && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
+
     && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
#endif
-
  ){
-
    /* The WAL has been completely backfilled (or it is empty).
-
    ** and can be safely ignored.
-
    */
-
    rc = walLockShared(pWal, WAL_READ_LOCK(0));
-
    walShmBarrier(pWal);
-
    if( rc==SQLITE_OK ){
-
      if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
-
        /* It is not safe to allow the reader to continue here if frames
-
        ** may have been appended to the log before READ_LOCK(0) was obtained.
-
        ** When holding READ_LOCK(0), the reader ignores the entire log file,
-
        ** which implies that the database file contains a trustworthy
-
        ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
-
        ** happening, this is usually correct.
-
        **
-
        ** However, if frames have been appended to the log (or if the log
-
        ** is wrapped and written for that matter) before the READ_LOCK(0)
-
        ** is obtained, that is not necessarily true. A checkpointer may
-
        ** have started to backfill the appended frames but crashed before
-
        ** it finished. Leaving a corrupt image in the database file.
-
        */
-
        walUnlockShared(pWal, WAL_READ_LOCK(0));
-
        return WAL_RETRY;
+
    ){
+
      /* The WAL has been completely backfilled (or it is empty).
+
      ** and can be safely ignored.
+
      */
+
      rc = walLockShared(pWal, WAL_READ_LOCK(0));
+
      walShmBarrier(pWal);
+
      if( rc==SQLITE_OK ){
+
        if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr,sizeof(WalIndexHdr)) ){
+
          /* It is not safe to allow the reader to continue here if frames
+
          ** may have been appended to the log before READ_LOCK(0) was obtained.
+
          ** When holding READ_LOCK(0), the reader ignores the entire log file,
+
          ** which implies that the database file contains a trustworthy
+
          ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
+
          ** happening, this is usually correct.
+
          **
+
          ** However, if frames have been appended to the log (or if the log
+
          ** is wrapped and written for that matter) before the READ_LOCK(0)
+
          ** is obtained, that is not necessarily true. A checkpointer may
+
          ** have started to backfill the appended frames but crashed before
+
          ** it finished. Leaving a corrupt image in the database file.
+
          */
+
          walUnlockShared(pWal, WAL_READ_LOCK(0));
+
          return WAL_RETRY;
+
        }
+
        pWal->readLock = 0;
+
        return SQLITE_OK;
+
      }else if( rc!=SQLITE_BUSY ){
+
        return rc;
      }
-
      pWal->readLock = 0;
-
      return SQLITE_OK;
-
    }else if( rc!=SQLITE_BUSY ){
-
      return rc;
    }
-
  }

-
  /* If we get this far, it means that the reader will want to use
-
  ** the WAL to get at content from recent commits.  The job now is
-
  ** to select one of the aReadMark[] entries that is closest to
-
  ** but not exceeding pWal->hdr.mxFrame and lock that entry.
-
  */
-
  mxReadMark = 0;
-
  mxI = 0;
-
  mxFrame = pWal->hdr.mxFrame;
+
    /* If we get this far, it means that the reader will want to use
+
    ** the WAL to get at content from recent commits.  The job now is
+
    ** to select one of the aReadMark[] entries that is closest to
+
    ** but not exceeding pWal->hdr.mxFrame and lock that entry.
+
    */
+
    mxReadMark = 0;
+
    mxI = 0;
+
    mxFrame = pWal->hdr.mxFrame;
#ifdef SQLITE_ENABLE_SNAPSHOT
-
  if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
-
    mxFrame = pWal->pSnapshot->mxFrame;
-
  }
-
#endif
-
  for(i=1; i<WAL_NREADER; i++){
-
    u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
-
    if( mxReadMark<=thisMark && thisMark<=mxFrame ){
-
      assert( thisMark!=READMARK_NOT_USED );
-
      mxReadMark = thisMark;
-
      mxI = i;
+
    if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
+
      mxFrame = pWal->pSnapshot->mxFrame;
    }
-
  }
-
  if( (pWal->readOnly & WAL_SHM_RDONLY)==0
-
   && (mxReadMark<mxFrame || mxI==0)
-
  ){
+
#endif
    for(i=1; i<WAL_NREADER; i++){
-
      rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
-
      if( rc==SQLITE_OK ){
-
        AtomicStore(pInfo->aReadMark+i,mxFrame);
-
        mxReadMark = mxFrame;
+
      u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
+
      if( mxReadMark<=thisMark && thisMark<=mxFrame ){
+
        assert( thisMark!=READMARK_NOT_USED );
+
        mxReadMark = thisMark;
        mxI = i;
-
        walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
-
        break;
-
      }else if( rc!=SQLITE_BUSY ){
-
        return rc;
      }
    }
-
  }
-
  if( mxI==0 ){
-
    assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
-
    return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
-
  }
+
    if( (pWal->readOnly & WAL_SHM_RDONLY)==0
+
     && (mxReadMark<mxFrame || mxI==0)
+
    ){
+
      for(i=1; i<WAL_NREADER; i++){
+
        rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
+
        if( rc==SQLITE_OK ){
+
          AtomicStore(pInfo->aReadMark+i,mxFrame);
+
          mxReadMark = mxFrame;
+
          mxI = i;
+
          walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
+
          break;
+
        }else if( rc!=SQLITE_BUSY ){
+
          return rc;
+
        }
+
      }
+
    }
+
    if( mxI==0 ){
+
      assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
+
      return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
+
    }

-
  (void)walEnableBlockingMs(pWal, nBlockTmout);
-
  rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
-
  walDisableBlocking(pWal);
-
  if( rc ){
+
    (void)walEnableBlockingMs(pWal, nBlockTmout);
+
    rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
+
    walDisableBlocking(pWal);
+
    if( rc ){
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
-
    if( rc==SQLITE_BUSY_TIMEOUT ){
-
      *pCnt |= WAL_RETRY_BLOCKED_MASK;
-
    }
+
      if( rc==SQLITE_BUSY_TIMEOUT ){
+
        *pCnt |= WAL_RETRY_BLOCKED_MASK;
+
      }
#else
-
    assert( rc!=SQLITE_BUSY_TIMEOUT );
+
      assert( rc!=SQLITE_BUSY_TIMEOUT );
#endif
-
    assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
-
    return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
-
  }
-
  /* Now that the read-lock has been obtained, check that neither the
-
  ** value in the aReadMark[] array or the contents of the wal-index
-
  ** header have changed.
-
  **
-
  ** It is necessary to check that the wal-index header did not change
-
  ** between the time it was read and when the shared-lock was obtained
-
  ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
-
  ** that the log file may have been wrapped by a writer, or that frames
-
  ** that occur later in the log than pWal->hdr.mxFrame may have been
-
  ** copied into the database by a checkpointer. If either of these things
-
  ** happened, then reading the database with the current value of
-
  ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
-
  ** instead.
-
  **
-
  ** Before checking that the live wal-index header has not changed
-
  ** since it was read, set Wal.minFrame to the first frame in the wal
-
  ** file that has not yet been checkpointed. This client will not need
-
  ** to read any frames earlier than minFrame from the wal file - they
-
  ** can be safely read directly from the database file.
-
  **
-
  ** Because a ShmBarrier() call is made between taking the copy of
-
  ** nBackfill and checking that the wal-header in shared-memory still
-
  ** matches the one cached in pWal->hdr, it is guaranteed that the
-
  ** checkpointer that set nBackfill was not working with a wal-index
-
  ** header newer than that cached in pWal->hdr. If it were, that could
-
  ** cause a problem. The checkpointer could omit to checkpoint
-
  ** a version of page X that lies before pWal->minFrame (call that version
-
  ** A) on the basis that there is a newer version (version B) of the same
-
  ** page later in the wal file. But if version B happens to like past
-
  ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
-
  ** that it can read version A from the database file. However, since
-
  ** we can guarantee that the checkpointer that set nBackfill could not
-
  ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
-
  */
-
  pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
-
  walShmBarrier(pWal);
-
  if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
-
   || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
-
  ){
-
    walUnlockShared(pWal, WAL_READ_LOCK(mxI));
-
    return WAL_RETRY;
-
  }else{
-
    assert( mxReadMark<=pWal->hdr.mxFrame );
-
    pWal->readLock = (i16)mxI;
+
      assert((rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT);
+
      return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
+
    }
+
    /* Now that the read-lock has been obtained, check that neither the
+
    ** value in the aReadMark[] array or the contents of the wal-index
+
    ** header have changed.
+
    **
+
    ** It is necessary to check that the wal-index header did not change
+
    ** between the time it was read and when the shared-lock was obtained
+
    ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
+
    ** that the log file may have been wrapped by a writer, or that frames
+
    ** that occur later in the log than pWal->hdr.mxFrame may have been
+
    ** copied into the database by a checkpointer. If either of these things
+
    ** happened, then reading the database with the current value of
+
    ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
+
    ** instead.
+
    **
+
    ** Before checking that the live wal-index header has not changed
+
    ** since it was read, set Wal.minFrame to the first frame in the wal
+
    ** file that has not yet been checkpointed. This client will not need
+
    ** to read any frames earlier than minFrame from the wal file - they
+
    ** can be safely read directly from the database file.
+
    **
+
    ** Because a ShmBarrier() call is made between taking the copy of
+
    ** nBackfill and checking that the wal-header in shared-memory still
+
    ** matches the one cached in pWal->hdr, it is guaranteed that the
+
    ** checkpointer that set nBackfill was not working with a wal-index
+
    ** header newer than that cached in pWal->hdr. If it were, that could
+
    ** cause a problem. The checkpointer could omit to checkpoint
+
    ** a version of page X that lies before pWal->minFrame (call that version
+
    ** A) on the basis that there is a newer version (version B) of the same
+
    ** page later in the wal file. But if version B happens to like past
+
    ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
+
    ** that it can read version A from the database file. However, since
+
    ** we can guarantee that the checkpointer that set nBackfill could not
+
    ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
+
    */
+
    pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
+
    walShmBarrier(pWal);
+
    if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
+
     || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
+
    ){
+
      walUnlockShared(pWal, WAL_READ_LOCK(mxI));
+
      return WAL_RETRY;
+
    }else{
+
      assert( mxReadMark<=pWal->hdr.mxFrame );
+
      pWal->readLock = (i16)mxI;
+
    }
  }
  return rc;
}
@@ -83951,27 +84091,30 @@ SQLITE_PRIVATE int sqlite3VdbeMemTooBig(Mem *p){
SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
  int i;
  Mem *pX;
-
  for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
-
    if( pX->pScopyFrom==pMem ){
-
      u16 mFlags;
-
      if( pVdbe->db->flags & SQLITE_VdbeTrace ){
-
        sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
-
          (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
-
      }
-
      /* If pX is marked as a shallow copy of pMem, then try to verify that
-
      ** no significant changes have been made to pX since the OP_SCopy.
-
      ** A significant change would indicated a missed call to this
-
      ** function for pX.  Minor changes, such as adding or removing a
-
      ** dual type, are allowed, as long as the underlying value is the
-
      ** same. */
-
      mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
-
      assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
-

-
      /* pMem is the register that is changing.  But also mark pX as
-
      ** undefined so that we can quickly detect the shallow-copy error */
-
      pX->flags = MEM_Undefined;
-
      pX->pScopyFrom = 0;
-
    }
+
  if( pMem->bScopy ){
+
    for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
+
      if( pX->pScopyFrom==pMem ){
+
        u16 mFlags;
+
        if( pVdbe->db->flags & SQLITE_VdbeTrace ){
+
          sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
+
            (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
+
        }
+
        /* If pX is marked as a shallow copy of pMem, then try to verify that
+
        ** no significant changes have been made to pX since the OP_SCopy.
+
        ** A significant change would indicated a missed call to this
+
        ** function for pX.  Minor changes, such as adding or removing a
+
        ** dual type, are allowed, as long as the underlying value is the
+
        ** same. */
+
        mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
+
        assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
+

+
        /* pMem is the register that is changing.  But also mark pX as
+
        ** undefined so that we can quickly detect the shallow-copy error */
+
        pX->flags = MEM_Undefined;
+
        pX->pScopyFrom = 0;
+
      }
+
    }
+
    pMem->bScopy = 0;
  }
  pMem->pScopyFrom = 0;
}
@@ -87105,6 +87248,7 @@ SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, VdbeOp *pOp){
** will be initialized before use.
*/
static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
+
  assert( db!=0 );
  if( N>0 ){
    do{
      p->flags = flags;
@@ -87112,6 +87256,7 @@ static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
      p->szMalloc = 0;
#ifdef SQLITE_DEBUG
      p->pScopyFrom = 0;
+
      p->bScopy = 0;
#endif
      p++;
    }while( (--N)>0 );
@@ -87130,6 +87275,7 @@ static void releaseMemArray(Mem *p, int N){
  if( p && N ){
    Mem *pEnd = &p[N];
    sqlite3 *db = p->db;
+
    assert( db!=0 );
    if( db->pnBytesFreed ){
      do{
        if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
@@ -87610,6 +87756,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
  assert( pParse!=0 );
  assert( p->eVdbeState==VDBE_INIT_STATE );
  assert( pParse==p->pParse );
+
  assert( pParse->db==p->db );
  p->pVList = pParse->pVList;
  pParse->pVList =  0;
  db = p->db;
@@ -90490,6 +90637,7 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook(
  sqlite3DbFree(db, preupdate.aRecord);
  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pUnpacked);
  vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pNewUnpacked);
+
  sqlite3VdbeMemRelease(&preupdate.oldipk);
  if( preupdate.aNew ){
    int i;
    for(i=0; i<pCsr->nField; i++){
@@ -90574,7 +90722,6 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
  sqlite3_int64 iNow;
  sqlite3_int64 iElapse;
  assert( p->startTime>0 );
-
  assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );
  assert( db->init.busy==0 );
  assert( p->zSql!=0 );
  sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
@@ -91294,7 +91441,7 @@ static int sqlite3Step(Vdbe *p){
      }

      assert( db->nVdbeWrite>0 || db->autoCommit==0
-
          || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
+
          || ((db->nDeferredCons + db->nDeferredImmCons)==0)
      );

#ifndef SQLITE_OMIT_TRACE
@@ -91805,6 +91952,7 @@ static const Mem *columnNullValue(void){
#ifdef SQLITE_DEBUG
        /* .pScopyFrom = */ (Mem*)0,
        /* .mScopyFlags= */ 0,
+
        /* .bScopy     = */ 0,
#endif
      };
  return &nullMem;
@@ -91846,7 +91994,7 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
**     sqlite3_column_int64()
**     sqlite3_column_text()
**     sqlite3_column_text16()
-
**     sqlite3_column_real()
+
**     sqlite3_column_double()
**     sqlite3_column_bytes()
**     sqlite3_column_bytes16()
**     sqlite3_column_blob()
@@ -92687,6 +92835,7 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa
  PreUpdate *p;
  Mem *pMem;
  int rc = SQLITE_OK;
+
  int iStore = 0;

#ifdef SQLITE_ENABLE_API_ARMOR
  if( db==0 || ppValue==0 ){
@@ -92701,67 +92850,73 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa
    goto preupdate_old_out;
  }
  if( p->pPk ){
-
    iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
+
    iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
+
  }else{
+
    iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
  }
-
  if( iIdx>=p->pCsr->nField || iIdx<0 ){
+
  if( iStore>=p->pCsr->nField || iStore<0 ){
    rc = SQLITE_RANGE;
    goto preupdate_old_out;
  }

-
  /* If the old.* record has not yet been loaded into memory, do so now. */
-
  if( p->pUnpacked==0 ){
-
    u32 nRec;
-
    u8 *aRec;
+
  if( iIdx==p->pTab->iPKey ){
+
    *ppValue = pMem = &p->oldipk;
+
    sqlite3VdbeMemSetInt64(pMem, p->iKey1);
+
  }else{

-
    assert( p->pCsr->eCurType==CURTYPE_BTREE );
-
    nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
-
    aRec = sqlite3DbMallocRaw(db, nRec);
-
    if( !aRec ) goto preupdate_old_out;
-
    rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);
-
    if( rc==SQLITE_OK ){
-
      p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
-
      if( !p->pUnpacked ) rc = SQLITE_NOMEM;
-
    }
-
    if( rc!=SQLITE_OK ){
-
      sqlite3DbFree(db, aRec);
-
      goto preupdate_old_out;
+
    /* If the old.* record has not yet been loaded into memory, do so now. */
+
    if( p->pUnpacked==0 ){
+
      u32 nRec;
+
      u8 *aRec;
+

+
      assert( p->pCsr->eCurType==CURTYPE_BTREE );
+
      nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor);
+
      aRec = sqlite3DbMallocRaw(db, nRec);
+
      if( !aRec ) goto preupdate_old_out;
+
      rc = sqlite3BtreePayload(p->pCsr->uc.pCursor, 0, nRec, aRec);
+
      if( rc==SQLITE_OK ){
+
        p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec);
+
        if( !p->pUnpacked ) rc = SQLITE_NOMEM;
+
      }
+
      if( rc!=SQLITE_OK ){
+
        sqlite3DbFree(db, aRec);
+
        goto preupdate_old_out;
+
      }
+
      p->aRecord = aRec;
    }
-
    p->aRecord = aRec;
-
  }

-
  pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
-
  if( iIdx==p->pTab->iPKey ){
-
    sqlite3VdbeMemSetInt64(pMem, p->iKey1);
-
  }else if( iIdx>=p->pUnpacked->nField ){
-
    /* This occurs when the table has been extended using ALTER TABLE
-
    ** ADD COLUMN. The value to return is the default value of the column. */
-
    Column *pCol = &p->pTab->aCol[iIdx];
-
    if( pCol->iDflt>0 ){
-
      if( p->apDflt==0 ){
-
        int nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
-
        p->apDflt = (sqlite3_value**)sqlite3DbMallocZero(db, nByte);
-
        if( p->apDflt==0 ) goto preupdate_old_out;
-
      }
-
      if( p->apDflt[iIdx]==0 ){
-
        sqlite3_value *pVal = 0;
-
        Expr *pDflt;
-
        assert( p->pTab!=0 && IsOrdinaryTable(p->pTab) );
-
        pDflt = p->pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr;
-
        rc = sqlite3ValueFromExpr(db, pDflt, ENC(db), pCol->affinity, &pVal);
-
        if( rc==SQLITE_OK && pVal==0 ){
-
          rc = SQLITE_CORRUPT_BKPT;
+
    pMem = *ppValue = &p->pUnpacked->aMem[iStore];
+
    if( iStore>=p->pUnpacked->nField ){
+
      /* This occurs when the table has been extended using ALTER TABLE
+
      ** ADD COLUMN. The value to return is the default value of the column. */
+
      Column *pCol = &p->pTab->aCol[iIdx];
+
      if( pCol->iDflt>0 ){
+
        if( p->apDflt==0 ){
+
          int nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
+
          p->apDflt = (sqlite3_value**)sqlite3DbMallocZero(db, nByte);
+
          if( p->apDflt==0 ) goto preupdate_old_out;
+
        }
+
        if( p->apDflt[iIdx]==0 ){
+
          sqlite3_value *pVal = 0;
+
          Expr *pDflt;
+
          assert( p->pTab!=0 && IsOrdinaryTable(p->pTab) );
+
          pDflt = p->pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr;
+
          rc = sqlite3ValueFromExpr(db, pDflt, ENC(db), pCol->affinity, &pVal);
+
          if( rc==SQLITE_OK && pVal==0 ){
+
            rc = SQLITE_CORRUPT_BKPT;
+
          }
+
          p->apDflt[iIdx] = pVal;
        }
-
        p->apDflt[iIdx] = pVal;
+
        *ppValue = p->apDflt[iIdx];
+
      }else{
+
        *ppValue = (sqlite3_value *)columnNullValue();
+
      }
+
    }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){
+
      if( pMem->flags & (MEM_Int|MEM_IntReal) ){
+
        testcase( pMem->flags & MEM_Int );
+
        testcase( pMem->flags & MEM_IntReal );
+
        sqlite3VdbeMemRealify(pMem);
      }
-
      *ppValue = p->apDflt[iIdx];
-
    }else{
-
      *ppValue = (sqlite3_value *)columnNullValue();
-
    }
-
  }else if( p->pTab->aCol[iIdx].affinity==SQLITE_AFF_REAL ){
-
    if( pMem->flags & (MEM_Int|MEM_IntReal) ){
-
      testcase( pMem->flags & MEM_Int );
-
      testcase( pMem->flags & MEM_IntReal );
-
      sqlite3VdbeMemRealify(pMem);
    }
  }

@@ -92835,6 +92990,7 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppVa
  PreUpdate *p;
  int rc = SQLITE_OK;
  Mem *pMem;
+
  int iStore = 0;

#ifdef SQLITE_ENABLE_API_ARMOR
  if( db==0 || ppValue==0 ){
@@ -92847,9 +93003,12 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppVa
    goto preupdate_new_out;
  }
  if( p->pPk && p->op!=SQLITE_UPDATE ){
-
    iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
+
    iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
+
  }else{
+
    iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
  }
-
  if( iIdx>=p->pCsr->nField || iIdx<0 ){
+

+
  if( iStore>=p->pCsr->nField || iStore<0 ){
    rc = SQLITE_RANGE;
    goto preupdate_new_out;
  }
@@ -92869,14 +93028,14 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppVa
      }
      p->pNewUnpacked = pUnpack;
    }
-
    pMem = &pUnpack->aMem[iIdx];
+
    pMem = &pUnpack->aMem[iStore];
    if( iIdx==p->pTab->iPKey ){
      sqlite3VdbeMemSetInt64(pMem, p->iKey2);
-
    }else if( iIdx>=pUnpack->nField ){
+
    }else if( iStore>=pUnpack->nField ){
      pMem = (sqlite3_value *)columnNullValue();
    }
  }else{
-
    /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
+
    /* For an UPDATE, memory cell (p->iNewReg+1+iStore) contains the required
    ** value. Make a copy of the cell contents and return a pointer to it.
    ** It is not safe to return a pointer to the memory cell itself as the
    ** caller may modify the value text encoding.
@@ -92889,13 +93048,13 @@ SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppVa
        goto preupdate_new_out;
      }
    }
-
    assert( iIdx>=0 && iIdx<p->pCsr->nField );
-
    pMem = &p->aNew[iIdx];
+
    assert( iStore>=0 && iStore<p->pCsr->nField );
+
    pMem = &p->aNew[iStore];
    if( pMem->flags==0 ){
      if( iIdx==p->pTab->iPKey ){
        sqlite3VdbeMemSetInt64(pMem, p->iKey2);
      }else{
-
        rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
+
        rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iStore]);
        if( rc!=SQLITE_OK ) goto preupdate_new_out;
      }
    }
@@ -93984,6 +94143,7 @@ static void registerTrace(int iReg, Mem *p){
  printf("R[%d] = ", iReg);
  memTracePrint(p);
  if( p->pScopyFrom ){
+
    assert( p->pScopyFrom->bScopy );
    printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
  }
  printf("\n");
@@ -94967,6 +95127,7 @@ case OP_Move: {
    { int i;
      for(i=1; i<p->nMem; i++){
        if( aMem[i].pScopyFrom==pIn1 ){
+
          assert( aMem[i].bScopy );
          aMem[i].pScopyFrom = pOut;
        }
      }
@@ -95039,6 +95200,7 @@ case OP_SCopy: { /* out2 */
#ifdef SQLITE_DEBUG
  pOut->pScopyFrom = pIn1;
  pOut->mScopyFlags = pIn1->flags;
+
  pIn1->bScopy = 1;
#endif
  break;
}
@@ -97915,9 +98077,11 @@ case OP_OpenEphemeral: { /* ncycle */
        }
      }
      pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
+
      assert( p->apCsr[pOp->p1]==pCx );
      if( rc ){
        assert( !sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) );
        sqlite3BtreeClose(pCx->ub.pBtx);
+
        p->apCsr[pOp->p1] = 0;  /* Not required; helps with static analysis */
      }else{
        assert( sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) );
      }
@@ -109847,7 +110011,7 @@ static int codeCompare(
  p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
  addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
                           (void*)p4, P4_COLLSEQ);
-
  sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
+
  sqlite3VdbeChangeP5(pParse->pVdbe, (u16)p5);
  return addr;
}

@@ -111300,16 +111464,13 @@ SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){
  int i;
  assert( db!=0 );
  if( p==0 ) return 0;
-
  assert( p->eU4!=EU4_EXPR );
  pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) );
  if( pNew==0 ) return 0;
  pNew->nId = p->nId;
-
  pNew->eU4 = p->eU4;
  for(i=0; i<p->nId; i++){
    struct IdList_item *pNewItem = &pNew->a[i];
    const struct IdList_item *pOldItem = &p->a[i];
    pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
-
    pNewItem->u4 = pOldItem->u4;
  }
  return pNew;
}
@@ -112014,7 +112175,7 @@ static int sqlite3ExprIsTableConstant(Expr *p, int iCur, int bAllowSubq){
**         (4a)  pExpr must come from an ON clause..
**         (4b)  and specifically the ON clause associated with the LEFT JOIN.
**
-
**   (5)  If pSrc is not the right operand of a LEFT JOIN or the left
+
**   (5)  If pSrc is the right operand of a LEFT JOIN or the left
**        operand of a RIGHT JOIN, then pExpr must be from the WHERE
**        clause, not an ON clause.
**
@@ -112653,6 +112814,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
            if( aiMap ) aiMap[i] = j;
          }

+
          assert( nExpr>0 && nExpr<BMS );
          assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
          if( colUsed==(MASKBIT(nExpr)-1) ){
            /* If we reach this point, that means the index pIdx is usable */
@@ -112832,6 +112994,7 @@ static int findCompatibleInRhsSubrtn(
    assert( pOp->opcode==OP_BeginSubrtn );
    pSig = pOp->p4.pSubrtnSig;
    assert( pSig!=0 );
+
    if( !pSig->bComplete ) continue;
    if( pNewSig->selId!=pSig->selId ) continue;
    if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue;
    pExpr->y.sub.iAddr = pSig->iAddr;
@@ -112878,6 +113041,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
  KeyInfo *pKeyInfo = 0;      /* Key information */
  int nVal;                   /* Size of vector pLeft */
  Vdbe *v;                    /* The prepared statement under construction */
+
  SubrtnSig *pSig = 0;        /* Signature for this subroutine */

  v = pParse->pVdbe;
  assert( v!=0 );
@@ -112898,7 +113062,6 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
    ** Compute a signature for the RHS of the IN operator to facility
    ** finding and reusing prior instances of the same IN operator.
    */
-
    SubrtnSig *pSig = 0;
    assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 );
    if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){
      pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0]));
@@ -112941,6 +113104,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
    pExpr->y.sub.iAddr =
      sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
    if( pSig ){
+
      pSig->bComplete = 0;
      pSig->iAddr = pExpr->y.sub.iAddr;
      pSig->regReturn = pExpr->y.sub.regReturn;
      pSig->iTable = iTab;
@@ -113076,6 +113240,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
    sqlite3ReleaseTempReg(pParse, r1);
    sqlite3ReleaseTempReg(pParse, r2);
  }
+
  if( pSig ) pSig->bComplete = 1;
  if( pKeyInfo ){
    sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
  }
@@ -115548,16 +115713,23 @@ SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,i
** same as that currently bound to variable pVar, non-zero is returned.
** Otherwise, if the values are not the same or if pExpr is not a simple
** SQL value, zero is returned.
+
**
+
** If the SQLITE_EnableQPSG flag is set on the database connection, then
+
** this routine always returns false.
*/
-
static int exprCompareVariable(
+
static SQLITE_NOINLINE int exprCompareVariable(
  const Parse *pParse,
  const Expr *pVar,
  const Expr *pExpr
){
-
  int res = 0;
+
  int res = 2;
  int iVar;
  sqlite3_value *pL, *pR = 0;

+
  if( pExpr->op==TK_VARIABLE && pVar->iColumn==pExpr->iColumn ){
+
    return 0;
+
  }
+
  if( (pParse->db->flags & SQLITE_EnableQPSG)!=0 ) return 2;
  sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, SQLITE_AFF_BLOB, &pR);
  if( pR ){
    iVar = pVar->iColumn;
@@ -115567,12 +115739,11 @@ static int exprCompareVariable(
      if( sqlite3_value_type(pL)==SQLITE_TEXT ){
        sqlite3_value_text(pL); /* Make sure the encoding is UTF-8 */
      }
-
      res =  0==sqlite3MemCompare(pL, pR, 0);
+
      res = sqlite3MemCompare(pL, pR, 0) ? 2 : 0;
    }
    sqlite3ValueFree(pR);
    sqlite3ValueFree(pL);
  }
-

  return res;
}

@@ -115598,12 +115769,10 @@ static int exprCompareVariable(
** just might result in some slightly slower code.  But returning
** an incorrect 0 or 1 could lead to a malfunction.
**
-
** If pParse is not NULL then TK_VARIABLE terms in pA with bindings in
-
** pParse->pReprepare can be matched against literals in pB.  The
-
** pParse->pVdbe->expmask bitmask is updated for each variable referenced.
-
** If pParse is NULL (the normal case) then any TK_VARIABLE term in
-
** Argument pParse should normally be NULL. If it is not NULL and pA or
-
** pB causes a return value of 2.
+
** If pParse is not NULL and SQLITE_EnableQPSG is off then TK_VARIABLE
+
** terms in pA with bindings in pParse->pReprepare can be matched against
+
** literals in pB.  The pParse->pVdbe->expmask bitmask is updated for
+
** each variable referenced.
*/
SQLITE_PRIVATE int sqlite3ExprCompare(
  const Parse *pParse,
@@ -115615,8 +115784,8 @@ SQLITE_PRIVATE int sqlite3ExprCompare(
  if( pA==0 || pB==0 ){
    return pB==pA ? 0 : 2;
  }
-
  if( pParse && pA->op==TK_VARIABLE && exprCompareVariable(pParse, pA, pB) ){
-
    return 0;
+
  if( pParse && pA->op==TK_VARIABLE ){
+
    return exprCompareVariable(pParse, pA, pB);
  }
  combinedFlags = pA->flags | pB->flags;
  if( combinedFlags & EP_IntValue ){
@@ -115812,17 +115981,69 @@ static int exprImpliesNotNull(
}

/*
+
** Return true if the boolean value of the expression is always either
+
** FALSE or NULL.
+
*/
+
static int sqlite3ExprIsNotTrue(Expr *pExpr){
+
  int v;
+
  if( pExpr->op==TK_NULL ) return 1;
+
  if( pExpr->op==TK_TRUEFALSE && sqlite3ExprTruthValue(pExpr)==0 ) return 1;
+
  v = 1;
+
  if( sqlite3ExprIsInteger(pExpr, &v, 0) && v==0 ) return 1;
+
  return 0;
+
}
+

+
/*
+
** Return true if the expression is one of the following:
+
**
+
**    CASE WHEN x THEN y END
+
**    CASE WHEN x THEN y ELSE NULL END
+
**    CASE WHEN x THEN y ELSE false END
+
**    iif(x,y)
+
**    iif(x,y,NULL)
+
**    iif(x,y,false)
+
*/
+
static int sqlite3ExprIsIIF(sqlite3 *db, const Expr *pExpr){
+
  ExprList *pList;
+
  if( pExpr->op==TK_FUNCTION ){
+
    const char *z = pExpr->u.zToken;
+
    FuncDef *pDef;
+
    if( (z[0]!='i' && z[0]!='I') ) return 0;
+
    if( pExpr->x.pList==0 ) return 0;
+
    pDef = sqlite3FindFunction(db, z, pExpr->x.pList->nExpr, ENC(db), 0);
+
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
+
    if( pDef==0 ) return 0;
+
#else
+
    if( NEVER(pDef==0) ) return 0;
+
#endif
+
    if( (pDef->funcFlags & SQLITE_FUNC_INLINE)==0 ) return 0;
+
    if( SQLITE_PTR_TO_INT(pDef->pUserData)!=INLINEFUNC_iif ) return 0;
+
  }else if( pExpr->op==TK_CASE ){
+
    if( pExpr->pLeft!=0 ) return 0;
+
  }else{
+
    return 0;
+
  }
+
  pList = pExpr->x.pList;
+
  assert( pList!=0 );
+
  if( pList->nExpr==2 ) return 1;
+
  if( pList->nExpr==3 && sqlite3ExprIsNotTrue(pList->a[2].pExpr) ) return 1;
+
  return 0;
+
}
+

+
/*
** Return true if we can prove the pE2 will always be true if pE1 is
** true.  Return false if we cannot complete the proof or if pE2 might
** be false.  Examples:
**
-
**     pE1: x==5       pE2: x==5             Result: true
-
**     pE1: x>0        pE2: x==5             Result: false
-
**     pE1: x=21       pE2: x=21 OR y=43     Result: true
-
**     pE1: x!=123     pE2: x IS NOT NULL    Result: true
-
**     pE1: x!=?1      pE2: x IS NOT NULL    Result: true
-
**     pE1: x IS NULL  pE2: x IS NOT NULL    Result: false
-
**     pE1: x IS ?2    pE2: x IS NOT NULL    Result: false
+
**     pE1: x==5        pE2: x==5             Result: true
+
**     pE1: x>0         pE2: x==5             Result: false
+
**     pE1: x=21        pE2: x=21 OR y=43     Result: true
+
**     pE1: x!=123      pE2: x IS NOT NULL    Result: true
+
**     pE1: x!=?1       pE2: x IS NOT NULL    Result: true
+
**     pE1: x IS NULL   pE2: x IS NOT NULL    Result: false
+
**     pE1: x IS ?2     pE2: x IS NOT NULL    Result: false
+
**     pE1: iif(x,y)    pE2: x                Result: true
+
**     PE1: iif(x,y,0)  pE2: x                Result: true
**
** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has
** Expr.iTable<0 then assume a table number given by iTab.
@@ -115856,6 +116077,9 @@ SQLITE_PRIVATE int sqlite3ExprImpliesExpr(
  ){
    return 1;
  }
+
  if( sqlite3ExprIsIIF(pParse->db, pE1) ){
+
    return sqlite3ExprImpliesExpr(pParse,pE1->x.pList->a[0].pExpr,pE2,iTab);
+
  }
  return 0;
}

@@ -121215,6 +121439,12 @@ static void attachFunc(
      sqlite3_free(zErr);
      return;
    }
+
    if( (db->flags & SQLITE_AttachWrite)==0 ){
+
      flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE);
+
      flags |= SQLITE_OPEN_READONLY;
+
    }else if( (db->flags & SQLITE_AttachCreate)==0 ){
+
      flags &= ~SQLITE_OPEN_CREATE;
+
    }
    assert( pVfs );
    flags |= SQLITE_OPEN_MAIN_DB;
    rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
@@ -121267,15 +121497,6 @@ static void attachFunc(
    sqlite3BtreeLeaveAll(db);
    assert( zErrDyn==0 || rc!=SQLITE_OK );
  }
-
#ifdef SQLITE_USER_AUTHENTICATION
-
  if( rc==SQLITE_OK && !REOPEN_AS_MEMDB(db) ){
-
    u8 newAuth = 0;
-
    rc = sqlite3UserAuthCheckLogin(db, zName, &newAuth);
-
    if( newAuth<db->auth.authLevel ){
-
      rc = SQLITE_AUTH_USER;
-
    }
-
  }
-
#endif
  if( rc ){
    if( ALWAYS(!REOPEN_AS_MEMDB(db)) ){
      int iDb = db->nDb - 1;
@@ -121773,11 +121994,7 @@ SQLITE_PRIVATE int sqlite3AuthReadCol(
  int rc;                            /* Auth callback return code */

  if( db->init.busy ) return SQLITE_OK;
-
  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext
-
#ifdef SQLITE_USER_AUTHENTICATION
-
                 ,db->auth.zAuthUser
-
#endif
-
                );
+
  rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext);
  if( rc==SQLITE_DENY ){
    char *z = sqlite3_mprintf("%s.%s", zTab, zCol);
    if( db->nDb>2 || iDb!=0 ) z = sqlite3_mprintf("%s.%z", zDb, z);
@@ -121884,11 +122101,7 @@ SQLITE_PRIVATE int sqlite3AuthCheck(
  testcase( zArg3==0 );
  testcase( pParse->zAuthContext==0 );

-
  rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext
-
#ifdef SQLITE_USER_AUTHENTICATION
-
                 ,db->auth.zAuthUser
-
#endif
-
                );
+
  rc = db->xAuth(db->pAuthArg,code,zArg1,zArg2,zArg3,pParse->zAuthContext);
  if( rc==SQLITE_DENY ){
    sqlite3ErrorMsg(pParse, "not authorized");
    pParse->rc = SQLITE_AUTH;
@@ -122121,17 +122334,6 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
    }
    sqlite3VdbeAddOp0(v, OP_Halt);

-
#if SQLITE_USER_AUTHENTICATION && !defined(SQLITE_OMIT_SHARED_CACHE)
-
    if( pParse->nTableLock>0 && db->init.busy==0 ){
-
      sqlite3UserAuthInit(db);
-
      if( db->auth.authLevel<UAUTH_User ){
-
        sqlite3ErrorMsg(pParse, "user not authenticated");
-
        pParse->rc = SQLITE_AUTH_USER;
-
        return;
-
      }
-
    }
-
#endif
-

    /* The cookie mask contains one bit for each database file open.
    ** (Bit 0 is for main, bit 1 is for temp, and so forth.)  Bits are
    ** set for each database that is used.  Generate code to start a
@@ -122260,16 +122462,6 @@ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
  pParse->nested--;
}

-
#if SQLITE_USER_AUTHENTICATION
-
/*
-
** Return TRUE if zTable is the name of the system table that stores the
-
** list of users and their access credentials.
-
*/
-
SQLITE_PRIVATE int sqlite3UserAuthTable(const char *zTable){
-
  return sqlite3_stricmp(zTable, "sqlite_user")==0;
-
}
-
#endif
-

/*
** Locate the in-memory structure that describes a particular database
** table given the name of that table and (optionally) the name of the
@@ -122288,13 +122480,6 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const cha

  /* All mutexes are required for schema access.  Make sure we hold them. */
  assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );
-
#if SQLITE_USER_AUTHENTICATION
-
  /* Only the admin user is allowed to know that the sqlite_user table
-
  ** exists */
-
  if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
-
    return 0;
-
  }
-
#endif
  if( zDatabase ){
    for(i=0; i<db->nDb; i++){
      if( sqlite3StrICmp(zDatabase, db->aDb[i].zDbSName)==0 ) break;
@@ -125953,9 +126138,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
  if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
       && db->init.busy==0
       && pTblName!=0
-
#if SQLITE_USER_AUTHENTICATION
-
       && sqlite3UserAuthTable(pTab->zName)==0
-
#endif
  ){
    sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
    goto exit_create_index;
@@ -126654,7 +126836,6 @@ SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){
  int i;
  assert( db!=0 );
  if( pList==0 ) return;
-
  assert( pList->eU4!=EU4_EXPR ); /* EU4_EXPR mode is not currently used */
  for(i=0; i<pList->nId; i++){
    sqlite3DbFree(db, pList->a[i].zName);
  }
@@ -128035,12 +128216,18 @@ static int matchQuality(
  u8 enc          /* Desired text encoding */
){
  int match;
-
  assert( p->nArg>=-1 );
+
  assert( p->nArg>=(-4) && p->nArg!=(-2) );
+
  assert( nArg>=(-2) );

  /* Wrong number of arguments means "no match" */
  if( p->nArg!=nArg ){
-
    if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;
+
    if( nArg==(-2) ) return p->xSFunc==0 ? 0 : FUNC_PERFECT_MATCH;
    if( p->nArg>=0 ) return 0;
+
    /* Special p->nArg values available to built-in functions only:
+
    **    -3     1 or more arguments required
+
    **    -4     2 or more arguments required
+
    */
+
    if( p->nArg<(-2) && nArg<(-2-p->nArg) ) return 0;
  }

  /* Give a better score to a function with a specific number of arguments
@@ -129663,7 +129850,6 @@ static void substrFunc(
  int len;
  int p0type;
  i64 p1, p2;
-
  int negP2 = 0;

  assert( argc==3 || argc==2 );
  if( sqlite3_value_type(argv[1])==SQLITE_NULL
@@ -129672,7 +129858,7 @@ static void substrFunc(
    return;
  }
  p0type = sqlite3_value_type(argv[0]);
-
  p1 = sqlite3_value_int(argv[1]);
+
  p1 = sqlite3_value_int64(argv[1]);
  if( p0type==SQLITE_BLOB ){
    len = sqlite3_value_bytes(argv[0]);
    z = sqlite3_value_blob(argv[0]);
@@ -129697,19 +129883,18 @@ static void substrFunc(
  if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */
#endif
  if( argc==3 ){
-
    p2 = sqlite3_value_int(argv[2]);
-
    if( p2<0 ){
-
      p2 = -p2;
-
      negP2 = 1;
-
    }
+
    p2 = sqlite3_value_int64(argv[2]);
  }else{
    p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
  }
  if( p1<0 ){
    p1 += len;
    if( p1<0 ){
-
      p2 += p1;
-
      if( p2<0 ) p2 = 0;
+
      if( p2<0 ){
+
        p2 = 0;
+
      }else{
+
        p2 += p1;
+
      }
      p1 = 0;
    }
  }else if( p1>0 ){
@@ -129717,12 +129902,13 @@ static void substrFunc(
  }else if( p2>0 ){
    p2--;
  }
-
  if( negP2 ){
-
    p1 -= p2;
-
    if( p1<0 ){
-
      p2 += p1;
-
      p1 = 0;
+
  if( p2<0 ){
+
    if( p2<-p1 ){
+
      p2 = p1;
+
    }else{
+
      p2 = -p2;
    }
+
    p1 -= p2;
  }
  assert( p1>=0 && p2>=0 );
  if( p0type!=SQLITE_BLOB ){
@@ -129736,9 +129922,11 @@ static void substrFunc(
    sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,
                          SQLITE_UTF8);
  }else{
-
    if( p1+p2>len ){
+
    if( p1>=len ){
+
      p1 = p2 = 0;
+
    }else if( p2>len-p1 ){
      p2 = len-p1;
-
      if( p2<0 ) p2 = 0;
+
      assert( p2>0 );
    }
    sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);
  }
@@ -129749,13 +129937,13 @@ static void substrFunc(
*/
#ifndef SQLITE_OMIT_FLOATING_POINT
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
-
  int n = 0;
+
  i64 n = 0;
  double r;
  char *zBuf;
  assert( argc==1 || argc==2 );
  if( argc==2 ){
    if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
-
    n = sqlite3_value_int(argv[1]);
+
    n = sqlite3_value_int64(argv[1]);
    if( n>30 ) n = 30;
    if( n<0 ) n = 0;
  }
@@ -129770,7 +129958,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  }else if( n==0 ){
    r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
  }else{
-
    zBuf = sqlite3_mprintf("%!.*f",n,r);
+
    zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
    if( zBuf==0 ){
      sqlite3_result_error_nomem(context);
      return;
@@ -131177,7 +131365,10 @@ static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
    assert( p->cnt>0 );
    p->cnt--;
    if( !p->approx ){
-
      p->iSum -= sqlite3_value_int64(argv[0]);
+
      if( sqlite3SubInt64(&p->iSum, sqlite3_value_int64(argv[0])) ){
+
        p->ovrfl = 1;
+
        p->approx = 1;
+
      }
    }else if( type==SQLITE_INTEGER ){
      i64 iVal = sqlite3_value_int64(argv[0]);
      if( iVal!=SMALLEST_INT64 ){
@@ -131987,9 +132178,6 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
    SFUNCTION(load_extension,    1, 0, 0, loadExt          ),
    SFUNCTION(load_extension,    2, 0, 0, loadExt          ),
#endif
-
#if SQLITE_USER_AUTHENTICATION
-
    FUNCTION(sqlite_crypt,       2, 0, 0, sqlite3CryptFunc ),
-
#endif
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
    DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),
    DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),
@@ -132006,12 +132194,10 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),
    FUNCTION(trim,               1, 3, 0, trimFunc         ),
    FUNCTION(trim,               2, 3, 0, trimFunc         ),
-
    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),
-
    FUNCTION(min,                0, 0, 1, 0                ),
+
    FUNCTION(min,               -3, 0, 1, minmaxFunc       ),
    WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
                                 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
-
    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),
-
    FUNCTION(max,                0, 1, 1, 0                ),
+
    FUNCTION(max,               -3, 1, 1, minmaxFunc       ),
    WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
                                 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
    FUNCTION2(typeof,            1, 0, 0, typeofFunc,  SQLITE_FUNC_TYPEOF),
@@ -132038,11 +132224,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
    FUNCTION(hex,                1, 0, 0, hexFunc          ),
    FUNCTION(unhex,              1, 0, 0, unhexFunc        ),
    FUNCTION(unhex,              2, 0, 0, unhexFunc        ),
-
    FUNCTION(concat,            -1, 0, 0, concatFunc       ),
-
    FUNCTION(concat,             0, 0, 0, 0                ),
-
    FUNCTION(concat_ws,         -1, 0, 0, concatwsFunc     ),
-
    FUNCTION(concat_ws,          0, 0, 0, 0                ),
-
    FUNCTION(concat_ws,          1, 0, 0, 0                ),
+
    FUNCTION(concat,            -3, 0, 0, concatFunc       ),
+
    FUNCTION(concat_ws,         -4, 0, 0, concatwsFunc     ),
    INLINE_FUNC(ifnull,          2, INLINEFUNC_coalesce, 0 ),
    VFUNCTION(random,            0, 0, 0, randomFunc       ),
    VFUNCTION(randomblob,        1, 0, 0, randomBlob       ),
@@ -132086,8 +132269,6 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
    FUNCTION(unknown,           -1, 0, 0, unknownFunc      ),
#endif
-
    FUNCTION(coalesce,           1, 0, 0, 0                ),
-
    FUNCTION(coalesce,           0, 0, 0, 0                ),
#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
    MFUNCTION(ceil,              1, xCeil,     ceilingFunc ),
    MFUNCTION(ceiling,           1, xCeil,     ceilingFunc ),
@@ -132125,8 +132306,9 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
    MFUNCTION(pi,                0, 0,         piFunc      ),
#endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
    FUNCTION(sign,               1, 0, 0,      signFunc    ),
-
    INLINE_FUNC(coalesce,       -1, INLINEFUNC_coalesce, 0 ),
-
    INLINE_FUNC(iif,             3, INLINEFUNC_iif,      0 ),
+
    INLINE_FUNC(coalesce,       -4, INLINEFUNC_coalesce, 0 ),
+
    INLINE_FUNC(iif,            -4, INLINEFUNC_iif,      0 ),
+
    INLINE_FUNC(if,             -4, INLINEFUNC_iif,      0 ),
  };
#ifndef SQLITE_OMIT_ALTERTABLE
  sqlite3AlterFunctions();
@@ -134572,6 +134754,7 @@ SQLITE_PRIVATE void sqlite3Insert(
  int regRowid;         /* registers holding insert rowid */
  int regData;          /* register holding first column to insert */
  int *aRegIdx = 0;     /* One register allocated to each index */
+
  int *aTabColMap = 0;  /* Mapping from pTab columns to pCol entries */

#ifndef SQLITE_OMIT_TRIGGER
  int isView;                 /* True if attempting to insert into a view */
@@ -134716,15 +134899,15 @@ SQLITE_PRIVATE void sqlite3Insert(
  */
  bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
  if( pColumn ){
-
    assert( pColumn->eU4!=EU4_EXPR );
-
    pColumn->eU4 = EU4_IDX;
-
    for(i=0; i<pColumn->nId; i++){
-
      pColumn->a[i].u4.idx = -1;
-
    }
+
    aTabColMap = sqlite3DbMallocZero(db, pTab->nCol*sizeof(int));
+
    if( aTabColMap==0 ) goto insert_cleanup;
    for(i=0; i<pColumn->nId; i++){
+
      const char *zCName = pColumn->a[i].zName;
+
      u8 hName = sqlite3StrIHash(zCName);
      for(j=0; j<pTab->nCol; j++){
-
        if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){
-
          pColumn->a[i].u4.idx = j;
+
        if( pTab->aCol[j].hName!=hName ) continue;
+
        if( sqlite3StrICmp(zCName, pTab->aCol[j].zCnName)==0 ){
+
          if( aTabColMap[j]==0 ) aTabColMap[j] = i+1;
          if( i!=j ) bIdListInOrder = 0;
          if( j==pTab->iPKey ){
            ipkColumn = i;  assert( !withoutRowid );
@@ -135046,9 +135229,9 @@ SQLITE_PRIVATE void sqlite3Insert(
      }
    }
    if( pColumn ){
-
      assert( pColumn->eU4==EU4_IDX );
-
      for(j=0; j<pColumn->nId && pColumn->a[j].u4.idx!=i; j++){}
-
      if( j>=pColumn->nId ){
+
      j = aTabColMap[i];
+
      assert( j>=0 && j<=pColumn->nId );
+
      if( j==0 ){
        /* A column not named in the insert column list gets its
        ** default value */
        sqlite3ExprCodeFactorable(pParse,
@@ -135056,7 +135239,7 @@ SQLITE_PRIVATE void sqlite3Insert(
            iRegStore);
        continue;
      }
-
      k = j;
+
      k = j - 1;
    }else if( nColumn==0 ){
      /* This is INSERT INTO ... DEFAULT VALUES.  Load the default value. */
      sqlite3ExprCodeFactorable(pParse,
@@ -135301,7 +135484,10 @@ insert_cleanup:
  sqlite3ExprListDelete(db, pList);
  sqlite3UpsertDelete(db, pUpsert);
  sqlite3SelectDelete(db, pSelect);
-
  sqlite3IdListDelete(db, pColumn);
+
  if( pColumn ){
+
    sqlite3IdListDelete(db, pColumn);
+
    sqlite3DbFree(db, aTabColMap);
+
  }
  if( aRegIdx ) sqlite3DbNNFreeNN(db, aRegIdx);
}

@@ -140639,12 +140825,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
        ** in auto-commit mode.  */
        mask &= ~(SQLITE_ForeignKeys);
      }
-
#if SQLITE_USER_AUTHENTICATION
-
      if( db->auth.authLevel==UAUTH_User ){
-
        /* Do not allow non-admin users to modify the schema arbitrarily */
-
        mask &= ~(SQLITE_WriteSchema);
-
      }
-
#endif

      if( sqlite3GetBoolean(zRight, 0) ){
        if( (mask & SQLITE_WriteSchema)==0
@@ -140780,7 +140960,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
            char *zSql = sqlite3MPrintf(db, "SELECT*FROM\"%w\"", pTab->zName);
            if( zSql ){
              sqlite3_stmt *pDummy = 0;
-
              (void)sqlite3_prepare(db, zSql, -1, &pDummy, 0);
+
              (void)sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_DONT_LOG,
+
                                       &pDummy, 0);
              (void)sqlite3_finalize(pDummy);
              sqlite3DbFree(db, zSql);
            }
@@ -141261,7 +141442,7 @@ SQLITE_PRIVATE void sqlite3Pragma(

      /* Do the b-tree integrity checks */
      sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
-
      sqlite3VdbeChangeP5(v, (u8)i);
+
      sqlite3VdbeChangeP5(v, (u16)i);
      addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
      sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
         sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
@@ -142881,14 +143062,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
#else
      encoding = SQLITE_UTF8;
#endif
-
      if( db->nVdbeActive>0 && encoding!=ENC(db)
-
       && (db->mDbFlags & DBFLAG_Vacuum)==0
-
      ){
-
        rc = SQLITE_LOCKED;
-
        goto initone_error_out;
-
      }else{
-
        sqlite3SetTextEncoding(db, encoding);
-
      }
+
      sqlite3SetTextEncoding(db, encoding);
    }else{
      /* If opening an attached database, the encoding much match ENC(db) */
      if( (meta[BTREE_TEXT_ENCODING-1] & 3)!=ENC(db) ){
@@ -147586,32 +147760,32 @@ static Expr *substExpr(
        if( pSubst->isOuterJoin ){
          ExprSetProperty(pNew, EP_CanBeNull);
        }
-
        if( ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) ){
-
          sqlite3SetJoinExpr(pNew, pExpr->w.iJoin,
-
                             pExpr->flags & (EP_OuterON|EP_InnerON));
-
        }
-
        sqlite3ExprDelete(db, pExpr);
-
        pExpr = pNew;
-
        if( pExpr->op==TK_TRUEFALSE ){
-
          pExpr->u.iValue = sqlite3ExprTruthValue(pExpr);
-
          pExpr->op = TK_INTEGER;
-
          ExprSetProperty(pExpr, EP_IntValue);
+
        if( pNew->op==TK_TRUEFALSE ){
+
          pNew->u.iValue = sqlite3ExprTruthValue(pNew);
+
          pNew->op = TK_INTEGER;
+
          ExprSetProperty(pNew, EP_IntValue);
        }

        /* Ensure that the expression now has an implicit collation sequence,
        ** just as it did when it was a column of a view or sub-query. */
        {
-
          CollSeq *pNat = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
+
          CollSeq *pNat = sqlite3ExprCollSeq(pSubst->pParse, pNew);
          CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse,
                pSubst->pCList->a[iColumn].pExpr
          );
-
          if( pNat!=pColl || (pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE) ){
-
            pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
+
          if( pNat!=pColl || (pNew->op!=TK_COLUMN && pNew->op!=TK_COLLATE) ){
+
            pNew = sqlite3ExprAddCollateString(pSubst->pParse, pNew,
                (pColl ? pColl->zName : "BINARY")
            );
          }
        }
-
        ExprClearProperty(pExpr, EP_Collate);
+
        ExprClearProperty(pNew, EP_Collate);
+
        if( ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) ){
+
          sqlite3SetJoinExpr(pNew, pExpr->w.iJoin,
+
                             pExpr->flags & (EP_OuterON|EP_InnerON));
+
        }
+
        sqlite3ExprDelete(db, pExpr);
+
        pExpr = pNew;
      }
    }
  }else{
@@ -148348,6 +148522,7 @@ static int flattenSubquery(
    /* Transfer the FROM clause terms from the subquery into the
    ** outer query.
    */
+
    iNewParent = pSubSrc->a[0].iCursor;
    for(i=0; i<nSubSrc; i++){
      SrcItem *pItem = &pSrc->a[i+iFrom];
      assert( pItem->fg.isTabFunc==0 );
@@ -148357,7 +148532,6 @@ static int flattenSubquery(
      if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing);
      *pItem = pSubSrc->a[i];
      pItem->fg.jointype |= ltorj;
-
      iNewParent = pSubSrc->a[i].iCursor;
      memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i]));
    }
    pSrc->a[iFrom].fg.jointype &= JT_LTORJ;
@@ -148397,6 +148571,7 @@ static int flattenSubquery(
    pWhere = pSub->pWhere;
    pSub->pWhere = 0;
    if( isOuterJoin>0 ){
+
      assert( pSubSrc->nSrc==1 );
      sqlite3SetJoinExpr(pWhere, iNewParent, EP_OuterON);
    }
    if( pWhere ){
@@ -150500,7 +150675,7 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){
      }
      sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
      sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
-
      sqlite3VdbeChangeP5(v, (u8)nArg);
+
      sqlite3VdbeChangeP5(v, (u16)nArg);
      sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v);
      sqlite3VdbeJumpHere(v, iTop);
      sqlite3ReleaseTempRange(pParse, regAgg, nArg);
@@ -150663,7 +150838,7 @@ static void updateAccumulator(
      }
      sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
      sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
-
      sqlite3VdbeChangeP5(v, (u8)nArg);
+
      sqlite3VdbeChangeP5(v, (u16)nArg);
      sqlite3ReleaseTempRange(pParse, regAgg, nArg);
    }
    if( addrNext ){
@@ -151496,7 +151671,7 @@ SQLITE_PRIVATE int sqlite3Select(
#endif
      assert( pSubq->pSelect && (pSub->selFlags & SF_PushDown)!=0 );
    }else{
-
      TREETRACE(0x4000,pParse,p,("WHERE-lcause push-down not possible\n"));
+
      TREETRACE(0x4000,pParse,p,("WHERE-clause push-down not possible\n"));
    }

    /* Convert unused result columns of the subquery into simple NULL
@@ -154057,7 +154232,7 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
    ** invocation is disallowed if (a) the sub-program is really a trigger,
    ** not a foreign key action, and (b) the flag to enable recursive triggers
    ** is clear.  */
-
    sqlite3VdbeChangeP5(v, (u8)bRecursive);
+
    sqlite3VdbeChangeP5(v, (u16)bRecursive);
  }
}

@@ -157168,7 +157343,9 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
  z = (const unsigned char*)zCreateTable;
  for(i=0; aKeyword[i]; i++){
    int tokenType = 0;
-
    do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
+
    do{
+
      z += sqlite3GetToken(z, &tokenType);
+
    }while( tokenType==TK_SPACE || tokenType==TK_COMMENT );
    if( tokenType!=aKeyword[i] ){
      sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
      return SQLITE_ERROR;
@@ -157899,8 +158076,10 @@ struct WhereLoop {
  /**** whereLoopXfer() copies fields above ***********************/
# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
  u16 nLSlot;           /* Number of slots allocated for aLTerm[] */
+
#ifdef WHERETRACE_ENABLED
  LogEst rStarDelta;    /* Cost delta due to star-schema heuristic.  Not
-
                        ** initialized unless pWInfo->nOutStarDelta>0 */
+
                        ** initialized unless pWInfo->bStarUsed */
+
#endif
  WhereTerm **aLTerm;   /* WhereTerms used */
  WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
  WhereTerm *aLTermSpace[3];  /* Initial aLTerm[] space */
@@ -157949,7 +158128,7 @@ struct WherePath {
  Bitmask revLoop;      /* aLoop[]s that should be reversed for ORDER BY */
  LogEst nRow;          /* Estimated number of rows generated by this path */
  LogEst rCost;         /* Total cost of this path */
-
  LogEst rUnsorted;     /* Total cost of this path ignoring sorting costs */
+
  LogEst rUnsort;       /* Total cost of this path ignoring sorting costs */
  i8 isOrdered;         /* No. of ORDER BY terms satisfied. -1 for unknown */
  WhereLoop **aLoop;    /* Array of WhereLoop objects implementing this path */
};
@@ -158222,9 +158401,13 @@ struct WhereInfo {
  unsigned bDeferredSeek :1;   /* Uses OP_DeferredSeek */
  unsigned untestedTerms :1;   /* Not all WHERE terms resolved by outer loop */
  unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */
-
  unsigned sorted :1;          /* True if really sorted (not just grouped) */
-
  LogEst nOutStarDelta;     /* Artifical nOut reduction for star-query */
+
  unsigned sorted        :1;   /* True if really sorted (not just grouped) */
+
  unsigned bStarDone     :1;   /* True if check for star-query is complete */
+
  unsigned bStarUsed     :1;   /* True if star-query heuristic is used */
  LogEst nRowOut;           /* Estimated number of output rows */
+
#ifdef WHERETRACE_ENABLED
+
  LogEst rTotalCost;        /* Total cost of the solution */
+
#endif
  int iTop;                 /* The very beginning of the WHERE loop */
  int iEndWhere;            /* End of the WHERE clause itself */
  WhereLoop *pLoops;        /* List of all WhereLoop objects */
@@ -158270,9 +158453,17 @@ SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
  const WhereInfo *pWInfo,        /* WHERE clause */
  const WhereLevel *pLevel        /* Bloom filter on this level */
);
+
SQLITE_PRIVATE void sqlite3WhereAddExplainText(
+
  Parse *pParse,                  /* Parse context */
+
  int addr,
+
  SrcList *pTabList,              /* Table list this loop refers to */
+
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
+
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
+
);
#else
# define sqlite3WhereExplainOneScan(u,v,w,x) 0
# define sqlite3WhereExplainBloomFilter(u,v,w) 0
+
# define  sqlite3WhereAddExplainText(u,v,w,x,y)
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
@@ -158474,38 +158665,38 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop){
}

/*
-
** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
-
** command, or if stmt_scanstatus_v2() stats are enabled, or if SQLITE_DEBUG
-
** was defined at compile-time. If it is not a no-op, a single OP_Explain
-
** opcode is added to the output to describe the table scan strategy in pLevel.
-
**
-
** If an OP_Explain opcode is added to the VM, its address is returned.
-
** Otherwise, if no OP_Explain is coded, zero is returned.
+
** This function sets the P4 value of an existing OP_Explain opcode to
+
** text describing the loop in pLevel. If the OP_Explain opcode already has
+
** a P4 value, it is freed before it is overwritten.
*/
-
SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
+
SQLITE_PRIVATE void sqlite3WhereAddExplainText(
  Parse *pParse,                  /* Parse context */
+
  int addr,                       /* Address of OP_Explain opcode */
  SrcList *pTabList,              /* Table list this loop refers to */
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
){
-
  int ret = 0;
#if !defined(SQLITE_DEBUG)
  if( sqlite3ParseToplevel(pParse)->explain==2 || IS_STMT_SCANSTATUS(pParse->db) )
#endif
  {
+
    VdbeOp *pOp = sqlite3VdbeGetOp(pParse->pVdbe, addr);
+

    SrcItem *pItem = &pTabList->a[pLevel->iFrom];
-
    Vdbe *v = pParse->pVdbe;      /* VM being constructed */
    sqlite3 *db = pParse->db;     /* Database handle */
    int isSearch;                 /* True for a SEARCH. False for SCAN. */
    WhereLoop *pLoop;             /* The controlling WhereLoop object */
    u32 flags;                    /* Flags that describe this loop */
+
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
    char *zMsg;                   /* Text to add to EQP output */
+
#endif
    StrAccum str;                 /* EQP output string */
    char zBuf[100];               /* Initial space for EQP output string */

+
    if( db->mallocFailed ) return;
+

    pLoop = pLevel->pWLoop;
    flags = pLoop->wsFlags;
-
    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0;

    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
@@ -158529,7 +158720,7 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
        zFmt = "AUTOMATIC PARTIAL COVERING INDEX";
      }else if( flags & WHERE_AUTO_INDEX ){
        zFmt = "AUTOMATIC COVERING INDEX";
-
      }else if( flags & WHERE_IDX_ONLY ){
+
      }else if( flags & (WHERE_IDX_ONLY|WHERE_EXPRIDX) ){
        zFmt = "COVERING INDEX %s";
      }else{
        zFmt = "INDEX %s";
@@ -158581,11 +158772,50 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
      sqlite3_str_append(&str, " (~1 row)", 9);
    }
#endif
+
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
    zMsg = sqlite3StrAccumFinish(&str);
    sqlite3ExplainBreakpoint("",zMsg);
-
    ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
-
                            pParse->addrExplain, pLoop->rRun,
-
                            zMsg, P4_DYNAMIC);
+
#endif
+

+
    assert( pOp->opcode==OP_Explain );
+
    assert( pOp->p4type==P4_DYNAMIC || pOp->p4.z==0 );
+
    sqlite3DbFree(db, pOp->p4.z);
+
    pOp->p4type = P4_DYNAMIC;
+
    pOp->p4.z = sqlite3StrAccumFinish(&str);
+
  }
+
}
+

+

+
/*
+
** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
+
** command, or if stmt_scanstatus_v2() stats are enabled, or if SQLITE_DEBUG
+
** was defined at compile-time. If it is not a no-op, a single OP_Explain
+
** opcode is added to the output to describe the table scan strategy in pLevel.
+
**
+
** If an OP_Explain opcode is added to the VM, its address is returned.
+
** Otherwise, if no OP_Explain is coded, zero is returned.
+
*/
+
SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
+
  Parse *pParse,                  /* Parse context */
+
  SrcList *pTabList,              /* Table list this loop refers to */
+
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
+
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
+
){
+
  int ret = 0;
+
#if !defined(SQLITE_DEBUG)
+
  if( sqlite3ParseToplevel(pParse)->explain==2 || IS_STMT_SCANSTATUS(pParse->db) )
+
#endif
+
  {
+
    if( (pLevel->pWLoop->wsFlags & WHERE_MULTI_OR)==0
+
     && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0
+
    ){
+
      Vdbe *v = pParse->pVdbe;
+
      int addr = sqlite3VdbeCurrentAddr(v);
+
      ret = sqlite3VdbeAddOp3(
+
          v, OP_Explain, addr, pParse->addrExplain, pLevel->pWLoop->rRun
+
      );
+
      sqlite3WhereAddExplainText(pParse, addr, pTabList, pLevel, wctrlFlags);
+
    }
  }
  return ret;
}
@@ -158684,9 +158914,10 @@ SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
      }
    }else{
      int addr;
+
      VdbeOp *pOp;
      assert( pSrclist->a[pLvl->iFrom].fg.isSubquery );
      addr = pSrclist->a[pLvl->iFrom].u4.pSubq->addrFillSub;
-
      VdbeOp *pOp = sqlite3VdbeGetOp(v, addr-1);
+
      pOp = sqlite3VdbeGetOp(v, addr-1);
      assert( sqlite3VdbeDb(v)->mallocFailed || pOp->opcode==OP_InitCoroutine );
      assert( sqlite3VdbeDb(v)->mallocFailed || pOp->p2>addr );
      sqlite3VdbeScanStatusRange(v, addrExplain, addr, pOp->p2-1);
@@ -158939,6 +159170,7 @@ static Expr *removeUnindexableInClauseTerms(
        pNew->pLeft->x.pList = pLhs;
      }
      pSelect->pEList = pRhs;
+
      pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */
      if( pLhs && pLhs->nExpr==1 ){
        /* Take care here not to generate a TK_VECTOR containing only a
        ** single value. Since the parser never creates such a vector, some
@@ -161486,12 +161718,12 @@ static int isLikeOrGlob(
     z = (u8*)pRight->u.zToken;
  }
  if( z ){
-
    /* Count the number of prefix bytes prior to the first wildcard.
-
    ** or U+fffd character.  If the underlying database has a UTF16LE
-
    ** encoding, then only consider ASCII characters.  Note that the
-
    ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in
-
    ** this code, but the database engine itself might be processing
-
    ** content using a different encoding. */
+
    /* Count the number of prefix bytes prior to the first wildcard,
+
    ** U+fffd character, or malformed utf-8. If the underlying database
+
    ** has a UTF16LE encoding, then only consider ASCII characters.  Note that
+
    ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this
+
    ** code, but the database engine itself might be processing content using a
+
    ** different encoding. */
    cnt = 0;
    while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
      cnt++;
@@ -161499,7 +161731,9 @@ static int isLikeOrGlob(
        cnt++;
      }else if( c>=0x80 ){
        const u8 *z2 = z+cnt-1;
-
        if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){
+
        if( c==0xff || sqlite3Utf8Read(&z2)==0xfffd  /* bad utf-8 */
+
         || ENC(db)==SQLITE_UTF16LE
+
        ){
          cnt--;
          break;
        }else{
@@ -162651,9 +162885,8 @@ static void exprAnalyze(
    }

    if( !db->mallocFailed ){
-
      u8 c, *pC;       /* Last character before the first wildcard */
+
      u8 *pC;       /* Last character before the first wildcard */
      pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
-
      c = *pC;
      if( noCase ){
        /* The point is to increment the last character before the first
        ** wildcard.  But if we increment '@', that will push it into the
@@ -162661,10 +162894,17 @@ static void exprAnalyze(
        ** inequality.  To avoid this, make sure to also run the full
        ** LIKE on all candidate expressions by clearing the isComplete flag
        */
-
        if( c=='A'-1 ) isComplete = 0;
-
        c = sqlite3UpperToLower[c];
+
        if( *pC=='A'-1 ) isComplete = 0;
+
        *pC = sqlite3UpperToLower[*pC];
      }
-
      *pC = c + 1;
+

+
      /* Increment the value of the last utf8 character in the prefix. */
+
      while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){
+
        *pC = 0x80;
+
        pC--;
+
      }
+
      assert( *pC!=0xFF );        /* isLikeOrGlob() guarantees this */
+
      (*pC)++;
    }
    zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
    pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
@@ -164011,7 +164251,7 @@ static int constraintCompatibleWithOuterJoin(
    return 0;
  }
  if( (pSrc->fg.jointype & (JT_LEFT|JT_RIGHT))!=0
-
   && ExprHasProperty(pTerm->pExpr, EP_InnerON)
+
   && NEVER(ExprHasProperty(pTerm->pExpr, EP_InnerON))
  ){
    return 0;
  }
@@ -164032,6 +164272,11 @@ static int constraintCompatibleWithOuterJoin(
**        more than 20, then return false.
**
**   3.   If no disqualifying conditions above are found, return true.
+
**
+
** 2025-01-03: I experimented with a new rule that returns false if the
+
** the datatype of the column is "BOOLEAN". This did not improve
+
** performance on any queries at hand, but it did burn CPU cycles, so the
+
** idea was not committed.
*/
static SQLITE_NOINLINE int columnIsGoodIndexCandidate(
  const Table *pTab,
@@ -164116,7 +164361,7 @@ static void explainAutomaticIndex(
    sqlite3_str *pStr = sqlite3_str_new(pParse->db);
    sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName);
    assert( pIdx->nColumn>1 );
-
    assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID );
+
    assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID || !HasRowid(pTab) );
    for(ii=0; ii<(pIdx->nColumn-1); ii++){
      const char *zName = 0;
      int iCol = pIdx->aiColumn[ii];
@@ -164247,6 +164492,19 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
  }else{
    extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
  }
+
  if( !HasRowid(pTable) ){
+
    /* For WITHOUT ROWID tables, ensure that all PRIMARY KEY columns are
+
    ** either in the idxCols mask or in the extraCols mask */
+
    for(i=0; i<pTable->nCol; i++){
+
      if( (pTable->aCol[i].colFlags & COLFLAG_PRIMKEY)==0 ) continue;
+
      if( i>=BMS-1 ){
+
        extraCols |= MASKBIT(BMS-1);
+
        break;
+
      }
+
      if( idxCols & MASKBIT(i) ) continue;
+
      extraCols |= MASKBIT(i);
+
    }
+
  }
  mxBitCol = MIN(BMS-1,pTable->nCol);
  testcase( pTable->nCol==BMS-1 );
  testcase( pTable->nCol==BMS-2 );
@@ -164258,7 +164516,8 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
  }

  /* Construct the Index object to describe this index */
-
  pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
+
  pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+HasRowid(pTable),
+
                                    0, &zNotUsed);
  if( pIdx==0 ) goto end_auto_index_create;
  pLoop->u.btree.pIndex = pIdx;
  pIdx->zName = "auto-index";
@@ -164314,8 +164573,10 @@ static SQLITE_NOINLINE void constructAutomaticIndex(
    }
  }
  assert( n==nKeyCol );
-
  pIdx->aiColumn[n] = XN_ROWID;
-
  pIdx->azColl[n] = sqlite3StrBINARY;
+
  if( HasRowid(pTable) ){
+
    pIdx->aiColumn[n] = XN_ROWID;
+
    pIdx->azColl[n] = sqlite3StrBINARY;
+
  }

  /* Create the automatic index */
  explainAutomaticIndex(pParse, pIdx, pPartial!=0, &addrExp);
@@ -165504,7 +165765,7 @@ static int whereInScanEst(
#endif /* SQLITE_ENABLE_STAT4 */


-
#ifdef WHERETRACE_ENABLED
+
#if defined(WHERETRACE_ENABLED) || defined(SQLITE_DEBUG)
/*
** Print the content of a WhereTerm object
*/
@@ -165548,6 +165809,9 @@ SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){
    sqlite3TreeViewExpr(0, pTerm->pExpr, 0);
  }
}
+
SQLITE_PRIVATE void sqlite3ShowWhereTerm(WhereTerm *pTerm){
+
  sqlite3WhereTermPrint(pTerm, 0);
+
}
#endif

#ifdef WHERETRACE_ENABLED
@@ -165579,8 +165843,9 @@ SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){
**     1.002.001         t2.t2xy              2 f 010241 N 2 cost 0,56,31
*/
SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
+
  WhereInfo *pWInfo;
  if( pWC ){
-
    WhereInfo *pWInfo = pWC->pWInfo;
+
    pWInfo = pWC->pWInfo;
    int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
    SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
    Table *pTab = pItem->pSTab;
@@ -165590,6 +165855,7 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause
    sqlite3DebugPrintf(" %12s",
                       pItem->zAlias ? pItem->zAlias : pTab->zName);
  }else{
+
    pWInfo = 0;
    sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d",
         p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab);
  }
@@ -165621,7 +165887,12 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause
  }else{
    sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
  }
-
  sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
+
  if( pWInfo && pWInfo->bStarUsed && p->rStarDelta!=0 ){
+
    sqlite3DebugPrintf(" cost %d,%d,%d delta=%d\n",
+
                       p->rSetup, p->rRun, p->nOut, p->rStarDelta);
+
  }else{
+
    sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
+
  }
  if( p->nLTerm && (sqlite3WhereTrace & 0x4000)!=0 ){
    int i;
    for(i=0; i<p->nLTerm; i++){
@@ -166733,7 +167004,6 @@ static int whereUsablePartialIndex(
    if( !whereUsablePartialIndex(iTab,jointype,pWC,pWhere->pLeft) ) return 0;
    pWhere = pWhere->pRight;
  }
-
  if( pParse->db->flags & SQLITE_EnableQPSG ) pParse = 0;
  for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
    Expr *pExpr;
    pExpr = pTerm->pExpr;
@@ -167088,7 +167358,6 @@ static int whereLoopAddBtree(
   && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
   && !pSrc->fg.isIndexedBy  /* Has no INDEXED BY clause */
   && !pSrc->fg.notIndexed   /* Has no NOT INDEXED clause */
-
   && HasRowid(pTab)         /* Not WITHOUT ROWID table. (FIXME: Why not?) */
   && !pSrc->fg.isCorrelated /* Not a correlated subquery */
   && !pSrc->fg.isRecursive  /* Not a recursive common table expression. */
   && (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */
@@ -168591,68 +168860,201 @@ static LogEst whereSortingCost(
**     18    for star queries
**     12    otherwise
**
-
** For the purposes of SQLite, a star-query is defined as a query
-
** with a large central table that is joined against four or more
-
** smaller tables.  The central table is called the "fact" table.
-
** The smaller tables that get joined are "dimension tables".
+
** For the purposes of this heuristic, a star-query is defined as a query
+
** with a large central table that is joined using an INNER JOIN,
+
** not CROSS or OUTER JOINs, against four or more smaller tables.
+
** The central table is called the "fact" table.  The smaller tables
+
** that get joined are "dimension tables".  Also, any table that is
+
** self-joined cannot be a dimension table; we assume that dimension
+
** tables may only be joined against fact tables.
**
** SIDE EFFECT:  (and really the whole point of this subroutine)
**
-
** If pWInfo describes a star-query, then the cost on WhereLoops for the
-
** fact table is reduced.  This heuristic helps keep fact tables in
-
** outer loops.  Without this heuristic, paths with fact tables in outer
-
** loops tend to get pruned by the mxChoice limit on the number of paths,
-
** resulting in poor query plans.  The total amount of heuristic cost
-
** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment
-
** for each WhereLoop is stored in its rStarDelta field.
+
** If pWInfo describes a star-query, then the cost for SCANs of dimension
+
** WhereLoops is increased to be slightly larger than the cost of a SCAN
+
** in the fact table.  Only SCAN costs are increased.  SEARCH costs are
+
** unchanged. This heuristic helps keep fact tables in outer loops. Without
+
** this heuristic, paths with fact tables in outer loops tend to get pruned
+
** by the mxChoice limit on the number of paths, resulting in poor query
+
** plans.  See the starschema1.test test module for examples of queries
+
** that need this heuristic to find good query plans.
+
**
+
** This heuristic can be completely disabled, so that no query is
+
** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to
+
** disable the SQLITE_StarQuery optimization.  In the CLI, the command
+
** to do that is:  ".testctrl opt -starquery".
+
**
+
** HISTORICAL NOTES:
+
**
+
** This optimization was first added on 2024-05-09 by check-in 38db9b5c83d.
+
** The original optimization reduced the cost and output size estimate for
+
** fact tables to help them move to outer loops.  But months later (as people
+
** started upgrading) performance regression reports started caming in,
+
** including:
+
**
+
**    forum post b18ef983e68d06d1 (2024-12-21)
+
**    forum post 0025389d0860af82 (2025-01-14)
+
**    forum post d87570a145599033 (2025-01-17)
+
**
+
** To address these, the criteria for a star-query was tightened to exclude
+
** cases where the fact and dimensions are separated by an outer join, and
+
** the affect of star-schema detection was changed to increase the rRun cost
+
** on just full table scans of dimension tables, rather than reducing costs
+
** in the all access methods of the fact table.
*/
-
static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
+
static int computeMxChoice(WhereInfo *pWInfo){
  int nLoop = pWInfo->nLevel;    /* Number of terms in the join */
-
  if( nRowEst==0 && nLoop>=5 ){
-
    /* Check to see if we are dealing with a star schema and if so, reduce
-
    ** the cost of fact tables relative to dimension tables, as a heuristic
-
    ** to help keep the fact tables in outer loops.
+
  WhereLoop *pWLoop;             /* For looping over WhereLoops */
+

+
#ifdef SQLITE_DEBUG
+
  /* The star-query detection code below makes use of the following
+
  ** properties of the WhereLoop list, so verify them before
+
  ** continuing:
+
  **    (1)  .maskSelf is the bitmask corresponding to .iTab
+
  **    (2)  The WhereLoop list is in ascending .iTab order
+
  */
+
  for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
+
    assert( pWLoop->maskSelf==MASKBIT(pWLoop->iTab) );
+
    assert( pWLoop->pNextLoop==0 || pWLoop->iTab<=pWLoop->pNextLoop->iTab );
+
  }
+
#endif /* SQLITE_DEBUG */
+

+
  if( nLoop>=5
+
   && !pWInfo->bStarDone
+
   && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery)
+
  ){
+
    SrcItem *aFromTabs;    /* All terms of the FROM clause */
+
    int iFromIdx;          /* Term of FROM clause is the candidate fact-table */
+
    Bitmask m;             /* Bitmask for candidate fact-table */
+
    Bitmask mSelfJoin = 0; /* Tables that cannot be dimension tables */
+
    WhereLoop *pStart;     /* Where to start searching for dimension-tables */
+

+
    pWInfo->bStarDone = 1; /* Only do this computation once */
+

+
    /* Look for fact tables with four or more dimensions where the
+
    ** dimension tables are not separately from the fact tables by an outer
+
    ** or cross join.  Adjust cost weights if found.
    */
-
    int iLoop;                /* Counter over join terms */
-
    Bitmask m;                /* Bitmask for current loop */
-
    assert( pWInfo->nOutStarDelta==0 );
-
    for(iLoop=0, m=1; iLoop<nLoop; iLoop++, m<<=1){
-
      WhereLoop *pWLoop;        /* For looping over WhereLoops */
+
    assert( !pWInfo->bStarUsed );
+
    aFromTabs = pWInfo->pTabList->a;
+
    pStart = pWInfo->pLoops;
+
    for(iFromIdx=0, m=1; iFromIdx<nLoop; iFromIdx++, m<<=1){
      int nDep = 0;             /* Number of dimension tables */
-
      LogEst rDelta;            /* Heuristic cost adjustment */
+
      LogEst mxRun;             /* Maximum SCAN cost of a fact table */
      Bitmask mSeen = 0;        /* Mask of dimension tables */
-
      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
-
        if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){
-
          nDep++;
-
          mSeen |= pWLoop->maskSelf;
+
      SrcItem *pFactTab;        /* The candidate fact table */
+

+
      pFactTab = aFromTabs + iFromIdx;
+
      if( (pFactTab->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
+
        /* If the candidate fact-table is the right table of an outer join
+
        ** restrict the search for dimension-tables to be tables to the right
+
        ** of the fact-table. */
+
        if( iFromIdx+4 > nLoop ) break;  /* Impossible to reach nDep>=4 */
+
        while( pStart && pStart->iTab<=iFromIdx ){
+
          pStart = pStart->pNextLoop;
+
        }
+
      }
+
      for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
+
        if( (aFromTabs[pWLoop->iTab].fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
+
          /* Fact-tables and dimension-tables cannot be separated by an
+
          ** outer join (at least for the definition of fact- and dimension-
+
          ** used by this heuristic). */
+
          break;
+
        }
+
        if( (pWLoop->prereq & m)!=0        /* pWInfo depends on iFromIdx */
+
         && (pWLoop->maskSelf & mSeen)==0  /* pWInfo not already a dependency */
+
         && (pWLoop->maskSelf & mSelfJoin)==0 /* Not a self-join */
+
        ){
+
          if( aFromTabs[pWLoop->iTab].pSTab==pFactTab->pSTab ){
+
            mSelfJoin |= m;
+
          }else{
+
            nDep++;
+
            mSeen |= pWLoop->maskSelf;
+
          }
        }
      }
      if( nDep<=3 ) continue;
-
      rDelta = 15*(nDep-3);
-
#ifdef WHERETRACE_ENABLED /* 0x4 */
-
      if( sqlite3WhereTrace&0x4 ){
-
         SrcItem *pItem = pWInfo->pTabList->a + iLoop;
-
         sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n",
-
             pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName,
-
             nDep, rDelta);
-
      }
-
#endif
-
      if( pWInfo->nOutStarDelta==0 ){
+

+
      /* If we reach this point, it means that pFactTab is a fact table
+
      ** with four or more dimensions connected by inner joins.  Proceed
+
      ** to make cost adjustments. */
+

+
#ifdef WHERETRACE_ENABLED
+
      /* Make sure rStarDelta values are initialized */
+
      if( !pWInfo->bStarUsed ){
        for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
          pWLoop->rStarDelta = 0;
        }
      }
-
      pWInfo->nOutStarDelta += rDelta;
+
#endif
+
      pWInfo->bStarUsed = 1;
+

+
      /* Compute the maximum cost of any WhereLoop for the
+
      ** fact table plus one epsilon */
+
      mxRun = LOGEST_MIN;
+
      for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
+
        if( pWLoop->iTab<iFromIdx ) continue;
+
        if( pWLoop->iTab>iFromIdx ) break;
+
        if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun;
+
      }
+
      if( ALWAYS(mxRun<LOGEST_MAX) ) mxRun++;
+

+
      /* Increase the cost of table scans for dimension tables to be
+
      ** slightly more than the maximum cost of the fact table */
+
      for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
+
        if( (pWLoop->maskSelf & mSeen)==0 ) continue;
+
        if( pWLoop->nLTerm ) continue;
+
        if( pWLoop->rRun<mxRun ){
+
#ifdef WHERETRACE_ENABLED /* 0x80000 */
+
          if( sqlite3WhereTrace & 0x80000 ){
+
            SrcItem *pDim = aFromTabs + pWLoop->iTab;
+
            sqlite3DebugPrintf(
+
              "Increase SCAN cost of dimension %s(%d) of fact %s(%d) to %d\n",
+
              pDim->zAlias ? pDim->zAlias: pDim->pSTab->zName, pWLoop->iTab,
+
              pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName,
+
              iFromIdx, mxRun
+
            );
+
          }
+
          pWLoop->rStarDelta = mxRun - pWLoop->rRun;
+
#endif /* WHERETRACE_ENABLED */
+
          pWLoop->rRun = mxRun;
+
        }
+
      }
+
    }
+
#ifdef WHERETRACE_ENABLED /* 0x80000 */
+
    if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->bStarUsed ){
+
      sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n");
      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
-
        if( pWLoop->maskSelf==m ){
-
          pWLoop->rRun -= rDelta;
-
          pWLoop->nOut -= rDelta;
-
          pWLoop->rStarDelta = rDelta;
+
        if( pWLoop->rStarDelta ){
+
          sqlite3WhereLoopPrint(pWLoop, &pWInfo->sWC);
        }
      }
    }
+
#endif
  }
-
  return pWInfo->nOutStarDelta>0 ? 18 : 12;
+
  return pWInfo->bStarUsed ? 18 : 12;
+
}
+

+
/*
+
** Two WhereLoop objects, pCandidate and pBaseline, are known to have the
+
** same cost.  Look deep into each to see if pCandidate is even slightly
+
** better than pBaseline.  Return false if it is, if pCandidate is is preferred.
+
** Return true if pBaseline is preferred or if we cannot tell the difference.
+
**
+
**    Result       Meaning
+
**    --------     ----------------------------------------------------------
+
**    true         We cannot tell the difference in pCandidate and pBaseline
+
**    false        pCandidate seems like a better choice than pBaseline
+
*/
+
static SQLITE_NOINLINE int whereLoopIsNoBetter(
+
  const WhereLoop *pCandidate,
+
  const WhereLoop *pBaseline
+
){
+
  if( (pCandidate->wsFlags & WHERE_INDEXED)==0 ) return 1;
+
  if( (pBaseline->wsFlags & WHERE_INDEXED)==0 ) return 1;
+
  if( pCandidate->u.btree.pIndex->szIdxRow <
+
        pBaseline->u.btree.pIndex->szIdxRow ) return 0;
+
  return 1;
}

/*
@@ -168676,7 +169078,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
  int mxI = 0;              /* Index of next entry to replace */
  int nOrderBy;             /* Number of ORDER BY clause terms */
  LogEst mxCost = 0;        /* Maximum cost of a set of paths */
-
  LogEst mxUnsorted = 0;    /* Maximum unsorted cost of a set of path */
+
  LogEst mxUnsort = 0;      /* Maximum unsorted cost of a set of path */
  int nTo, nFrom;           /* Number of valid entries in aTo[] and aFrom[] */
  WherePath *aFrom;         /* All nFrom paths at the previous level */
  WherePath *aTo;           /* The nTo best paths at the current level */
@@ -168705,8 +169107,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
    mxChoice = 1;
  }else if( nLoop==2 ){
    mxChoice = 5;
+
  }else if( pParse->nErr ){
+
    mxChoice = 1;
  }else{
-
    mxChoice = computeMxChoice(pWInfo, nRowEst);
+
    mxChoice = computeMxChoice(pWInfo);
  }
  assert( nLoop<=pWInfo->pTabList->nSrc );

@@ -168773,7 +169177,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
      for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
        LogEst nOut;                      /* Rows visited by (pFrom+pWLoop) */
        LogEst rCost;                     /* Cost of path (pFrom+pWLoop) */
-
        LogEst rUnsorted;                 /* Unsorted cost of (pFrom+pWLoop) */
+
        LogEst rUnsort;                   /* Unsorted cost of (pFrom+pWLoop) */
        i8 isOrdered;                     /* isOrdered for (pFrom+pWLoop) */
        Bitmask maskNew;                  /* Mask of src visited by (..) */
        Bitmask revMask;                  /* Mask of rev-order loops for (..) */
@@ -168791,11 +169195,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){

        /* At this point, pWLoop is a candidate to be the next loop.
        ** Compute its cost */
-
        rUnsorted = pWLoop->rRun + pFrom->nRow;
+
        rUnsort = pWLoop->rRun + pFrom->nRow;
        if( pWLoop->rSetup ){
-
          rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted);
+
          rUnsort = sqlite3LogEstAdd(pWLoop->rSetup, rUnsort);
        }
-
        rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);
+
        rUnsort = sqlite3LogEstAdd(rUnsort, pFrom->rUnsort);
        nOut = pFrom->nRow + pWLoop->nOut;
        maskNew = pFrom->maskLoop | pWLoop->maskSelf;
        isOrdered = pFrom->isOrdered;
@@ -168817,15 +169221,15 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
          ** extra encouragement to the query planner to select a plan
          ** where the rows emerge in the correct order without any sorting
          ** required. */
-
          rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 3;
+
          rCost = sqlite3LogEstAdd(rUnsort, aSortCost[isOrdered]) + 3;

          WHERETRACE(0x002,
              ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
               aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
-
               rUnsorted, rCost));
+
               rUnsort, rCost));
        }else{
-
          rCost = rUnsorted;
-
          rUnsorted -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */
+
          rCost = rUnsort;
+
          rUnsort -= 2;  /* TUNING:  Slight bias in favor of no-sort plans */
        }

        /* Check to see if pWLoop should be added to the set of
@@ -168851,7 +169255,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
        if( jj>=nTo ){
          /* None of the existing best-so-far paths match the candidate. */
          if( nTo>=mxChoice
-
           && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))
+
           && (rCost>mxCost || (rCost==mxCost && rUnsort>=mxUnsort))
          ){
            /* The current candidate is no better than any of the mxChoice
            ** paths currently in the best-so-far buffer.  So discard
@@ -168859,7 +169263,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf("Skip   %s cost=%-3d,%3d,%3d order=%c\n",
-
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
+
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
                  isOrdered>=0 ? isOrdered+'0' : '?');
            }
#endif
@@ -168878,7 +169282,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
#ifdef WHERETRACE_ENABLED /* 0x4 */
          if( sqlite3WhereTrace&0x4 ){
            sqlite3DebugPrintf("New    %s cost=%-3d,%3d,%3d order=%c\n",
-
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
+
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
                isOrdered>=0 ? isOrdered+'0' : '?');
          }
#endif
@@ -168889,24 +169293,23 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
          ** pTo or if the candidate should be skipped.
          **
          ** The conditional is an expanded vector comparison equivalent to:
-
          **   (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
+
          **   (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort)
          */
-
          if( pTo->rCost<rCost
-
           || (pTo->rCost==rCost
-
               && (pTo->nRow<nOut
-
                   || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
-
                  )
-
              )
+
          if( (pTo->rCost<rCost)
+
           || (pTo->rCost==rCost && pTo->nRow<nOut)
+
           || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort<rUnsort)
+
           || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort==rUnsort
+
                  && whereLoopIsNoBetter(pWLoop, pTo->aLoop[iLoop]) )
          ){
#ifdef WHERETRACE_ENABLED /* 0x4 */
            if( sqlite3WhereTrace&0x4 ){
              sqlite3DebugPrintf(
                  "Skip   %s cost=%-3d,%3d,%3d order=%c",
-
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
+
                  wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
                  isOrdered>=0 ? isOrdered+'0' : '?');
              sqlite3DebugPrintf("   vs %s cost=%-3d,%3d,%3d order=%c\n",
                  wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
-
                  pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
+
                  pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
            }
#endif
            /* Discard the candidate path from further consideration */
@@ -168920,11 +169323,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
          if( sqlite3WhereTrace&0x4 ){
            sqlite3DebugPrintf(
                "Update %s cost=%-3d,%3d,%3d order=%c",
-
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
+
                wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
                isOrdered>=0 ? isOrdered+'0' : '?');
            sqlite3DebugPrintf("  was %s cost=%-3d,%3d,%3d order=%c\n",
                wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
-
                pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
+
                pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
          }
#endif
        }
@@ -168933,20 +169336,20 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
        pTo->revLoop = revMask;
        pTo->nRow = nOut;
        pTo->rCost = rCost;
-
        pTo->rUnsorted = rUnsorted;
+
        pTo->rUnsort = rUnsort;
        pTo->isOrdered = isOrdered;
        memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
        pTo->aLoop[iLoop] = pWLoop;
        if( nTo>=mxChoice ){
          mxI = 0;
          mxCost = aTo[0].rCost;
-
          mxUnsorted = aTo[0].nRow;
+
          mxUnsort = aTo[0].nRow;
          for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
            if( pTo->rCost>mxCost
-
             || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted)
+
             || (pTo->rCost==mxCost && pTo->rUnsort>mxUnsort)
            ){
              mxCost = pTo->rCost;
-
              mxUnsorted = pTo->rUnsorted;
+
              mxUnsort = pTo->rUnsort;
              mxI = jj;
            }
          }
@@ -168958,8 +169361,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
    if( sqlite3WhereTrace & 0x02 ){
      LogEst rMin, rFloor = 0;
      int nDone = 0;
+
      int nProgress;
      sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
-
      while( nDone<nTo ){
+
      do{
+
        nProgress = 0;
        rMin = 0x7fff;
        for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
          if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost;
@@ -168975,10 +169380,11 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
              sqlite3DebugPrintf("\n");
            }
            nDone++;
+
            nProgress++;
          }
        }
        rFloor = rMin;
-
      }
+
      }while( nDone<nTo && nProgress>0 );
    }
#endif

@@ -169072,7 +169478,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
    }
  }

-
  pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta;
+
  pWInfo->nRowOut = pFrom->nRow;
+
#ifdef WHERETRACE_ENABLED
+
  pWInfo->rTotalCost = pFrom->rCost;
+
#endif

  /* Free temporary memory and return success */
  sqlite3StackFreeNN(pParse->db, pSpace);
@@ -169394,7 +169803,7 @@ static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
      }
      if( hasRightJoin
       && ExprHasProperty(pTerm->pExpr, EP_InnerON)
-
       && pTerm->pExpr->w.iJoin==pItem->iCursor
+
       && NEVER(pTerm->pExpr->w.iJoin==pItem->iCursor)
      ){
        break;  /* restriction (5) */
      }
@@ -169470,7 +169879,6 @@ static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
      }
    }
    nSearch += pLoop->nOut;
-
    if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta;
  }
}

@@ -169953,7 +170361,8 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
  assert( db->mallocFailed==0 );
#ifdef WHERETRACE_ENABLED
  if( sqlite3WhereTrace ){
-
    sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
+
    sqlite3DebugPrintf("---- Solution cost=%d, nRow=%d",
+
                       pWInfo->rTotalCost, pWInfo->nRowOut);
    if( pWInfo->nOBSat>0 ){
      sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
    }
@@ -170314,6 +170723,7 @@ whereBeginError:
  ){
    if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
    sqlite3VdbePrintOp(0, pc, pOp);
+
    sqlite3ShowWhereTerm(0); /* So compiler won't complain about unused func */
  }
#endif

@@ -170613,14 +171023,28 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
            pOp->p2 = x;
            pOp->p1 = pLevel->iIdxCur;
            OpcodeRewriteTrace(db, k, pOp);
-
          }else{
-
            /* Unable to translate the table reference into an index
-
            ** reference.  Verify that this is harmless - that the
-
            ** table being referenced really is open.
-
            */
+
          }else if( pLoop->wsFlags & (WHERE_IDX_ONLY|WHERE_EXPRIDX) ){
            if( pLoop->wsFlags & WHERE_IDX_ONLY ){
+
              /* An error. pLoop is supposed to be a covering index loop,
+
              ** and yet the VM code refers to a column of the table that
+
              ** is not part of the index.  */
              sqlite3ErrorMsg(pParse, "internal query planner error");
              pParse->rc = SQLITE_INTERNAL;
+
            }else{
+
              /* The WHERE_EXPRIDX flag is set by the planner when it is likely
+
              ** that pLoop is a covering index loop, but it is not possible
+
              ** to be 100% sure. In this case, any OP_Explain opcode
+
              ** corresponding to this loop describes the index as a "COVERING
+
              ** INDEX". But, pOp proves that pLoop is not actually a covering
+
              ** index loop. So clear the WHERE_EXPRIDX flag and rewrite the
+
              ** text that accompanies the OP_Explain opcode, if any.  */
+
              pLoop->wsFlags &= ~WHERE_EXPRIDX;
+
              sqlite3WhereAddExplainText(pParse,
+
                  pLevel->addrBody-1,
+
                  pTabList,
+
                  pLevel,
+
                  pWInfo->wctrlFlags
+
              );
            }
          }
        }else if( pOp->opcode==OP_Rowid ){
@@ -172328,6 +172752,7 @@ static void windowAggStep(
    int regArg;
    int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin);
    int i;
+
    int addrIf = 0;

    assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED );

@@ -172344,6 +172769,18 @@ static void windowAggStep(
    }
    regArg = reg;

+
    if( pWin->pFilter ){
+
      int regTmp;
+
      assert( ExprUseXList(pWin->pOwner) );
+
      assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr );
+
      assert( pWin->bExprArgs || nArg  ||pWin->pOwner->x.pList==0 );
+
      regTmp = sqlite3GetTempReg(pParse);
+
      sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
+
      addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
+
      VdbeCoverage(v);
+
      sqlite3ReleaseTempReg(pParse, regTmp);
+
    }
+

    if( pMWin->regStartRowid==0
     && (pFunc->funcFlags & SQLITE_FUNC_MINMAX)
     && (pWin->eStart!=TK_UNBOUNDED)
@@ -172363,25 +172800,13 @@ static void windowAggStep(
      }
      sqlite3VdbeJumpHere(v, addrIsNull);
    }else if( pWin->regApp ){
+
      assert( pWin->pFilter==0 );
      assert( pFunc->zName==nth_valueName
           || pFunc->zName==first_valueName
      );
      assert( bInverse==0 || bInverse==1 );
      sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
    }else if( pFunc->xSFunc!=noopStepFunc ){
-
      int addrIf = 0;
-
      if( pWin->pFilter ){
-
        int regTmp;
-
        assert( ExprUseXList(pWin->pOwner) );
-
        assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr );
-
        assert( pWin->bExprArgs || nArg  ||pWin->pOwner->x.pList==0 );
-
        regTmp = sqlite3GetTempReg(pParse);
-
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
-
        addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
-
        VdbeCoverage(v);
-
        sqlite3ReleaseTempReg(pParse, regTmp);
-
      }
-

      if( pWin->bExprArgs ){
        int iOp = sqlite3VdbeCurrentAddr(v);
        int iEnd;
@@ -172408,12 +172833,13 @@ static void windowAggStep(
      sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
                        bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
-
      sqlite3VdbeChangeP5(v, (u8)nArg);
+
      sqlite3VdbeChangeP5(v, (u16)nArg);
      if( pWin->bExprArgs ){
        sqlite3ReleaseTempRange(pParse, regArg, nArg);
      }
-
      if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
    }
+

+
    if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
  }
}

@@ -173841,6 +174267,13 @@ struct TrigEvent { int a; IdList * b; };
struct FrameBound     { int eType; Expr *pExpr; };

/*
+
** Generate a syntax error
+
*/
+
static void parserSyntaxError(Parse *pParse, Token *p){
+
  sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", p);
+
}
+

+
/*
** Disable lookaside memory allocation for objects that might be
** shared across database connections.
*/
@@ -174187,7 +174620,8 @@ static void updateDeleteLimitError(
#define TK_ERROR                          182
#define TK_QNUMBER                        183
#define TK_SPACE                          184
-
#define TK_ILLEGAL                        185
+
#define TK_COMMENT                        185
+
#define TK_ILLEGAL                        186
#endif
/**************** End token definitions ***************************************/

@@ -174252,31 +174686,31 @@ static void updateDeleteLimitError(
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-
#define YYNOCODE 322
+
#define YYNOCODE 323
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 102
#define sqlite3ParserTOKENTYPE Token
typedef union {
  int yyinit;
  sqlite3ParserTOKENTYPE yy0;
-
  ExprList* yy14;
-
  With* yy59;
-
  Cte* yy67;
-
  Upsert* yy122;
-
  IdList* yy132;
-
  int yy144;
-
  const char* yy168;
-
  SrcList* yy203;
-
  Window* yy211;
-
  OnOrUsing yy269;
-
  struct TrigEvent yy286;
-
  struct {int value; int mask;} yy383;
-
  u32 yy391;
-
  TriggerStep* yy427;
-
  Expr* yy454;
-
  u8 yy462;
-
  struct FrameBound yy509;
-
  Select* yy555;
+
  u32 yy9;
+
  struct TrigEvent yy28;
+
  With* yy125;
+
  IdList* yy204;
+
  struct FrameBound yy205;
+
  TriggerStep* yy319;
+
  const char* yy342;
+
  Cte* yy361;
+
  ExprList* yy402;
+
  Upsert* yy403;
+
  OnOrUsing yy421;
+
  u8 yy444;
+
  struct {int value; int mask;} yy481;
+
  Window* yy483;
+
  int yy502;
+
  SrcList* yy563;
+
  Expr* yy590;
+
  Select* yy637;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -174298,7 +174732,7 @@ typedef union {
#define YYNSTATE             583
#define YYNRULE              409
#define YYNRULE_WITH_ACTION  344
-
#define YYNTOKEN             186
+
#define YYNTOKEN             187
#define YY_MAX_SHIFT         582
#define YY_MIN_SHIFTREDUCE   845
#define YY_MAX_SHIFTREDUCE   1253
@@ -174307,8 +174741,8 @@ typedef union {
#define YY_NO_ACTION         1256
#define YY_MIN_REDUCE        1257
#define YY_MAX_REDUCE        1665
-
#define YY_MIN_DSTRCTR       205
-
#define YY_MAX_DSTRCTR       319
+
#define YY_MIN_DSTRCTR       206
+
#define YY_MAX_DSTRCTR       320
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))

@@ -174404,211 +174838,211 @@ static const YYACTIONTYPE yy_action[] = {
 /*    80 */   573,  421,  562,  137,  138,   91,  559, 1228, 1228, 1063,
 /*    90 */  1066, 1053, 1053,  135,  135,  136,  136,  136,  136,  296,
 /*   100 */   460,  398, 1249,  134,  134,  134,  134,  133,  133,  132,
-
 /*   110 */   132,  132,  131,  128,  451,   44, 1050, 1050, 1064, 1067,
+
 /*   110 */   132,  132,  131,  128,  451,  451, 1050, 1050, 1064, 1067,
 /*   120 */  1255,    1,    1,  582,    2, 1259,  581, 1174, 1259, 1174,
-
 /*   130 */   321,  413,  155,  321, 1584,  155,  379,  112,  498, 1341,
+
 /*   130 */   321,  413,  155,  321, 1584,  155,  379,  112,  481, 1341,
 /*   140 */   456,  299, 1341,  134,  134,  134,  134,  133,  133,  132,
-
 /*   150 */   132,  132,  131,  128,  451,  137,  138,   91, 1105, 1228,
+
 /*   150 */   132,  132,  131,  128,  451,  137,  138,   91,  498, 1228,
 /*   160 */  1228, 1063, 1066, 1053, 1053,  135,  135,  136,  136,  136,
-
 /*   170 */   136, 1204,  320,  567,  288,  288,  283,  288,  288,  523,
-
 /*   180 */   523, 1250,  139, 1541,    7,  214,  503,  573, 1169,  562,
-
 /*   190 */   573, 1054,  562,  136,  136,  136,  136,  129,  401,  547,
-
 /*   200 */   487, 1169,  245, 1568, 1169,  245,  133,  133,  132,  132,
-
 /*   210 */   132,  131,  128,  451,  261,  134,  134,  134,  134,  133,
-
 /*   220 */   133,  132,  132,  132,  131,  128,  451,  451, 1204, 1205,
-
 /*   230 */  1204,  130,  127,  234,  455,  413,  182,  455,  130,  127,
+
 /*   170 */   136, 1204,  862, 1281,  288,  288,  283,  288,  288,  523,
+
 /*   180 */   523, 1250,  139,  578,    7,  578, 1345,  573, 1169,  562,
+
 /*   190 */   573, 1054,  562,  136,  136,  136,  136,  129,  573,  547,
+
 /*   200 */   562, 1169,  245, 1541, 1169,  245,  133,  133,  132,  132,
+
 /*   210 */   132,  131,  128,  451,  302,  134,  134,  134,  134,  133,
+
 /*   220 */   133,  132,  132,  132,  131,  128,  451, 1575, 1204, 1205,
+
 /*   230 */  1204,    7,  470,  550,  455,  413,  550,  455,  130,  127,
 /*   240 */   234,  134,  134,  134,  134,  133,  133,  132,  132,  132,
-
 /*   250 */   131,  128,  451,  136,  136,  136,  136,  538,  576,  137,
-
 /*   260 */   138,   91,  261, 1228, 1228, 1063, 1066, 1053, 1053,  135,
-
 /*   270 */   135,  136,  136,  136,  136,   44,  472,  346, 1204,  472,
-
 /*   280 */   346,   51,   51,  418,   93,  157,  134,  134,  134,  134,
-
 /*   290 */   133,  133,  132,  132,  132,  131,  128,  451,  166,  363,
-
 /*   300 */   298,  134,  134,  134,  134,  133,  133,  132,  132,  132,
-
 /*   310 */   131,  128,  451, 1293,  461, 1570,  423,  377,  275,  134,
+
 /*   250 */   131,  128,  451,  136,  136,  136,  136,  538,  483,  137,
+
 /*   260 */   138,   91, 1019, 1228, 1228, 1063, 1066, 1053, 1053,  135,
+
 /*   270 */   135,  136,  136,  136,  136, 1085,  576, 1204,  132,  132,
+
 /*   280 */   132,  131,  128,  451,   93,  214,  134,  134,  134,  134,
+
 /*   290 */   133,  133,  132,  132,  132,  131,  128,  451,  401,   19,
+
 /*   300 */    19,  134,  134,  134,  134,  133,  133,  132,  132,  132,
+
 /*   310 */   131,  128,  451, 1498,  426,  267,  344,  467,  332,  134,
 /*   320 */   134,  134,  134,  133,  133,  132,  132,  132,  131,  128,
-
 /*   330 */   451,  418,  320,  567, 1292, 1204, 1205, 1204,  257,  413,
-
 /*   340 */   483,  511,  508,  507,   94,  132,  132,  132,  131,  128,
-
 /*   350 */   451,  506, 1204,  548,  548,  388,  576,  384,    7,  413,
-
 /*   360 */   550,  229,  522,  137,  138,   91,  530, 1228, 1228, 1063,
-
 /*   370 */  1066, 1053, 1053,  135,  135,  136,  136,  136,  136,   51,
-
 /*   380 */    51, 1582,  380,  137,  138,   91,  331, 1228, 1228, 1063,
-
 /*   390 */  1066, 1053, 1053,  135,  135,  136,  136,  136,  136,  320,
-
 /*   400 */   567,  288,  288,  320,  567, 1602,  582,    2, 1259, 1204,
-
 /*   410 */  1205, 1204, 1628,  321,  573,  155,  562,  576, 1511,  264,
-
 /*   420 */   231,  520, 1341,  134,  134,  134,  134,  133,  133,  132,
-
 /*   430 */   132,  132,  131,  128,  451,  519, 1511, 1513, 1333, 1333,
-
 /*   440 */    82,   82,  498,  134,  134,  134,  134,  133,  133,  132,
-
 /*   450 */   132,  132,  131,  128,  451, 1435,  257,  288,  288,  511,
-
 /*   460 */   508,  507,  944, 1568,  413, 1019, 1204,  943,  360,  506,
-
 /*   470 */   573, 1598,  562,   44,  575,  551,  551,  557, 1107, 1582,
-
 /*   480 */   544,  576, 1107,   40,  417,  245,  531, 1505,  137,  138,
+
 /*   330 */   451, 1281,  576,    6, 1204, 1205, 1204,  257,  576,  413,
+
 /*   340 */   511,  508,  507, 1279,   94, 1019,  464, 1204,  551,  551,
+
 /*   350 */   506, 1224, 1571,   44,   38,   51,   51,  411,  576,  413,
+
 /*   360 */    45,   51,   51,  137,  138,   91,  530, 1228, 1228, 1063,
+
 /*   370 */  1066, 1053, 1053,  135,  135,  136,  136,  136,  136,  398,
+
 /*   380 */  1148,   82,   82,  137,  138,   91,   39, 1228, 1228, 1063,
+
 /*   390 */  1066, 1053, 1053,  135,  135,  136,  136,  136,  136,  344,
+
 /*   400 */    44,  288,  288,  375, 1204, 1205, 1204,  209, 1204, 1224,
+
 /*   410 */   320,  567,  471,  576,  573,  576,  562,  576,  316,  264,
+
 /*   420 */   231,   46,  160,  134,  134,  134,  134,  133,  133,  132,
+
 /*   430 */   132,  132,  131,  128,  451,  303,   82,   82,   82,   82,
+
 /*   440 */    82,   82,  442,  134,  134,  134,  134,  133,  133,  132,
+
 /*   450 */   132,  132,  131,  128,  451, 1582,  544,  320,  567, 1250,
+
 /*   460 */   874, 1582,  380,  382,  413, 1204, 1205, 1204,  360,  182,
+
 /*   470 */   288,  288, 1576,  557, 1339,  557,    7,  557, 1277,  472,
+
 /*   480 */   346,  526,  531,  573,  556,  562,  439, 1511,  137,  138,
 /*   490 */    91,  219, 1228, 1228, 1063, 1066, 1053, 1053,  135,  135,
-
 /*   500 */   136,  136,  136,  136,   81,   81, 1281, 1204,  413,  553,
-
 /*   510 */  1511,   48,  512,  448,  447,  493,  578,  455,  578,  344,
-
 /*   520 */    45, 1204, 1233, 1204, 1205, 1204,  428, 1235,  158,  882,
-
 /*   530 */   320,  567,  137,  138,   91, 1234, 1228, 1228, 1063, 1066,
+
 /*   500 */   136,  136,  136,  136,  465, 1511, 1513,  532,  413,  288,
+
 /*   510 */   288,  423,  512,  288,  288,  411,  288,  288,  874,  130,
+
 /*   520 */   127,  234,  573, 1107,  562, 1204,  573, 1107,  562,  573,
+
 /*   530 */   560,  562,  137,  138,   91, 1293, 1228, 1228, 1063, 1066,
 /*   540 */  1053, 1053,  135,  135,  136,  136,  136,  136,  134,  134,
 /*   550 */   134,  134,  133,  133,  132,  132,  132,  131,  128,  451,
-
 /*   560 */  1236,  576, 1236,  329, 1204, 1205, 1204,  387,  492,  403,
-
 /*   570 */  1040,  382,  489,  123,  568, 1569,    4,  377, 1204, 1205,
-
 /*   580 */  1204,  570,  570,  570,   82,   82,  882, 1029, 1331, 1331,
-
 /*   590 */   571, 1028,  134,  134,  134,  134,  133,  133,  132,  132,
-
 /*   600 */   132,  131,  128,  451,  288,  288, 1281, 1204,  576,  423,
-
 /*   610 */   576, 1568,  413,  423,  452,  378,  886,  573, 1279,  562,
-
 /*   620 */    46,  557,  532, 1028, 1028, 1030,  565,  130,  127,  234,
-
 /*   630 */   556,   82,   82,   82,   82,  479,  137,  138,   91,  462,
+
 /*   560 */   493,  503, 1292, 1204,  257,  288,  288,  511,  508,  507,
+
 /*   570 */  1204, 1628, 1169,  123,  568,  275,    4,  506,  573, 1511,
+
 /*   580 */   562,  331, 1204, 1205, 1204, 1169,  548,  548, 1169,  261,
+
 /*   590 */   571,    7,  134,  134,  134,  134,  133,  133,  132,  132,
+
 /*   600 */   132,  131,  128,  451,  108,  533,  130,  127,  234, 1204,
+
 /*   610 */   448,  447,  413, 1451,  452,  983,  886,   96, 1598, 1233,
+
 /*   620 */  1204, 1205, 1204,  984, 1235, 1450,  565, 1204, 1205, 1204,
+
 /*   630 */   229,  522, 1234,  534, 1333, 1333,  137,  138,   91, 1449,
 /*   640 */  1228, 1228, 1063, 1066, 1053, 1053,  135,  135,  136,  136,
-
 /*   650 */   136,  136, 1188,  487, 1506, 1040,  413,    6, 1204,   50,
-
 /*   660 */   879,  121,  121,  948, 1204, 1205, 1204,  358,  557,  122,
-
 /*   670 */   316,  452,  577,  452,  535, 1204, 1028,  439,  303,  212,
-
 /*   680 */   137,  138,   91,  213, 1228, 1228, 1063, 1066, 1053, 1053,
+
 /*   650 */   136,  136,  373, 1595,  971, 1040,  413, 1236,  418, 1236,
+
 /*   660 */   879,  121,  121,  948,  373, 1595, 1204, 1205, 1204,  122,
+
 /*   670 */  1204,  452,  577,  452,  363,  417, 1028,  882,  373, 1595,
+
 /*   680 */   137,  138,   91,  462, 1228, 1228, 1063, 1066, 1053, 1053,
 /*   690 */   135,  135,  136,  136,  136,  136,  134,  134,  134,  134,
 /*   700 */   133,  133,  132,  132,  132,  131,  128,  451, 1028, 1028,
-
 /*   710 */  1030, 1031,   35,  288,  288, 1204, 1205, 1204, 1040, 1339,
-
 /*   720 */   533,  123,  568, 1569,    4,  377,  573, 1019,  562,  353,
-
 /*   730 */  1277,  356, 1204, 1205, 1204, 1029,  488, 1188,  571, 1028,
+
 /*   710 */  1030, 1031,   35,  570,  570,  570,  197,  423, 1040,  198,
+
 /*   720 */  1204,  123,  568, 1204,    4,  320,  567, 1204, 1205, 1204,
+
 /*   730 */    40,  388,  576,  384,  882, 1029,  423, 1188,  571, 1028,
 /*   740 */   134,  134,  134,  134,  133,  133,  132,  132,  132,  131,
-
 /*   750 */   128,  451,  576,  343,  288,  288,  449,  449,  449,  971,
-
 /*   760 */   413, 1627,  452,  911, 1187,  288,  288,  573,  464,  562,
-
 /*   770 */   238, 1028, 1028, 1030,  565,   82,   82,  498,  573,  411,
-
 /*   780 */   562,  344,  467,  332,  137,  138,   91,  197, 1228, 1228,
+
 /*   750 */   128,  451,  529, 1568, 1204,   19,   19, 1204,  575,  492,
+
 /*   760 */   413,  157,  452,  489, 1187, 1331, 1331,    5, 1204,  949,
+
 /*   770 */   431, 1028, 1028, 1030,  565,   22,   22, 1204, 1205, 1204,
+
 /*   780 */  1204, 1205, 1204,  477,  137,  138,   91,  212, 1228, 1228,
 /*   790 */  1063, 1066, 1053, 1053,  135,  135,  136,  136,  136,  136,
-
 /*   800 */  1188,  528, 1169, 1040,  413, 1110, 1110,  495, 1041,  121,
-
 /*   810 */   121, 1204,  317,  540,  862, 1169, 1244,  122, 1169,  452,
-
 /*   820 */   577,  452, 1340,  198, 1028, 1204,  481,  526,  137,  138,
-
 /*   830 */    91,  560, 1228, 1228, 1063, 1066, 1053, 1053,  135,  135,
+
 /*   800 */  1188,   48,  111, 1040,  413, 1204,  213,  970, 1041,  121,
+
 /*   810 */   121, 1204, 1205, 1204, 1204, 1205, 1204,  122,  221,  452,
+
 /*   820 */   577,  452,   44,  487, 1028, 1204, 1205, 1204,  137,  138,
+
 /*   830 */    91,  378, 1228, 1228, 1063, 1066, 1053, 1053,  135,  135,
 /*   840 */   136,  136,  136,  136,  134,  134,  134,  134,  133,  133,
 /*   850 */   132,  132,  132,  131,  128,  451, 1028, 1028, 1030, 1031,
-
 /*   860 */    35, 1204,  288,  288, 1204,  477,  288,  288, 1204, 1205,
-
 /*   870 */  1204,  539,  481,  437,  470,  573, 1451,  562,  364,  573,
-
 /*   880 */  1153,  562, 1204, 1205, 1204, 1188,    5,  576,  134,  134,
+
 /*   860 */    35,  461, 1204, 1205, 1204, 1569, 1040,  377,  214, 1149,
+
 /*   870 */  1657,  535, 1657,  437,  902,  320,  567, 1568,  364,  320,
+
 /*   880 */   567,  412,  329, 1029,  519, 1188,    3, 1028,  134,  134,
 /*   890 */   134,  134,  133,  133,  132,  132,  132,  131,  128,  451,
-
 /*   900 */   221,  214,  302,   96, 1149, 1657,  232, 1657,  413,  392,
-
 /*   910 */    19,   19, 1024,  949,  406,  373, 1595, 1085, 1204, 1205,
-
 /*   920 */  1204, 1204, 1205, 1204, 1204,  426, 1149, 1658,  413, 1658,
-
 /*   930 */  1659,  399,  137,  138,   91,    3, 1228, 1228, 1063, 1066,
-
 /*   940 */  1053, 1053,  135,  135,  136,  136,  136,  136,  304, 1311,
-
 /*   950 */   514, 1204,  137,  138,   91, 1498, 1228, 1228, 1063, 1066,
-
 /*   960 */  1053, 1053,  135,  135,  136,  136,  136,  136,  434,  131,
-
 /*   970 */   128,  451,  375, 1204,  274,  291,  372,  517,  367,  516,
-
 /*   980 */   262, 1204, 1205, 1204, 1147,  227,  363,  448,  447, 1435,
-
 /*   990 */  1568, 1310,  134,  134,  134,  134,  133,  133,  132,  132,
-
 /*  1000 */   132,  131,  128,  451, 1568,  576, 1147,  487, 1204, 1205,
-
 /*  1010 */  1204,  442,  134,  134,  134,  134,  133,  133,  132,  132,
-
 /*  1020 */   132,  131,  128,  451,  386,  576,  485,  576,   19,   19,
-
 /*  1030 */  1204, 1205, 1204, 1345, 1236,  970, 1236,  574,   47,  936,
-
 /*  1040 */   936,  473,  413,  431, 1552,  573, 1125,  562,   19,   19,
-
 /*  1050 */    19,   19,   49,  336,  850,  851,  852,  111, 1368,  315,
-
 /*  1060 */   429,  576,  413,  433,  341,  306,  137,  138,   91,  115,
+
 /*   900 */  1659,  399, 1169,  307,  893,  307,  515,  576,  413,  214,
+
 /*   910 */   498,  944, 1024,  540,  903, 1169,  943,  392, 1169, 1028,
+
 /*   920 */  1028, 1030,  406,  298, 1204,   50, 1149, 1658,  413, 1658,
+
 /*   930 */   145,  145,  137,  138,   91,  293, 1228, 1228, 1063, 1066,
+
 /*   940 */  1053, 1053,  135,  135,  136,  136,  136,  136, 1188, 1147,
+
 /*   950 */   514, 1568,  137,  138,   91, 1505, 1228, 1228, 1063, 1066,
+
 /*   960 */  1053, 1053,  135,  135,  136,  136,  136,  136,  434,  323,
+
 /*   970 */   435,  539,  111, 1506,  274,  291,  372,  517,  367,  516,
+
 /*   980 */   262, 1204, 1205, 1204, 1574,  481,  363,  576,    7, 1569,
+
 /*   990 */  1568,  377,  134,  134,  134,  134,  133,  133,  132,  132,
+
 /*  1000 */   132,  131,  128,  451, 1568,  576, 1147,  576,  232,  576,
+
 /*  1010 */    19,   19,  134,  134,  134,  134,  133,  133,  132,  132,
+
 /*  1020 */   132,  131,  128,  451, 1169,  433,  576, 1207,   19,   19,
+
 /*  1030 */    19,   19,   19,   19, 1627,  576,  911, 1169,   47,  120,
+
 /*  1040 */  1169,  117,  413,  306,  498,  438, 1125,  206,  336,   19,
+
 /*  1050 */    19, 1435,   49,  449,  449,  449, 1368,  315,   81,   81,
+
 /*  1060 */   576,  304,  413, 1570,  207,  377,  137,  138,   91,  115,
 /*  1070 */  1228, 1228, 1063, 1066, 1053, 1053,  135,  135,  136,  136,
-
 /*  1080 */   136,  136,  576, 1309,   82,   82,  137,  138,   91,  529,
+
 /*  1080 */   136,  136,  576,   82,   82, 1207,  137,  138,   91, 1340,
 /*  1090 */  1228, 1228, 1063, 1066, 1053, 1053,  135,  135,  136,  136,
-
 /*  1100 */   136,  136, 1569,  222,  377,   19,   19,  305, 1126, 1169,
-
 /*  1110 */   398, 1148,   22,   22,  498,  333, 1569,  335,  377,  576,
-
 /*  1120 */   438,  445, 1169, 1127,  486, 1169,  134,  134,  134,  134,
+
 /*  1100 */   136,  136, 1569,  386,  377,   82,   82,  463, 1126, 1552,
+
 /*  1110 */   333,  463,  335,  131,  128,  451, 1569,  161,  377,   16,
+
 /*  1120 */   317,  387,  428, 1127,  448,  447,  134,  134,  134,  134,
 /*  1130 */   133,  133,  132,  132,  132,  131,  128,  451, 1128,  576,
-
 /*  1140 */   902,  576,  145,  145,    6,  576,  134,  134,  134,  134,
-
 /*  1150 */   133,  133,  132,  132,  132,  131,  128,  451,  214, 1336,
-
 /*  1160 */   922,  576,   19,   19,   19,   19, 1282,  419,   19,   19,
-
 /*  1170 */   923,  412,  515,  141,  576, 1169,  413,  206,  465,  207,
-
 /*  1180 */   903,  215, 1575,  552,  147,  147,    7,  227, 1169,  411,
-
 /*  1190 */  1250, 1169,  120,  307,  117,  307,  413,   66,   66,  334,
+
 /*  1140 */  1105,   10,  445,  267,  576, 1554,  134,  134,  134,  134,
+
 /*  1150 */   133,  133,  132,  132,  132,  131,  128,  451,  532,  576,
+
 /*  1160 */   922,  576,   19,   19,  576, 1573,  576,  147,  147,    7,
+
 /*  1170 */   923, 1236,  498, 1236,  576,  487,  413,  552,  285, 1224,
+
 /*  1180 */   969,  215,   82,   82,   66,   66, 1435,   67,   67,   21,
+
 /*  1190 */    21, 1110, 1110,  495,  334,  297,  413,   53,   53,  297,
 /*  1200 */   137,  138,   91,  119, 1228, 1228, 1063, 1066, 1053, 1053,
-
 /*  1210 */   135,  135,  136,  136,  136,  136,  413,  285,  209,  969,
-
 /*  1220 */   137,  138,   91,  471, 1228, 1228, 1063, 1066, 1053, 1053,
-
 /*  1230 */   135,  135,  136,  136,  136,  136,  435,   10, 1450,  267,
-
 /*  1240 */   137,  126,   91, 1435, 1228, 1228, 1063, 1066, 1053, 1053,
-
 /*  1250 */   135,  135,  136,  136,  136,  136, 1435, 1435,  410,  409,
+
 /*  1210 */   135,  135,  136,  136,  136,  136,  413, 1336, 1311,  446,
+
 /*  1220 */   137,  138,   91,  227, 1228, 1228, 1063, 1066, 1053, 1053,
+
 /*  1230 */   135,  135,  136,  136,  136,  136,  574, 1224,  936,  936,
+
 /*  1240 */   137,  126,   91,  141, 1228, 1228, 1063, 1066, 1053, 1053,
+
 /*  1250 */   135,  135,  136,  136,  136,  136,  533,  429,  472,  346,
 /*  1260 */   134,  134,  134,  134,  133,  133,  132,  132,  132,  131,
-
 /*  1270 */   128,  451,  576,  969,  576, 1224,  498,  373, 1595, 1554,
+
 /*  1270 */   128,  451,  576,  457,  233,  343, 1435,  403,  498, 1550,
 /*  1280 */   134,  134,  134,  134,  133,  133,  132,  132,  132,  131,
-
 /*  1290 */   128,  451,  532,  457,  576,   82,   82,   82,   82,  111,
+
 /*  1290 */   128,  451,  576,  324,  576,   82,   82,  487,  576,  969,
 /*  1300 */   134,  134,  134,  134,  133,  133,  132,  132,  132,  131,
-
 /*  1310 */   128,  451,  109,  233,  430, 1576,  546,   67,   67,    7,
-
 /*  1320 */   413,  351,  550, 1550,  260,  259,  258,  494,  443,  569,
-
 /*  1330 */   419,  983,  446, 1224,  450,  545, 1207,  576,  969,  984,
-
 /*  1340 */   413,  475, 1449, 1574, 1180,  138,   91,    7, 1228, 1228,
+
 /*  1310 */   128,  451,  288,  288,  546,   68,   68,   54,   54,  553,
+
 /*  1320 */   413,   69,   69,  351,    6,  573,  944,  562,  410,  409,
+
 /*  1330 */  1435,  943,  450,  545,  260,  259,  258,  576,  158,  576,
+
 /*  1340 */   413,  222, 1180,  479,  969,  138,   91,  430, 1228, 1228,
 /*  1350 */  1063, 1066, 1053, 1053,  135,  135,  136,  136,  136,  136,
-
 /*  1360 */    21,   21,  267,  576,  300, 1126,   91,  233, 1228, 1228,
+
 /*  1360 */    70,   70,   71,   71,  576, 1126,   91,  576, 1228, 1228,
 /*  1370 */  1063, 1066, 1053, 1053,  135,  135,  136,  136,  136,  136,
-
 /*  1380 */  1127,  373, 1595,  161, 1573,   16,   53,   53,    7,  108,
-
 /*  1390 */   533,   38,  969,  125, 1207, 1128, 1180,  576, 1224,  123,
-
 /*  1400 */   568,  893,    4,  324,  134,  134,  134,  134,  133,  133,
-
 /*  1410 */   132,  132,  132,  131,  128,  451,  571,  564,  534,  576,
-
 /*  1420 */    68,   68,  576,   39,  134,  134,  134,  134,  133,  133,
-
 /*  1430 */   132,  132,  132,  131,  128,  451,  576,  160, 1571, 1223,
-
 /*  1440 */   452,  576,   54,   54,  576,   69,   69,  576, 1366,  576,
-
 /*  1450 */   420,  184,  565,  463,  297,  576, 1224,  463,  297,   70,
-
 /*  1460 */    70,  576,   44,  474,   71,   71,  576,   72,   72,  576,
-
 /*  1470 */    73,   73,   55,   55,  411,  874,  242,  576,   56,   56,
-
 /*  1480 */   576, 1040,  576,  478,   57,   57,  576,  121,  121,   59,
-
 /*  1490 */    59,   23,   60,   60,  411,  122,  319,  452,  577,  452,
-
 /*  1500 */    74,   74, 1028,   75,   75,   76,   76,  411,  290,   20,
-
 /*  1510 */    20,  108,  287,  231,  553,  123,  568,  325,    4,  320,
-
 /*  1520 */   567,   97,  218,  944, 1144,  328,  400,  576,  943,  576,
-
 /*  1530 */  1380,  424,  571,  874, 1028, 1028, 1030, 1031,   35,  293,
-
 /*  1540 */   534,  576, 1104,  576, 1104,    9,  576,  342,  576,  111,
-
 /*  1550 */    77,   77,  143,  143,  576,  205,  452,  222, 1379,  889,
-
 /*  1560 */   576,  901,  900, 1188,  144,  144,   78,   78,  565,   62,
-
 /*  1570 */    62,   79,   79,  323, 1021,  576,  266,   63,   63,  908,
-
 /*  1580 */   909, 1589,  542,   80,   80,  576,  371,  541,  123,  568,
-
 /*  1590 */   480,    4,  266,  482,  244,  266,  370, 1040,   64,   64,
-
 /*  1600 */   576,  466,  576,  121,  121,  571, 1557,  576,  170,  170,
-
 /*  1610 */   576,  122,  576,  452,  577,  452,  576,  889, 1028,  576,
-
 /*  1620 */   165,  576,  111,  171,  171,   87,   87,  337, 1616,  452,
-
 /*  1630 */    65,   65, 1530,   83,   83,  146,  146,  986,  987,   84,
-
 /*  1640 */    84,  565,  168,  168,  148,  148, 1092,  347, 1032,  111,
-
 /*  1650 */  1028, 1028, 1030, 1031,   35,  542, 1103,  576, 1103,  576,
-
 /*  1660 */   543,  123,  568,  504,    4,  263,  576,  361, 1529,  111,
-
 /*  1670 */  1040, 1088,  576,  263,  576,  490,  121,  121,  571, 1188,
-
 /*  1680 */   142,  142,  169,  169,  122,  576,  452,  577,  452,  162,
-
 /*  1690 */   162, 1028,  576,  563,  576,  152,  152,  151,  151,  348,
-
 /*  1700 */  1376,  974,  452,  266, 1092,  942, 1032,  125,  149,  149,
-
 /*  1710 */   939,  576,  125,  576,  565,  150,  150,   86,   86,  872,
-
 /*  1720 */   352,  159,  576, 1028, 1028, 1030, 1031,   35,  542,  941,
-
 /*  1730 */   576,  125,  355,  541,   88,   88,   85,   85,  357,  359,
-
 /*  1740 */  1324, 1308,  366, 1040,  376,   52,   52,  499, 1389,  121,
-
 /*  1750 */   121, 1434, 1188,   58,   58, 1362, 1374,  122, 1439,  452,
-
 /*  1760 */   577,  452, 1289,  167, 1028, 1280,  280, 1268, 1267, 1269,
-
 /*  1770 */  1609, 1359,  312,  313,   12,  314,  397, 1421,  224, 1416,
-
 /*  1780 */   295,  237, 1409,  339,  340, 1426,  301,  345,  484,  228,
-
 /*  1790 */  1371, 1307, 1372, 1370, 1425,  404, 1028, 1028, 1030, 1031,
-
 /*  1800 */    35, 1601, 1192,  454,  509,  369,  292, 1502,  210, 1501,
-
 /*  1810 */  1369,  396,  396,  395,  277,  393,  211,  566,  859, 1612,
-
 /*  1820 */  1244,  123,  568,  391,    4, 1188,  223,  270, 1549, 1547,
-
 /*  1830 */  1241,  239,  186,  327,  422,   96,  195,  220,  571,  235,
-
 /*  1840 */   180,  326,  188,  468,  190, 1507,  191,  192,   92,  193,
-
 /*  1850 */   469,   95, 1422,   13,  502,  247, 1430,  109,  199,  402,
-
 /*  1860 */   476,  405,  452, 1496, 1428, 1427,   14,  491,  251,  102,
-
 /*  1870 */   497, 1518,  241,  281,  565,  253,  203,  354,  500,  254,
-
 /*  1880 */   175, 1270,  407,   43,  350,  518, 1327,  436,  255, 1326,
-
 /*  1890 */  1325, 1318,  104,  893, 1626,  229,  408,  440, 1625,  441,
-
 /*  1900 */   240,  310, 1296, 1040,  311, 1317,  527, 1594, 1297,  121,
-
 /*  1910 */   121,  368, 1295, 1624,  268,  269, 1580,  122, 1579,  452,
-
 /*  1920 */   577,  452,  374,  444, 1028, 1394, 1393,  140,  553,   90,
-
 /*  1930 */   568,   11,    4, 1483,  383,  414,  385,  110,  116,  216,
-
 /*  1940 */   320,  567, 1350,  555,   42,  318,  571,  537, 1349,  389,
-
 /*  1950 */   390,  579, 1198,  276,  279,  278, 1028, 1028, 1030, 1031,
-
 /*  1960 */    35,  580,  415, 1265,  458, 1260,  416,  185, 1534,  172,
-
 /*  1970 */   452, 1535,  173,  156,  308,  846, 1533, 1532,  453,  217,
-
 /*  1980 */   225,   89,  565,  174,  322, 1188,  226,  236, 1102,  154,
-
 /*  1990 */  1100,  330,  176,  187, 1223,  189,  925,  338,  243, 1116,
-
 /*  2000 */   246,  194,  177,  178,  425,  427,   98,   99,  196,  100,
-
 /*  2010 */   101, 1040,  179, 1119,  248, 1115,  249,  121,  121,   24,
-
 /*  2020 */   163,  250,  349, 1108,  266,  122, 1238,  452,  577,  452,
-
 /*  2030 */  1192,  454, 1028,  200,  292,  496,  252,  201,  861,  396,
+
 /*  1380 */  1127,  166,  850,  851,  852, 1282,  419,   72,   72,  108,
+
 /*  1390 */    73,   73, 1310,  358, 1180, 1128,  576,  305,  576,  123,
+
 /*  1400 */   568,  494,    4,  488,  134,  134,  134,  134,  133,  133,
+
 /*  1410 */   132,  132,  132,  131,  128,  451,  571,  564,  534,   55,
+
 /*  1420 */    55,   56,   56,  576,  134,  134,  134,  134,  133,  133,
+
 /*  1430 */   132,  132,  132,  131,  128,  451,  576, 1104,  233, 1104,
+
 /*  1440 */   452, 1602,  582,    2, 1259,  576,   57,   57,  576,  321,
+
 /*  1450 */   576,  155,  565, 1435,  485,  353,  576,  356, 1341,   59,
+
 /*  1460 */    59,  576,   44,  969,  569,  419,  576,  238,   60,   60,
+
 /*  1470 */   261,   74,   74,   75,   75,  287,  231,  576, 1366,   76,
+
 /*  1480 */    76, 1040,  420,  184,   20,   20,  576,  121,  121,   77,
+
 /*  1490 */    77,   97,  218,  288,  288,  122,  125,  452,  577,  452,
+
 /*  1500 */   143,  143, 1028,  576,  520,  576,  573,  576,  562,  144,
+
 /*  1510 */   144,  474,  227, 1244,  478,  123,  568,  576,    4,  320,
+
 /*  1520 */   567,  245,  411,  576,  443,  411,   78,   78,   62,   62,
+
 /*  1530 */    79,   79,  571,  319, 1028, 1028, 1030, 1031,   35,  418,
+
 /*  1540 */    63,   63,  576,  290,  411,    9,   80,   80, 1144,  576,
+
 /*  1550 */   400,  576,  486,  455,  576, 1223,  452,  576,  325,  342,
+
 /*  1560 */   576,  111,  576, 1188,  242,   64,   64,  473,  565,  576,
+
 /*  1570 */    23,  576,  170,  170,  171,  171,  576,   87,   87,  328,
+
 /*  1580 */    65,   65,  542,   83,   83,  146,  146,  541,  123,  568,
+
 /*  1590 */   341,    4,   84,   84,  168,  168,  576, 1040,  576,  148,
+
 /*  1600 */   148,  576, 1380,  121,  121,  571, 1021,  576,  266,  576,
+
 /*  1610 */   424,  122,  576,  452,  577,  452,  576,  553, 1028,  142,
+
 /*  1620 */   142,  169,  169,  576,  162,  162,  528,  889,  371,  452,
+
 /*  1630 */   152,  152,  151,  151, 1379,  149,  149,  109,  370,  150,
+
 /*  1640 */   150,  565,  576,  480,  576,  266,   86,   86,  576, 1092,
+
 /*  1650 */  1028, 1028, 1030, 1031,   35,  542,  482,  576,  266,  466,
+
 /*  1660 */   543,  123,  568, 1616,    4,   88,   88,   85,   85,  475,
+
 /*  1670 */  1040,   52,   52,  222,  901,  900,  121,  121,  571, 1188,
+
 /*  1680 */    58,   58,  244, 1032,  122,  889,  452,  577,  452,  908,
+
 /*  1690 */   909, 1028,  300,  347,  504,  111,  263,  361,  165,  111,
+
 /*  1700 */   111, 1088,  452,  263,  974, 1153,  266, 1092,  986,  987,
+
 /*  1710 */   942,  939,  125,  125,  565, 1103,  872, 1103,  159,  941,
+
 /*  1720 */  1309,  125, 1557, 1028, 1028, 1030, 1031,   35,  542,  337,
+
 /*  1730 */  1530,  205, 1529,  541,  499, 1589,  490,  348, 1376,  352,
+
 /*  1740 */   355, 1032,  357, 1040,  359, 1324, 1308,  366,  563,  121,
+
 /*  1750 */   121,  376, 1188, 1389, 1434, 1362,  280,  122, 1374,  452,
+
 /*  1760 */   577,  452,  167, 1439, 1028, 1289, 1280, 1268, 1267, 1269,
+
 /*  1770 */  1609, 1359,  312,  313,  314,  397,   12,  237,  224, 1421,
+
 /*  1780 */   295, 1416, 1409, 1426,  339,  484,  340,  509, 1371, 1612,
+
 /*  1790 */  1372, 1425, 1244,  404,  301,  228, 1028, 1028, 1030, 1031,
+
 /*  1800 */    35, 1601, 1192,  454,  345, 1307,  292,  369, 1502, 1501,
+
 /*  1810 */   270,  396,  396,  395,  277,  393, 1370, 1369,  859, 1549,
+
 /*  1820 */   186,  123,  568,  235,    4, 1188,  391,  210,  211,  223,
+
 /*  1830 */  1547,  239, 1241,  327,  422,   96,  220,  195,  571,  180,
+
 /*  1840 */   188,  326,  468,  469,  190,  191,  502,  192,  193,  566,
+
 /*  1850 */   247,  109, 1430,  491,  199,  251,  102,  281,  402,  476,
+
 /*  1860 */   405, 1496,  452,  497,  253, 1422,   13, 1428,   14, 1427,
+
 /*  1870 */   203, 1507,  241,  500,  565,  354,  407,   92,   95, 1270,
+
 /*  1880 */   175,  254,  518,   43, 1327,  255, 1326, 1325,  436, 1518,
+
 /*  1890 */   350, 1318,  104,  229,  893, 1626,  440,  441, 1625,  408,
+
 /*  1900 */   240, 1296,  268, 1040,  310,  269, 1297,  527,  444,  121,
+
 /*  1910 */   121,  368, 1295, 1594, 1624,  311, 1394,  122, 1317,  452,
+
 /*  1920 */   577,  452,  374, 1580, 1028, 1393,  140,  553,   11,   90,
+
 /*  1930 */   568,  385,    4,  116,  318,  414, 1579,  110, 1483,  537,
+
 /*  1940 */   320,  567, 1350,  555,   42,  579,  571, 1349, 1198,  383,
+
 /*  1950 */   276,  390,  216,  389,  278,  279, 1028, 1028, 1030, 1031,
+
 /*  1960 */    35,  172,  580, 1265,  458, 1260,  415,  416,  185,  156,
+
 /*  1970 */   452, 1534, 1535,  173, 1533, 1532,   89,  308,  225,  226,
+
 /*  1980 */   846,  174,  565,  453,  217, 1188,  322,  236, 1102,  154,
+
 /*  1990 */  1100,  330,  187,  176, 1223,  243,  189,  925,  338,  246,
+
 /*  2000 */  1116,  194,  177,  425,  178,  427,   98,  196,   99,  100,
+
 /*  2010 */   101, 1040,  179, 1119, 1115,  248,  249,  121,  121,  163,
+
 /*  2020 */    24,  250,  349, 1238,  496,  122, 1108,  452,  577,  452,
+
 /*  2030 */  1192,  454, 1028,  266,  292,  200,  252,  201,  861,  396,
 /*  2040 */   396,  395,  277,  393,   15,  501,  859,  370,  292,  256,
 /*  2050 */   202,  554,  505,  396,  396,  395,  277,  393,  103,  239,
 /*  2060 */   859,  327,   25,   26, 1028, 1028, 1030, 1031,   35,  326,
 /*  2070 */   362,  510,  891,  239,  365,  327,  513,  904,  105,  309,
 /*  2080 */   164,  181,   27,  326,  106,  521,  107, 1185, 1069, 1155,
-
 /*  2090 */    17, 1154,  284, 1188,  286,  978,  265,  204,  125, 1171,
-
 /*  2100 */   241,  230,  972, 1175,   28, 1160,   29, 1179,  175, 1173,
-
 /*  2110 */    30,   43,   31, 1178,  241,   32,   41,  549,    8,   33,
-
 /*  2120 */   208,  111,  175, 1083, 1070,   43,  113, 1068,  240,  114,
-
 /*  2130 */  1072,   34, 1073,  561, 1124,  118,  271,   36,   18, 1194,
-
 /*  2140 */  1033,  873,  240,  935,  124,   37,  272,  273, 1617,  572,
-
 /*  2150 */   183,  153,  394, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
+
 /*  2090 */    17, 1154,  230, 1188,  284,  286,  265,  204,  125, 1171,
+
 /*  2100 */   241,   28,  978,  972,   29,   41, 1175, 1179,  175, 1173,
+
 /*  2110 */    30,   43,   31,    8,  241, 1178,   32, 1160,  208,  549,
+
 /*  2120 */    33,  111,  175, 1083, 1070,   43, 1068, 1072,  240,  113,
+
 /*  2130 */   114,   34,  561,  118, 1124,  271, 1073,   36,   18,  572,
+
 /*  2140 */  1033,  873,  240,  124,   37,  935,  272,  273, 1617,  183,
+
 /*  2150 */   153,  394, 1194, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
 /*  2160 */  1256, 1256, 1256,  414, 1256, 1256, 1256, 1256,  320,  567,
 /*  2170 */  1256, 1256, 1256, 1256, 1256, 1256, 1256,  414, 1256, 1256,
 /*  2180 */  1256, 1256,  320,  567, 1256, 1256, 1256, 1256, 1256, 1256,
@@ -174616,257 +175050,257 @@ static const YYACTIONTYPE yy_action[] = {
 /*  2200 */  1256, 1256, 1256, 1256, 1256, 1256,  458,
};
static const YYCODETYPE yy_lookahead[] = {
-
 /*     0 */   276,  277,  278,  240,  241,  224,  194,  226,  194,  240,
-
 /*    10 */   241,  194,  216,  220,  194,  234,  253,  194,  255,   19,
-
 /*    20 */   224,  297,  253,  194,  255,  205,  212,  213,  205,  217,
-
 /*    30 */   218,   31,  205,  194,  217,  218,  194,  217,  218,   39,
-
 /*    40 */   217,  218,  312,   43,   44,   45,  316,   47,   48,   49,
+
 /*     0 */   277,  278,  279,  241,  242,  225,  195,  227,  195,  241,
+
 /*    10 */   242,  195,  217,  221,  195,  235,  254,  195,  256,   19,
+
 /*    20 */   225,  298,  254,  195,  256,  206,  213,  214,  206,  218,
+
 /*    30 */   219,   31,  206,  195,  218,  219,  195,  218,  219,   39,
+
 /*    40 */   218,  219,  313,   43,   44,   45,  317,   47,   48,   49,
 /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,   58,   19,
-
 /*    60 */   240,  241,  194,  240,  241,  194,  254,  240,  241,  276,
-
 /*    70 */   277,  278,  233,  253,  254,  255,  253,  254,  255,  217,
-
 /*    80 */   253,  239,  255,   43,   44,   45,  263,   47,   48,   49,
-
 /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,   58,  270,
-
 /*   100 */   286,   22,   23,  103,  104,  105,  106,  107,  108,  109,
-
 /*   110 */   110,  111,  112,  113,  114,   82,   47,   48,   49,   50,
-
 /*   120 */   186,  187,  188,  189,  190,  191,  189,   87,  191,   89,
-
 /*   130 */   196,   19,  198,  196,  317,  198,  319,   25,  194,  205,
-
 /*   140 */   298,  270,  205,  103,  104,  105,  106,  107,  108,  109,
-
 /*   150 */   110,  111,  112,  113,  114,   43,   44,   45,   11,   47,
+
 /*    60 */   241,  242,  195,  241,  242,  195,  255,  241,  242,  277,
+
 /*    70 */   278,  279,  234,  254,  255,  256,  254,  255,  256,  218,
+
 /*    80 */   254,  240,  256,   43,   44,   45,  264,   47,   48,   49,
+
 /*    90 */    50,   51,   52,   53,   54,   55,   56,   57,   58,  271,
+
 /*   100 */   287,   22,   23,  103,  104,  105,  106,  107,  108,  109,
+
 /*   110 */   110,  111,  112,  113,  114,  114,   47,   48,   49,   50,
+
 /*   120 */   187,  188,  189,  190,  191,  192,  190,   87,  192,   89,
+
 /*   130 */   197,   19,  199,  197,  318,  199,  320,   25,  195,  206,
+
 /*   140 */   299,  271,  206,  103,  104,  105,  106,  107,  108,  109,
+
 /*   150 */   110,  111,  112,  113,  114,   43,   44,   45,  195,   47,
 /*   160 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
-
 /*   170 */    58,   60,  139,  140,  240,  241,  214,  240,  241,  311,
-
 /*   180 */   312,  102,   70,  239,  316,  194,   19,  253,   77,  255,
-
 /*   190 */   253,  122,  255,   55,   56,   57,   58,   59,  207,   88,
-
 /*   200 */   194,   90,  268,  194,   93,  268,  107,  108,  109,  110,
-
 /*   210 */   111,  112,  113,  114,   47,  103,  104,  105,  106,  107,
-
 /*   220 */   108,  109,  110,  111,  112,  113,  114,  114,  117,  118,
-
 /*   230 */   119,  276,  277,  278,  300,   19,  194,  300,  276,  277,
-
 /*   240 */   278,  103,  104,  105,  106,  107,  108,  109,  110,  111,
-
 /*   250 */   112,  113,  114,   55,   56,   57,   58,  146,  194,   43,
-
 /*   260 */    44,   45,   47,   47,   48,   49,   50,   51,   52,   53,
-
 /*   270 */    54,   55,   56,   57,   58,   82,  129,  130,   60,  129,
-
 /*   280 */   130,  217,  218,  116,   68,   25,  103,  104,  105,  106,
-
 /*   290 */   107,  108,  109,  110,  111,  112,  113,  114,   23,  132,
-
 /*   300 */   294,  103,  104,  105,  106,  107,  108,  109,  110,  111,
-
 /*   310 */   112,  113,  114,  217,  121,  306,  194,  308,   26,  103,
+
 /*   170 */    58,   60,   21,  195,  241,  242,  215,  241,  242,  312,
+
 /*   180 */   313,  102,   70,  205,  317,  207,  242,  254,   77,  256,
+
 /*   190 */   254,  122,  256,   55,   56,   57,   58,   59,  254,   88,
+
 /*   200 */   256,   90,  269,  240,   93,  269,  107,  108,  109,  110,
+
 /*   210 */   111,  112,  113,  114,  271,  103,  104,  105,  106,  107,
+
 /*   220 */   108,  109,  110,  111,  112,  113,  114,  313,  117,  118,
+
 /*   230 */   119,  317,   81,  195,  301,   19,  195,  301,  277,  278,
+
 /*   240 */   279,  103,  104,  105,  106,  107,  108,  109,  110,  111,
+
 /*   250 */   112,  113,  114,   55,   56,   57,   58,  146,  195,   43,
+
 /*   260 */    44,   45,   74,   47,   48,   49,   50,   51,   52,   53,
+
 /*   270 */    54,   55,   56,   57,   58,  124,  195,   60,  109,  110,
+
 /*   280 */   111,  112,  113,  114,   68,  195,  103,  104,  105,  106,
+
 /*   290 */   107,  108,  109,  110,  111,  112,  113,  114,  208,  218,
+
 /*   300 */   219,  103,  104,  105,  106,  107,  108,  109,  110,  111,
+
 /*   310 */   112,  113,  114,  162,  233,   24,  128,  129,  130,  103,
 /*   320 */   104,  105,  106,  107,  108,  109,  110,  111,  112,  113,
-
 /*   330 */   114,  116,  139,  140,  217,  117,  118,  119,  120,   19,
-
 /*   340 */   194,  123,  124,  125,   24,  109,  110,  111,  112,  113,
-
 /*   350 */   114,  133,   60,  311,  312,  250,  194,  252,  316,   19,
-
 /*   360 */   194,  166,  167,   43,   44,   45,  205,   47,   48,   49,
-
 /*   370 */    50,   51,   52,   53,   54,   55,   56,   57,   58,  217,
-
 /*   380 */   218,  317,  318,   43,   44,   45,  264,   47,   48,   49,
-
 /*   390 */    50,   51,   52,   53,   54,   55,   56,   57,   58,  139,
-
 /*   400 */   140,  240,  241,  139,  140,  188,  189,  190,  191,  117,
-
 /*   410 */   118,  119,  231,  196,  253,  198,  255,  194,  194,  258,
-
 /*   420 */   259,  146,  205,  103,  104,  105,  106,  107,  108,  109,
-
 /*   430 */   110,  111,  112,  113,  114,  109,  212,  213,  236,  237,
-
 /*   440 */   217,  218,  194,  103,  104,  105,  106,  107,  108,  109,
-
 /*   450 */   110,  111,  112,  113,  114,  194,  120,  240,  241,  123,
-
 /*   460 */   124,  125,  136,  194,   19,   74,   60,  141,   23,  133,
-
 /*   470 */   253,  194,  255,   82,  194,  309,  310,  254,   29,  317,
-
 /*   480 */   318,  194,   33,   22,  199,  268,  263,  239,   43,   44,
+
 /*   330 */   114,  195,  195,  215,  117,  118,  119,  120,  195,   19,
+
 /*   340 */   123,  124,  125,  207,   24,   74,  246,   60,  310,  311,
+
 /*   350 */   133,   60,  311,   82,   22,  218,  219,  257,  195,   19,
+
 /*   360 */    73,  218,  219,   43,   44,   45,  206,   47,   48,   49,
+
 /*   370 */    50,   51,   52,   53,   54,   55,   56,   57,   58,   22,
+
 /*   380 */    23,  218,  219,   43,   44,   45,   54,   47,   48,   49,
+
 /*   390 */    50,   51,   52,   53,   54,   55,   56,   57,   58,  128,
+
 /*   400 */    82,  241,  242,  195,  117,  118,  119,  289,   60,  118,
+
 /*   410 */   139,  140,  294,  195,  254,  195,  256,  195,  255,  259,
+
 /*   420 */   260,   73,   22,  103,  104,  105,  106,  107,  108,  109,
+
 /*   430 */   110,  111,  112,  113,  114,  206,  218,  219,  218,  219,
+
 /*   440 */   218,  219,  234,  103,  104,  105,  106,  107,  108,  109,
+
 /*   450 */   110,  111,  112,  113,  114,  318,  319,  139,  140,  102,
+
 /*   460 */    60,  318,  319,  221,   19,  117,  118,  119,   23,  195,
+
 /*   470 */   241,  242,  313,  255,  206,  255,  317,  255,  206,  129,
+
 /*   480 */   130,  206,  264,  254,  264,  256,  264,  195,   43,   44,
 /*   490 */    45,  151,   47,   48,   49,   50,   51,   52,   53,   54,
-
 /*   500 */    55,   56,   57,   58,  217,  218,  194,   60,   19,  146,
-
 /*   510 */   286,  242,   23,  107,  108,   66,  204,  300,  206,  128,
-
 /*   520 */    73,   60,  116,  117,  118,  119,  265,  121,  165,   60,
-
 /*   530 */   139,  140,   43,   44,   45,  129,   47,   48,   49,   50,
+
 /*   500 */    55,   56,   57,   58,  246,  213,  214,   19,   19,  241,
+
 /*   510 */   242,  195,   23,  241,  242,  257,  241,  242,  118,  277,
+
 /*   520 */   278,  279,  254,   29,  256,   60,  254,   33,  256,  254,
+
 /*   530 */   206,  256,   43,   44,   45,  218,   47,   48,   49,   50,
 /*   540 */    51,   52,   53,   54,   55,   56,   57,   58,  103,  104,
 /*   550 */   105,  106,  107,  108,  109,  110,  111,  112,  113,  114,
-
 /*   560 */   154,  194,  156,  194,  117,  118,  119,  280,  283,  205,
-
 /*   570 */   101,  220,  287,   19,   20,  306,   22,  308,  117,  118,
-
 /*   580 */   119,  211,  212,  213,  217,  218,  117,  118,  236,  237,
-
 /*   590 */    36,  122,  103,  104,  105,  106,  107,  108,  109,  110,
-
 /*   600 */   111,  112,  113,  114,  240,  241,  194,   60,  194,  194,
-
 /*   610 */   194,  194,   19,  194,   60,  194,   23,  253,  206,  255,
-
 /*   620 */    73,  254,   19,  154,  155,  156,   72,  276,  277,  278,
-
 /*   630 */   263,  217,  218,  217,  218,  271,   43,   44,   45,  271,
+
 /*   560 */    66,   19,  218,   60,  120,  241,  242,  123,  124,  125,
+
 /*   570 */    60,  232,   77,   19,   20,   26,   22,  133,  254,  287,
+
 /*   580 */   256,  265,  117,  118,  119,   90,  312,  313,   93,   47,
+
 /*   590 */    36,  317,  103,  104,  105,  106,  107,  108,  109,  110,
+
 /*   600 */   111,  112,  113,  114,  116,  117,  277,  278,  279,   60,
+
 /*   610 */   107,  108,   19,  276,   60,   31,   23,  152,  195,  116,
+
 /*   620 */   117,  118,  119,   39,  121,  276,   72,  117,  118,  119,
+
 /*   630 */   166,  167,  129,  145,  237,  238,   43,   44,   45,  276,
 /*   640 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
-
 /*   650 */    57,   58,  183,  194,  285,  101,   19,  214,   60,  242,
-
 /*   660 */    23,  107,  108,  109,  117,  118,  119,   16,  254,  115,
-
 /*   670 */   254,  117,  118,  119,  194,   60,  122,  263,  205,  264,
-
 /*   680 */    43,   44,   45,  264,   47,   48,   49,   50,   51,   52,
+
 /*   650 */    57,   58,  315,  316,  144,  101,   19,  154,  116,  156,
+
 /*   660 */    23,  107,  108,  109,  315,  316,  117,  118,  119,  115,
+
 /*   670 */    60,  117,  118,  119,  132,  200,  122,   60,  315,  316,
+
 /*   680 */    43,   44,   45,  272,   47,   48,   49,   50,   51,   52,
 /*   690 */    53,   54,   55,   56,   57,   58,  103,  104,  105,  106,
 /*   700 */   107,  108,  109,  110,  111,  112,  113,  114,  154,  155,
-
 /*   710 */   156,  157,  158,  240,  241,  117,  118,  119,  101,  205,
-
 /*   720 */   117,   19,   20,  306,   22,  308,  253,   74,  255,   78,
-
 /*   730 */   205,   80,  117,  118,  119,  118,  293,  183,   36,  122,
+
 /*   710 */   156,  157,  158,  212,  213,  214,   22,  195,  101,   22,
+
 /*   720 */    60,   19,   20,   60,   22,  139,  140,  117,  118,  119,
+
 /*   730 */    22,  251,  195,  253,  117,  118,  195,  183,   36,  122,
 /*   740 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
-
 /*   750 */   113,  114,  194,  294,  240,  241,  211,  212,  213,  144,
-
 /*   760 */    19,   23,   60,   25,   23,  240,  241,  253,  245,  255,
-
 /*   770 */    15,  154,  155,  156,   72,  217,  218,  194,  253,  256,
-
 /*   780 */   255,  128,  129,  130,   43,   44,   45,   22,   47,   48,
+
 /*   750 */   113,  114,  195,  195,   60,  218,  219,   60,  195,  284,
+
 /*   760 */    19,   25,   60,  288,   23,  237,  238,   22,   60,  109,
+
 /*   770 */   233,  154,  155,  156,   72,  218,  219,  117,  118,  119,
+
 /*   780 */   117,  118,  119,  116,   43,   44,   45,  265,   47,   48,
 /*   790 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   58,
-
 /*   800 */   183,   19,   77,  101,   19,  128,  129,  130,   23,  107,
-
 /*   810 */   108,   60,  254,   88,   21,   90,   61,  115,   93,  117,
-
 /*   820 */   118,  119,  239,   22,  122,   60,  194,  205,   43,   44,
-
 /*   830 */    45,  205,   47,   48,   49,   50,   51,   52,   53,   54,
+
 /*   800 */   183,  243,   25,  101,   19,   60,  265,  144,   23,  107,
+
 /*   810 */   108,  117,  118,  119,  117,  118,  119,  115,  151,  117,
+
 /*   820 */   118,  119,   82,  195,  122,  117,  118,  119,   43,   44,
+
 /*   830 */    45,  195,   47,   48,   49,   50,   51,   52,   53,   54,
 /*   840 */    55,   56,   57,   58,  103,  104,  105,  106,  107,  108,
 /*   850 */   109,  110,  111,  112,  113,  114,  154,  155,  156,  157,
-
 /*   860 */   158,   60,  240,  241,   60,  116,  240,  241,  117,  118,
-
 /*   870 */   119,  146,  194,   19,   81,  253,  275,  255,   24,  253,
-
 /*   880 */    98,  255,  117,  118,  119,  183,   22,  194,  103,  104,
+
 /*   860 */   158,  121,  117,  118,  119,  307,  101,  309,  195,   22,
+
 /*   870 */    23,  195,   25,   19,   35,  139,  140,  195,   24,  139,
+
 /*   880 */   140,  208,  195,  118,  109,  183,   22,  122,  103,  104,
 /*   890 */   105,  106,  107,  108,  109,  110,  111,  112,  113,  114,
-
 /*   900 */   151,  194,  270,  152,   22,   23,  194,   25,   19,  202,
-
 /*   910 */   217,  218,   23,  109,  207,  314,  315,  124,  117,  118,
-
 /*   920 */   119,  117,  118,  119,   60,  232,   22,   23,   19,   25,
-
 /*   930 */   303,  304,   43,   44,   45,   22,   47,   48,   49,   50,
-
 /*   940 */    51,   52,   53,   54,   55,   56,   57,   58,  270,  227,
-
 /*   950 */    96,   60,   43,   44,   45,  162,   47,   48,   49,   50,
-
 /*   960 */    51,   52,   53,   54,   55,   56,   57,   58,  114,  112,
-
 /*   970 */   113,  114,  194,   60,  120,  121,  122,  123,  124,  125,
-
 /*   980 */   126,  117,  118,  119,  102,   25,  132,  107,  108,  194,
-
 /*   990 */   194,  227,  103,  104,  105,  106,  107,  108,  109,  110,
-
 /*  1000 */   111,  112,  113,  114,  194,  194,  102,  194,  117,  118,
-
 /*  1010 */   119,  233,  103,  104,  105,  106,  107,  108,  109,  110,
-
 /*  1020 */   111,  112,  113,  114,  194,  194,   19,  194,  217,  218,
-
 /*  1030 */   117,  118,  119,  241,  154,  144,  156,  135,  242,  137,
-
 /*  1040 */   138,  130,   19,  232,  194,  253,   23,  255,  217,  218,
-
 /*  1050 */   217,  218,  242,   16,    7,    8,    9,   25,  261,  262,
-
 /*  1060 */   265,  194,   19,  232,  153,  232,   43,   44,   45,  160,
+
 /*   900 */   304,  305,   77,  230,  127,  232,   67,  195,   19,  195,
+
 /*   910 */   195,  136,   23,   88,   75,   90,  141,  203,   93,  154,
+
 /*   920 */   155,  156,  208,  295,   60,  243,   22,   23,   19,   25,
+
 /*   930 */   218,  219,   43,   44,   45,  100,   47,   48,   49,   50,
+
 /*   940 */    51,   52,   53,   54,   55,   56,   57,   58,  183,  102,
+
 /*   950 */    96,  195,   43,   44,   45,  240,   47,   48,   49,   50,
+
 /*   960 */    51,   52,   53,   54,   55,   56,   57,   58,  114,  134,
+
 /*   970 */   131,  146,   25,  286,  120,  121,  122,  123,  124,  125,
+
 /*   980 */   126,  117,  118,  119,  313,  195,  132,  195,  317,  307,
+
 /*   990 */   195,  309,  103,  104,  105,  106,  107,  108,  109,  110,
+
 /*  1000 */   111,  112,  113,  114,  195,  195,  102,  195,  195,  195,
+
 /*  1010 */   218,  219,  103,  104,  105,  106,  107,  108,  109,  110,
+
 /*  1020 */   111,  112,  113,  114,   77,  233,  195,   60,  218,  219,
+
 /*  1030 */   218,  219,  218,  219,   23,  195,   25,   90,  243,  159,
+
 /*  1040 */    93,  161,   19,  233,  195,  233,   23,  233,   16,  218,
+
 /*  1050 */   219,  195,  243,  212,  213,  214,  262,  263,  218,  219,
+
 /*  1060 */   195,  271,   19,  307,  233,  309,   43,   44,   45,  160,
 /*  1070 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
-
 /*  1080 */    57,   58,  194,  227,  217,  218,   43,   44,   45,  194,
+
 /*  1080 */    57,   58,  195,  218,  219,  118,   43,   44,   45,  240,
 /*  1090 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
-
 /*  1100 */    57,   58,  306,  143,  308,  217,  218,  294,   12,   77,
-
 /*  1110 */    22,   23,  217,  218,  194,   78,  306,   80,  308,  194,
-
 /*  1120 */   232,  254,   90,   27,  117,   93,  103,  104,  105,  106,
-
 /*  1130 */   107,  108,  109,  110,  111,  112,  113,  114,   42,  194,
-
 /*  1140 */    35,  194,  217,  218,  214,  194,  103,  104,  105,  106,
-
 /*  1150 */   107,  108,  109,  110,  111,  112,  113,  114,  194,  239,
-
 /*  1160 */    64,  194,  217,  218,  217,  218,  209,  210,  217,  218,
-
 /*  1170 */    74,  207,   67,   22,  194,   77,   19,  232,  245,  232,
-
 /*  1180 */    75,   24,  312,  232,  217,  218,  316,   25,   90,  256,
-
 /*  1190 */   102,   93,  159,  229,  161,  231,   19,  217,  218,  162,
+
 /*  1100 */    57,   58,  307,  195,  309,  218,  219,  263,   12,  195,
+
 /*  1110 */    78,  267,   80,  112,  113,  114,  307,   22,  309,   24,
+
 /*  1120 */   255,  281,  266,   27,  107,  108,  103,  104,  105,  106,
+
 /*  1130 */   107,  108,  109,  110,  111,  112,  113,  114,   42,  195,
+
 /*  1140 */    11,   22,  255,   24,  195,  195,  103,  104,  105,  106,
+
 /*  1150 */   107,  108,  109,  110,  111,  112,  113,  114,   19,  195,
+
 /*  1160 */    64,  195,  218,  219,  195,  313,  195,  218,  219,  317,
+
 /*  1170 */    74,  154,  195,  156,  195,  195,   19,  233,   23,   60,
+
 /*  1180 */    25,   24,  218,  219,  218,  219,  195,  218,  219,  218,
+
 /*  1190 */   219,  128,  129,  130,  162,  263,   19,  218,  219,  267,
 /*  1200 */    43,   44,   45,  160,   47,   48,   49,   50,   51,   52,
-
 /*  1210 */    53,   54,   55,   56,   57,   58,   19,   23,  288,   25,
-
 /*  1220 */    43,   44,   45,  293,   47,   48,   49,   50,   51,   52,
-
 /*  1230 */    53,   54,   55,   56,   57,   58,  131,   22,  275,   24,
-
 /*  1240 */    43,   44,   45,  194,   47,   48,   49,   50,   51,   52,
-
 /*  1250 */    53,   54,   55,   56,   57,   58,  194,  194,  107,  108,
+
 /*  1210 */    53,   54,   55,   56,   57,   58,   19,  240,  228,  255,
+
 /*  1220 */    43,   44,   45,   25,   47,   48,   49,   50,   51,   52,
+
 /*  1230 */    53,   54,   55,   56,   57,   58,  135,  118,  137,  138,
+
 /*  1240 */    43,   44,   45,   22,   47,   48,   49,   50,   51,   52,
+
 /*  1250 */    53,   54,   55,   56,   57,   58,  117,  266,  129,  130,
 /*  1260 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
-
 /*  1270 */   113,  114,  194,   25,  194,   60,  194,  314,  315,  194,
+
 /*  1270 */   113,  114,  195,  195,  119,  295,  195,  206,  195,  195,
 /*  1280 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
-
 /*  1290 */   113,  114,   19,  194,  194,  217,  218,  217,  218,   25,
+
 /*  1290 */   113,  114,  195,  195,  195,  218,  219,  195,  195,  144,
 /*  1300 */   103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
-
 /*  1310 */   113,  114,  150,  119,  265,  312,   67,  217,  218,  316,
-
 /*  1320 */    19,  239,  194,  194,  128,  129,  130,  265,  265,  209,
-
 /*  1330 */   210,   31,  254,  118,  254,   86,   60,  194,  144,   39,
-
 /*  1340 */    19,  130,  275,  312,   95,   44,   45,  316,   47,   48,
+
 /*  1310 */   113,  114,  241,  242,   67,  218,  219,  218,  219,  146,
+
 /*  1320 */    19,  218,  219,  240,  215,  254,  136,  256,  107,  108,
+
 /*  1330 */   195,  141,  255,   86,  128,  129,  130,  195,  165,  195,
+
 /*  1340 */    19,  143,   95,  272,   25,   44,   45,  266,   47,   48,
 /*  1350 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   58,
-
 /*  1360 */   217,  218,   24,  194,  153,   12,   45,  119,   47,   48,
+
 /*  1360 */   218,  219,  218,  219,  195,   12,   45,  195,   47,   48,
 /*  1370 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   58,
-
 /*  1380 */    27,  314,  315,   22,  312,   24,  217,  218,  316,  116,
-
 /*  1390 */   117,   22,  144,   25,  118,   42,  147,  194,   60,   19,
-
 /*  1400 */    20,  127,   22,  194,  103,  104,  105,  106,  107,  108,
-
 /*  1410 */   109,  110,  111,  112,  113,  114,   36,   64,  145,  194,
-
 /*  1420 */   217,  218,  194,   54,  103,  104,  105,  106,  107,  108,
-
 /*  1430 */   109,  110,  111,  112,  113,  114,  194,   22,  310,   25,
-
 /*  1440 */    60,  194,  217,  218,  194,  217,  218,  194,  260,  194,
-
 /*  1450 */   301,  302,   72,  262,  262,  194,  118,  266,  266,  217,
-
 /*  1460 */   218,  194,   82,  245,  217,  218,  194,  217,  218,  194,
-
 /*  1470 */   217,  218,  217,  218,  256,   60,   24,  194,  217,  218,
-
 /*  1480 */   194,  101,  194,  245,  217,  218,  194,  107,  108,  217,
-
 /*  1490 */   218,   22,  217,  218,  256,  115,  245,  117,  118,  119,
-
 /*  1500 */   217,  218,  122,  217,  218,  217,  218,  256,   22,  217,
-
 /*  1510 */   218,  116,  258,  259,  146,   19,   20,  194,   22,  139,
-
 /*  1520 */   140,  150,  151,  136,   23,  194,   25,  194,  141,  194,
-
 /*  1530 */   194,   62,   36,  118,  154,  155,  156,  157,  158,  100,
-
 /*  1540 */   145,  194,  154,  194,  156,   49,  194,   23,  194,   25,
-
 /*  1550 */   217,  218,  217,  218,  194,  257,   60,  143,  194,   60,
-
 /*  1560 */   194,  121,  122,  183,  217,  218,  217,  218,   72,  217,
-
 /*  1570 */   218,  217,  218,  134,   23,  194,   25,  217,  218,    7,
-
 /*  1580 */     8,  321,   86,  217,  218,  194,  122,   91,   19,   20,
-
 /*  1590 */    23,   22,   25,   23,  142,   25,  132,  101,  217,  218,
-
 /*  1600 */   194,  194,  194,  107,  108,   36,  194,  194,  217,  218,
-
 /*  1610 */   194,  115,  194,  117,  118,  119,  194,  118,  122,  194,
-
 /*  1620 */    23,  194,   25,  217,  218,  217,  218,  194,  142,   60,
-
 /*  1630 */   217,  218,  194,  217,  218,  217,  218,   84,   85,  217,
-
 /*  1640 */   218,   72,  217,  218,  217,  218,   60,   23,   60,   25,
-
 /*  1650 */   154,  155,  156,  157,  158,   86,  154,  194,  156,  194,
-
 /*  1660 */    91,   19,   20,   23,   22,   25,  194,   23,  194,   25,
-
 /*  1670 */   101,   23,  194,   25,  194,  194,  107,  108,   36,  183,
-
 /*  1680 */   217,  218,  217,  218,  115,  194,  117,  118,  119,  217,
-
 /*  1690 */   218,  122,  194,  237,  194,  217,  218,  217,  218,  194,
-
 /*  1700 */   194,   23,   60,   25,  118,   23,  118,   25,  217,  218,
-
 /*  1710 */    23,  194,   25,  194,   72,  217,  218,  217,  218,   23,
-
 /*  1720 */   194,   25,  194,  154,  155,  156,  157,  158,   86,   23,
-
 /*  1730 */   194,   25,  194,   91,  217,  218,  217,  218,  194,  194,
-
 /*  1740 */   194,  194,  194,  101,  194,  217,  218,  290,  194,  107,
-
 /*  1750 */   108,  194,  183,  217,  218,  194,  194,  115,  194,  117,
-
 /*  1760 */   118,  119,  194,  243,  122,  194,  289,  194,  194,  194,
-
 /*  1770 */   194,  257,  257,  257,  244,  257,  192,  273,  215,  269,
-
 /*  1780 */   246,  299,  269,  295,  247,  273,  247,  246,  295,  230,
-
 /*  1790 */   261,  226,  261,  261,  273,  273,  154,  155,  156,  157,
-
 /*  1800 */   158,    0,    1,    2,  221,  220,    5,  220,  250,  220,
-
 /*  1810 */   261,   10,   11,   12,   13,   14,  250,  282,   17,  197,
-
 /*  1820 */    61,   19,   20,  246,   22,  183,  244,  142,  201,  201,
-
 /*  1830 */    38,   30,  299,   32,  201,  152,   22,  151,   36,  299,
-
 /*  1840 */    43,   40,  235,   18,  238,  285,  238,  238,  296,  238,
-
 /*  1850 */   201,  296,  274,  272,   18,  200,  235,  150,  235,  247,
-
 /*  1860 */   247,  247,   60,  247,  274,  274,  272,  201,  200,  159,
-
 /*  1870 */    63,  292,   71,  201,   72,  200,   22,  201,  222,  200,
-
 /*  1880 */    79,  201,  222,   82,  291,  116,  219,   65,  200,  219,
-
 /*  1890 */   219,  228,   22,  127,  225,  166,  222,   24,  225,  114,
-
 /*  1900 */    99,  284,  221,  101,  284,  228,  307,  315,  219,  107,
-
 /*  1910 */   108,  219,  219,  219,  201,   92,  320,  115,  320,  117,
-
 /*  1920 */   118,  119,  222,   83,  122,  267,  267,  149,  146,   19,
-
 /*  1930 */    20,   22,   22,  279,  250,  134,  201,  148,  159,  249,
-
 /*  1940 */   139,  140,  251,  141,   25,  281,   36,  147,  251,  248,
-
 /*  1950 */   247,  203,   13,  195,    6,  195,  154,  155,  156,  157,
-
 /*  1960 */   158,  193,  305,  193,  163,  193,  305,  302,  214,  208,
-
 /*  1970 */    60,  214,  208,  223,  223,    4,  214,  214,    3,   22,
-
 /*  1980 */   215,  214,   72,  208,  164,  183,  215,   15,   23,   16,
-
 /*  1990 */    23,  140,  131,  152,   25,  143,   20,   16,   24,    1,
-
 /*  2000 */   145,  143,  131,  131,   62,   37,   54,   54,  152,   54,
-
 /*  2010 */    54,  101,  131,  117,   34,    1,  142,  107,  108,   22,
-
 /*  2020 */     5,  116,  162,   69,   25,  115,   76,  117,  118,  119,
-
 /*  2030 */     1,    2,  122,   69,    5,   41,  142,  116,   20,   10,
+
 /*  1380 */    27,   23,    7,    8,    9,  210,  211,  218,  219,  116,
+
 /*  1390 */   218,  219,  228,   16,  147,   42,  195,  295,  195,   19,
+
 /*  1400 */    20,  266,   22,  294,  103,  104,  105,  106,  107,  108,
+
 /*  1410 */   109,  110,  111,  112,  113,  114,   36,   64,  145,  218,
+
 /*  1420 */   219,  218,  219,  195,  103,  104,  105,  106,  107,  108,
+
 /*  1430 */   109,  110,  111,  112,  113,  114,  195,  154,  119,  156,
+
 /*  1440 */    60,  189,  190,  191,  192,  195,  218,  219,  195,  197,
+
 /*  1450 */   195,  199,   72,  195,   19,   78,  195,   80,  206,  218,
+
 /*  1460 */   219,  195,   82,  144,  210,  211,  195,   15,  218,  219,
+
 /*  1470 */    47,  218,  219,  218,  219,  259,  260,  195,  261,  218,
+
 /*  1480 */   219,  101,  302,  303,  218,  219,  195,  107,  108,  218,
+
 /*  1490 */   219,  150,  151,  241,  242,  115,   25,  117,  118,  119,
+
 /*  1500 */   218,  219,  122,  195,  146,  195,  254,  195,  256,  218,
+
 /*  1510 */   219,  246,   25,   61,  246,   19,   20,  195,   22,  139,
+
 /*  1520 */   140,  269,  257,  195,  266,  257,  218,  219,  218,  219,
+
 /*  1530 */   218,  219,   36,  246,  154,  155,  156,  157,  158,  116,
+
 /*  1540 */   218,  219,  195,   22,  257,   49,  218,  219,   23,  195,
+
 /*  1550 */    25,  195,  117,  301,  195,   25,   60,  195,  195,   23,
+
 /*  1560 */   195,   25,  195,  183,   24,  218,  219,  130,   72,  195,
+
 /*  1570 */    22,  195,  218,  219,  218,  219,  195,  218,  219,  195,
+
 /*  1580 */   218,  219,   86,  218,  219,  218,  219,   91,   19,   20,
+
 /*  1590 */   153,   22,  218,  219,  218,  219,  195,  101,  195,  218,
+
 /*  1600 */   219,  195,  195,  107,  108,   36,   23,  195,   25,  195,
+
 /*  1610 */    62,  115,  195,  117,  118,  119,  195,  146,  122,  218,
+
 /*  1620 */   219,  218,  219,  195,  218,  219,   19,   60,  122,   60,
+
 /*  1630 */   218,  219,  218,  219,  195,  218,  219,  150,  132,  218,
+
 /*  1640 */   219,   72,  195,   23,  195,   25,  218,  219,  195,   60,
+
 /*  1650 */   154,  155,  156,  157,  158,   86,   23,  195,   25,  195,
+
 /*  1660 */    91,   19,   20,  142,   22,  218,  219,  218,  219,  130,
+
 /*  1670 */   101,  218,  219,  143,  121,  122,  107,  108,   36,  183,
+
 /*  1680 */   218,  219,  142,   60,  115,  118,  117,  118,  119,    7,
+
 /*  1690 */     8,  122,  153,   23,   23,   25,   25,   23,   23,   25,
+
 /*  1700 */    25,   23,   60,   25,   23,   98,   25,  118,   84,   85,
+
 /*  1710 */    23,   23,   25,   25,   72,  154,   23,  156,   25,   23,
+
 /*  1720 */   228,   25,  195,  154,  155,  156,  157,  158,   86,  195,
+
 /*  1730 */   195,  258,  195,   91,  291,  322,  195,  195,  195,  195,
+
 /*  1740 */   195,  118,  195,  101,  195,  195,  195,  195,  238,  107,
+
 /*  1750 */   108,  195,  183,  195,  195,  195,  290,  115,  195,  117,
+
 /*  1760 */   118,  119,  244,  195,  122,  195,  195,  195,  195,  195,
+
 /*  1770 */   195,  258,  258,  258,  258,  193,  245,  300,  216,  274,
+
 /*  1780 */   247,  270,  270,  274,  296,  296,  248,  222,  262,  198,
+
 /*  1790 */   262,  274,   61,  274,  248,  231,  154,  155,  156,  157,
+
 /*  1800 */   158,    0,    1,    2,  247,  227,    5,  221,  221,  221,
+
 /*  1810 */   142,   10,   11,   12,   13,   14,  262,  262,   17,  202,
+
 /*  1820 */   300,   19,   20,  300,   22,  183,  247,  251,  251,  245,
+
 /*  1830 */   202,   30,   38,   32,  202,  152,  151,   22,   36,   43,
+
 /*  1840 */   236,   40,   18,  202,  239,  239,   18,  239,  239,  283,
+
 /*  1850 */   201,  150,  236,  202,  236,  201,  159,  202,  248,  248,
+
 /*  1860 */   248,  248,   60,   63,  201,  275,  273,  275,  273,  275,
+
 /*  1870 */    22,  286,   71,  223,   72,  202,  223,  297,  297,  202,
+
 /*  1880 */    79,  201,  116,   82,  220,  201,  220,  220,   65,  293,
+
 /*  1890 */   292,  229,   22,  166,  127,  226,   24,  114,  226,  223,
+
 /*  1900 */    99,  222,  202,  101,  285,   92,  220,  308,   83,  107,
+
 /*  1910 */   108,  220,  220,  316,  220,  285,  268,  115,  229,  117,
+
 /*  1920 */   118,  119,  223,  321,  122,  268,  149,  146,   22,   19,
+
 /*  1930 */    20,  202,   22,  159,  282,  134,  321,  148,  280,  147,
+
 /*  1940 */   139,  140,  252,  141,   25,  204,   36,  252,   13,  251,
+
 /*  1950 */   196,  248,  250,  249,  196,    6,  154,  155,  156,  157,
+
 /*  1960 */   158,  209,  194,  194,  163,  194,  306,  306,  303,  224,
+
 /*  1970 */    60,  215,  215,  209,  215,  215,  215,  224,  216,  216,
+
 /*  1980 */     4,  209,   72,    3,   22,  183,  164,   15,   23,   16,
+
 /*  1990 */    23,  140,  152,  131,   25,   24,  143,   20,   16,  145,
+
 /*  2000 */     1,  143,  131,   62,  131,   37,   54,  152,   54,   54,
+
 /*  2010 */    54,  101,  131,  117,    1,   34,  142,  107,  108,    5,
+
 /*  2020 */    22,  116,  162,   76,   41,  115,   69,  117,  118,  119,
+
 /*  2030 */     1,    2,  122,   25,    5,   69,  142,  116,   20,   10,
 /*  2040 */    11,   12,   13,   14,   24,   19,   17,  132,    5,  126,
 /*  2050 */    22,  141,   68,   10,   11,   12,   13,   14,   22,   30,
 /*  2060 */    17,   32,   22,   22,  154,  155,  156,  157,  158,   40,
 /*  2070 */    23,   68,   60,   30,   24,   32,   97,   28,   22,   68,
 /*  2080 */    23,   37,   34,   40,  150,   22,   25,   23,   23,   23,
-
 /*  2090 */    22,   98,   23,  183,   23,  117,   34,   22,   25,   89,
-
 /*  2100 */    71,  142,  144,   76,   34,   23,   34,   76,   79,   87,
-
 /*  2110 */    34,   82,   34,   94,   71,   34,   22,   24,   44,   34,
-
 /*  2120 */    25,   25,   79,   23,   23,   82,  143,   23,   99,  143,
-
 /*  2130 */    23,   22,   11,   25,   23,   25,   22,   22,   22,    1,
-
 /*  2140 */    23,   23,   99,  136,   22,   22,  142,  142,  142,   25,
-
 /*  2150 */    25,   23,   15,    1,  322,  322,  322,  322,  322,  322,
-
 /*  2160 */   322,  322,  322,  134,  322,  322,  322,  322,  139,  140,
-
 /*  2170 */   322,  322,  322,  322,  322,  322,  322,  134,  322,  322,
-
 /*  2180 */   322,  322,  139,  140,  322,  322,  322,  322,  322,  322,
-
 /*  2190 */   322,  322,  163,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2200 */   322,  322,  322,  322,  322,  322,  163,  322,  322,  322,
-
 /*  2210 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2220 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2230 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2240 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2250 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2260 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2270 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2280 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2290 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2300 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2310 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2320 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2330 */   322,  322,  322,  322,  322,  322,  322,  322,  322,  322,
-
 /*  2340 */   186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-
 /*  2350 */   186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-
 /*  2360 */   186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-
 /*  2370 */   186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-
 /*  2380 */   186,  186,  186,  186,  186,  186,  186,  186,  186,  186,
-
 /*  2390 */   186,  186,  186,
+
 /*  2090 */    22,   98,  142,  183,   23,   23,   34,   22,   25,   89,
+
 /*  2100 */    71,   34,  117,  144,   34,   22,   76,   76,   79,   87,
+
 /*  2110 */    34,   82,   34,   44,   71,   94,   34,   23,   25,   24,
+
 /*  2120 */    34,   25,   79,   23,   23,   82,   23,   23,   99,  143,
+
 /*  2130 */   143,   22,   25,   25,   23,   22,   11,   22,   22,   25,
+
 /*  2140 */    23,   23,   99,   22,   22,  136,  142,  142,  142,   25,
+
 /*  2150 */    23,   15,    1,    1,  323,  323,  323,  323,  323,  323,
+
 /*  2160 */   323,  323,  323,  134,  323,  323,  323,  323,  139,  140,
+
 /*  2170 */   323,  323,  323,  323,  323,  323,  323,  134,  323,  323,
+
 /*  2180 */   323,  323,  139,  140,  323,  323,  323,  323,  323,  323,
+
 /*  2190 */   323,  323,  163,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2200 */   323,  323,  323,  323,  323,  323,  163,  323,  323,  323,
+
 /*  2210 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2220 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2230 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2240 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2250 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2260 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2270 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2280 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2290 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2300 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2310 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2320 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2330 */   323,  323,  323,  323,  323,  323,  323,  323,  323,  323,
+
 /*  2340 */   323,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
 /*  2350 */   187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
 /*  2360 */   187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
 /*  2370 */   187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
 /*  2380 */   187,  187,  187,  187,  187,  187,  187,  187,  187,  187,
+
 /*  2390 */   187,  187,  187,  187,
};
#define YY_SHIFT_COUNT    (582)
#define YY_SHIFT_MIN      (0)
#define YY_SHIFT_MAX      (2152)
static const unsigned short int yy_shift_ofst[] = {
-
 /*     0 */  2029, 1801, 2043, 1380, 1380,   33,  391, 1496, 1569, 1642,
-
 /*    10 */   702,  702,  702,  193,   33,   33,   33,   33,   33,    0,
+
 /*     0 */  2029, 1801, 2043, 1380, 1380,  318,  271, 1496, 1569, 1642,
+
 /*    10 */   702,  702,  702,  740,  318,  318,  318,  318,  318,    0,
 /*    20 */     0,  216, 1177,  702,  702,  702,  702,  702,  702,  702,
-
 /*    30 */   702,  702,  702,  702,  702,  702,  702,  702,  406,  406,
-
 /*    40 */   111,  111,  218,  447,  547,  598,  598,  260,  260,  260,
-
 /*    50 */   260,   40,  112,  320,  340,  445,  489,  593,  637,  741,
+
 /*    30 */   702,  702,  702,  702,  702,  702,  702,  702,  503,  503,
+
 /*    40 */   111,  111,  217,  287,  348,  610,  610,  736,  736,  736,
+
 /*    50 */   736,   40,  112,  320,  340,  445,  489,  593,  637,  741,
 /*    60 */   785,  889,  909, 1023, 1043, 1157, 1177, 1177, 1177, 1177,
 /*    70 */  1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
 /*    80 */  1177, 1177, 1177, 1177, 1197, 1177, 1301, 1321, 1321,  554,
@@ -174876,97 +175310,97 @@ static const unsigned short int yy_shift_ofst[] = {
 /*   120 */   702,  702,  702,  702,  702,  702,  702,  702,  702,  702,
 /*   130 */   702,  702,  702,  702,  702,  702,  702,  702,  702,  702,
 /*   140 */   702,  702,  138,  198,  198,  198,  198,  198,  198,  198,
-
 /*   150 */   183,   99,  236,  292,  598,  793,  167,  598,  598,  880,
-
 /*   160 */   880,  598,  857,  150,  195,  195,  195,  264,  113,  113,
-
 /*   170 */  2207, 2207,  854,  854,  854,  751,  765,  765,  765,  765,
-
 /*   180 */  1096, 1096,  725,  292,  882,  904,  598,  598,  598,  598,
-
 /*   190 */   598,  598,  598,  598,  598,  598,  598,  598,  598,  598,
-
 /*   200 */   598,  598,  598,  598,  598, 1273, 1032, 1032,  598,  147,
-
 /*   210 */  1098, 1098,  603,  603, 1276, 1276,  363, 2207, 2207, 2207,
-
 /*   220 */  2207, 2207, 2207, 2207,  469,  617,  617,  801,  336,  461,
-
 /*   230 */   804,  864,  615,  891,  913,  598,  598,  598,  598,  598,
-
 /*   240 */   598,  598,  598,  598,  598,  653,  598,  598,  598,  598,
-
 /*   250 */   598,  598,  598,  598,  598,  598,  598,  598, 1105, 1105,
-
 /*   260 */  1105,  598,  598,  598, 1194,  598,  598,  598, 1215, 1249,
-
 /*   270 */   598, 1353,  598,  598,  598,  598,  598,  598,  598,  598,
-
 /*   280 */   677,  449,  902, 1338, 1338, 1338, 1338, 1248,  902,  902,
-
 /*   290 */   326, 1151, 1047,  755,  749, 1371,  960, 1371, 1007, 1162,
-
 /*   300 */   749,  749, 1162,  749,  960, 1007, 1274,  738,  215, 1300,
-
 /*   310 */  1300, 1300, 1395, 1395, 1395, 1395, 1368, 1368, 1033, 1414,
-
 /*   320 */  1387, 1361, 1759, 1759, 1685, 1685, 1792, 1792, 1685, 1683,
-
 /*   330 */  1686, 1814, 1797, 1825, 1825, 1825, 1825, 1685, 1836, 1707,
-
 /*   340 */  1686, 1686, 1707, 1814, 1797, 1707, 1797, 1707, 1685, 1836,
-
 /*   350 */  1710, 1807, 1685, 1836, 1854, 1685, 1836, 1685, 1836, 1854,
-
 /*   360 */  1769, 1769, 1769, 1822, 1870, 1870, 1854, 1769, 1766, 1769,
-
 /*   370 */  1822, 1769, 1769, 1729, 1873, 1785, 1785, 1854, 1685, 1823,
-
 /*   380 */  1823, 1840, 1840, 1778, 1782, 1909, 1685, 1779, 1778, 1789,
-
 /*   390 */  1800, 1707, 1919, 1939, 1939, 1948, 1948, 1948, 2207, 2207,
+
 /*   150 */   183,   99,  169,  549,  610,  151,  542,  610,  610, 1017,
+
 /*   160 */  1017,  610, 1001,  350,  464,  464,  464,  586,    1,    1,
+
 /*   170 */  2207, 2207,  854,  854,  854,  465,  694,  694,  694,  694,
+
 /*   180 */  1096, 1096,  825,  549,  847,  904,  610,  610,  610,  610,
+
 /*   190 */   610,  610,  610,  610,  610,  610,  610,  610,  610,  610,
+
 /*   200 */   610,  610,  610,  610,  610,  488,  947,  947,  610, 1129,
+
 /*   210 */   495,  495, 1139, 1139,  967,  967, 1173, 2207, 2207, 2207,
+
 /*   220 */  2207, 2207, 2207, 2207,  617,  765,  765,  697,  444,  708,
+
 /*   230 */   660,  745,  510,  663,  864,  610,  610,  610,  610,  610,
+
 /*   240 */   610,  610,  610,  610,  610,  188,  610,  610,  610,  610,
+
 /*   250 */   610,  610,  610,  610,  610,  610,  610,  610,  839,  839,
+
 /*   260 */   839,  610,  610,  610, 1155,  610,  610,  610, 1119, 1247,
+
 /*   270 */   610, 1353,  610,  610,  610,  610,  610,  610,  610,  610,
+
 /*   280 */  1063,  494, 1101,  291,  291,  291,  291, 1319, 1101, 1101,
+
 /*   290 */   775, 1221, 1375, 1452,  667, 1341, 1198, 1341, 1435, 1487,
+
 /*   300 */   667,  667, 1487,  667, 1198, 1435,  777, 1011, 1423,  584,
+
 /*   310 */   584,  584, 1273, 1273, 1273, 1273, 1471, 1471,  880, 1530,
+
 /*   320 */  1190, 1095, 1731, 1731, 1668, 1668, 1794, 1794, 1668, 1683,
+
 /*   330 */  1685, 1815, 1796, 1824, 1824, 1824, 1824, 1668, 1828, 1701,
+
 /*   340 */  1685, 1685, 1701, 1815, 1796, 1701, 1796, 1701, 1668, 1828,
+
 /*   350 */  1697, 1800, 1668, 1828, 1848, 1668, 1828, 1668, 1828, 1848,
+
 /*   360 */  1766, 1766, 1766, 1823, 1870, 1870, 1848, 1766, 1767, 1766,
+
 /*   370 */  1823, 1766, 1766, 1727, 1872, 1783, 1783, 1848, 1668, 1813,
+
 /*   380 */  1813, 1825, 1825, 1777, 1781, 1906, 1668, 1774, 1777, 1789,
+
 /*   390 */  1792, 1701, 1919, 1935, 1935, 1949, 1949, 1949, 2207, 2207,
 /*   400 */  2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207,
-
 /*   410 */  2207, 2207, 2207,   69, 1037,   79, 1088,  651, 1196, 1415,
-
 /*   420 */  1501, 1439, 1369, 1452,  911, 1211, 1524, 1469, 1551, 1567,
-
 /*   430 */  1570, 1624, 1640, 1644, 1499, 1440, 1572, 1464, 1597,  275,
-
 /*   440 */   782, 1586, 1648, 1678, 1553, 1682, 1687, 1388, 1502, 1696,
-
 /*   450 */  1706, 1588, 1486, 1971, 1975, 1957, 1820, 1972, 1973, 1965,
-
 /*   460 */  1967, 1851, 1841, 1861, 1969, 1969, 1974, 1852, 1976, 1855,
-
 /*   470 */  1981, 1998, 1858, 1871, 1969, 1872, 1942, 1968, 1969, 1856,
-
 /*   480 */  1952, 1953, 1955, 1956, 1881, 1896, 1980, 1874, 2014, 2015,
-
 /*   490 */  1997, 1905, 1860, 1954, 1999, 1964, 1950, 1994, 1894, 1921,
+
 /*   410 */  2207, 2207, 2207,   69, 1032,   79,  357, 1377, 1206,  400,
+
 /*   420 */  1525,  835,  332, 1540, 1437, 1539, 1536, 1548, 1583, 1620,
+
 /*   430 */  1633, 1670, 1671, 1674, 1567, 1553, 1682, 1506, 1675, 1358,
+
 /*   440 */  1607, 1589, 1678, 1681, 1624, 1687, 1688, 1283, 1561, 1693,
+
 /*   450 */  1696, 1623, 1521, 1976, 1980, 1962, 1822, 1972, 1973, 1965,
+
 /*   460 */  1967, 1851, 1840, 1862, 1969, 1969, 1971, 1853, 1977, 1854,
+
 /*   470 */  1982, 1999, 1858, 1871, 1969, 1873, 1941, 1968, 1969, 1855,
+
 /*   480 */  1952, 1954, 1955, 1956, 1881, 1896, 1981, 1874, 2013, 2014,
+
 /*   490 */  1998, 1905, 1860, 1957, 2008, 1966, 1947, 1983, 1894, 1921,
 /*   500 */  2020, 2018, 2026, 1915, 1923, 2028, 1984, 2036, 2040, 2047,
 /*   510 */  2041, 2003, 2012, 2050, 1979, 2049, 2056, 2011, 2044, 2057,
-
 /*   520 */  2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1959,
-
 /*   530 */  2069, 2071, 1978, 2062, 2075, 1958, 2073, 2070, 2072, 2076,
-
 /*   540 */  2078, 2010, 2027, 2022, 2074, 2031, 2019, 2081, 2082, 2094,
-
 /*   550 */  2093, 2095, 2096, 2085, 1983, 1986, 2100, 2073, 2101, 2104,
-
 /*   560 */  2107, 2109, 2108, 2110, 2111, 2114, 2121, 2115, 2116, 2117,
-
 /*   570 */  2118, 2122, 2123, 2124, 2007, 2004, 2005, 2006, 2125, 2128,
-
 /*   580 */  2137, 2138, 2152,
+
 /*   520 */  2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1950,
+
 /*   530 */  2071, 2072, 1985, 2062, 2075, 1959, 2073, 2067, 2070, 2076,
+
 /*   540 */  2078, 2010, 2030, 2022, 2069, 2031, 2021, 2082, 2094, 2083,
+
 /*   550 */  2095, 2093, 2096, 2086, 1986, 1987, 2100, 2073, 2101, 2103,
+
 /*   560 */  2104, 2109, 2107, 2108, 2111, 2113, 2125, 2115, 2116, 2117,
+
 /*   570 */  2118, 2121, 2122, 2114, 2009, 2004, 2005, 2006, 2124, 2127,
+
 /*   580 */  2136, 2151, 2152,
};
#define YY_REDUCE_COUNT (412)
-
#define YY_REDUCE_MIN   (-276)
-
#define YY_REDUCE_MAX   (1775)
+
#define YY_REDUCE_MIN   (-277)
+
#define YY_REDUCE_MAX   (1772)
static const short yy_reduce_ofst[] = {
-
 /*     0 */   -66,  217,  -63, -177, -180,  161,  364,   64, -183,  162,
-
 /*    10 */   223,  367,  414, -173,  473,  514,  525,  622,  626, -207,
-
 /*    20 */   351, -276,  -38,  693,  811,  831,  833,  888, -188,  945,
-
 /*    30 */   947,  416,  558,  951,  867,  287, 1078, 1080, -186,  224,
-
 /*    40 */  -132,   42,  964,  269,  417,  796,  810, -237, -231, -237,
-
 /*    50 */  -231,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-
 /*    60 */   -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-
 /*    70 */   -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-
 /*    80 */   -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  895,
-
 /*    90 */   925,  967,  980, 1100, 1143, 1169, 1203, 1225, 1228, 1242,
-
 /*   100 */  1247, 1250, 1253, 1255, 1261, 1267, 1272, 1275, 1283, 1286,
-
 /*   110 */  1288, 1292, 1333, 1335, 1347, 1349, 1352, 1354, 1360, 1366,
-
 /*   120 */  1381, 1391, 1406, 1408, 1413, 1416, 1418, 1422, 1425, 1427,
-
 /*   130 */  1463, 1465, 1472, 1478, 1480, 1491, 1498, 1500, 1517, 1519,
-
 /*   140 */  1528, 1536,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-
 /*   150 */   -45,  -45,  -45,  312, -158,  285, -219,    9,  166,  370,
-
 /*   160 */   545,  707,  -45,  930,  601,  963, 1067,  792,  -45,  -45,
-
 /*   170 */   -45,  -45, -204, -204, -204,  369, -171, -129,  632,  678,
-
 /*   180 */   202,  352, -270,  412,  627,  627,   -9,  122,  415,  419,
-
 /*   190 */   -56,  248,  583,  920,    6,  261,  459,  795, 1049,  813,
-
 /*   200 */  1062, 1082, -161,  778, 1063,  797,  870, 1003, 1128,  443,
-
 /*   210 */  1031, 1072, 1191, 1192,  957, 1120,  105, 1149,  523,  933,
-
 /*   220 */  1218, 1238, 1254, 1251, -138,   96,  117,  146,  181,  277,
-
 /*   230 */   280,  421,  480,  712,  830,  850, 1085, 1099, 1129, 1209,
-
 /*   240 */  1323, 1331, 1336, 1364, 1407,  368, 1412, 1433, 1438, 1474,
-
 /*   250 */  1481, 1505, 1506, 1526, 1538, 1544, 1545, 1546,  722,  764,
-
 /*   260 */   856, 1547, 1548, 1550, 1188, 1554, 1557, 1561, 1298, 1260,
-
 /*   270 */  1562, 1456, 1564,  280, 1568, 1571, 1573, 1574, 1575, 1576,
-
 /*   280 */  1457, 1477, 1520, 1514, 1515, 1516, 1518, 1188, 1520, 1520,
-
 /*   290 */  1530, 1563, 1584, 1482, 1504, 1510, 1534, 1513, 1488, 1537,
-
 /*   300 */  1512, 1521, 1539, 1522, 1541, 1493, 1583, 1559, 1565, 1585,
-
 /*   310 */  1587, 1589, 1529, 1531, 1532, 1549, 1558, 1566, 1535, 1577,
-
 /*   320 */  1582, 1622, 1533, 1540, 1627, 1628, 1552, 1555, 1633, 1560,
-
 /*   330 */  1578, 1581, 1607, 1606, 1608, 1609, 1611, 1649, 1655, 1612,
-
 /*   340 */  1590, 1591, 1613, 1594, 1621, 1614, 1623, 1616, 1666, 1668,
-
 /*   350 */  1579, 1593, 1672, 1675, 1656, 1676, 1679, 1680, 1688, 1660,
-
 /*   360 */  1667, 1670, 1671, 1663, 1669, 1673, 1674, 1689, 1681, 1692,
-
 /*   370 */  1677, 1693, 1694, 1592, 1599, 1617, 1620, 1700, 1713, 1596,
-
 /*   380 */  1598, 1658, 1659, 1691, 1684, 1654, 1735, 1664, 1697, 1690,
-
 /*   390 */  1701, 1703, 1748, 1758, 1760, 1768, 1770, 1772, 1657, 1661,
-
 /*   400 */  1665, 1761, 1754, 1757, 1762, 1763, 1764, 1750, 1751, 1765,
-
 /*   410 */  1771, 1767, 1775,
+
 /*     0 */   -67, 1252,  -64, -178, -181,  160, 1071,  143, -184,  137,
+
 /*    10 */   218,  220,  222, -174,  229,  268,  272,  275,  324, -208,
+
 /*    20 */   242, -277,  -39,   81,  537,  792,  810,  812, -189,  814,
+
 /*    30 */   831,  163,  865,  944,  887,  840,  964, 1077, -187,  292,
+
 /*    40 */  -133,  274,  673,  558,  682,  795,  809, -238, -232, -238,
+
 /*    50 */  -232,  329,  329,  329,  329,  329,  329,  329,  329,  329,
+
 /*    60 */   329,  329,  329,  329,  329,  329,  329,  329,  329,  329,
+
 /*    70 */   329,  329,  329,  329,  329,  329,  329,  329,  329,  329,
+
 /*    80 */   329,  329,  329,  329,  329,  329,  329,  329,  329,  557,
+
 /*    90 */   712,  949,  966,  969,  971,  979, 1097, 1099, 1103, 1142,
+
 /*   100 */  1144, 1169, 1172, 1201, 1203, 1228, 1241, 1250, 1253, 1255,
+
 /*   110 */  1261, 1266, 1271, 1282, 1291, 1308, 1310, 1312, 1322, 1328,
+
 /*   120 */  1347, 1354, 1356, 1359, 1362, 1365, 1367, 1374, 1376, 1381,
+
 /*   130 */  1401, 1403, 1406, 1412, 1414, 1417, 1421, 1428, 1447, 1449,
+
 /*   140 */  1453, 1462,  329,  329,  329,  329,  329,  329,  329,  329,
+
 /*   150 */   329,  329,  329,  -22, -159,  475, -220,  756,   38,  501,
+
 /*   160 */   841,  714,  329,  118,  337,  349,  363,  -56,  329,  329,
+
 /*   170 */   329,  329, -205, -205, -205,  687, -172, -130,  -57,  790,
+
 /*   180 */   397,  528, -271,  136,  596,  596,   90,  316,  522,  541,
+
 /*   190 */   -37,  715,  849,  977,  628,  856,  980,  991, 1081, 1102,
+
 /*   200 */  1135, 1083, -162,  208, 1258,  794,  -86,  159,   41, 1109,
+
 /*   210 */   671,  852,  844,  932, 1175, 1254,  480, 1180,  100,  258,
+
 /*   220 */  1265, 1268, 1216, 1287, -139,  317,  344,   63,  339,  423,
+
 /*   230 */   563,  636,  676,  813,  908,  914,  950, 1078, 1084, 1098,
+
 /*   240 */  1363, 1384, 1407, 1439, 1464,  411, 1527, 1534, 1535, 1537,
+
 /*   250 */  1541, 1542, 1543, 1544, 1545, 1547, 1549, 1550,  990, 1164,
+
 /*   260 */  1492, 1551, 1552, 1556, 1217, 1558, 1559, 1560, 1473, 1413,
+
 /*   270 */  1563, 1510, 1568,  563, 1570, 1571, 1572, 1573, 1574, 1575,
+
 /*   280 */  1443, 1466, 1518, 1513, 1514, 1515, 1516, 1217, 1518, 1518,
+
 /*   290 */  1531, 1562, 1582, 1477, 1505, 1511, 1533, 1512, 1488, 1538,
+
 /*   300 */  1509, 1517, 1546, 1519, 1557, 1489, 1565, 1564, 1578, 1586,
+
 /*   310 */  1587, 1588, 1526, 1528, 1554, 1555, 1576, 1577, 1566, 1579,
+
 /*   320 */  1584, 1591, 1520, 1523, 1617, 1628, 1580, 1581, 1632, 1585,
+
 /*   330 */  1590, 1593, 1604, 1605, 1606, 1608, 1609, 1641, 1649, 1610,
+
 /*   340 */  1592, 1594, 1611, 1595, 1616, 1612, 1618, 1613, 1651, 1654,
+
 /*   350 */  1596, 1598, 1655, 1663, 1650, 1673, 1680, 1677, 1684, 1653,
+
 /*   360 */  1664, 1666, 1667, 1662, 1669, 1672, 1676, 1686, 1679, 1691,
+
 /*   370 */  1689, 1692, 1694, 1597, 1599, 1619, 1630, 1699, 1700, 1602,
+
 /*   380 */  1615, 1648, 1657, 1690, 1698, 1658, 1729, 1652, 1695, 1702,
+
 /*   390 */  1704, 1703, 1741, 1754, 1758, 1768, 1769, 1771, 1660, 1661,
+
 /*   400 */  1665, 1752, 1756, 1757, 1759, 1760, 1764, 1745, 1753, 1762,
+
 /*   410 */  1763, 1761, 1772,
};
static const YYACTIONTYPE yy_default[] = {
 /*     0 */  1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254,
@@ -175232,6 +175666,7 @@ static const YYCODETYPE yyFallback[] = {
    0,  /*      ERROR => nothing */
    0,  /*    QNUMBER => nothing */
    0,  /*      SPACE => nothing */
+
    0,  /*    COMMENT => nothing */
    0,  /*    ILLEGAL => nothing */
};
#endif /* YYFALLBACK */
@@ -175501,143 +175936,144 @@ static const char *const yyTokenName[] = {
  /*  182 */ "ERROR",
  /*  183 */ "QNUMBER",
  /*  184 */ "SPACE",
-
  /*  185 */ "ILLEGAL",
-
  /*  186 */ "input",
-
  /*  187 */ "cmdlist",
-
  /*  188 */ "ecmd",
-
  /*  189 */ "cmdx",
-
  /*  190 */ "explain",
-
  /*  191 */ "cmd",
-
  /*  192 */ "transtype",
-
  /*  193 */ "trans_opt",
-
  /*  194 */ "nm",
-
  /*  195 */ "savepoint_opt",
-
  /*  196 */ "create_table",
-
  /*  197 */ "create_table_args",
-
  /*  198 */ "createkw",
-
  /*  199 */ "temp",
-
  /*  200 */ "ifnotexists",
-
  /*  201 */ "dbnm",
-
  /*  202 */ "columnlist",
-
  /*  203 */ "conslist_opt",
-
  /*  204 */ "table_option_set",
-
  /*  205 */ "select",
-
  /*  206 */ "table_option",
-
  /*  207 */ "columnname",
-
  /*  208 */ "carglist",
-
  /*  209 */ "typetoken",
-
  /*  210 */ "typename",
-
  /*  211 */ "signed",
-
  /*  212 */ "plus_num",
-
  /*  213 */ "minus_num",
-
  /*  214 */ "scanpt",
-
  /*  215 */ "scantok",
-
  /*  216 */ "ccons",
-
  /*  217 */ "term",
-
  /*  218 */ "expr",
-
  /*  219 */ "onconf",
-
  /*  220 */ "sortorder",
-
  /*  221 */ "autoinc",
-
  /*  222 */ "eidlist_opt",
-
  /*  223 */ "refargs",
-
  /*  224 */ "defer_subclause",
-
  /*  225 */ "generated",
-
  /*  226 */ "refarg",
-
  /*  227 */ "refact",
-
  /*  228 */ "init_deferred_pred_opt",
-
  /*  229 */ "conslist",
-
  /*  230 */ "tconscomma",
-
  /*  231 */ "tcons",
-
  /*  232 */ "sortlist",
-
  /*  233 */ "eidlist",
-
  /*  234 */ "defer_subclause_opt",
-
  /*  235 */ "orconf",
-
  /*  236 */ "resolvetype",
-
  /*  237 */ "raisetype",
-
  /*  238 */ "ifexists",
-
  /*  239 */ "fullname",
-
  /*  240 */ "selectnowith",
-
  /*  241 */ "oneselect",
-
  /*  242 */ "wqlist",
-
  /*  243 */ "multiselect_op",
-
  /*  244 */ "distinct",
-
  /*  245 */ "selcollist",
-
  /*  246 */ "from",
-
  /*  247 */ "where_opt",
-
  /*  248 */ "groupby_opt",
-
  /*  249 */ "having_opt",
-
  /*  250 */ "orderby_opt",
-
  /*  251 */ "limit_opt",
-
  /*  252 */ "window_clause",
-
  /*  253 */ "values",
-
  /*  254 */ "nexprlist",
-
  /*  255 */ "mvalues",
-
  /*  256 */ "sclp",
-
  /*  257 */ "as",
-
  /*  258 */ "seltablist",
-
  /*  259 */ "stl_prefix",
-
  /*  260 */ "joinop",
-
  /*  261 */ "on_using",
-
  /*  262 */ "indexed_by",
-
  /*  263 */ "exprlist",
-
  /*  264 */ "xfullname",
-
  /*  265 */ "idlist",
-
  /*  266 */ "indexed_opt",
-
  /*  267 */ "nulls",
-
  /*  268 */ "with",
-
  /*  269 */ "where_opt_ret",
-
  /*  270 */ "setlist",
-
  /*  271 */ "insert_cmd",
-
  /*  272 */ "idlist_opt",
-
  /*  273 */ "upsert",
-
  /*  274 */ "returning",
-
  /*  275 */ "filter_over",
-
  /*  276 */ "likeop",
-
  /*  277 */ "between_op",
-
  /*  278 */ "in_op",
-
  /*  279 */ "paren_exprlist",
-
  /*  280 */ "case_operand",
-
  /*  281 */ "case_exprlist",
-
  /*  282 */ "case_else",
-
  /*  283 */ "uniqueflag",
-
  /*  284 */ "collate",
-
  /*  285 */ "vinto",
-
  /*  286 */ "nmnum",
-
  /*  287 */ "trigger_decl",
-
  /*  288 */ "trigger_cmd_list",
-
  /*  289 */ "trigger_time",
-
  /*  290 */ "trigger_event",
-
  /*  291 */ "foreach_clause",
-
  /*  292 */ "when_clause",
-
  /*  293 */ "trigger_cmd",
-
  /*  294 */ "trnm",
-
  /*  295 */ "tridxby",
-
  /*  296 */ "database_kw_opt",
-
  /*  297 */ "key_opt",
-
  /*  298 */ "add_column_fullname",
-
  /*  299 */ "kwcolumn_opt",
-
  /*  300 */ "create_vtab",
-
  /*  301 */ "vtabarglist",
-
  /*  302 */ "vtabarg",
-
  /*  303 */ "vtabargtoken",
-
  /*  304 */ "lp",
-
  /*  305 */ "anylist",
-
  /*  306 */ "wqitem",
-
  /*  307 */ "wqas",
-
  /*  308 */ "withnm",
-
  /*  309 */ "windowdefn_list",
-
  /*  310 */ "windowdefn",
-
  /*  311 */ "window",
-
  /*  312 */ "frame_opt",
-
  /*  313 */ "part_opt",
-
  /*  314 */ "filter_clause",
-
  /*  315 */ "over_clause",
-
  /*  316 */ "range_or_rows",
-
  /*  317 */ "frame_bound",
-
  /*  318 */ "frame_bound_s",
-
  /*  319 */ "frame_bound_e",
-
  /*  320 */ "frame_exclude_opt",
-
  /*  321 */ "frame_exclude",
+
  /*  185 */ "COMMENT",
+
  /*  186 */ "ILLEGAL",
+
  /*  187 */ "input",
+
  /*  188 */ "cmdlist",
+
  /*  189 */ "ecmd",
+
  /*  190 */ "cmdx",
+
  /*  191 */ "explain",
+
  /*  192 */ "cmd",
+
  /*  193 */ "transtype",
+
  /*  194 */ "trans_opt",
+
  /*  195 */ "nm",
+
  /*  196 */ "savepoint_opt",
+
  /*  197 */ "create_table",
+
  /*  198 */ "create_table_args",
+
  /*  199 */ "createkw",
+
  /*  200 */ "temp",
+
  /*  201 */ "ifnotexists",
+
  /*  202 */ "dbnm",
+
  /*  203 */ "columnlist",
+
  /*  204 */ "conslist_opt",
+
  /*  205 */ "table_option_set",
+
  /*  206 */ "select",
+
  /*  207 */ "table_option",
+
  /*  208 */ "columnname",
+
  /*  209 */ "carglist",
+
  /*  210 */ "typetoken",
+
  /*  211 */ "typename",
+
  /*  212 */ "signed",
+
  /*  213 */ "plus_num",
+
  /*  214 */ "minus_num",
+
  /*  215 */ "scanpt",
+
  /*  216 */ "scantok",
+
  /*  217 */ "ccons",
+
  /*  218 */ "term",
+
  /*  219 */ "expr",
+
  /*  220 */ "onconf",
+
  /*  221 */ "sortorder",
+
  /*  222 */ "autoinc",
+
  /*  223 */ "eidlist_opt",
+
  /*  224 */ "refargs",
+
  /*  225 */ "defer_subclause",
+
  /*  226 */ "generated",
+
  /*  227 */ "refarg",
+
  /*  228 */ "refact",
+
  /*  229 */ "init_deferred_pred_opt",
+
  /*  230 */ "conslist",
+
  /*  231 */ "tconscomma",
+
  /*  232 */ "tcons",
+
  /*  233 */ "sortlist",
+
  /*  234 */ "eidlist",
+
  /*  235 */ "defer_subclause_opt",
+
  /*  236 */ "orconf",
+
  /*  237 */ "resolvetype",
+
  /*  238 */ "raisetype",
+
  /*  239 */ "ifexists",
+
  /*  240 */ "fullname",
+
  /*  241 */ "selectnowith",
+
  /*  242 */ "oneselect",
+
  /*  243 */ "wqlist",
+
  /*  244 */ "multiselect_op",
+
  /*  245 */ "distinct",
+
  /*  246 */ "selcollist",
+
  /*  247 */ "from",
+
  /*  248 */ "where_opt",
+
  /*  249 */ "groupby_opt",
+
  /*  250 */ "having_opt",
+
  /*  251 */ "orderby_opt",
+
  /*  252 */ "limit_opt",
+
  /*  253 */ "window_clause",
+
  /*  254 */ "values",
+
  /*  255 */ "nexprlist",
+
  /*  256 */ "mvalues",
+
  /*  257 */ "sclp",
+
  /*  258 */ "as",
+
  /*  259 */ "seltablist",
+
  /*  260 */ "stl_prefix",
+
  /*  261 */ "joinop",
+
  /*  262 */ "on_using",
+
  /*  263 */ "indexed_by",
+
  /*  264 */ "exprlist",
+
  /*  265 */ "xfullname",
+
  /*  266 */ "idlist",
+
  /*  267 */ "indexed_opt",
+
  /*  268 */ "nulls",
+
  /*  269 */ "with",
+
  /*  270 */ "where_opt_ret",
+
  /*  271 */ "setlist",
+
  /*  272 */ "insert_cmd",
+
  /*  273 */ "idlist_opt",
+
  /*  274 */ "upsert",
+
  /*  275 */ "returning",
+
  /*  276 */ "filter_over",
+
  /*  277 */ "likeop",
+
  /*  278 */ "between_op",
+
  /*  279 */ "in_op",
+
  /*  280 */ "paren_exprlist",
+
  /*  281 */ "case_operand",
+
  /*  282 */ "case_exprlist",
+
  /*  283 */ "case_else",
+
  /*  284 */ "uniqueflag",
+
  /*  285 */ "collate",
+
  /*  286 */ "vinto",
+
  /*  287 */ "nmnum",
+
  /*  288 */ "trigger_decl",
+
  /*  289 */ "trigger_cmd_list",
+
  /*  290 */ "trigger_time",
+
  /*  291 */ "trigger_event",
+
  /*  292 */ "foreach_clause",
+
  /*  293 */ "when_clause",
+
  /*  294 */ "trigger_cmd",
+
  /*  295 */ "trnm",
+
  /*  296 */ "tridxby",
+
  /*  297 */ "database_kw_opt",
+
  /*  298 */ "key_opt",
+
  /*  299 */ "add_column_fullname",
+
  /*  300 */ "kwcolumn_opt",
+
  /*  301 */ "create_vtab",
+
  /*  302 */ "vtabarglist",
+
  /*  303 */ "vtabarg",
+
  /*  304 */ "vtabargtoken",
+
  /*  305 */ "lp",
+
  /*  306 */ "anylist",
+
  /*  307 */ "wqitem",
+
  /*  308 */ "wqas",
+
  /*  309 */ "withnm",
+
  /*  310 */ "windowdefn_list",
+
  /*  311 */ "windowdefn",
+
  /*  312 */ "window",
+
  /*  313 */ "frame_opt",
+
  /*  314 */ "part_opt",
+
  /*  315 */ "filter_clause",
+
  /*  316 */ "over_clause",
+
  /*  317 */ "range_or_rows",
+
  /*  318 */ "frame_bound",
+
  /*  319 */ "frame_bound_s",
+
  /*  320 */ "frame_bound_e",
+
  /*  321 */ "frame_exclude_opt",
+
  /*  322 */ "frame_exclude",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */

@@ -176177,98 +176613,98 @@ static void yy_destructor(
    ** inside the C code.
    */
/********* Begin destructor definitions ***************************************/
-
    case 205: /* select */
-
    case 240: /* selectnowith */
-
    case 241: /* oneselect */
-
    case 253: /* values */
-
    case 255: /* mvalues */
+
    case 206: /* select */
+
    case 241: /* selectnowith */
+
    case 242: /* oneselect */
+
    case 254: /* values */
+
    case 256: /* mvalues */
{
-
sqlite3SelectDelete(pParse->db, (yypminor->yy555));
-
}
-
      break;
-
    case 217: /* term */
-
    case 218: /* expr */
-
    case 247: /* where_opt */
-
    case 249: /* having_opt */
-
    case 269: /* where_opt_ret */
-
    case 280: /* case_operand */
-
    case 282: /* case_else */
-
    case 285: /* vinto */
-
    case 292: /* when_clause */
-
    case 297: /* key_opt */
-
    case 314: /* filter_clause */
+
sqlite3SelectDelete(pParse->db, (yypminor->yy637));
+
}
+
      break;
+
    case 218: /* term */
+
    case 219: /* expr */
+
    case 248: /* where_opt */
+
    case 250: /* having_opt */
+
    case 270: /* where_opt_ret */
+
    case 281: /* case_operand */
+
    case 283: /* case_else */
+
    case 286: /* vinto */
+
    case 293: /* when_clause */
+
    case 298: /* key_opt */
+
    case 315: /* filter_clause */
{
-
sqlite3ExprDelete(pParse->db, (yypminor->yy454));
-
}
-
      break;
-
    case 222: /* eidlist_opt */
-
    case 232: /* sortlist */
-
    case 233: /* eidlist */
-
    case 245: /* selcollist */
-
    case 248: /* groupby_opt */
-
    case 250: /* orderby_opt */
-
    case 254: /* nexprlist */
-
    case 256: /* sclp */
-
    case 263: /* exprlist */
-
    case 270: /* setlist */
-
    case 279: /* paren_exprlist */
-
    case 281: /* case_exprlist */
-
    case 313: /* part_opt */
+
sqlite3ExprDelete(pParse->db, (yypminor->yy590));
+
}
+
      break;
+
    case 223: /* eidlist_opt */
+
    case 233: /* sortlist */
+
    case 234: /* eidlist */
+
    case 246: /* selcollist */
+
    case 249: /* groupby_opt */
+
    case 251: /* orderby_opt */
+
    case 255: /* nexprlist */
+
    case 257: /* sclp */
+
    case 264: /* exprlist */
+
    case 271: /* setlist */
+
    case 280: /* paren_exprlist */
+
    case 282: /* case_exprlist */
+
    case 314: /* part_opt */
{
-
sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
+
sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
}
      break;
-
    case 239: /* fullname */
-
    case 246: /* from */
-
    case 258: /* seltablist */
-
    case 259: /* stl_prefix */
-
    case 264: /* xfullname */
+
    case 240: /* fullname */
+
    case 247: /* from */
+
    case 259: /* seltablist */
+
    case 260: /* stl_prefix */
+
    case 265: /* xfullname */
{
-
sqlite3SrcListDelete(pParse->db, (yypminor->yy203));
+
sqlite3SrcListDelete(pParse->db, (yypminor->yy563));
}
      break;
-
    case 242: /* wqlist */
+
    case 243: /* wqlist */
{
-
sqlite3WithDelete(pParse->db, (yypminor->yy59));
+
sqlite3WithDelete(pParse->db, (yypminor->yy125));
}
      break;
-
    case 252: /* window_clause */
-
    case 309: /* windowdefn_list */
+
    case 253: /* window_clause */
+
    case 310: /* windowdefn_list */
{
-
sqlite3WindowListDelete(pParse->db, (yypminor->yy211));
+
sqlite3WindowListDelete(pParse->db, (yypminor->yy483));
}
      break;
-
    case 265: /* idlist */
-
    case 272: /* idlist_opt */
+
    case 266: /* idlist */
+
    case 273: /* idlist_opt */
{
-
sqlite3IdListDelete(pParse->db, (yypminor->yy132));
+
sqlite3IdListDelete(pParse->db, (yypminor->yy204));
}
      break;
-
    case 275: /* filter_over */
-
    case 310: /* windowdefn */
-
    case 311: /* window */
-
    case 312: /* frame_opt */
-
    case 315: /* over_clause */
+
    case 276: /* filter_over */
+
    case 311: /* windowdefn */
+
    case 312: /* window */
+
    case 313: /* frame_opt */
+
    case 316: /* over_clause */
{
-
sqlite3WindowDelete(pParse->db, (yypminor->yy211));
+
sqlite3WindowDelete(pParse->db, (yypminor->yy483));
}
      break;
-
    case 288: /* trigger_cmd_list */
-
    case 293: /* trigger_cmd */
+
    case 289: /* trigger_cmd_list */
+
    case 294: /* trigger_cmd */
{
-
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy427));
+
sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy319));
}
      break;
-
    case 290: /* trigger_event */
+
    case 291: /* trigger_event */
{
-
sqlite3IdListDelete(pParse->db, (yypminor->yy286).b);
+
sqlite3IdListDelete(pParse->db, (yypminor->yy28).b);
}
      break;
-
    case 317: /* frame_bound */
-
    case 318: /* frame_bound_s */
-
    case 319: /* frame_bound_e */
+
    case 318: /* frame_bound */
+
    case 319: /* frame_bound_s */
+
    case 320: /* frame_bound_e */
{
-
sqlite3ExprDelete(pParse->db, (yypminor->yy509).pExpr);
+
sqlite3ExprDelete(pParse->db, (yypminor->yy205).pExpr);
}
      break;
/********* End destructor definitions *****************************************/
@@ -176570,415 +177006,415 @@ static void yy_shift(
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
static const YYCODETYPE yyRuleInfoLhs[] = {
-
   190,  /* (0) explain ::= EXPLAIN */
-
   190,  /* (1) explain ::= EXPLAIN QUERY PLAN */
-
   189,  /* (2) cmdx ::= cmd */
-
   191,  /* (3) cmd ::= BEGIN transtype trans_opt */
-
   192,  /* (4) transtype ::= */
-
   192,  /* (5) transtype ::= DEFERRED */
-
   192,  /* (6) transtype ::= IMMEDIATE */
-
   192,  /* (7) transtype ::= EXCLUSIVE */
-
   191,  /* (8) cmd ::= COMMIT|END trans_opt */
-
   191,  /* (9) cmd ::= ROLLBACK trans_opt */
-
   191,  /* (10) cmd ::= SAVEPOINT nm */
-
   191,  /* (11) cmd ::= RELEASE savepoint_opt nm */
-
   191,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
-
   196,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
-
   198,  /* (14) createkw ::= CREATE */
-
   200,  /* (15) ifnotexists ::= */
-
   200,  /* (16) ifnotexists ::= IF NOT EXISTS */
-
   199,  /* (17) temp ::= TEMP */
-
   199,  /* (18) temp ::= */
-
   197,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
-
   197,  /* (20) create_table_args ::= AS select */
-
   204,  /* (21) table_option_set ::= */
-
   204,  /* (22) table_option_set ::= table_option_set COMMA table_option */
-
   206,  /* (23) table_option ::= WITHOUT nm */
-
   206,  /* (24) table_option ::= nm */
-
   207,  /* (25) columnname ::= nm typetoken */
-
   209,  /* (26) typetoken ::= */
-
   209,  /* (27) typetoken ::= typename LP signed RP */
-
   209,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
-
   210,  /* (29) typename ::= typename ID|STRING */
-
   214,  /* (30) scanpt ::= */
-
   215,  /* (31) scantok ::= */
-
   216,  /* (32) ccons ::= CONSTRAINT nm */
-
   216,  /* (33) ccons ::= DEFAULT scantok term */
-
   216,  /* (34) ccons ::= DEFAULT LP expr RP */
-
   216,  /* (35) ccons ::= DEFAULT PLUS scantok term */
-
   216,  /* (36) ccons ::= DEFAULT MINUS scantok term */
-
   216,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
-
   216,  /* (38) ccons ::= NOT NULL onconf */
-
   216,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
-
   216,  /* (40) ccons ::= UNIQUE onconf */
-
   216,  /* (41) ccons ::= CHECK LP expr RP */
-
   216,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
-
   216,  /* (43) ccons ::= defer_subclause */
-
   216,  /* (44) ccons ::= COLLATE ID|STRING */
-
   225,  /* (45) generated ::= LP expr RP */
-
   225,  /* (46) generated ::= LP expr RP ID */
-
   221,  /* (47) autoinc ::= */
-
   221,  /* (48) autoinc ::= AUTOINCR */
-
   223,  /* (49) refargs ::= */
-
   223,  /* (50) refargs ::= refargs refarg */
-
   226,  /* (51) refarg ::= MATCH nm */
-
   226,  /* (52) refarg ::= ON INSERT refact */
-
   226,  /* (53) refarg ::= ON DELETE refact */
-
   226,  /* (54) refarg ::= ON UPDATE refact */
-
   227,  /* (55) refact ::= SET NULL */
-
   227,  /* (56) refact ::= SET DEFAULT */
-
   227,  /* (57) refact ::= CASCADE */
-
   227,  /* (58) refact ::= RESTRICT */
-
   227,  /* (59) refact ::= NO ACTION */
-
   224,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-
   224,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
-
   228,  /* (62) init_deferred_pred_opt ::= */
-
   228,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
-
   228,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-
   203,  /* (65) conslist_opt ::= */
-
   230,  /* (66) tconscomma ::= COMMA */
-
   231,  /* (67) tcons ::= CONSTRAINT nm */
-
   231,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-
   231,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
-
   231,  /* (70) tcons ::= CHECK LP expr RP onconf */
-
   231,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
-
   234,  /* (72) defer_subclause_opt ::= */
-
   219,  /* (73) onconf ::= */
-
   219,  /* (74) onconf ::= ON CONFLICT resolvetype */
-
   235,  /* (75) orconf ::= */
-
   235,  /* (76) orconf ::= OR resolvetype */
-
   236,  /* (77) resolvetype ::= IGNORE */
-
   236,  /* (78) resolvetype ::= REPLACE */
-
   191,  /* (79) cmd ::= DROP TABLE ifexists fullname */
-
   238,  /* (80) ifexists ::= IF EXISTS */
-
   238,  /* (81) ifexists ::= */
-
   191,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
-
   191,  /* (83) cmd ::= DROP VIEW ifexists fullname */
-
   191,  /* (84) cmd ::= select */
-
   205,  /* (85) select ::= WITH wqlist selectnowith */
-
   205,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
-
   205,  /* (87) select ::= selectnowith */
-
   240,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
-
   243,  /* (89) multiselect_op ::= UNION */
-
   243,  /* (90) multiselect_op ::= UNION ALL */
-
   243,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
-
   241,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
-
   241,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
-
   253,  /* (94) values ::= VALUES LP nexprlist RP */
-
   241,  /* (95) oneselect ::= mvalues */
-
   255,  /* (96) mvalues ::= values COMMA LP nexprlist RP */
-
   255,  /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
-
   244,  /* (98) distinct ::= DISTINCT */
-
   244,  /* (99) distinct ::= ALL */
-
   244,  /* (100) distinct ::= */
-
   256,  /* (101) sclp ::= */
-
   245,  /* (102) selcollist ::= sclp scanpt expr scanpt as */
-
   245,  /* (103) selcollist ::= sclp scanpt STAR */
-
   245,  /* (104) selcollist ::= sclp scanpt nm DOT STAR */
-
   257,  /* (105) as ::= AS nm */
-
   257,  /* (106) as ::= */
-
   246,  /* (107) from ::= */
-
   246,  /* (108) from ::= FROM seltablist */
-
   259,  /* (109) stl_prefix ::= seltablist joinop */
-
   259,  /* (110) stl_prefix ::= */
-
   258,  /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
-
   258,  /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
-
   258,  /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
-
   258,  /* (114) seltablist ::= stl_prefix LP select RP as on_using */
-
   258,  /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
-
   201,  /* (116) dbnm ::= */
-
   201,  /* (117) dbnm ::= DOT nm */
-
   239,  /* (118) fullname ::= nm */
-
   239,  /* (119) fullname ::= nm DOT nm */
-
   264,  /* (120) xfullname ::= nm */
-
   264,  /* (121) xfullname ::= nm DOT nm */
-
   264,  /* (122) xfullname ::= nm DOT nm AS nm */
-
   264,  /* (123) xfullname ::= nm AS nm */
-
   260,  /* (124) joinop ::= COMMA|JOIN */
-
   260,  /* (125) joinop ::= JOIN_KW JOIN */
-
   260,  /* (126) joinop ::= JOIN_KW nm JOIN */
-
   260,  /* (127) joinop ::= JOIN_KW nm nm JOIN */
-
   261,  /* (128) on_using ::= ON expr */
-
   261,  /* (129) on_using ::= USING LP idlist RP */
-
   261,  /* (130) on_using ::= */
-
   266,  /* (131) indexed_opt ::= */
-
   262,  /* (132) indexed_by ::= INDEXED BY nm */
-
   262,  /* (133) indexed_by ::= NOT INDEXED */
-
   250,  /* (134) orderby_opt ::= */
-
   250,  /* (135) orderby_opt ::= ORDER BY sortlist */
-
   232,  /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
-
   232,  /* (137) sortlist ::= expr sortorder nulls */
-
   220,  /* (138) sortorder ::= ASC */
-
   220,  /* (139) sortorder ::= DESC */
-
   220,  /* (140) sortorder ::= */
-
   267,  /* (141) nulls ::= NULLS FIRST */
-
   267,  /* (142) nulls ::= NULLS LAST */
-
   267,  /* (143) nulls ::= */
-
   248,  /* (144) groupby_opt ::= */
-
   248,  /* (145) groupby_opt ::= GROUP BY nexprlist */
-
   249,  /* (146) having_opt ::= */
-
   249,  /* (147) having_opt ::= HAVING expr */
-
   251,  /* (148) limit_opt ::= */
-
   251,  /* (149) limit_opt ::= LIMIT expr */
-
   251,  /* (150) limit_opt ::= LIMIT expr OFFSET expr */
-
   251,  /* (151) limit_opt ::= LIMIT expr COMMA expr */
-
   191,  /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
-
   247,  /* (153) where_opt ::= */
-
   247,  /* (154) where_opt ::= WHERE expr */
-
   269,  /* (155) where_opt_ret ::= */
-
   269,  /* (156) where_opt_ret ::= WHERE expr */
-
   269,  /* (157) where_opt_ret ::= RETURNING selcollist */
-
   269,  /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
-
   191,  /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
-
   270,  /* (160) setlist ::= setlist COMMA nm EQ expr */
-
   270,  /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
-
   270,  /* (162) setlist ::= nm EQ expr */
-
   270,  /* (163) setlist ::= LP idlist RP EQ expr */
-
   191,  /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
-
   191,  /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
-
   273,  /* (166) upsert ::= */
-
   273,  /* (167) upsert ::= RETURNING selcollist */
-
   273,  /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-
   273,  /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-
   273,  /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
-
   273,  /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-
   274,  /* (172) returning ::= RETURNING selcollist */
-
   271,  /* (173) insert_cmd ::= INSERT orconf */
-
   271,  /* (174) insert_cmd ::= REPLACE */
-
   272,  /* (175) idlist_opt ::= */
-
   272,  /* (176) idlist_opt ::= LP idlist RP */
-
   265,  /* (177) idlist ::= idlist COMMA nm */
-
   265,  /* (178) idlist ::= nm */
-
   218,  /* (179) expr ::= LP expr RP */
-
   218,  /* (180) expr ::= ID|INDEXED|JOIN_KW */
-
   218,  /* (181) expr ::= nm DOT nm */
-
   218,  /* (182) expr ::= nm DOT nm DOT nm */
-
   217,  /* (183) term ::= NULL|FLOAT|BLOB */
-
   217,  /* (184) term ::= STRING */
-
   217,  /* (185) term ::= INTEGER */
-
   218,  /* (186) expr ::= VARIABLE */
-
   218,  /* (187) expr ::= expr COLLATE ID|STRING */
-
   218,  /* (188) expr ::= CAST LP expr AS typetoken RP */
-
   218,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
-
   218,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
-
   218,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
-
   218,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
-
   218,  /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
-
   218,  /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
-
   217,  /* (195) term ::= CTIME_KW */
-
   218,  /* (196) expr ::= LP nexprlist COMMA expr RP */
-
   218,  /* (197) expr ::= expr AND expr */
-
   218,  /* (198) expr ::= expr OR expr */
-
   218,  /* (199) expr ::= expr LT|GT|GE|LE expr */
-
   218,  /* (200) expr ::= expr EQ|NE expr */
-
   218,  /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
-
   218,  /* (202) expr ::= expr PLUS|MINUS expr */
-
   218,  /* (203) expr ::= expr STAR|SLASH|REM expr */
-
   218,  /* (204) expr ::= expr CONCAT expr */
-
   276,  /* (205) likeop ::= NOT LIKE_KW|MATCH */
-
   218,  /* (206) expr ::= expr likeop expr */
-
   218,  /* (207) expr ::= expr likeop expr ESCAPE expr */
-
   218,  /* (208) expr ::= expr ISNULL|NOTNULL */
-
   218,  /* (209) expr ::= expr NOT NULL */
-
   218,  /* (210) expr ::= expr IS expr */
-
   218,  /* (211) expr ::= expr IS NOT expr */
-
   218,  /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
-
   218,  /* (213) expr ::= expr IS DISTINCT FROM expr */
-
   218,  /* (214) expr ::= NOT expr */
-
   218,  /* (215) expr ::= BITNOT expr */
-
   218,  /* (216) expr ::= PLUS|MINUS expr */
-
   218,  /* (217) expr ::= expr PTR expr */
-
   277,  /* (218) between_op ::= BETWEEN */
-
   277,  /* (219) between_op ::= NOT BETWEEN */
-
   218,  /* (220) expr ::= expr between_op expr AND expr */
-
   278,  /* (221) in_op ::= IN */
-
   278,  /* (222) in_op ::= NOT IN */
-
   218,  /* (223) expr ::= expr in_op LP exprlist RP */
-
   218,  /* (224) expr ::= LP select RP */
-
   218,  /* (225) expr ::= expr in_op LP select RP */
-
   218,  /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
-
   218,  /* (227) expr ::= EXISTS LP select RP */
-
   218,  /* (228) expr ::= CASE case_operand case_exprlist case_else END */
-
   281,  /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
-
   281,  /* (230) case_exprlist ::= WHEN expr THEN expr */
-
   282,  /* (231) case_else ::= ELSE expr */
-
   282,  /* (232) case_else ::= */
-
   280,  /* (233) case_operand ::= */
-
   263,  /* (234) exprlist ::= */
-
   254,  /* (235) nexprlist ::= nexprlist COMMA expr */
-
   254,  /* (236) nexprlist ::= expr */
-
   279,  /* (237) paren_exprlist ::= */
-
   279,  /* (238) paren_exprlist ::= LP exprlist RP */
-
   191,  /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
-
   283,  /* (240) uniqueflag ::= UNIQUE */
-
   283,  /* (241) uniqueflag ::= */
-
   222,  /* (242) eidlist_opt ::= */
-
   222,  /* (243) eidlist_opt ::= LP eidlist RP */
-
   233,  /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
-
   233,  /* (245) eidlist ::= nm collate sortorder */
-
   284,  /* (246) collate ::= */
-
   284,  /* (247) collate ::= COLLATE ID|STRING */
-
   191,  /* (248) cmd ::= DROP INDEX ifexists fullname */
-
   191,  /* (249) cmd ::= VACUUM vinto */
-
   191,  /* (250) cmd ::= VACUUM nm vinto */
-
   285,  /* (251) vinto ::= INTO expr */
-
   285,  /* (252) vinto ::= */
-
   191,  /* (253) cmd ::= PRAGMA nm dbnm */
-
   191,  /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
-
   191,  /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
-
   191,  /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
-
   191,  /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
-
   212,  /* (258) plus_num ::= PLUS INTEGER|FLOAT */
-
   213,  /* (259) minus_num ::= MINUS INTEGER|FLOAT */
-
   191,  /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
-
   287,  /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
-
   289,  /* (262) trigger_time ::= BEFORE|AFTER */
-
   289,  /* (263) trigger_time ::= INSTEAD OF */
-
   289,  /* (264) trigger_time ::= */
-
   290,  /* (265) trigger_event ::= DELETE|INSERT */
-
   290,  /* (266) trigger_event ::= UPDATE */
-
   290,  /* (267) trigger_event ::= UPDATE OF idlist */
-
   292,  /* (268) when_clause ::= */
-
   292,  /* (269) when_clause ::= WHEN expr */
-
   288,  /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
-
   288,  /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
-
   294,  /* (272) trnm ::= nm DOT nm */
-
   295,  /* (273) tridxby ::= INDEXED BY nm */
-
   295,  /* (274) tridxby ::= NOT INDEXED */
-
   293,  /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-
   293,  /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
-
   293,  /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-
   293,  /* (278) trigger_cmd ::= scanpt select scanpt */
-
   218,  /* (279) expr ::= RAISE LP IGNORE RP */
-
   218,  /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
-
   237,  /* (281) raisetype ::= ROLLBACK */
-
   237,  /* (282) raisetype ::= ABORT */
-
   237,  /* (283) raisetype ::= FAIL */
-
   191,  /* (284) cmd ::= DROP TRIGGER ifexists fullname */
-
   191,  /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
-
   191,  /* (286) cmd ::= DETACH database_kw_opt expr */
-
   297,  /* (287) key_opt ::= */
-
   297,  /* (288) key_opt ::= KEY expr */
-
   191,  /* (289) cmd ::= REINDEX */
-
   191,  /* (290) cmd ::= REINDEX nm dbnm */
-
   191,  /* (291) cmd ::= ANALYZE */
-
   191,  /* (292) cmd ::= ANALYZE nm dbnm */
-
   191,  /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
-
   191,  /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
-
   191,  /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
-
   298,  /* (296) add_column_fullname ::= fullname */
-
   191,  /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
-
   191,  /* (298) cmd ::= create_vtab */
-
   191,  /* (299) cmd ::= create_vtab LP vtabarglist RP */
-
   300,  /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
-
   302,  /* (301) vtabarg ::= */
-
   303,  /* (302) vtabargtoken ::= ANY */
-
   303,  /* (303) vtabargtoken ::= lp anylist RP */
-
   304,  /* (304) lp ::= LP */
-
   268,  /* (305) with ::= WITH wqlist */
-
   268,  /* (306) with ::= WITH RECURSIVE wqlist */
-
   307,  /* (307) wqas ::= AS */
-
   307,  /* (308) wqas ::= AS MATERIALIZED */
-
   307,  /* (309) wqas ::= AS NOT MATERIALIZED */
-
   306,  /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
-
   308,  /* (311) withnm ::= nm */
-
   242,  /* (312) wqlist ::= wqitem */
-
   242,  /* (313) wqlist ::= wqlist COMMA wqitem */
-
   309,  /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
-
   310,  /* (315) windowdefn ::= nm AS LP window RP */
-
   311,  /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
-
   311,  /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
-
   311,  /* (318) window ::= ORDER BY sortlist frame_opt */
-
   311,  /* (319) window ::= nm ORDER BY sortlist frame_opt */
-
   311,  /* (320) window ::= nm frame_opt */
-
   312,  /* (321) frame_opt ::= */
-
   312,  /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
-
   312,  /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
-
   316,  /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
-
   318,  /* (325) frame_bound_s ::= frame_bound */
-
   318,  /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
-
   319,  /* (327) frame_bound_e ::= frame_bound */
-
   319,  /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
-
   317,  /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
-
   317,  /* (330) frame_bound ::= CURRENT ROW */
-
   320,  /* (331) frame_exclude_opt ::= */
-
   320,  /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
-
   321,  /* (333) frame_exclude ::= NO OTHERS */
-
   321,  /* (334) frame_exclude ::= CURRENT ROW */
-
   321,  /* (335) frame_exclude ::= GROUP|TIES */
-
   252,  /* (336) window_clause ::= WINDOW windowdefn_list */
-
   275,  /* (337) filter_over ::= filter_clause over_clause */
-
   275,  /* (338) filter_over ::= over_clause */
-
   275,  /* (339) filter_over ::= filter_clause */
-
   315,  /* (340) over_clause ::= OVER LP window RP */
-
   315,  /* (341) over_clause ::= OVER nm */
-
   314,  /* (342) filter_clause ::= FILTER LP WHERE expr RP */
-
   217,  /* (343) term ::= QNUMBER */
-
   186,  /* (344) input ::= cmdlist */
-
   187,  /* (345) cmdlist ::= cmdlist ecmd */
-
   187,  /* (346) cmdlist ::= ecmd */
-
   188,  /* (347) ecmd ::= SEMI */
-
   188,  /* (348) ecmd ::= cmdx SEMI */
-
   188,  /* (349) ecmd ::= explain cmdx SEMI */
-
   193,  /* (350) trans_opt ::= */
-
   193,  /* (351) trans_opt ::= TRANSACTION */
-
   193,  /* (352) trans_opt ::= TRANSACTION nm */
-
   195,  /* (353) savepoint_opt ::= SAVEPOINT */
-
   195,  /* (354) savepoint_opt ::= */
-
   191,  /* (355) cmd ::= create_table create_table_args */
-
   204,  /* (356) table_option_set ::= table_option */
-
   202,  /* (357) columnlist ::= columnlist COMMA columnname carglist */
-
   202,  /* (358) columnlist ::= columnname carglist */
-
   194,  /* (359) nm ::= ID|INDEXED|JOIN_KW */
-
   194,  /* (360) nm ::= STRING */
-
   209,  /* (361) typetoken ::= typename */
-
   210,  /* (362) typename ::= ID|STRING */
-
   211,  /* (363) signed ::= plus_num */
-
   211,  /* (364) signed ::= minus_num */
-
   208,  /* (365) carglist ::= carglist ccons */
-
   208,  /* (366) carglist ::= */
-
   216,  /* (367) ccons ::= NULL onconf */
-
   216,  /* (368) ccons ::= GENERATED ALWAYS AS generated */
-
   216,  /* (369) ccons ::= AS generated */
-
   203,  /* (370) conslist_opt ::= COMMA conslist */
-
   229,  /* (371) conslist ::= conslist tconscomma tcons */
-
   229,  /* (372) conslist ::= tcons */
-
   230,  /* (373) tconscomma ::= */
-
   234,  /* (374) defer_subclause_opt ::= defer_subclause */
-
   236,  /* (375) resolvetype ::= raisetype */
-
   240,  /* (376) selectnowith ::= oneselect */
-
   241,  /* (377) oneselect ::= values */
-
   256,  /* (378) sclp ::= selcollist COMMA */
-
   257,  /* (379) as ::= ID|STRING */
-
   266,  /* (380) indexed_opt ::= indexed_by */
-
   274,  /* (381) returning ::= */
-
   218,  /* (382) expr ::= term */
-
   276,  /* (383) likeop ::= LIKE_KW|MATCH */
-
   280,  /* (384) case_operand ::= expr */
-
   263,  /* (385) exprlist ::= nexprlist */
-
   286,  /* (386) nmnum ::= plus_num */
-
   286,  /* (387) nmnum ::= nm */
-
   286,  /* (388) nmnum ::= ON */
-
   286,  /* (389) nmnum ::= DELETE */
-
   286,  /* (390) nmnum ::= DEFAULT */
-
   212,  /* (391) plus_num ::= INTEGER|FLOAT */
-
   291,  /* (392) foreach_clause ::= */
-
   291,  /* (393) foreach_clause ::= FOR EACH ROW */
-
   294,  /* (394) trnm ::= nm */
-
   295,  /* (395) tridxby ::= */
-
   296,  /* (396) database_kw_opt ::= DATABASE */
-
   296,  /* (397) database_kw_opt ::= */
-
   299,  /* (398) kwcolumn_opt ::= */
-
   299,  /* (399) kwcolumn_opt ::= COLUMNKW */
-
   301,  /* (400) vtabarglist ::= vtabarg */
-
   301,  /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
-
   302,  /* (402) vtabarg ::= vtabarg vtabargtoken */
-
   305,  /* (403) anylist ::= */
-
   305,  /* (404) anylist ::= anylist LP anylist RP */
-
   305,  /* (405) anylist ::= anylist ANY */
-
   268,  /* (406) with ::= */
-
   309,  /* (407) windowdefn_list ::= windowdefn */
-
   311,  /* (408) window ::= frame_opt */
+
   191,  /* (0) explain ::= EXPLAIN */
+
   191,  /* (1) explain ::= EXPLAIN QUERY PLAN */
+
   190,  /* (2) cmdx ::= cmd */
+
   192,  /* (3) cmd ::= BEGIN transtype trans_opt */
+
   193,  /* (4) transtype ::= */
+
   193,  /* (5) transtype ::= DEFERRED */
+
   193,  /* (6) transtype ::= IMMEDIATE */
+
   193,  /* (7) transtype ::= EXCLUSIVE */
+
   192,  /* (8) cmd ::= COMMIT|END trans_opt */
+
   192,  /* (9) cmd ::= ROLLBACK trans_opt */
+
   192,  /* (10) cmd ::= SAVEPOINT nm */
+
   192,  /* (11) cmd ::= RELEASE savepoint_opt nm */
+
   192,  /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+
   197,  /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+
   199,  /* (14) createkw ::= CREATE */
+
   201,  /* (15) ifnotexists ::= */
+
   201,  /* (16) ifnotexists ::= IF NOT EXISTS */
+
   200,  /* (17) temp ::= TEMP */
+
   200,  /* (18) temp ::= */
+
   198,  /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
+
   198,  /* (20) create_table_args ::= AS select */
+
   205,  /* (21) table_option_set ::= */
+
   205,  /* (22) table_option_set ::= table_option_set COMMA table_option */
+
   207,  /* (23) table_option ::= WITHOUT nm */
+
   207,  /* (24) table_option ::= nm */
+
   208,  /* (25) columnname ::= nm typetoken */
+
   210,  /* (26) typetoken ::= */
+
   210,  /* (27) typetoken ::= typename LP signed RP */
+
   210,  /* (28) typetoken ::= typename LP signed COMMA signed RP */
+
   211,  /* (29) typename ::= typename ID|STRING */
+
   215,  /* (30) scanpt ::= */
+
   216,  /* (31) scantok ::= */
+
   217,  /* (32) ccons ::= CONSTRAINT nm */
+
   217,  /* (33) ccons ::= DEFAULT scantok term */
+
   217,  /* (34) ccons ::= DEFAULT LP expr RP */
+
   217,  /* (35) ccons ::= DEFAULT PLUS scantok term */
+
   217,  /* (36) ccons ::= DEFAULT MINUS scantok term */
+
   217,  /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
+
   217,  /* (38) ccons ::= NOT NULL onconf */
+
   217,  /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+
   217,  /* (40) ccons ::= UNIQUE onconf */
+
   217,  /* (41) ccons ::= CHECK LP expr RP */
+
   217,  /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
+
   217,  /* (43) ccons ::= defer_subclause */
+
   217,  /* (44) ccons ::= COLLATE ID|STRING */
+
   226,  /* (45) generated ::= LP expr RP */
+
   226,  /* (46) generated ::= LP expr RP ID */
+
   222,  /* (47) autoinc ::= */
+
   222,  /* (48) autoinc ::= AUTOINCR */
+
   224,  /* (49) refargs ::= */
+
   224,  /* (50) refargs ::= refargs refarg */
+
   227,  /* (51) refarg ::= MATCH nm */
+
   227,  /* (52) refarg ::= ON INSERT refact */
+
   227,  /* (53) refarg ::= ON DELETE refact */
+
   227,  /* (54) refarg ::= ON UPDATE refact */
+
   228,  /* (55) refact ::= SET NULL */
+
   228,  /* (56) refact ::= SET DEFAULT */
+
   228,  /* (57) refact ::= CASCADE */
+
   228,  /* (58) refact ::= RESTRICT */
+
   228,  /* (59) refact ::= NO ACTION */
+
   225,  /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+
   225,  /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+
   229,  /* (62) init_deferred_pred_opt ::= */
+
   229,  /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+
   229,  /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+
   204,  /* (65) conslist_opt ::= */
+
   231,  /* (66) tconscomma ::= COMMA */
+
   232,  /* (67) tcons ::= CONSTRAINT nm */
+
   232,  /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+
   232,  /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
+
   232,  /* (70) tcons ::= CHECK LP expr RP onconf */
+
   232,  /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+
   235,  /* (72) defer_subclause_opt ::= */
+
   220,  /* (73) onconf ::= */
+
   220,  /* (74) onconf ::= ON CONFLICT resolvetype */
+
   236,  /* (75) orconf ::= */
+
   236,  /* (76) orconf ::= OR resolvetype */
+
   237,  /* (77) resolvetype ::= IGNORE */
+
   237,  /* (78) resolvetype ::= REPLACE */
+
   192,  /* (79) cmd ::= DROP TABLE ifexists fullname */
+
   239,  /* (80) ifexists ::= IF EXISTS */
+
   239,  /* (81) ifexists ::= */
+
   192,  /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+
   192,  /* (83) cmd ::= DROP VIEW ifexists fullname */
+
   192,  /* (84) cmd ::= select */
+
   206,  /* (85) select ::= WITH wqlist selectnowith */
+
   206,  /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
+
   206,  /* (87) select ::= selectnowith */
+
   241,  /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
+
   244,  /* (89) multiselect_op ::= UNION */
+
   244,  /* (90) multiselect_op ::= UNION ALL */
+
   244,  /* (91) multiselect_op ::= EXCEPT|INTERSECT */
+
   242,  /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+
   242,  /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
+
   254,  /* (94) values ::= VALUES LP nexprlist RP */
+
   242,  /* (95) oneselect ::= mvalues */
+
   256,  /* (96) mvalues ::= values COMMA LP nexprlist RP */
+
   256,  /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
+
   245,  /* (98) distinct ::= DISTINCT */
+
   245,  /* (99) distinct ::= ALL */
+
   245,  /* (100) distinct ::= */
+
   257,  /* (101) sclp ::= */
+
   246,  /* (102) selcollist ::= sclp scanpt expr scanpt as */
+
   246,  /* (103) selcollist ::= sclp scanpt STAR */
+
   246,  /* (104) selcollist ::= sclp scanpt nm DOT STAR */
+
   258,  /* (105) as ::= AS nm */
+
   258,  /* (106) as ::= */
+
   247,  /* (107) from ::= */
+
   247,  /* (108) from ::= FROM seltablist */
+
   260,  /* (109) stl_prefix ::= seltablist joinop */
+
   260,  /* (110) stl_prefix ::= */
+
   259,  /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
+
   259,  /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
+
   259,  /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
+
   259,  /* (114) seltablist ::= stl_prefix LP select RP as on_using */
+
   259,  /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
+
   202,  /* (116) dbnm ::= */
+
   202,  /* (117) dbnm ::= DOT nm */
+
   240,  /* (118) fullname ::= nm */
+
   240,  /* (119) fullname ::= nm DOT nm */
+
   265,  /* (120) xfullname ::= nm */
+
   265,  /* (121) xfullname ::= nm DOT nm */
+
   265,  /* (122) xfullname ::= nm DOT nm AS nm */
+
   265,  /* (123) xfullname ::= nm AS nm */
+
   261,  /* (124) joinop ::= COMMA|JOIN */
+
   261,  /* (125) joinop ::= JOIN_KW JOIN */
+
   261,  /* (126) joinop ::= JOIN_KW nm JOIN */
+
   261,  /* (127) joinop ::= JOIN_KW nm nm JOIN */
+
   262,  /* (128) on_using ::= ON expr */
+
   262,  /* (129) on_using ::= USING LP idlist RP */
+
   262,  /* (130) on_using ::= */
+
   267,  /* (131) indexed_opt ::= */
+
   263,  /* (132) indexed_by ::= INDEXED BY nm */
+
   263,  /* (133) indexed_by ::= NOT INDEXED */
+
   251,  /* (134) orderby_opt ::= */
+
   251,  /* (135) orderby_opt ::= ORDER BY sortlist */
+
   233,  /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
+
   233,  /* (137) sortlist ::= expr sortorder nulls */
+
   221,  /* (138) sortorder ::= ASC */
+
   221,  /* (139) sortorder ::= DESC */
+
   221,  /* (140) sortorder ::= */
+
   268,  /* (141) nulls ::= NULLS FIRST */
+
   268,  /* (142) nulls ::= NULLS LAST */
+
   268,  /* (143) nulls ::= */
+
   249,  /* (144) groupby_opt ::= */
+
   249,  /* (145) groupby_opt ::= GROUP BY nexprlist */
+
   250,  /* (146) having_opt ::= */
+
   250,  /* (147) having_opt ::= HAVING expr */
+
   252,  /* (148) limit_opt ::= */
+
   252,  /* (149) limit_opt ::= LIMIT expr */
+
   252,  /* (150) limit_opt ::= LIMIT expr OFFSET expr */
+
   252,  /* (151) limit_opt ::= LIMIT expr COMMA expr */
+
   192,  /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+
   248,  /* (153) where_opt ::= */
+
   248,  /* (154) where_opt ::= WHERE expr */
+
   270,  /* (155) where_opt_ret ::= */
+
   270,  /* (156) where_opt_ret ::= WHERE expr */
+
   270,  /* (157) where_opt_ret ::= RETURNING selcollist */
+
   270,  /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
+
   192,  /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+
   271,  /* (160) setlist ::= setlist COMMA nm EQ expr */
+
   271,  /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
+
   271,  /* (162) setlist ::= nm EQ expr */
+
   271,  /* (163) setlist ::= LP idlist RP EQ expr */
+
   192,  /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+
   192,  /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+
   274,  /* (166) upsert ::= */
+
   274,  /* (167) upsert ::= RETURNING selcollist */
+
   274,  /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+
   274,  /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+
   274,  /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
+
   274,  /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+
   275,  /* (172) returning ::= RETURNING selcollist */
+
   272,  /* (173) insert_cmd ::= INSERT orconf */
+
   272,  /* (174) insert_cmd ::= REPLACE */
+
   273,  /* (175) idlist_opt ::= */
+
   273,  /* (176) idlist_opt ::= LP idlist RP */
+
   266,  /* (177) idlist ::= idlist COMMA nm */
+
   266,  /* (178) idlist ::= nm */
+
   219,  /* (179) expr ::= LP expr RP */
+
   219,  /* (180) expr ::= ID|INDEXED|JOIN_KW */
+
   219,  /* (181) expr ::= nm DOT nm */
+
   219,  /* (182) expr ::= nm DOT nm DOT nm */
+
   218,  /* (183) term ::= NULL|FLOAT|BLOB */
+
   218,  /* (184) term ::= STRING */
+
   218,  /* (185) term ::= INTEGER */
+
   219,  /* (186) expr ::= VARIABLE */
+
   219,  /* (187) expr ::= expr COLLATE ID|STRING */
+
   219,  /* (188) expr ::= CAST LP expr AS typetoken RP */
+
   219,  /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
+
   219,  /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
+
   219,  /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
+
   219,  /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
+
   219,  /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
+
   219,  /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
+
   218,  /* (195) term ::= CTIME_KW */
+
   219,  /* (196) expr ::= LP nexprlist COMMA expr RP */
+
   219,  /* (197) expr ::= expr AND expr */
+
   219,  /* (198) expr ::= expr OR expr */
+
   219,  /* (199) expr ::= expr LT|GT|GE|LE expr */
+
   219,  /* (200) expr ::= expr EQ|NE expr */
+
   219,  /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+
   219,  /* (202) expr ::= expr PLUS|MINUS expr */
+
   219,  /* (203) expr ::= expr STAR|SLASH|REM expr */
+
   219,  /* (204) expr ::= expr CONCAT expr */
+
   277,  /* (205) likeop ::= NOT LIKE_KW|MATCH */
+
   219,  /* (206) expr ::= expr likeop expr */
+
   219,  /* (207) expr ::= expr likeop expr ESCAPE expr */
+
   219,  /* (208) expr ::= expr ISNULL|NOTNULL */
+
   219,  /* (209) expr ::= expr NOT NULL */
+
   219,  /* (210) expr ::= expr IS expr */
+
   219,  /* (211) expr ::= expr IS NOT expr */
+
   219,  /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
+
   219,  /* (213) expr ::= expr IS DISTINCT FROM expr */
+
   219,  /* (214) expr ::= NOT expr */
+
   219,  /* (215) expr ::= BITNOT expr */
+
   219,  /* (216) expr ::= PLUS|MINUS expr */
+
   219,  /* (217) expr ::= expr PTR expr */
+
   278,  /* (218) between_op ::= BETWEEN */
+
   278,  /* (219) between_op ::= NOT BETWEEN */
+
   219,  /* (220) expr ::= expr between_op expr AND expr */
+
   279,  /* (221) in_op ::= IN */
+
   279,  /* (222) in_op ::= NOT IN */
+
   219,  /* (223) expr ::= expr in_op LP exprlist RP */
+
   219,  /* (224) expr ::= LP select RP */
+
   219,  /* (225) expr ::= expr in_op LP select RP */
+
   219,  /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
+
   219,  /* (227) expr ::= EXISTS LP select RP */
+
   219,  /* (228) expr ::= CASE case_operand case_exprlist case_else END */
+
   282,  /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+
   282,  /* (230) case_exprlist ::= WHEN expr THEN expr */
+
   283,  /* (231) case_else ::= ELSE expr */
+
   283,  /* (232) case_else ::= */
+
   281,  /* (233) case_operand ::= */
+
   264,  /* (234) exprlist ::= */
+
   255,  /* (235) nexprlist ::= nexprlist COMMA expr */
+
   255,  /* (236) nexprlist ::= expr */
+
   280,  /* (237) paren_exprlist ::= */
+
   280,  /* (238) paren_exprlist ::= LP exprlist RP */
+
   192,  /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+
   284,  /* (240) uniqueflag ::= UNIQUE */
+
   284,  /* (241) uniqueflag ::= */
+
   223,  /* (242) eidlist_opt ::= */
+
   223,  /* (243) eidlist_opt ::= LP eidlist RP */
+
   234,  /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
+
   234,  /* (245) eidlist ::= nm collate sortorder */
+
   285,  /* (246) collate ::= */
+
   285,  /* (247) collate ::= COLLATE ID|STRING */
+
   192,  /* (248) cmd ::= DROP INDEX ifexists fullname */
+
   192,  /* (249) cmd ::= VACUUM vinto */
+
   192,  /* (250) cmd ::= VACUUM nm vinto */
+
   286,  /* (251) vinto ::= INTO expr */
+
   286,  /* (252) vinto ::= */
+
   192,  /* (253) cmd ::= PRAGMA nm dbnm */
+
   192,  /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
+
   192,  /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+
   192,  /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
+
   192,  /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+
   213,  /* (258) plus_num ::= PLUS INTEGER|FLOAT */
+
   214,  /* (259) minus_num ::= MINUS INTEGER|FLOAT */
+
   192,  /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+
   288,  /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+
   290,  /* (262) trigger_time ::= BEFORE|AFTER */
+
   290,  /* (263) trigger_time ::= INSTEAD OF */
+
   290,  /* (264) trigger_time ::= */
+
   291,  /* (265) trigger_event ::= DELETE|INSERT */
+
   291,  /* (266) trigger_event ::= UPDATE */
+
   291,  /* (267) trigger_event ::= UPDATE OF idlist */
+
   293,  /* (268) when_clause ::= */
+
   293,  /* (269) when_clause ::= WHEN expr */
+
   289,  /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+
   289,  /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
+
   295,  /* (272) trnm ::= nm DOT nm */
+
   296,  /* (273) tridxby ::= INDEXED BY nm */
+
   296,  /* (274) tridxby ::= NOT INDEXED */
+
   294,  /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+
   294,  /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+
   294,  /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+
   294,  /* (278) trigger_cmd ::= scanpt select scanpt */
+
   219,  /* (279) expr ::= RAISE LP IGNORE RP */
+
   219,  /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
+
   238,  /* (281) raisetype ::= ROLLBACK */
+
   238,  /* (282) raisetype ::= ABORT */
+
   238,  /* (283) raisetype ::= FAIL */
+
   192,  /* (284) cmd ::= DROP TRIGGER ifexists fullname */
+
   192,  /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+
   192,  /* (286) cmd ::= DETACH database_kw_opt expr */
+
   298,  /* (287) key_opt ::= */
+
   298,  /* (288) key_opt ::= KEY expr */
+
   192,  /* (289) cmd ::= REINDEX */
+
   192,  /* (290) cmd ::= REINDEX nm dbnm */
+
   192,  /* (291) cmd ::= ANALYZE */
+
   192,  /* (292) cmd ::= ANALYZE nm dbnm */
+
   192,  /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
+
   192,  /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+
   192,  /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+
   299,  /* (296) add_column_fullname ::= fullname */
+
   192,  /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+
   192,  /* (298) cmd ::= create_vtab */
+
   192,  /* (299) cmd ::= create_vtab LP vtabarglist RP */
+
   301,  /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+
   303,  /* (301) vtabarg ::= */
+
   304,  /* (302) vtabargtoken ::= ANY */
+
   304,  /* (303) vtabargtoken ::= lp anylist RP */
+
   305,  /* (304) lp ::= LP */
+
   269,  /* (305) with ::= WITH wqlist */
+
   269,  /* (306) with ::= WITH RECURSIVE wqlist */
+
   308,  /* (307) wqas ::= AS */
+
   308,  /* (308) wqas ::= AS MATERIALIZED */
+
   308,  /* (309) wqas ::= AS NOT MATERIALIZED */
+
   307,  /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
+
   309,  /* (311) withnm ::= nm */
+
   243,  /* (312) wqlist ::= wqitem */
+
   243,  /* (313) wqlist ::= wqlist COMMA wqitem */
+
   310,  /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
+
   311,  /* (315) windowdefn ::= nm AS LP window RP */
+
   312,  /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+
   312,  /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+
   312,  /* (318) window ::= ORDER BY sortlist frame_opt */
+
   312,  /* (319) window ::= nm ORDER BY sortlist frame_opt */
+
   312,  /* (320) window ::= nm frame_opt */
+
   313,  /* (321) frame_opt ::= */
+
   313,  /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+
   313,  /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+
   317,  /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
+
   319,  /* (325) frame_bound_s ::= frame_bound */
+
   319,  /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
+
   320,  /* (327) frame_bound_e ::= frame_bound */
+
   320,  /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
+
   318,  /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
+
   318,  /* (330) frame_bound ::= CURRENT ROW */
+
   321,  /* (331) frame_exclude_opt ::= */
+
   321,  /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
+
   322,  /* (333) frame_exclude ::= NO OTHERS */
+
   322,  /* (334) frame_exclude ::= CURRENT ROW */
+
   322,  /* (335) frame_exclude ::= GROUP|TIES */
+
   253,  /* (336) window_clause ::= WINDOW windowdefn_list */
+
   276,  /* (337) filter_over ::= filter_clause over_clause */
+
   276,  /* (338) filter_over ::= over_clause */
+
   276,  /* (339) filter_over ::= filter_clause */
+
   316,  /* (340) over_clause ::= OVER LP window RP */
+
   316,  /* (341) over_clause ::= OVER nm */
+
   315,  /* (342) filter_clause ::= FILTER LP WHERE expr RP */
+
   218,  /* (343) term ::= QNUMBER */
+
   187,  /* (344) input ::= cmdlist */
+
   188,  /* (345) cmdlist ::= cmdlist ecmd */
+
   188,  /* (346) cmdlist ::= ecmd */
+
   189,  /* (347) ecmd ::= SEMI */
+
   189,  /* (348) ecmd ::= cmdx SEMI */
+
   189,  /* (349) ecmd ::= explain cmdx SEMI */
+
   194,  /* (350) trans_opt ::= */
+
   194,  /* (351) trans_opt ::= TRANSACTION */
+
   194,  /* (352) trans_opt ::= TRANSACTION nm */
+
   196,  /* (353) savepoint_opt ::= SAVEPOINT */
+
   196,  /* (354) savepoint_opt ::= */
+
   192,  /* (355) cmd ::= create_table create_table_args */
+
   205,  /* (356) table_option_set ::= table_option */
+
   203,  /* (357) columnlist ::= columnlist COMMA columnname carglist */
+
   203,  /* (358) columnlist ::= columnname carglist */
+
   195,  /* (359) nm ::= ID|INDEXED|JOIN_KW */
+
   195,  /* (360) nm ::= STRING */
+
   210,  /* (361) typetoken ::= typename */
+
   211,  /* (362) typename ::= ID|STRING */
+
   212,  /* (363) signed ::= plus_num */
+
   212,  /* (364) signed ::= minus_num */
+
   209,  /* (365) carglist ::= carglist ccons */
+
   209,  /* (366) carglist ::= */
+
   217,  /* (367) ccons ::= NULL onconf */
+
   217,  /* (368) ccons ::= GENERATED ALWAYS AS generated */
+
   217,  /* (369) ccons ::= AS generated */
+
   204,  /* (370) conslist_opt ::= COMMA conslist */
+
   230,  /* (371) conslist ::= conslist tconscomma tcons */
+
   230,  /* (372) conslist ::= tcons */
+
   231,  /* (373) tconscomma ::= */
+
   235,  /* (374) defer_subclause_opt ::= defer_subclause */
+
   237,  /* (375) resolvetype ::= raisetype */
+
   241,  /* (376) selectnowith ::= oneselect */
+
   242,  /* (377) oneselect ::= values */
+
   257,  /* (378) sclp ::= selcollist COMMA */
+
   258,  /* (379) as ::= ID|STRING */
+
   267,  /* (380) indexed_opt ::= indexed_by */
+
   275,  /* (381) returning ::= */
+
   219,  /* (382) expr ::= term */
+
   277,  /* (383) likeop ::= LIKE_KW|MATCH */
+
   281,  /* (384) case_operand ::= expr */
+
   264,  /* (385) exprlist ::= nexprlist */
+
   287,  /* (386) nmnum ::= plus_num */
+
   287,  /* (387) nmnum ::= nm */
+
   287,  /* (388) nmnum ::= ON */
+
   287,  /* (389) nmnum ::= DELETE */
+
   287,  /* (390) nmnum ::= DEFAULT */
+
   213,  /* (391) plus_num ::= INTEGER|FLOAT */
+
   292,  /* (392) foreach_clause ::= */
+
   292,  /* (393) foreach_clause ::= FOR EACH ROW */
+
   295,  /* (394) trnm ::= nm */
+
   296,  /* (395) tridxby ::= */
+
   297,  /* (396) database_kw_opt ::= DATABASE */
+
   297,  /* (397) database_kw_opt ::= */
+
   300,  /* (398) kwcolumn_opt ::= */
+
   300,  /* (399) kwcolumn_opt ::= COLUMNKW */
+
   302,  /* (400) vtabarglist ::= vtabarg */
+
   302,  /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
+
   303,  /* (402) vtabarg ::= vtabarg vtabargtoken */
+
   306,  /* (403) anylist ::= */
+
   306,  /* (404) anylist ::= anylist LP anylist RP */
+
   306,  /* (405) anylist ::= anylist ANY */
+
   269,  /* (406) with ::= */
+
   310,  /* (407) windowdefn_list ::= windowdefn */
+
   312,  /* (408) window ::= frame_opt */
};

/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
@@ -177444,16 +177880,16 @@ static YYACTIONTYPE yy_reduce(
{ sqlite3FinishCoding(pParse); }
        break;
      case 3: /* cmd ::= BEGIN transtype trans_opt */
-
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy144);}
+
{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
        break;
      case 4: /* transtype ::= */
-
{yymsp[1].minor.yy144 = TK_DEFERRED;}
+
{yymsp[1].minor.yy502 = TK_DEFERRED;}
        break;
      case 5: /* transtype ::= DEFERRED */
      case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
      case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
      case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324);
-
{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/}
+
{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
        break;
      case 8: /* cmd ::= COMMIT|END trans_opt */
      case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
@@ -177476,7 +177912,7 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
-
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy144,0,0,yymsp[-2].minor.yy144);
+
   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
}
        break;
      case 14: /* createkw ::= CREATE */
@@ -177490,38 +177926,38 @@ static YYACTIONTYPE yy_reduce(
      case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
      case 100: /* distinct ::= */ yytestcase(yyruleno==100);
      case 246: /* collate ::= */ yytestcase(yyruleno==246);
-
{yymsp[1].minor.yy144 = 0;}
+
{yymsp[1].minor.yy502 = 0;}
        break;
      case 16: /* ifnotexists ::= IF NOT EXISTS */
-
{yymsp[-2].minor.yy144 = 1;}
+
{yymsp[-2].minor.yy502 = 1;}
        break;
      case 17: /* temp ::= TEMP */
-
{yymsp[0].minor.yy144 = pParse->db->init.busy==0;}
+
{yymsp[0].minor.yy502 = pParse->db->init.busy==0;}
        break;
      case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
{
-
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy391,0);
+
  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy9,0);
}
        break;
      case 20: /* create_table_args ::= AS select */
{
-
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy555);
-
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
+
  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy637);
+
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
}
        break;
      case 21: /* table_option_set ::= */
-
{yymsp[1].minor.yy391 = 0;}
+
{yymsp[1].minor.yy9 = 0;}
        break;
      case 22: /* table_option_set ::= table_option_set COMMA table_option */
-
{yylhsminor.yy391 = yymsp[-2].minor.yy391|yymsp[0].minor.yy391;}
-
  yymsp[-2].minor.yy391 = yylhsminor.yy391;
+
{yylhsminor.yy9 = yymsp[-2].minor.yy9|yymsp[0].minor.yy9;}
+
  yymsp[-2].minor.yy9 = yylhsminor.yy9;
        break;
      case 23: /* table_option ::= WITHOUT nm */
{
  if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
-
    yymsp[-1].minor.yy391 = TF_WithoutRowid | TF_NoVisibleRowid;
+
    yymsp[-1].minor.yy9 = TF_WithoutRowid | TF_NoVisibleRowid;
  }else{
-
    yymsp[-1].minor.yy391 = 0;
+
    yymsp[-1].minor.yy9 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
@@ -177529,13 +177965,13 @@ static YYACTIONTYPE yy_reduce(
      case 24: /* table_option ::= nm */
{
  if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
-
    yylhsminor.yy391 = TF_Strict;
+
    yylhsminor.yy9 = TF_Strict;
  }else{
-
    yylhsminor.yy391 = 0;
+
    yylhsminor.yy9 = 0;
    sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
  }
}
-
  yymsp[0].minor.yy391 = yylhsminor.yy391;
+
  yymsp[0].minor.yy9 = yylhsminor.yy9;
        break;
      case 25: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
@@ -177561,7 +177997,7 @@ static YYACTIONTYPE yy_reduce(
      case 30: /* scanpt ::= */
{
  assert( yyLookahead!=YYNOCODE );
-
  yymsp[1].minor.yy168 = yyLookaheadToken.z;
+
  yymsp[1].minor.yy342 = yyLookaheadToken.z;
}
        break;
      case 31: /* scantok ::= */
@@ -177575,17 +178011,17 @@ static YYACTIONTYPE yy_reduce(
{pParse->constraintName = yymsp[0].minor.yy0;}
        break;
      case 33: /* ccons ::= DEFAULT scantok term */
-
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 34: /* ccons ::= DEFAULT LP expr RP */
-
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+
{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
        break;
      case 35: /* ccons ::= DEFAULT PLUS scantok term */
-
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+
{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
        break;
      case 36: /* ccons ::= DEFAULT MINUS scantok term */
{
-
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0);
+
  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy590, 0);
  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
}
        break;
@@ -177600,151 +178036,155 @@ static YYACTIONTYPE yy_reduce(
}
        break;
      case 38: /* ccons ::= NOT NULL onconf */
-
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy144);}
+
{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
        break;
      case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy144,yymsp[0].minor.yy144,yymsp[-2].minor.yy144);}
+
{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
        break;
      case 40: /* ccons ::= UNIQUE onconf */
-
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy144,0,0,0,0,
+
{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
                                   SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 41: /* ccons ::= CHECK LP expr RP */
-
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
+
{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
        break;
      case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy144);}
+
{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy502);}
        break;
      case 43: /* ccons ::= defer_subclause */
-
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy144);}
+
{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
        break;
      case 44: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
        break;
      case 45: /* generated ::= LP expr RP */
-
{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);}
+
{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy590,0);}
        break;
      case 46: /* generated ::= LP expr RP ID */
-
{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);}
+
{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy590,&yymsp[0].minor.yy0);}
        break;
      case 48: /* autoinc ::= AUTOINCR */
-
{yymsp[0].minor.yy144 = 1;}
+
{yymsp[0].minor.yy502 = 1;}
        break;
      case 49: /* refargs ::= */
-
{ yymsp[1].minor.yy144 = OE_None*0x0101; /* EV: R-19803-45884 */}
+
{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
        break;
      case 50: /* refargs ::= refargs refarg */
-
{ yymsp[-1].minor.yy144 = (yymsp[-1].minor.yy144 & ~yymsp[0].minor.yy383.mask) | yymsp[0].minor.yy383.value; }
+
{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy481.mask) | yymsp[0].minor.yy481.value; }
        break;
      case 51: /* refarg ::= MATCH nm */
-
{ yymsp[-1].minor.yy383.value = 0;     yymsp[-1].minor.yy383.mask = 0x000000; }
+
{ yymsp[-1].minor.yy481.value = 0;     yymsp[-1].minor.yy481.mask = 0x000000; }
        break;
      case 52: /* refarg ::= ON INSERT refact */
-
{ yymsp[-2].minor.yy383.value = 0;     yymsp[-2].minor.yy383.mask = 0x000000; }
+
{ yymsp[-2].minor.yy481.value = 0;     yymsp[-2].minor.yy481.mask = 0x000000; }
        break;
      case 53: /* refarg ::= ON DELETE refact */
-
{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144;     yymsp[-2].minor.yy383.mask = 0x0000ff; }
+
{ yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502;     yymsp[-2].minor.yy481.mask = 0x0000ff; }
        break;
      case 54: /* refarg ::= ON UPDATE refact */
-
{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144<<8;  yymsp[-2].minor.yy383.mask = 0x00ff00; }
+
{ yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502<<8;  yymsp[-2].minor.yy481.mask = 0x00ff00; }
        break;
      case 55: /* refact ::= SET NULL */
-
{ yymsp[-1].minor.yy144 = OE_SetNull;  /* EV: R-33326-45252 */}
+
{ yymsp[-1].minor.yy502 = OE_SetNull;  /* EV: R-33326-45252 */}
        break;
      case 56: /* refact ::= SET DEFAULT */
-
{ yymsp[-1].minor.yy144 = OE_SetDflt;  /* EV: R-33326-45252 */}
+
{ yymsp[-1].minor.yy502 = OE_SetDflt;  /* EV: R-33326-45252 */}
        break;
      case 57: /* refact ::= CASCADE */
-
{ yymsp[0].minor.yy144 = OE_Cascade;  /* EV: R-33326-45252 */}
+
{ yymsp[0].minor.yy502 = OE_Cascade;  /* EV: R-33326-45252 */}
        break;
      case 58: /* refact ::= RESTRICT */
-
{ yymsp[0].minor.yy144 = OE_Restrict; /* EV: R-33326-45252 */}
+
{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
        break;
      case 59: /* refact ::= NO ACTION */
-
{ yymsp[-1].minor.yy144 = OE_None;     /* EV: R-33326-45252 */}
+
{ yymsp[-1].minor.yy502 = OE_None;     /* EV: R-33326-45252 */}
        break;
      case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-
{yymsp[-2].minor.yy144 = 0;}
+
{yymsp[-2].minor.yy502 = 0;}
        break;
      case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
      case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
      case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173);
-
{yymsp[-1].minor.yy144 = yymsp[0].minor.yy144;}
+
{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
        break;
      case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
      case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
      case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
      case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
      case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
-
{yymsp[-1].minor.yy144 = 1;}
+
{yymsp[-1].minor.yy502 = 1;}
        break;
      case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-
{yymsp[-1].minor.yy144 = 0;}
+
{yymsp[-1].minor.yy502 = 0;}
        break;
      case 66: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
        break;
      case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy144,yymsp[-2].minor.yy144,0);}
+
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
        break;
      case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
-
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy144,0,0,0,0,
+
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy502,0,0,0,0,
                                       SQLITE_IDXTYPE_UNIQUE);}
        break;
      case 70: /* tcons ::= CHECK LP expr RP onconf */
-
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
+
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy590,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
        break;
      case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
-
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy144);
-
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy144);
+
    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy502);
+
    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
}
        break;
      case 73: /* onconf ::= */
      case 75: /* orconf ::= */ yytestcase(yyruleno==75);
-
{yymsp[1].minor.yy144 = OE_Default;}
+
{yymsp[1].minor.yy502 = OE_Default;}
        break;
      case 74: /* onconf ::= ON CONFLICT resolvetype */
-
{yymsp[-2].minor.yy144 = yymsp[0].minor.yy144;}
+
{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
        break;
      case 77: /* resolvetype ::= IGNORE */
-
{yymsp[0].minor.yy144 = OE_Ignore;}
+
{yymsp[0].minor.yy502 = OE_Ignore;}
        break;
      case 78: /* resolvetype ::= REPLACE */
      case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174);
-
{yymsp[0].minor.yy144 = OE_Replace;}
+
{yymsp[0].minor.yy502 = OE_Replace;}
        break;
      case 79: /* cmd ::= DROP TABLE ifexists fullname */
{
-
  sqlite3DropTable(pParse, yymsp[0].minor.yy203, 0, yymsp[-1].minor.yy144);
+
  sqlite3DropTable(pParse, yymsp[0].minor.yy563, 0, yymsp[-1].minor.yy502);
}
        break;
      case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
{
-
  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy555, yymsp[-7].minor.yy144, yymsp[-5].minor.yy144);
+
  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[0].minor.yy637, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
}
        break;
      case 83: /* cmd ::= DROP VIEW ifexists fullname */
{
-
  sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144);
+
  sqlite3DropTable(pParse, yymsp[0].minor.yy563, 1, yymsp[-1].minor.yy502);
}
        break;
      case 84: /* cmd ::= select */
{
  SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
-
  sqlite3Select(pParse, yymsp[0].minor.yy555, &dest);
-
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
+
  if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0
+
   || sqlite3ReadSchema(pParse)==SQLITE_OK
+
  ){
+
    sqlite3Select(pParse, yymsp[0].minor.yy637, &dest);
+
  }
+
  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
}
        break;
      case 85: /* select ::= WITH wqlist selectnowith */
-
{yymsp[-2].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
+
{yymsp[-2].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
        break;
      case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
-
{yymsp[-3].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
+
{yymsp[-3].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
        break;
      case 87: /* select ::= selectnowith */
{
-
  Select *p = yymsp[0].minor.yy555;
+
  Select *p = yymsp[0].minor.yy637;
  if( p ){
    parserDoubleLinkSelect(pParse, p);
  }
@@ -177752,8 +178192,8 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
-
  Select *pRhs = yymsp[0].minor.yy555;
-
  Select *pLhs = yymsp[-2].minor.yy555;
+
  Select *pRhs = yymsp[0].minor.yy637;
+
  Select *pLhs = yymsp[-2].minor.yy637;
  if( pRhs && pRhs->pPrior ){
    SrcList *pFrom;
    Token x;
@@ -177763,60 +178203,60 @@ static YYACTIONTYPE yy_reduce(
    pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
  }
  if( pRhs ){
-
    pRhs->op = (u8)yymsp[-1].minor.yy144;
+
    pRhs->op = (u8)yymsp[-1].minor.yy502;
    pRhs->pPrior = pLhs;
    if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
    pRhs->selFlags &= ~SF_MultiValue;
-
    if( yymsp[-1].minor.yy144!=TK_ALL ) pParse->hasCompound = 1;
+
    if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
  }else{
    sqlite3SelectDelete(pParse->db, pLhs);
  }
-
  yymsp[-2].minor.yy555 = pRhs;
+
  yymsp[-2].minor.yy637 = pRhs;
}
        break;
      case 89: /* multiselect_op ::= UNION */
      case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
-
{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-OP*/}
+
{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
        break;
      case 90: /* multiselect_op ::= UNION ALL */
-
{yymsp[-1].minor.yy144 = TK_ALL;}
+
{yymsp[-1].minor.yy502 = TK_ALL;}
        break;
      case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
-
  yymsp[-8].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy203,yymsp[-4].minor.yy454,yymsp[-3].minor.yy14,yymsp[-2].minor.yy454,yymsp[-1].minor.yy14,yymsp[-7].minor.yy144,yymsp[0].minor.yy454);
+
  yymsp[-8].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy402,yymsp[-5].minor.yy563,yymsp[-4].minor.yy590,yymsp[-3].minor.yy402,yymsp[-2].minor.yy590,yymsp[-1].minor.yy402,yymsp[-7].minor.yy502,yymsp[0].minor.yy590);
}
        break;
      case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
{
-
  yymsp[-9].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy14,yymsp[-6].minor.yy203,yymsp[-5].minor.yy454,yymsp[-4].minor.yy14,yymsp[-3].minor.yy454,yymsp[-1].minor.yy14,yymsp[-8].minor.yy144,yymsp[0].minor.yy454);
-
  if( yymsp[-9].minor.yy555 ){
-
    yymsp[-9].minor.yy555->pWinDefn = yymsp[-2].minor.yy211;
+
  yymsp[-9].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy402,yymsp[-6].minor.yy563,yymsp[-5].minor.yy590,yymsp[-4].minor.yy402,yymsp[-3].minor.yy590,yymsp[-1].minor.yy402,yymsp[-8].minor.yy502,yymsp[0].minor.yy590);
+
  if( yymsp[-9].minor.yy637 ){
+
    yymsp[-9].minor.yy637->pWinDefn = yymsp[-2].minor.yy483;
  }else{
-
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy211);
+
    sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy483);
  }
}
        break;
      case 94: /* values ::= VALUES LP nexprlist RP */
{
-
  yymsp[-3].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0);
+
  yymsp[-3].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
}
        break;
      case 95: /* oneselect ::= mvalues */
{
-
  sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy555);
+
  sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy637);
}
        break;
      case 96: /* mvalues ::= values COMMA LP nexprlist RP */
      case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97);
{
-
  yymsp[-4].minor.yy555 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy555, yymsp[-1].minor.yy14);
+
  yymsp[-4].minor.yy637 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy637, yymsp[-1].minor.yy402);
}
        break;
      case 98: /* distinct ::= DISTINCT */
-
{yymsp[0].minor.yy144 = SF_Distinct;}
+
{yymsp[0].minor.yy502 = SF_Distinct;}
        break;
      case 99: /* distinct ::= ALL */
-
{yymsp[0].minor.yy144 = SF_All;}
+
{yymsp[0].minor.yy502 = SF_All;}
        break;
      case 101: /* sclp ::= */
      case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134);
@@ -177824,20 +178264,20 @@ static YYACTIONTYPE yy_reduce(
      case 234: /* exprlist ::= */ yytestcase(yyruleno==234);
      case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237);
      case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242);
-
{yymsp[1].minor.yy14 = 0;}
+
{yymsp[1].minor.yy402 = 0;}
        break;
      case 102: /* selcollist ::= sclp scanpt expr scanpt as */
{
-
   yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
-
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[0].minor.yy0, 1);
-
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy14,yymsp[-3].minor.yy168,yymsp[-1].minor.yy168);
+
   yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
+
   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[0].minor.yy0, 1);
+
   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy402,yymsp[-3].minor.yy342,yymsp[-1].minor.yy342);
}
        break;
      case 103: /* selcollist ::= sclp scanpt STAR */
{
  Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
  sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
-
  yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, p);
+
  yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
}
        break;
      case 104: /* selcollist ::= sclp scanpt nm DOT STAR */
@@ -177847,7 +178287,7 @@ static YYACTIONTYPE yy_reduce(
  sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
  pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
  pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, pDot);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
}
        break;
      case 105: /* as ::= AS nm */
@@ -177858,50 +178298,50 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 107: /* from ::= */
      case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110);
-
{yymsp[1].minor.yy203 = 0;}
+
{yymsp[1].minor.yy563 = 0;}
        break;
      case 108: /* from ::= FROM seltablist */
{
-
  yymsp[-1].minor.yy203 = yymsp[0].minor.yy203;
-
  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy203);
+
  yymsp[-1].minor.yy563 = yymsp[0].minor.yy563;
+
  sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy563);
}
        break;
      case 109: /* stl_prefix ::= seltablist joinop */
{
-
   if( ALWAYS(yymsp[-1].minor.yy203 && yymsp[-1].minor.yy203->nSrc>0) ) yymsp[-1].minor.yy203->a[yymsp[-1].minor.yy203->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy144;
+
   if( ALWAYS(yymsp[-1].minor.yy563 && yymsp[-1].minor.yy563->nSrc>0) ) yymsp[-1].minor.yy563->a[yymsp[-1].minor.yy563->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
}
        break;
      case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */
{
-
  yymsp[-4].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy203,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
+
  yymsp[-4].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy563,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
}
        break;
      case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
{
-
  yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy269);
-
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-1].minor.yy0);
+
  yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy421);
+
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-1].minor.yy0);
}
        break;
      case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
{
-
  yymsp[-7].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy203,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
-
  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy203, yymsp[-3].minor.yy14);
+
  yymsp[-7].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy563,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
+
  sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy563, yymsp[-3].minor.yy402);
}
        break;
      case 114: /* seltablist ::= stl_prefix LP select RP as on_using */
{
-
    yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy555,&yymsp[0].minor.yy269);
+
    yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy637,&yymsp[0].minor.yy421);
  }
        break;
      case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
{
-
    if( yymsp[-5].minor.yy203==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy269.pOn==0 && yymsp[0].minor.yy269.pUsing==0 ){
-
      yymsp[-5].minor.yy203 = yymsp[-3].minor.yy203;
-
    }else if( ALWAYS(yymsp[-3].minor.yy203!=0) && yymsp[-3].minor.yy203->nSrc==1 ){
-
      yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
-
      if( yymsp[-5].minor.yy203 ){
-
        SrcItem *pNew = &yymsp[-5].minor.yy203->a[yymsp[-5].minor.yy203->nSrc-1];
-
        SrcItem *pOld = yymsp[-3].minor.yy203->a;
+
    if( yymsp[-5].minor.yy563==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy421.pOn==0 && yymsp[0].minor.yy421.pUsing==0 ){
+
      yymsp[-5].minor.yy563 = yymsp[-3].minor.yy563;
+
    }else if( ALWAYS(yymsp[-3].minor.yy563!=0) && yymsp[-3].minor.yy563->nSrc==1 ){
+
      yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
+
      if( yymsp[-5].minor.yy563 ){
+
        SrcItem *pNew = &yymsp[-5].minor.yy563->a[yymsp[-5].minor.yy563->nSrc-1];
+
        SrcItem *pOld = yymsp[-3].minor.yy563->a;
        assert( pOld->fg.fixedSchema==0 );
        pNew->zName = pOld->zName;
        assert( pOld->fg.fixedSchema==0 );
@@ -177926,12 +178366,12 @@ static YYACTIONTYPE yy_reduce(
        }
        pOld->zName = 0;
      }
-
      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy203);
+
      sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy563);
    }else{
      Select *pSubquery;
-
      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy203);
-
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy203,0,0,0,0,SF_NestedFrom,0);
-
      yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy269);
+
      sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy563);
+
      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy563,0,0,0,0,SF_NestedFrom,0);
+
      yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy421);
    }
  }
        break;
@@ -177941,56 +178381,56 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 118: /* fullname ::= nm */
{
-
  yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
-
  if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
+
  yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
+
  if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
}
-
  yymsp[0].minor.yy203 = yylhsminor.yy203;
+
  yymsp[0].minor.yy563 = yylhsminor.yy563;
        break;
      case 119: /* fullname ::= nm DOT nm */
{
-
  yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
-
  if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
+
  yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+
  if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
}
-
  yymsp[-2].minor.yy203 = yylhsminor.yy203;
+
  yymsp[-2].minor.yy563 = yylhsminor.yy563;
        break;
      case 120: /* xfullname ::= nm */
-
{yymsp[0].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+
{yymsp[0].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
        break;
      case 121: /* xfullname ::= nm DOT nm */
-
{yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+
{yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 122: /* xfullname ::= nm DOT nm AS nm */
{
-
   yymsp[-4].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
-
   if( yymsp[-4].minor.yy203 ) yymsp[-4].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+
   yymsp[-4].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+
   if( yymsp[-4].minor.yy563 ) yymsp[-4].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 123: /* xfullname ::= nm AS nm */
{
-
   yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
-
   if( yymsp[-2].minor.yy203 ) yymsp[-2].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+
   yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+
   if( yymsp[-2].minor.yy563 ) yymsp[-2].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
        break;
      case 124: /* joinop ::= COMMA|JOIN */
-
{ yymsp[0].minor.yy144 = JT_INNER; }
+
{ yymsp[0].minor.yy502 = JT_INNER; }
        break;
      case 125: /* joinop ::= JOIN_KW JOIN */
-
{yymsp[-1].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
+
{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
        break;
      case 126: /* joinop ::= JOIN_KW nm JOIN */
-
{yymsp[-2].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+
{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
        break;
      case 127: /* joinop ::= JOIN_KW nm nm JOIN */
-
{yymsp[-3].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+
{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
        break;
      case 128: /* on_using ::= ON expr */
-
{yymsp[-1].minor.yy269.pOn = yymsp[0].minor.yy454; yymsp[-1].minor.yy269.pUsing = 0;}
+
{yymsp[-1].minor.yy421.pOn = yymsp[0].minor.yy590; yymsp[-1].minor.yy421.pUsing = 0;}
        break;
      case 129: /* on_using ::= USING LP idlist RP */
-
{yymsp[-3].minor.yy269.pOn = 0; yymsp[-3].minor.yy269.pUsing = yymsp[-1].minor.yy132;}
+
{yymsp[-3].minor.yy421.pOn = 0; yymsp[-3].minor.yy421.pUsing = yymsp[-1].minor.yy204;}
        break;
      case 130: /* on_using ::= */
-
{yymsp[1].minor.yy269.pOn = 0; yymsp[1].minor.yy269.pUsing = 0;}
+
{yymsp[1].minor.yy421.pOn = 0; yymsp[1].minor.yy421.pUsing = 0;}
        break;
      case 132: /* indexed_by ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
@@ -178000,35 +178440,35 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 135: /* orderby_opt ::= ORDER BY sortlist */
      case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145);
-
{yymsp[-2].minor.yy14 = yymsp[0].minor.yy14;}
+
{yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
        break;
      case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */
{
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14,yymsp[-2].minor.yy454);
-
  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402,yymsp[-2].minor.yy590);
+
  sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
}
        break;
      case 137: /* sortlist ::= expr sortorder nulls */
{
-
  yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/
-
  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
+
  yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy590); /*A-overwrites-Y*/
+
  sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
}
        break;
      case 138: /* sortorder ::= ASC */
-
{yymsp[0].minor.yy144 = SQLITE_SO_ASC;}
+
{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
        break;
      case 139: /* sortorder ::= DESC */
-
{yymsp[0].minor.yy144 = SQLITE_SO_DESC;}
+
{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
        break;
      case 140: /* sortorder ::= */
      case 143: /* nulls ::= */ yytestcase(yyruleno==143);
-
{yymsp[1].minor.yy144 = SQLITE_SO_UNDEFINED;}
+
{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
        break;
      case 141: /* nulls ::= NULLS FIRST */
-
{yymsp[-1].minor.yy144 = SQLITE_SO_ASC;}
+
{yymsp[-1].minor.yy502 = SQLITE_SO_ASC;}
        break;
      case 142: /* nulls ::= NULLS LAST */
-
{yymsp[-1].minor.yy144 = SQLITE_SO_DESC;}
+
{yymsp[-1].minor.yy502 = SQLITE_SO_DESC;}
        break;
      case 146: /* having_opt ::= */
      case 148: /* limit_opt ::= */ yytestcase(yyruleno==148);
@@ -178037,42 +178477,42 @@ static YYACTIONTYPE yy_reduce(
      case 232: /* case_else ::= */ yytestcase(yyruleno==232);
      case 233: /* case_operand ::= */ yytestcase(yyruleno==233);
      case 252: /* vinto ::= */ yytestcase(yyruleno==252);
-
{yymsp[1].minor.yy454 = 0;}
+
{yymsp[1].minor.yy590 = 0;}
        break;
      case 147: /* having_opt ::= HAVING expr */
      case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154);
      case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156);
      case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
      case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251);
-
{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
+
{yymsp[-1].minor.yy590 = yymsp[0].minor.yy590;}
        break;
      case 149: /* limit_opt ::= LIMIT expr */
-
{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);}
+
{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,0);}
        break;
      case 150: /* limit_opt ::= LIMIT expr OFFSET expr */
-
{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+
{yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
        break;
      case 151: /* limit_opt ::= LIMIT expr COMMA expr */
-
{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);}
+
{yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,yymsp[-2].minor.yy590);}
        break;
      case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
{
-
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy203, &yymsp[-1].minor.yy0);
-
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy203,yymsp[0].minor.yy454,0,0);
+
  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy563, &yymsp[-1].minor.yy0);
+
  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy563,yymsp[0].minor.yy590,0,0);
}
        break;
      case 157: /* where_opt_ret ::= RETURNING selcollist */
-
{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-1].minor.yy454 = 0;}
+
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-1].minor.yy590 = 0;}
        break;
      case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
-
{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;}
+
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-3].minor.yy590 = yymsp[-2].minor.yy590;}
        break;
      case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
{
-
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-4].minor.yy0);
-
  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy14,"set list");
-
  if( yymsp[-1].minor.yy203 ){
-
    SrcList *pFromClause = yymsp[-1].minor.yy203;
+
  sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-4].minor.yy0);
+
  sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy402,"set list");
+
  if( yymsp[-1].minor.yy563 ){
+
    SrcList *pFromClause = yymsp[-1].minor.yy563;
    if( pFromClause->nSrc>1 ){
      Select *pSubquery;
      Token as;
@@ -178081,90 +178521,90 @@ static YYACTIONTYPE yy_reduce(
      as.z = 0;
      pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
    }
-
    yymsp[-5].minor.yy203 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy203, pFromClause);
+
    yymsp[-5].minor.yy563 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy563, pFromClause);
  }
-
  sqlite3Update(pParse,yymsp[-5].minor.yy203,yymsp[-2].minor.yy14,yymsp[0].minor.yy454,yymsp[-6].minor.yy144,0,0,0);
+
  sqlite3Update(pParse,yymsp[-5].minor.yy563,yymsp[-2].minor.yy402,yymsp[0].minor.yy590,yymsp[-6].minor.yy502,0,0,0);
}
        break;
      case 160: /* setlist ::= setlist COMMA nm EQ expr */
{
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
-
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, 1);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
+
  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, 1);
}
        break;
      case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
-
  yymsp[-6].minor.yy14 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy14, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
+
  yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
}
        break;
      case 162: /* setlist ::= nm EQ expr */
{
-
  yylhsminor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454);
-
  sqlite3ExprListSetName(pParse, yylhsminor.yy14, &yymsp[-2].minor.yy0, 1);
+
  yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy590);
+
  sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
}
-
  yymsp[-2].minor.yy14 = yylhsminor.yy14;
+
  yymsp[-2].minor.yy402 = yylhsminor.yy402;
        break;
      case 163: /* setlist ::= LP idlist RP EQ expr */
{
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
}
        break;
      case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
-
  sqlite3Insert(pParse, yymsp[-3].minor.yy203, yymsp[-1].minor.yy555, yymsp[-2].minor.yy132, yymsp[-5].minor.yy144, yymsp[0].minor.yy122);
+
  sqlite3Insert(pParse, yymsp[-3].minor.yy563, yymsp[-1].minor.yy637, yymsp[-2].minor.yy204, yymsp[-5].minor.yy502, yymsp[0].minor.yy403);
}
        break;
      case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
{
-
  sqlite3Insert(pParse, yymsp[-4].minor.yy203, 0, yymsp[-3].minor.yy132, yymsp[-6].minor.yy144, 0);
+
  sqlite3Insert(pParse, yymsp[-4].minor.yy563, 0, yymsp[-3].minor.yy204, yymsp[-6].minor.yy502, 0);
}
        break;
      case 166: /* upsert ::= */
-
{ yymsp[1].minor.yy122 = 0; }
+
{ yymsp[1].minor.yy403 = 0; }
        break;
      case 167: /* upsert ::= RETURNING selcollist */
-
{ yymsp[-1].minor.yy122 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy14); }
+
{ yymsp[-1].minor.yy403 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy402); }
        break;
      case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-
{ yymsp[-11].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy14,yymsp[-6].minor.yy454,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,yymsp[0].minor.yy122);}
+
{ yymsp[-11].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy402,yymsp[-6].minor.yy590,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,yymsp[0].minor.yy403);}
        break;
      case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-
{ yymsp[-8].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy14,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy122); }
+
{ yymsp[-8].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy402,yymsp[-3].minor.yy590,0,0,yymsp[0].minor.yy403); }
        break;
      case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */
-
{ yymsp[-4].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
+
{ yymsp[-4].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
        break;
      case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-
{ yymsp[-7].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,0);}
+
{ yymsp[-7].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,0);}
        break;
      case 172: /* returning ::= RETURNING selcollist */
-
{sqlite3AddReturning(pParse,yymsp[0].minor.yy14);}
+
{sqlite3AddReturning(pParse,yymsp[0].minor.yy402);}
        break;
      case 175: /* idlist_opt ::= */
-
{yymsp[1].minor.yy132 = 0;}
+
{yymsp[1].minor.yy204 = 0;}
        break;
      case 176: /* idlist_opt ::= LP idlist RP */
-
{yymsp[-2].minor.yy132 = yymsp[-1].minor.yy132;}
+
{yymsp[-2].minor.yy204 = yymsp[-1].minor.yy204;}
        break;
      case 177: /* idlist ::= idlist COMMA nm */
-
{yymsp[-2].minor.yy132 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy132,&yymsp[0].minor.yy0);}
+
{yymsp[-2].minor.yy204 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy204,&yymsp[0].minor.yy0);}
        break;
      case 178: /* idlist ::= nm */
-
{yymsp[0].minor.yy132 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+
{yymsp[0].minor.yy204 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
        break;
      case 179: /* expr ::= LP expr RP */
-
{yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;}
+
{yymsp[-2].minor.yy590 = yymsp[-1].minor.yy590;}
        break;
      case 180: /* expr ::= ID|INDEXED|JOIN_KW */
-
{yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+
{yymsp[0].minor.yy590=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 181: /* expr ::= nm DOT nm */
{
  Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
  Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
-
  yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+
  yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
-
  yymsp[-2].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-2].minor.yy590 = yylhsminor.yy590;
        break;
      case 182: /* expr ::= nm DOT nm DOT nm */
{
@@ -178175,27 +178615,27 @@ static YYACTIONTYPE yy_reduce(
  if( IN_RENAME_OBJECT ){
    sqlite3RenameTokenRemap(pParse, 0, temp1);
  }
-
  yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+
  yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
-
  yymsp[-4].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-4].minor.yy590 = yylhsminor.yy590;
        break;
      case 183: /* term ::= NULL|FLOAT|BLOB */
      case 184: /* term ::= STRING */ yytestcase(yyruleno==184);
-
{yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+
{yymsp[0].minor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
        break;
      case 185: /* term ::= INTEGER */
{
-
  yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
-
  if( yylhsminor.yy454 ) yylhsminor.yy454->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
+
  yylhsminor.yy590 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+
  if( yylhsminor.yy590 ) yylhsminor.yy590->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
}
-
  yymsp[0].minor.yy454 = yylhsminor.yy454;
+
  yymsp[0].minor.yy590 = yylhsminor.yy590;
        break;
      case 186: /* expr ::= VARIABLE */
{
  if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
    u32 n = yymsp[0].minor.yy0.n;
-
    yymsp[0].minor.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
-
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n);
+
    yymsp[0].minor.yy590 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+
    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy590, n);
  }else{
    /* When doing a nested parse, one can include terms in an expression
    ** that look like this:   #1 #2 ...  These terms refer to registers
@@ -178203,81 +178643,81 @@ static YYACTIONTYPE yy_reduce(
    Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
    assert( t.n>=2 );
    if( pParse->nested==0 ){
-
      sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
-
      yymsp[0].minor.yy454 = 0;
+
      parserSyntaxError(pParse, &t);
+
      yymsp[0].minor.yy590 = 0;
    }else{
-
      yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
-
      if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable);
+
      yymsp[0].minor.yy590 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+
      if( yymsp[0].minor.yy590 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy590->iTable);
    }
  }
}
        break;
      case 187: /* expr ::= expr COLLATE ID|STRING */
{
-
  yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1);
+
  yymsp[-2].minor.yy590 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy590, &yymsp[0].minor.yy0, 1);
}
        break;
      case 188: /* expr ::= CAST LP expr AS typetoken RP */
{
-
  yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
-
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0);
+
  yymsp[-5].minor.yy590 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+
  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy590, yymsp[-3].minor.yy590, 0);
}
        break;
      case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy144);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy502);
}
-
  yymsp[-4].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-4].minor.yy590 = yylhsminor.yy590;
        break;
      case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy14, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy144);
-
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-1].minor.yy14);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy402, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy502);
+
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-1].minor.yy402);
}
-
  yymsp[-7].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-7].minor.yy590 = yylhsminor.yy590;
        break;
      case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
-
  yymsp[-3].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-3].minor.yy590 = yylhsminor.yy590;
        break;
      case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy14, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy144);
-
  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy402, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy502);
+
  sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
}
-
  yymsp[-5].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-5].minor.yy590 = yylhsminor.yy590;
        break;
      case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy14, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy144);
-
  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
-
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-2].minor.yy14);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy402, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy502);
+
  sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
+
  sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-2].minor.yy402);
}
-
  yymsp[-8].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-8].minor.yy590 = yylhsminor.yy590;
        break;
      case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
-
  sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
+
  sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
}
-
  yymsp[-4].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-4].minor.yy590 = yylhsminor.yy590;
        break;
      case 195: /* term ::= CTIME_KW */
{
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
-
  yymsp[0].minor.yy454 = yylhsminor.yy454;
+
  yymsp[0].minor.yy590 = yylhsminor.yy590;
        break;
      case 196: /* expr ::= LP nexprlist COMMA expr RP */
{
-
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454);
-
  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
-
  if( yymsp[-4].minor.yy454 ){
-
    yymsp[-4].minor.yy454->x.pList = pList;
+
  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590);
+
  yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+
  if( yymsp[-4].minor.yy590 ){
+
    yymsp[-4].minor.yy590->x.pList = pList;
    if( ALWAYS(pList->nExpr) ){
-
      yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
+
      yymsp[-4].minor.yy590->flags |= pList->a[0].pExpr->flags & EP_Propagate;
    }
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
@@ -178285,7 +178725,7 @@ static YYACTIONTYPE yy_reduce(
}
        break;
      case 197: /* expr ::= expr AND expr */
-
{yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+
{yymsp[-2].minor.yy590=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
        break;
      case 198: /* expr ::= expr OR expr */
      case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
@@ -178294,7 +178734,7 @@ static YYACTIONTYPE yy_reduce(
      case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
      case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
      case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
-
{yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+
{yymsp[-2].minor.yy590=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
        break;
      case 205: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
@@ -178304,11 +178744,11 @@ static YYACTIONTYPE yy_reduce(
  ExprList *pList;
  int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
  yymsp[-1].minor.yy0.n &= 0x7fffffff;
-
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy454);
-
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454);
-
  yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
-
  if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0);
-
  if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc;
+
  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy590);
+
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy590);
+
  yymsp[-2].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+
  if( bNot ) yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy590, 0);
+
  if( yymsp[-2].minor.yy590 ) yymsp[-2].minor.yy590->flags |= EP_InfixFunc;
}
        break;
      case 207: /* expr ::= expr likeop expr ESCAPE expr */
@@ -178316,91 +178756,91 @@ static YYACTIONTYPE yy_reduce(
  ExprList *pList;
  int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
  yymsp[-3].minor.yy0.n &= 0x7fffffff;
-
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
-
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy454);
-
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
-
  yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
-
  if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
-
  if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc;
+
  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
+
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy590);
+
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
+
  yymsp[-4].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
+
  if( bNot ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
+
  if( yymsp[-4].minor.yy590 ) yymsp[-4].minor.yy590->flags |= EP_InfixFunc;
}
        break;
      case 208: /* expr ::= expr ISNULL|NOTNULL */
-
{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);}
+
{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy590,0);}
        break;
      case 209: /* expr ::= expr NOT NULL */
-
{yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);}
+
{yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy590,0);}
        break;
      case 210: /* expr ::= expr IS expr */
{
-
  yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);
-
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL);
+
  yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);
+
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-2].minor.yy590, TK_ISNULL);
}
        break;
      case 211: /* expr ::= expr IS NOT expr */
{
-
  yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454);
-
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL);
+
  yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy590,yymsp[0].minor.yy590);
+
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-3].minor.yy590, TK_NOTNULL);
}
        break;
      case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */
{
-
  yymsp[-5].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy454,yymsp[0].minor.yy454);
-
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-5].minor.yy454, TK_ISNULL);
+
  yymsp[-5].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy590,yymsp[0].minor.yy590);
+
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-5].minor.yy590, TK_ISNULL);
}
        break;
      case 213: /* expr ::= expr IS DISTINCT FROM expr */
{
-
  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy454,yymsp[0].minor.yy454);
-
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-4].minor.yy454, TK_NOTNULL);
+
  yymsp[-4].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy590,yymsp[0].minor.yy590);
+
  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-4].minor.yy590, TK_NOTNULL);
}
        break;
      case 214: /* expr ::= NOT expr */
      case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
-
{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/}
+
{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy590, 0);/*A-overwrites-B*/}
        break;
      case 216: /* expr ::= PLUS|MINUS expr */
{
-
  Expr *p = yymsp[0].minor.yy454;
+
  Expr *p = yymsp[0].minor.yy590;
  u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS);
  assert( TK_UPLUS>TK_PLUS );
  assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) );
  if( p && p->op==TK_UPLUS ){
    p->op = op;
-
    yymsp[-1].minor.yy454 = p;
+
    yymsp[-1].minor.yy590 = p;
  }else{
-
    yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0);
+
    yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, op, p, 0);
    /*A-overwrites-B*/
  }
}
        break;
      case 217: /* expr ::= expr PTR expr */
{
-
  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454);
-
  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy454);
-
  yylhsminor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+
  ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy590);
+
  pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy590);
+
  yylhsminor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
}
-
  yymsp[-2].minor.yy454 = yylhsminor.yy454;
+
  yymsp[-2].minor.yy590 = yylhsminor.yy590;
        break;
      case 218: /* between_op ::= BETWEEN */
      case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
-
{yymsp[0].minor.yy144 = 0;}
+
{yymsp[0].minor.yy502 = 0;}
        break;
      case 220: /* expr ::= expr between_op expr AND expr */
{
-
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
-
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
-
  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
-
  if( yymsp[-4].minor.yy454 ){
-
    yymsp[-4].minor.yy454->x.pList = pList;
+
  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
+
  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
+
  yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy590, 0);
+
  if( yymsp[-4].minor.yy590 ){
+
    yymsp[-4].minor.yy590->x.pList = pList;
  }else{
    sqlite3ExprListDelete(pParse->db, pList);
  }
-
  if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+
  if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
}
        break;
      case 223: /* expr ::= expr in_op LP exprlist RP */
{
-
    if( yymsp[-1].minor.yy14==0 ){
+
    if( yymsp[-1].minor.yy402==0 ){
      /* Expressions of the form
      **
      **      expr1 IN ()
@@ -178409,110 +178849,110 @@ static YYACTIONTYPE yy_reduce(
      ** simplify to constants 0 (false) and 1 (true), respectively,
      ** regardless of the value of expr1.
      */
-
      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy454);
-
      yymsp[-4].minor.yy454 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy144 ? "true" : "false");
-
      if( yymsp[-4].minor.yy454 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy454);
-
    }else{
-
      Expr *pRHS = yymsp[-1].minor.yy14->a[0].pExpr;
-
      if( yymsp[-1].minor.yy14->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy454->op!=TK_VECTOR ){
-
        yymsp[-1].minor.yy14->a[0].pExpr = 0;
-
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
+
      sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
+
      yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
+
      if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
+
    }else{
+
      Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
+
      if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
+
        yymsp[-1].minor.yy402->a[0].pExpr = 0;
+
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
        pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
-
        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy454, pRHS);
-
      }else if( yymsp[-1].minor.yy14->nExpr==1 && pRHS->op==TK_SELECT ){
-
        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
-
        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pRHS->x.pSelect);
+
        yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy590, pRHS);
+
      }else if( yymsp[-1].minor.yy402->nExpr==1 && pRHS->op==TK_SELECT ){
+
        yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
+
        sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pRHS->x.pSelect);
        pRHS->x.pSelect = 0;
-
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
-
      }else{
-
        yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
-
        if( yymsp[-4].minor.yy454==0 ){
-
          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
-
        }else if( yymsp[-4].minor.yy454->pLeft->op==TK_VECTOR ){
-
          int nExpr = yymsp[-4].minor.yy454->pLeft->x.pList->nExpr;
-
          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy14);
+
        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
+
      }else{
+
        yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
+
        if( yymsp[-4].minor.yy590==0 ){
+
          sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
+
        }else if( yymsp[-4].minor.yy590->pLeft->op==TK_VECTOR ){
+
          int nExpr = yymsp[-4].minor.yy590->pLeft->x.pList->nExpr;
+
          Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy402);
          if( pSelectRHS ){
            parserDoubleLinkSelect(pParse, pSelectRHS);
-
            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelectRHS);
+
            sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelectRHS);
          }
        }else{
-
          yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy14;
-
          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
+
          yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy402;
+
          sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
        }
      }
-
      if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+
      if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
    }
  }
        break;
      case 224: /* expr ::= LP select RP */
{
-
    yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
-
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy555);
+
    yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+
    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy590, yymsp[-1].minor.yy637);
  }
        break;
      case 225: /* expr ::= expr in_op LP select RP */
{
-
    yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
-
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy555);
-
    if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+
    yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
+
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, yymsp[-1].minor.yy637);
+
    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
  }
        break;
      case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
    SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
-
    if( yymsp[0].minor.yy14 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy14);
-
    yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
-
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect);
-
    if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+
    if( yymsp[0].minor.yy402 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy402);
+
    yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
+
    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelect);
+
    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
  }
        break;
      case 227: /* expr ::= EXISTS LP select RP */
{
    Expr *p;
-
    p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
-
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy555);
+
    p = yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+
    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy637);
  }
        break;
      case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
{
-
  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0);
-
  if( yymsp[-4].minor.yy454 ){
-
    yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy14;
-
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
+
  yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy590, 0);
+
  if( yymsp[-4].minor.yy590 ){
+
    yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy590 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590) : yymsp[-2].minor.yy402;
+
    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
  }else{
-
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
-
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
+
    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
+
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
  }
}
        break;
      case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
-
  yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
+
  yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
}
        break;
      case 230: /* case_exprlist ::= WHEN expr THEN expr */
{
-
  yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
-
  yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, yymsp[0].minor.yy454);
+
  yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
+
  yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402, yymsp[0].minor.yy590);
}
        break;
      case 235: /* nexprlist ::= nexprlist COMMA expr */
-
{yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy454);}
+
{yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy590);}
        break;
      case 236: /* nexprlist ::= expr */
-
{yymsp[0].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/}
+
{yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy590); /*A-overwrites-Y*/}
        break;
      case 238: /* paren_exprlist ::= LP exprlist RP */
      case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243);
-
{yymsp[-2].minor.yy14 = yymsp[-1].minor.yy14;}
+
{yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
        break;
      case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
  sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
-
                     sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy144,
-
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy144, SQLITE_IDXTYPE_APPDEF);
+
                     sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-10].minor.yy502,
+
                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy590, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
  if( IN_RENAME_OBJECT && pParse->pNewIndex ){
    sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
  }
@@ -178520,29 +178960,29 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 240: /* uniqueflag ::= UNIQUE */
      case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282);
-
{yymsp[0].minor.yy144 = OE_Abort;}
+
{yymsp[0].minor.yy502 = OE_Abort;}
        break;
      case 241: /* uniqueflag ::= */
-
{yymsp[1].minor.yy144 = OE_None;}
+
{yymsp[1].minor.yy502 = OE_None;}
        break;
      case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
-
  yymsp[-4].minor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144);
+
  yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
}
        break;
      case 245: /* eidlist ::= nm collate sortorder */
{
-
  yymsp[-2].minor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); /*A-overwrites-Y*/
+
  yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
}
        break;
      case 248: /* cmd ::= DROP INDEX ifexists fullname */
-
{sqlite3DropIndex(pParse, yymsp[0].minor.yy203, yymsp[-1].minor.yy144);}
+
{sqlite3DropIndex(pParse, yymsp[0].minor.yy563, yymsp[-1].minor.yy502);}
        break;
      case 249: /* cmd ::= VACUUM vinto */
-
{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);}
+
{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy590);}
        break;
      case 250: /* cmd ::= VACUUM nm vinto */
-
{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);}
+
{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy590);}
        break;
      case 253: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
@@ -178564,50 +179004,50 @@ static YYACTIONTYPE yy_reduce(
  Token all;
  all.z = yymsp[-3].minor.yy0.z;
  all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
-
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy427, &all);
+
  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy319, &all);
}
        break;
      case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
-
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy144, yymsp[-4].minor.yy286.a, yymsp[-4].minor.yy286.b, yymsp[-2].minor.yy203, yymsp[0].minor.yy454, yymsp[-10].minor.yy144, yymsp[-8].minor.yy144);
+
  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy28.a, yymsp[-4].minor.yy28.b, yymsp[-2].minor.yy563, yymsp[0].minor.yy590, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
  yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
        break;
      case 262: /* trigger_time ::= BEFORE|AFTER */
-
{ yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/ }
+
{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
        break;
      case 263: /* trigger_time ::= INSTEAD OF */
-
{ yymsp[-1].minor.yy144 = TK_INSTEAD;}
+
{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
        break;
      case 264: /* trigger_time ::= */
-
{ yymsp[1].minor.yy144 = TK_BEFORE; }
+
{ yymsp[1].minor.yy502 = TK_BEFORE; }
        break;
      case 265: /* trigger_event ::= DELETE|INSERT */
      case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266);
-
{yymsp[0].minor.yy286.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy286.b = 0;}
+
{yymsp[0].minor.yy28.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy28.b = 0;}
        break;
      case 267: /* trigger_event ::= UPDATE OF idlist */
-
{yymsp[-2].minor.yy286.a = TK_UPDATE; yymsp[-2].minor.yy286.b = yymsp[0].minor.yy132;}
+
{yymsp[-2].minor.yy28.a = TK_UPDATE; yymsp[-2].minor.yy28.b = yymsp[0].minor.yy204;}
        break;
      case 268: /* when_clause ::= */
      case 287: /* key_opt ::= */ yytestcase(yyruleno==287);
-
{ yymsp[1].minor.yy454 = 0; }
+
{ yymsp[1].minor.yy590 = 0; }
        break;
      case 269: /* when_clause ::= WHEN expr */
      case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288);
-
{ yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; }
+
{ yymsp[-1].minor.yy590 = yymsp[0].minor.yy590; }
        break;
      case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
-
  assert( yymsp[-2].minor.yy427!=0 );
-
  yymsp[-2].minor.yy427->pLast->pNext = yymsp[-1].minor.yy427;
-
  yymsp[-2].minor.yy427->pLast = yymsp[-1].minor.yy427;
+
  assert( yymsp[-2].minor.yy319!=0 );
+
  yymsp[-2].minor.yy319->pLast->pNext = yymsp[-1].minor.yy319;
+
  yymsp[-2].minor.yy319->pLast = yymsp[-1].minor.yy319;
}
        break;
      case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
-
  assert( yymsp[-1].minor.yy427!=0 );
-
  yymsp[-1].minor.yy427->pLast = yymsp[-1].minor.yy427;
+
  assert( yymsp[-1].minor.yy319!=0 );
+
  yymsp[-1].minor.yy319->pLast = yymsp[-1].minor.yy319;
}
        break;
      case 272: /* trnm ::= nm DOT nm */
@@ -178633,58 +179073,58 @@ static YYACTIONTYPE yy_reduce(
}
        break;
      case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-
{yylhsminor.yy427 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy203, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454, yymsp[-7].minor.yy144, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy168);}
-
  yymsp[-8].minor.yy427 = yylhsminor.yy427;
+
{yylhsminor.yy319 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy563, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590, yymsp[-7].minor.yy502, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy342);}
+
  yymsp[-8].minor.yy319 = yylhsminor.yy319;
        break;
      case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
-
   yylhsminor.yy427 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy132,yymsp[-2].minor.yy555,yymsp[-6].minor.yy144,yymsp[-1].minor.yy122,yymsp[-7].minor.yy168,yymsp[0].minor.yy168);/*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/
+
   yylhsminor.yy319 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy204,yymsp[-2].minor.yy637,yymsp[-6].minor.yy502,yymsp[-1].minor.yy403,yymsp[-7].minor.yy342,yymsp[0].minor.yy342);/*yylhsminor.yy319-overwrites-yymsp[-6].minor.yy502*/
}
-
  yymsp[-7].minor.yy427 = yylhsminor.yy427;
+
  yymsp[-7].minor.yy319 = yylhsminor.yy319;
        break;
      case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-
{yylhsminor.yy427 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy168);}
-
  yymsp[-5].minor.yy427 = yylhsminor.yy427;
+
{yylhsminor.yy319 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy590, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy342);}
+
  yymsp[-5].minor.yy319 = yylhsminor.yy319;
        break;
      case 278: /* trigger_cmd ::= scanpt select scanpt */
-
{yylhsminor.yy427 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy555, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/}
-
  yymsp[-2].minor.yy427 = yylhsminor.yy427;
+
{yylhsminor.yy319 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy637, yymsp[-2].minor.yy342, yymsp[0].minor.yy342); /*yylhsminor.yy319-overwrites-yymsp[-1].minor.yy637*/}
+
  yymsp[-2].minor.yy319 = yylhsminor.yy319;
        break;
      case 279: /* expr ::= RAISE LP IGNORE RP */
{
-
  yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
-
  if( yymsp[-3].minor.yy454 ){
-
    yymsp[-3].minor.yy454->affExpr = OE_Ignore;
+
  yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+
  if( yymsp[-3].minor.yy590 ){
+
    yymsp[-3].minor.yy590->affExpr = OE_Ignore;
  }
}
        break;
      case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */
{
-
  yymsp[-5].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy454, 0);
-
  if( yymsp[-5].minor.yy454 ) {
-
    yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144;
+
  yymsp[-5].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy590, 0);
+
  if( yymsp[-5].minor.yy590 ) {
+
    yymsp[-5].minor.yy590->affExpr = (char)yymsp[-3].minor.yy502;
  }
}
        break;
      case 281: /* raisetype ::= ROLLBACK */
-
{yymsp[0].minor.yy144 = OE_Rollback;}
+
{yymsp[0].minor.yy502 = OE_Rollback;}
        break;
      case 283: /* raisetype ::= FAIL */
-
{yymsp[0].minor.yy144 = OE_Fail;}
+
{yymsp[0].minor.yy502 = OE_Fail;}
        break;
      case 284: /* cmd ::= DROP TRIGGER ifexists fullname */
{
-
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy203,yymsp[-1].minor.yy144);
+
  sqlite3DropTrigger(pParse,yymsp[0].minor.yy563,yymsp[-1].minor.yy502);
}
        break;
      case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
-
  sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454);
+
  sqlite3Attach(pParse, yymsp[-3].minor.yy590, yymsp[-1].minor.yy590, yymsp[0].minor.yy590);
}
        break;
      case 286: /* cmd ::= DETACH database_kw_opt expr */
{
-
  sqlite3Detach(pParse, yymsp[0].minor.yy454);
+
  sqlite3Detach(pParse, yymsp[0].minor.yy590);
}
        break;
      case 289: /* cmd ::= REINDEX */
@@ -178701,7 +179141,7 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
-
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy203,&yymsp[0].minor.yy0);
+
  sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy563,&yymsp[0].minor.yy0);
}
        break;
      case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
@@ -178712,18 +179152,18 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
{
-
  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy203, &yymsp[0].minor.yy0);
+
  sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy563, &yymsp[0].minor.yy0);
}
        break;
      case 296: /* add_column_fullname ::= fullname */
{
  disableLookaside(pParse);
-
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy203);
+
  sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy563);
}
        break;
      case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
-
  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy203, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+
  sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy563, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
        break;
      case 298: /* cmd ::= create_vtab */
@@ -178734,7 +179174,7 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
-
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy144);
+
    sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
}
        break;
      case 301: /* vtabarg ::= */
@@ -178747,20 +179187,20 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 305: /* with ::= WITH wqlist */
      case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306);
-
{ sqlite3WithPush(pParse, yymsp[0].minor.yy59, 1); }
+
{ sqlite3WithPush(pParse, yymsp[0].minor.yy125, 1); }
        break;
      case 307: /* wqas ::= AS */
-
{yymsp[0].minor.yy462 = M10d_Any;}
+
{yymsp[0].minor.yy444 = M10d_Any;}
        break;
      case 308: /* wqas ::= AS MATERIALIZED */
-
{yymsp[-1].minor.yy462 = M10d_Yes;}
+
{yymsp[-1].minor.yy444 = M10d_Yes;}
        break;
      case 309: /* wqas ::= AS NOT MATERIALIZED */
-
{yymsp[-2].minor.yy462 = M10d_No;}
+
{yymsp[-2].minor.yy444 = M10d_No;}
        break;
      case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */
{
-
  yymsp[-5].minor.yy67 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy555, yymsp[-3].minor.yy462); /*A-overwrites-X*/
+
  yymsp[-5].minor.yy361 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy637, yymsp[-3].minor.yy444); /*A-overwrites-X*/
}
        break;
      case 311: /* withnm ::= nm */
@@ -178768,160 +179208,160 @@ static YYACTIONTYPE yy_reduce(
        break;
      case 312: /* wqlist ::= wqitem */
{
-
  yymsp[0].minor.yy59 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy67); /*A-overwrites-X*/
+
  yymsp[0].minor.yy125 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy361); /*A-overwrites-X*/
}
        break;
      case 313: /* wqlist ::= wqlist COMMA wqitem */
{
-
  yymsp[-2].minor.yy59 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy59, yymsp[0].minor.yy67);
+
  yymsp[-2].minor.yy125 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy125, yymsp[0].minor.yy361);
}
        break;
      case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
-
  assert( yymsp[0].minor.yy211!=0 );
-
  sqlite3WindowChain(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy211);
-
  yymsp[0].minor.yy211->pNextWin = yymsp[-2].minor.yy211;
-
  yylhsminor.yy211 = yymsp[0].minor.yy211;
+
  assert( yymsp[0].minor.yy483!=0 );
+
  sqlite3WindowChain(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy483);
+
  yymsp[0].minor.yy483->pNextWin = yymsp[-2].minor.yy483;
+
  yylhsminor.yy483 = yymsp[0].minor.yy483;
}
-
  yymsp[-2].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-2].minor.yy483 = yylhsminor.yy483;
        break;
      case 315: /* windowdefn ::= nm AS LP window RP */
{
-
  if( ALWAYS(yymsp[-1].minor.yy211) ){
-
    yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
+
  if( ALWAYS(yymsp[-1].minor.yy483) ){
+
    yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
  }
-
  yylhsminor.yy211 = yymsp[-1].minor.yy211;
+
  yylhsminor.yy483 = yymsp[-1].minor.yy483;
}
-
  yymsp[-4].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-4].minor.yy483 = yylhsminor.yy483;
        break;
      case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
{
-
  yymsp[-4].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, 0);
+
  yymsp[-4].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, 0);
}
        break;
      case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
{
-
  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, &yymsp[-5].minor.yy0);
+
  yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, &yymsp[-5].minor.yy0);
}
-
  yymsp[-5].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-5].minor.yy483 = yylhsminor.yy483;
        break;
      case 318: /* window ::= ORDER BY sortlist frame_opt */
{
-
  yymsp[-3].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, 0);
+
  yymsp[-3].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, 0);
}
        break;
      case 319: /* window ::= nm ORDER BY sortlist frame_opt */
{
-
  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
+
  yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0);
}
-
  yymsp[-4].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-4].minor.yy483 = yylhsminor.yy483;
        break;
      case 320: /* window ::= nm frame_opt */
{
-
  yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, 0, &yymsp[-1].minor.yy0);
+
  yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, 0, &yymsp[-1].minor.yy0);
}
-
  yymsp[-1].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-1].minor.yy483 = yylhsminor.yy483;
        break;
      case 321: /* frame_opt ::= */
{
-
  yymsp[1].minor.yy211 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
+
  yymsp[1].minor.yy483 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
}
        break;
      case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
{
-
  yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy144, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy462);
+
  yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy502, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy444);
}
-
  yymsp[-2].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-2].minor.yy483 = yylhsminor.yy483;
        break;
      case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
{
-
  yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy144, yymsp[-3].minor.yy509.eType, yymsp[-3].minor.yy509.pExpr, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, yymsp[0].minor.yy462);
+
  yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy502, yymsp[-3].minor.yy205.eType, yymsp[-3].minor.yy205.pExpr, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, yymsp[0].minor.yy444);
}
-
  yymsp[-5].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-5].minor.yy483 = yylhsminor.yy483;
        break;
      case 325: /* frame_bound_s ::= frame_bound */
      case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327);
-
{yylhsminor.yy509 = yymsp[0].minor.yy509;}
-
  yymsp[0].minor.yy509 = yylhsminor.yy509;
+
{yylhsminor.yy205 = yymsp[0].minor.yy205;}
+
  yymsp[0].minor.yy205 = yylhsminor.yy205;
        break;
      case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */
      case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328);
      case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330);
-
{yylhsminor.yy509.eType = yymsp[-1].major; yylhsminor.yy509.pExpr = 0;}
-
  yymsp[-1].minor.yy509 = yylhsminor.yy509;
+
{yylhsminor.yy205.eType = yymsp[-1].major; yylhsminor.yy205.pExpr = 0;}
+
  yymsp[-1].minor.yy205 = yylhsminor.yy205;
        break;
      case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */
-
{yylhsminor.yy509.eType = yymsp[0].major; yylhsminor.yy509.pExpr = yymsp[-1].minor.yy454;}
-
  yymsp[-1].minor.yy509 = yylhsminor.yy509;
+
{yylhsminor.yy205.eType = yymsp[0].major; yylhsminor.yy205.pExpr = yymsp[-1].minor.yy590;}
+
  yymsp[-1].minor.yy205 = yylhsminor.yy205;
        break;
      case 331: /* frame_exclude_opt ::= */
-
{yymsp[1].minor.yy462 = 0;}
+
{yymsp[1].minor.yy444 = 0;}
        break;
      case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
-
{yymsp[-1].minor.yy462 = yymsp[0].minor.yy462;}
+
{yymsp[-1].minor.yy444 = yymsp[0].minor.yy444;}
        break;
      case 333: /* frame_exclude ::= NO OTHERS */
      case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334);
-
{yymsp[-1].minor.yy462 = yymsp[-1].major; /*A-overwrites-X*/}
+
{yymsp[-1].minor.yy444 = yymsp[-1].major; /*A-overwrites-X*/}
        break;
      case 335: /* frame_exclude ::= GROUP|TIES */
-
{yymsp[0].minor.yy462 = yymsp[0].major; /*A-overwrites-X*/}
+
{yymsp[0].minor.yy444 = yymsp[0].major; /*A-overwrites-X*/}
        break;
      case 336: /* window_clause ::= WINDOW windowdefn_list */
-
{ yymsp[-1].minor.yy211 = yymsp[0].minor.yy211; }
+
{ yymsp[-1].minor.yy483 = yymsp[0].minor.yy483; }
        break;
      case 337: /* filter_over ::= filter_clause over_clause */
{
-
  if( yymsp[0].minor.yy211 ){
-
    yymsp[0].minor.yy211->pFilter = yymsp[-1].minor.yy454;
+
  if( yymsp[0].minor.yy483 ){
+
    yymsp[0].minor.yy483->pFilter = yymsp[-1].minor.yy590;
  }else{
-
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
+
    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
  }
-
  yylhsminor.yy211 = yymsp[0].minor.yy211;
+
  yylhsminor.yy483 = yymsp[0].minor.yy483;
}
-
  yymsp[-1].minor.yy211 = yylhsminor.yy211;
+
  yymsp[-1].minor.yy483 = yylhsminor.yy483;
        break;
      case 338: /* filter_over ::= over_clause */
{
-
  yylhsminor.yy211 = yymsp[0].minor.yy211;
+
  yylhsminor.yy483 = yymsp[0].minor.yy483;
}
-
  yymsp[0].minor.yy211 = yylhsminor.yy211;
+
  yymsp[0].minor.yy483 = yylhsminor.yy483;
        break;
      case 339: /* filter_over ::= filter_clause */
{
-
  yylhsminor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
-
  if( yylhsminor.yy211 ){
-
    yylhsminor.yy211->eFrmType = TK_FILTER;
-
    yylhsminor.yy211->pFilter = yymsp[0].minor.yy454;
+
  yylhsminor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+
  if( yylhsminor.yy483 ){
+
    yylhsminor.yy483->eFrmType = TK_FILTER;
+
    yylhsminor.yy483->pFilter = yymsp[0].minor.yy590;
  }else{
-
    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy454);
+
    sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy590);
  }
}
-
  yymsp[0].minor.yy211 = yylhsminor.yy211;
+
  yymsp[0].minor.yy483 = yylhsminor.yy483;
        break;
      case 340: /* over_clause ::= OVER LP window RP */
{
-
  yymsp[-3].minor.yy211 = yymsp[-1].minor.yy211;
-
  assert( yymsp[-3].minor.yy211!=0 );
+
  yymsp[-3].minor.yy483 = yymsp[-1].minor.yy483;
+
  assert( yymsp[-3].minor.yy483!=0 );
}
        break;
      case 341: /* over_clause ::= OVER nm */
{
-
  yymsp[-1].minor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
-
  if( yymsp[-1].minor.yy211 ){
-
    yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
+
  yymsp[-1].minor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+
  if( yymsp[-1].minor.yy483 ){
+
    yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
  }
}
        break;
      case 342: /* filter_clause ::= FILTER LP WHERE expr RP */
-
{ yymsp[-4].minor.yy454 = yymsp[-1].minor.yy454; }
+
{ yymsp[-4].minor.yy590 = yymsp[-1].minor.yy590; }
        break;
      case 343: /* term ::= QNUMBER */
{
-
  yylhsminor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
-
  sqlite3DequoteNumber(pParse, yylhsminor.yy454);
+
  yylhsminor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
+
  sqlite3DequoteNumber(pParse, yylhsminor.yy590);
}
-
  yymsp[0].minor.yy454 = yylhsminor.yy454;
+
  yymsp[0].minor.yy590 = yylhsminor.yy590;
        break;
      default:
      /* (344) input ::= cmdlist */ yytestcase(yyruleno==344);
@@ -179051,7 +179491,7 @@ static void yy_syntax_error(

  UNUSED_PARAMETER(yymajor);  /* Silence some compiler warnings */
  if( TOKEN.z[0] ){
-
    sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN);
+
    parserSyntaxError(pParse, &TOKEN);
  }else{
    sqlite3ErrorMsg(pParse, "incomplete input");
  }
@@ -180102,7 +180542,7 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
    case CC_MINUS: {
      if( z[1]=='-' ){
        for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
-
        *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */
+
        *tokenType = TK_COMMENT;
        return i;
      }else if( z[1]=='>' ){
        *tokenType = TK_PTR;
@@ -180138,7 +180578,7 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
      }
      for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
      if( c ) i++;
-
      *tokenType = TK_SPACE;   /* IMP: R-22934-25134 */
+
      *tokenType = TK_COMMENT;
      return i;
    }
    case CC_PERCENT: {
@@ -180467,12 +180907,12 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
    if( tokenType>=TK_WINDOW ){
      assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
           || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
-
           || tokenType==TK_QNUMBER
+
           || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
      );
#else
    if( tokenType>=TK_SPACE ){
      assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
-
           || tokenType==TK_QNUMBER
+
           || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
      );
#endif /* SQLITE_OMIT_WINDOWFUNC */
      if( AtomicLoad(&db->u1.isInterrupted) ){
@@ -180506,6 +180946,9 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
        assert( n==6 );
        tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
+
      }else if( tokenType==TK_COMMENT && (db->flags & SQLITE_Comments)!=0 ){
+
        zSql += n;
+
        continue;
      }else if( tokenType!=TK_QNUMBER ){
        Token x;
        x.z = zSql;
@@ -180542,7 +180985,9 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
    if( pParse->zErrMsg==0 ){
      pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
    }
-
    sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
+
    if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){
+
      sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
+
    }
    nErr++;
  }
  pParse->zTail = zSql;
@@ -180610,6 +181055,7 @@ SQLITE_PRIVATE char *sqlite3Normalize(
    n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
    if( NEVER(n<=0) ) break;
    switch( tokenType ){
+
      case TK_COMMENT:
      case TK_SPACE: {
        break;
      }
@@ -182051,7 +182497,7 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
    default: {
      static const struct {
        int op;      /* The opcode */
-
        u32 mask;    /* Mask of the bit in sqlite3.flags to set/clear */
+
        u64 mask;    /* Mask of the bit in sqlite3.flags to set/clear */
      } aFlagOp[] = {
        { SQLITE_DBCONFIG_ENABLE_FKEY,           SQLITE_ForeignKeys    },
        { SQLITE_DBCONFIG_ENABLE_TRIGGER,        SQLITE_EnableTrigger  },
@@ -182072,6 +182518,9 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
        { SQLITE_DBCONFIG_TRUSTED_SCHEMA,        SQLITE_TrustedSchema  },
        { SQLITE_DBCONFIG_STMT_SCANSTATUS,       SQLITE_StmtScanStatus },
        { SQLITE_DBCONFIG_REVERSE_SCANORDER,     SQLITE_ReverseOrder   },
+
        { SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE,  SQLITE_AttachCreate   },
+
        { SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE,   SQLITE_AttachWrite    },
+
        { SQLITE_DBCONFIG_ENABLE_COMMENTS,       SQLITE_Comments       },
      };
      unsigned int i;
      rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
@@ -182515,10 +182964,6 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
  sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */
  sqlite3ValueFree(db->pErr);
  sqlite3CloseExtensions(db);
-
#if SQLITE_USER_AUTHENTICATION
-
  sqlite3_free(db->auth.zAuthUser);
-
  sqlite3_free(db->auth.zAuthPW);
-
#endif

  db->eOpenState = SQLITE_STATE_ERROR;

@@ -183953,8 +184398,8 @@ static const int aHardLimit[] = {
#if SQLITE_MAX_VDBE_OP<40
# error SQLITE_MAX_VDBE_OP must be at least 40
#endif
-
#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127
-
# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127
+
#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>32767
+
# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 32767
#endif
#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125
# error SQLITE_MAX_ATTACHED must be between 0 and 125
@@ -184021,8 +184466,8 @@ SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
  if( newLimit>=0 ){                   /* IMP: R-52476-28732 */
    if( newLimit>aHardLimit[limitId] ){
      newLimit = aHardLimit[limitId];  /* IMP: R-51463-25634 */
-
    }else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){
-
      newLimit = 1;
+
    }else if( newLimit<SQLITE_MIN_LENGTH && limitId==SQLITE_LIMIT_LENGTH ){
+
      newLimit = SQLITE_MIN_LENGTH;
    }
    db->aLimit[limitId] = newLimit;
  }
@@ -184417,6 +184862,9 @@ static int openDatabase(
                 | SQLITE_EnableTrigger
                 | SQLITE_EnableView
                 | SQLITE_CacheSpill
+
                 | SQLITE_AttachCreate
+
                 | SQLITE_AttachWrite
+
                 | SQLITE_Comments
#if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0
                 | SQLITE_TrustedSchema
#endif
@@ -185367,7 +185815,6 @@ SQLITE_API int sqlite3_test_control(int op, ...){
      ** issue "defined but not used" warnings. */
      if( x==9999 ){
        sqlite3ShowExpr(0);
-
        sqlite3ShowExpr(0);
        sqlite3ShowExprList(0);
        sqlite3ShowIdList(0);
        sqlite3ShowSrcList(0);
@@ -187723,6 +188170,7 @@ SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **);
SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
+
SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor*, Fts3Expr*);

/* fts3_tokenize_vtab.c */
SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
@@ -189798,10 +190246,15 @@ static int fts3PoslistPhraseMerge(
  if( *p1==POS_COLUMN ){
    p1++;
    p1 += fts3GetVarint32(p1, &iCol1);
+
    /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN
+
    ** entry, so this is actually end-of-doclist. */
+
    if( iCol1==0 ) return 0;
  }
  if( *p2==POS_COLUMN ){
    p2++;
    p2 += fts3GetVarint32(p2, &iCol2);
+
    /* As above, iCol2==0 indicates corruption. */
+
    if( iCol2==0 ) return 0;
  }

  while( 1 ){
@@ -192972,7 +193425,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
      nTmp += p->pRight->pPhrase->doclist.nList;
    }
    nTmp += p->pPhrase->doclist.nList;
-
    aTmp = sqlite3_malloc64(nTmp*2);
+
    aTmp = sqlite3_malloc64(nTmp*2 + FTS3_VARINT_MAX);
    if( !aTmp ){
      *pRc = SQLITE_NOMEM;
      res = 0;
@@ -193237,6 +193690,24 @@ static void fts3EvalRestart(
}

/*
+
** Expression node pExpr is an MSR phrase. This function restarts pExpr
+
** so that it is a regular phrase query, not an MSR. SQLITE_OK is returned
+
** if successful, or an SQLite error code otherwise.
+
*/
+
SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor *pCsr, Fts3Expr *pExpr){
+
  int rc = SQLITE_OK;
+
  if( pExpr->bEof==0 ){
+
    i64 iDocid = pExpr->iDocid;
+
    fts3EvalRestart(pCsr, pExpr, &rc);
+
    while( rc==SQLITE_OK && pExpr->iDocid!=iDocid ){
+
      fts3EvalNextRow(pCsr, pExpr, &rc);
+
      if( pExpr->bEof ) rc = FTS_CORRUPT_VTAB;
+
    }
+
  }
+
  return rc;
+
}
+

+
/*
** After allocating the Fts3Expr.aMI[] array for each phrase in the
** expression rooted at pExpr, the cursor iterates through all rows matched
** by pExpr, calling this function for each row. This function increments
@@ -193623,7 +194094,7 @@ SQLITE_PRIVATE int sqlite3Fts3Corrupt(){
}
#endif

-
#if !SQLITE_CORE
+
#if !defined(SQLITE_CORE)
/*
** Initialize API pointer table, if required.
*/
@@ -194525,10 +194996,11 @@ static int getNextString(
        Fts3PhraseToken *pToken;

        p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
-
        if( !p ) goto no_mem;
-

        zTemp = fts3ReallocOrFree(zTemp, nTemp + nByte);
-
        if( !zTemp ) goto no_mem;
+
        if( !zTemp || !p ){
+
          rc = SQLITE_NOMEM;
+
          goto getnextstring_out;
+
        }

        assert( nToken==ii );
        pToken = &((Fts3Phrase *)(&p[1]))->aToken[ii];
@@ -194543,9 +195015,6 @@ static int getNextString(
        nToken = ii+1;
      }
    }
-

-
    pModule->xClose(pCursor);
-
    pCursor = 0;
  }

  if( rc==SQLITE_DONE ){
@@ -194553,7 +195022,10 @@ static int getNextString(
    char *zBuf = 0;

    p = fts3ReallocOrFree(p, nSpace + nToken*sizeof(Fts3PhraseToken) + nTemp);
-
    if( !p ) goto no_mem;
+
    if( !p ){
+
      rc = SQLITE_NOMEM;
+
      goto getnextstring_out;
+
    }
    memset(p, 0, (char *)&(((Fts3Phrase *)&p[1])->aToken[0])-(char *)p);
    p->eType = FTSQUERY_PHRASE;
    p->pPhrase = (Fts3Phrase *)&p[1];
@@ -194561,11 +195033,9 @@ static int getNextString(
    p->pPhrase->nToken = nToken;

    zBuf = (char *)&p->pPhrase->aToken[nToken];
+
    assert( nTemp==0 || zTemp );
    if( zTemp ){
      memcpy(zBuf, zTemp, nTemp);
-
      sqlite3_free(zTemp);
-
    }else{
-
      assert( nTemp==0 );
    }

    for(jj=0; jj<p->pPhrase->nToken; jj++){
@@ -194575,17 +195045,17 @@ static int getNextString(
    rc = SQLITE_OK;
  }

-
  *ppExpr = p;
-
  return rc;
-
no_mem:
-

+
 getnextstring_out:
  if( pCursor ){
    pModule->xClose(pCursor);
  }
  sqlite3_free(zTemp);
-
  sqlite3_free(p);
-
  *ppExpr = 0;
-
  return SQLITE_NOMEM;
+
  if( rc!=SQLITE_OK ){
+
    sqlite3_free(p);
+
    p = 0;
+
  }
+
  *ppExpr = p;
+
  return rc;
}

/*
@@ -205195,6 +205665,22 @@ static int fts3ExprTermOffsetInit(Fts3Expr *pExpr, int iPhrase, void *ctx){
}

/*
+
** If expression pExpr is a phrase expression that uses an MSR query,
+
** restart it as a regular, non-incremental query. Return SQLITE_OK
+
** if successful, or an SQLite error code otherwise.
+
*/
+
static int fts3ExprRestartIfCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
+
  TermOffsetCtx *p = (TermOffsetCtx*)ctx;
+
  int rc = SQLITE_OK;
+
  UNUSED_PARAMETER(iPhrase);
+
  if( pExpr->pPhrase && pExpr->pPhrase->bIncr ){
+
    rc = sqlite3Fts3MsrCancel(p->pCsr, pExpr);
+
    pExpr->pPhrase->bIncr = 0;
+
  }
+
  return rc;
+
}
+

+
/*
** Implementation of offsets() function.
*/
SQLITE_PRIVATE void sqlite3Fts3Offsets(
@@ -205230,6 +205716,12 @@ SQLITE_PRIVATE void sqlite3Fts3Offsets(
  sCtx.iDocid = pCsr->iPrevId;
  sCtx.pCsr = pCsr;

+
  /* If a query restart will be required, do it here, rather than later of
+
  ** after pointers to poslist buffers that may be invalidated by a restart
+
  ** have been saved.  */
+
  rc = sqlite3Fts3ExprIterate(pCsr->pExpr, fts3ExprRestartIfCb, (void*)&sCtx);
+
  if( rc!=SQLITE_OK ) goto offsets_out;
+

  /* Loop through the table columns, appending offset information to
  ** string-buffer res for each column.
  */
@@ -215397,8 +215889,8 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
    sqlite3_str_append(pOut, "}", 1);
  }
  errCode = sqlite3_str_errcode(pOut);
-
  sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
  sqlite3_result_error_code(ctx, errCode);
+
  sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
}

/* This routine implements an SQL function that returns the "depth" parameter
@@ -217914,7 +218406,7 @@ SQLITE_API int sqlite3_rtree_query_callback(
  );
}

-
#if !SQLITE_CORE
+
#ifndef SQLITE_CORE
#ifdef _WIN32
__declspec(dllexport)
#endif
@@ -218505,7 +218997,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){
  return rc;
}

-
#if !SQLITE_CORE
+
#ifndef SQLITE_CORE
#ifdef _WIN32
__declspec(dllexport)
#endif
@@ -226103,6 +226595,24 @@ static int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
  return SQLITE_OK;
}

+
/*
+
** Open write transactions. Since we do not know in advance which database
+
** files will be written by the sqlite_dbpage virtual table, start a write
+
** transaction on them all.
+
**
+
** Return SQLITE_OK if successful, or an SQLite error code otherwise.
+
*/
+
static int dbpageBeginTrans(DbpageTable *pTab){
+
  sqlite3 *db = pTab->db;
+
  int rc = SQLITE_OK;
+
  int i;
+
  for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
+
    Btree *pBt = db->aDb[i].pBt;
+
    if( pBt ) rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
+
  }
+
  return rc;
+
}
+

static int dbpageUpdate(
  sqlite3_vtab *pVtab,
  int argc,
@@ -226170,6 +226680,12 @@ static int dbpageUpdate(
      goto update_fail;
    }
  }
+

+
  if( dbpageBeginTrans(pTab)!=SQLITE_OK ){
+
    zErr = "failed to open transaction";
+
    goto update_fail;
+
  }
+

  pPager = sqlite3BtreePager(pBt);
  rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);
  if( rc==SQLITE_OK ){
@@ -226179,28 +226695,21 @@ static int dbpageUpdate(
      memcpy(aPage, pData, szPage);
      pTab->pgnoTrunc = 0;
    }
+
  }else{
+
    pTab->pgnoTrunc = 0;
  }
  sqlite3PagerUnref(pDbPage);
  return rc;

update_fail:
+
  pTab->pgnoTrunc = 0;
  sqlite3_free(pVtab->zErrMsg);
  pVtab->zErrMsg = sqlite3_mprintf("%s", zErr);
  return SQLITE_ERROR;
}

-
/* Since we do not know in advance which database files will be
-
** written by the sqlite_dbpage virtual table, start a write transaction
-
** on them all.
-
*/
static int dbpageBegin(sqlite3_vtab *pVtab){
  DbpageTable *pTab = (DbpageTable *)pVtab;
-
  sqlite3 *db = pTab->db;
-
  int i;
-
  for(i=0; i<db->nDb; i++){
-
    Btree *pBt = db->aDb[i].pBt;
-
    if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
-
  }
  pTab->pgnoTrunc = 0;
  return SQLITE_OK;
}
@@ -226212,7 +226721,11 @@ static int dbpageSync(sqlite3_vtab *pVtab){
  if( pTab->pgnoTrunc>0 ){
    Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
    Pager *pPager = sqlite3BtreePager(pBt);
-
    sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
+
    sqlite3BtreeEnter(pBt);
+
    if( pTab->pgnoTrunc<sqlite3BtreeLastPage(pBt) ){
+
      sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
+
    }
+
    sqlite3BtreeLeave(pBt);
  }
  pTab->pgnoTrunc = 0;
  return SQLITE_OK;
@@ -226232,7 +226745,7 @@ static int dbpageRollbackTo(sqlite3_vtab *pVtab, int notUsed1){
*/
SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
  static sqlite3_module dbpage_module = {
-
    0,                            /* iVersion */
+
    2,                            /* iVersion */
    dbpageConnect,                /* xCreate */
    dbpageConnect,                /* xConnect */
    dbpageBestIndex,              /* xBestIndex */
@@ -226407,11 +226920,13 @@ struct sqlite3_changeset_iter {
struct SessionTable {
  SessionTable *pNext;
  char *zName;                    /* Local name of table */
-
  int nCol;                       /* Number of columns in table zName */
+
  int nCol;                       /* Number of non-hidden columns */
+
  int nTotalCol;                  /* Number of columns including hidden */
  int bStat1;                     /* True if this is sqlite_stat1 */
  int bRowid;                     /* True if this table uses rowid for PK */
  const char **azCol;             /* Column names */
  const char **azDflt;            /* Default value expressions */
+
  int *aiIdx;                     /* Index to pass to xNew/xOld */
  u8 *abPK;                       /* Array of primary key flags */
  int nEntry;                     /* Total number of entries in hash table */
  int nChange;                    /* Size of apChange[] array */
@@ -226814,22 +227329,22 @@ static int sessionPreupdateHash(
  unsigned int h = 0;             /* Hash value to return */
  int i;                          /* Used to iterate through columns */

+
  assert( pTab->nTotalCol==pSession->hook.xCount(pSession->hook.pCtx) );
  if( pTab->bRowid ){
-
    assert( pTab->nCol-1==pSession->hook.xCount(pSession->hook.pCtx) );
    h = sessionHashAppendI64(h, iRowid);
  }else{
    assert( *pbNullPK==0 );
-
    assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );
    for(i=0; i<pTab->nCol; i++){
      if( pTab->abPK[i] ){
        int rc;
        int eType;
        sqlite3_value *pVal;
+
        int iIdx = pTab->aiIdx[i];

        if( bNew ){
-
          rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);
+
          rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
        }else{
-
          rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);
+
          rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
        }
        if( rc!=SQLITE_OK ) return rc;

@@ -227166,6 +227681,7 @@ static int sessionPreupdateEqual(
      sqlite3_value *pVal;        /* Value returned by preupdate_new/old */
      int rc;                     /* Error code from preupdate_new/old */
      int eType = *a++;           /* Type of value from change record */
+
      int iIdx = pTab->aiIdx[iCol];

      /* The following calls to preupdate_new() and preupdate_old() can not
      ** fail. This is because they cache their return values, and by the
@@ -227174,10 +227690,10 @@ static int sessionPreupdateEqual(
      ** this (that the method has already been called). */
      if( op==SQLITE_INSERT ){
        /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */
-
        rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);
+
        rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
      }else{
        /* assert( db->pPreUpdate->pUnpacked ); */
-
        rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);
+
        rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
      }
      assert( rc==SQLITE_OK );
      (void)rc;                   /* Suppress warning about unused variable */
@@ -227302,9 +227818,11 @@ static int sessionTableInfo(
  const char *zDb,                /* Name of attached database (e.g. "main") */
  const char *zThis,              /* Table name */
  int *pnCol,                     /* OUT: number of columns */
+
  int *pnTotalCol,                /* OUT: number of hidden columns */
  const char **pzTab,             /* OUT: Copy of zThis */
  const char ***pazCol,           /* OUT: Array of column names for table */
  const char ***pazDflt,          /* OUT: Array of default value expressions */
+
  int **paiIdx,                   /* OUT: Array of xNew/xOld indexes */
  u8 **pabPK,                     /* OUT: Array of booleans - true for PK col */
  int *pbRowid                    /* OUT: True if only PK is a rowid */
){
@@ -227319,6 +227837,7 @@ static int sessionTableInfo(
  char **azCol = 0;
  char **azDflt = 0;
  u8 *abPK = 0;
+
  int *aiIdx = 0;
  int bRowid = 0;                 /* Set to true to use rowid as PK */

  assert( pazCol && pabPK );
@@ -227326,6 +227845,8 @@ static int sessionTableInfo(
  *pazCol = 0;
  *pabPK = 0;
  *pnCol = 0;
+
  if( pnTotalCol ) *pnTotalCol = 0;
+
  if( paiIdx ) *paiIdx = 0;
  if( pzTab ) *pzTab = 0;
  if( pazDflt ) *pazDflt = 0;

@@ -227335,9 +227856,9 @@ static int sessionTableInfo(
    if( rc==SQLITE_OK ){
      /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
      zPragma = sqlite3_mprintf(
-
          "SELECT 0, 'tbl',  '', 0, '', 1     UNION ALL "
-
          "SELECT 1, 'idx',  '', 0, '', 2     UNION ALL "
-
          "SELECT 2, 'stat', '', 0, '', 0"
+
          "SELECT 0, 'tbl',  '', 0, '', 1, 0     UNION ALL "
+
          "SELECT 1, 'idx',  '', 0, '', 2, 0     UNION ALL "
+
          "SELECT 2, 'stat', '', 0, '', 0, 0"
      );
    }else if( rc==SQLITE_ERROR ){
      zPragma = sqlite3_mprintf("");
@@ -227345,7 +227866,7 @@ static int sessionTableInfo(
      return rc;
    }
  }else{
-
    zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
+
    zPragma = sqlite3_mprintf("PRAGMA '%q'.table_xinfo('%q')", zDb, zThis);
  }
  if( !zPragma ){
    return SQLITE_NOMEM;
@@ -227362,7 +227883,9 @@ static int sessionTableInfo(
  while( SQLITE_ROW==sqlite3_step(pStmt) ){
    nByte += sqlite3_column_bytes(pStmt, 1);          /* name */
    nByte += sqlite3_column_bytes(pStmt, 4);          /* dflt_value */
-
    nDbCol++;
+
    if( sqlite3_column_int(pStmt, 6)==0 ){            /* !hidden */
+
      nDbCol++;
+
    }
    if( sqlite3_column_int(pStmt, 5) ) bRowid = 0;    /* pk */
  }
  if( nDbCol==0 ) bRowid = 0;
@@ -227371,7 +227894,7 @@ static int sessionTableInfo(
  rc = sqlite3_reset(pStmt);

  if( rc==SQLITE_OK ){
-
    nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1);
+
    nByte += nDbCol * (sizeof(const char *)*2 +sizeof(int)+sizeof(u8) + 1 + 1);
    pAlloc = sessionMalloc64(pSession, nByte);
    if( pAlloc==0 ){
      rc = SQLITE_NOMEM;
@@ -227382,8 +227905,8 @@ static int sessionTableInfo(
  if( rc==SQLITE_OK ){
    azCol = (char **)pAlloc;
    azDflt = (char**)&azCol[nDbCol];
-
    pAlloc = (u8 *)&azDflt[nDbCol];
-
    abPK = (u8 *)pAlloc;
+
    aiIdx = (int*)&azDflt[nDbCol];
+
    abPK = (u8 *)&aiIdx[nDbCol];
    pAlloc = &abPK[nDbCol];
    if( pzTab ){
      memcpy(pAlloc, zThis, nThis+1);
@@ -227398,27 +227921,32 @@ static int sessionTableInfo(
      azCol[i] = (char*)pAlloc;
      pAlloc += nName+1;
      abPK[i] = 1;
+
      aiIdx[i] = -1;
      i++;
    }
    while( SQLITE_ROW==sqlite3_step(pStmt) ){
-
      int nName = sqlite3_column_bytes(pStmt, 1);
-
      int nDflt = sqlite3_column_bytes(pStmt, 4);
-
      const unsigned char *zName = sqlite3_column_text(pStmt, 1);
-
      const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
-

-
      if( zName==0 ) break;
-
      memcpy(pAlloc, zName, nName+1);
-
      azCol[i] = (char *)pAlloc;
-
      pAlloc += nName+1;
-
      if( zDflt ){
-
        memcpy(pAlloc, zDflt, nDflt+1);
-
        azDflt[i] = (char *)pAlloc;
-
        pAlloc += nDflt+1;
-
      }else{
-
        azDflt[i] = 0;
+
      if( sqlite3_column_int(pStmt, 6)==0 ){            /* !hidden */
+
        int nName = sqlite3_column_bytes(pStmt, 1);
+
        int nDflt = sqlite3_column_bytes(pStmt, 4);
+
        const unsigned char *zName = sqlite3_column_text(pStmt, 1);
+
        const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
+

+
        if( zName==0 ) break;
+
        memcpy(pAlloc, zName, nName+1);
+
        azCol[i] = (char *)pAlloc;
+
        pAlloc += nName+1;
+
        if( zDflt ){
+
          memcpy(pAlloc, zDflt, nDflt+1);
+
          azDflt[i] = (char *)pAlloc;
+
          pAlloc += nDflt+1;
+
        }else{
+
          azDflt[i] = 0;
+
        }
+
        abPK[i] = sqlite3_column_int(pStmt, 5);
+
        aiIdx[i] = sqlite3_column_int(pStmt, 0);
+
        i++;
      }
-
      abPK[i] = sqlite3_column_int(pStmt, 5);
-
      i++;
+
      if( pnTotalCol ) (*pnTotalCol)++;
    }
    rc = sqlite3_reset(pStmt);
  }
@@ -227431,6 +227959,7 @@ static int sessionTableInfo(
    if( pazDflt ) *pazDflt = (const char**)azDflt;
    *pabPK = abPK;
    *pnCol = nDbCol;
+
    if( paiIdx ) *paiIdx = aiIdx;
  }else{
    sessionFree(pSession, azCol);
  }
@@ -227462,7 +227991,8 @@ static int sessionInitTable(
    u8 *abPK;
    assert( pTab->azCol==0 || pTab->abPK==0 );
    rc = sessionTableInfo(pSession, db, zDb,
-
        pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK,
+
        pTab->zName, &pTab->nCol, &pTab->nTotalCol, 0, &pTab->azCol,
+
        &pTab->azDflt, &pTab->aiIdx, &abPK,
        ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0)
    );
    if( rc==SQLITE_OK ){
@@ -227497,15 +228027,17 @@ static int sessionInitTable(
*/
static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
  int nCol = 0;
+
  int nTotalCol = 0;
  const char **azCol = 0;
  const char **azDflt = 0;
+
  int *aiIdx = 0;
  u8 *abPK = 0;
  int bRowid = 0;

  assert( pSession->rc==SQLITE_OK );

  pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb,
-
      pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK,
+
      pTab->zName, &nCol, &nTotalCol, 0, &azCol, &azDflt, &aiIdx, &abPK,
      (pSession->bImplicitPK ? &bRowid : 0)
  );
  if( pSession->rc==SQLITE_OK ){
@@ -227528,8 +228060,10 @@ static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
        const char **a = pTab->azCol;
        pTab->azCol = azCol;
        pTab->nCol = nCol;
+
        pTab->nTotalCol = nTotalCol;
        pTab->azDflt = azDflt;
        pTab->abPK = abPK;
+
        pTab->aiIdx = aiIdx;
        azCol = a;
      }
      if( pSession->bEnableSize ){
@@ -227847,7 +228381,7 @@ static int sessionUpdateMaxSize(
      int ii;
      for(ii=0; ii<pTab->nCol; ii++){
        sqlite3_value *p = 0;
-
        pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
+
        pSession->hook.xNew(pSession->hook.pCtx, pTab->aiIdx[ii], &p);
        sessionSerializeValue(0, p, &nNew);
      }
    }
@@ -227867,8 +228401,9 @@ static int sessionUpdateMaxSize(
      int bChanged = 1;
      int nOld = 0;
      int eType;
+
      int iIdx = pTab->aiIdx[ii];
      sqlite3_value *p = 0;
-
      pSession->hook.xNew(pSession->hook.pCtx, ii-pTab->bRowid, &p);
+
      pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
      if( p==0 ){
        return SQLITE_NOMEM;
      }
@@ -227965,11 +228500,11 @@ static void sessionPreupdateOneChange(
  /* Check the number of columns in this xPreUpdate call matches the
  ** number of columns in the table.  */
  nExpect = pSession->hook.xCount(pSession->hook.pCtx);
-
  if( (pTab->nCol-pTab->bRowid)<nExpect ){
+
  if( pTab->nTotalCol<nExpect ){
    if( sessionReinitTable(pSession, pTab) ) return;
    if( sessionUpdateChanges(pSession, pTab) ) return;
  }
-
  if( (pTab->nCol-pTab->bRowid)!=nExpect ){
+
  if( pTab->nTotalCol!=nExpect ){
    pSession->rc = SQLITE_SCHEMA;
    return;
  }
@@ -228026,14 +228561,15 @@ static void sessionPreupdateOneChange(

      /* Figure out how large an allocation is required */
      nByte = sizeof(SessionChange);
-
      for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
+
      for(i=pTab->bRowid; i<pTab->nCol; i++){
+
        int iIdx = pTab->aiIdx[i];
        sqlite3_value *p = 0;
        if( op!=SQLITE_INSERT ){
          /* This may fail if the column has a non-NULL default and was added
          ** using ALTER TABLE ADD COLUMN after this record was created. */
-
          rc = pSession->hook.xOld(pSession->hook.pCtx, i, &p);
+
          rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
        }else if( pTab->abPK[i] ){
-
          TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);
+
          TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx,iIdx,&p);
          assert( trc==SQLITE_OK );
        }

@@ -228068,12 +228604,13 @@ static void sessionPreupdateOneChange(
        sessionPutI64(&pC->aRecord[1], iRowid);
        nByte = 9;
      }
-
      for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
+
      for(i=pTab->bRowid; i<pTab->nCol; i++){
        sqlite3_value *p = 0;
+
        int iIdx = pTab->aiIdx[i];
        if( op!=SQLITE_INSERT ){
-
          pSession->hook.xOld(pSession->hook.pCtx, i, &p);
+
          pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
        }else if( pTab->abPK[i] ){
-
          pSession->hook.xNew(pSession->hook.pCtx, i, &p);
+
          pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
        }
        sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
      }
@@ -228475,7 +229012,8 @@ SQLITE_API int sqlite3session_diff(
      int bRowid = 0;
      u8 *abPK;
      const char **azCol = 0;
-
      rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK,
+
      rc = sessionTableInfo(0, db, zFrom, zTbl,
+
          &nCol, 0, 0, &azCol, 0, 0, &abPK,
          pSession->bImplicitPK ? &bRowid : 0
      );
      if( rc==SQLITE_OK ){
@@ -228799,9 +229337,11 @@ static void sessionAppendIdent(
    char *zOut = (char *)&p->aBuf[p->nBuf];
    const char *zIn = zStr;
    *zOut++ = '"';
-
    while( *zIn ){
-
      if( *zIn=='"' ) *zOut++ = '"';
-
      *zOut++ = *(zIn++);
+
    if( zIn!=0 ){
+
      while( *zIn ){
+
        if( *zIn=='"' ) *zOut++ = '"';
+
        *zOut++ = *(zIn++);
+
      }
    }
    *zOut++ = '"';
    p->nBuf = (int)((u8 *)zOut - p->aBuf);
@@ -229052,10 +229592,10 @@ static int sessionSelectStmt(
  int rc = SQLITE_OK;
  char *zSql = 0;
  const char *zSep = "";
-
  const char *zCols = bRowid ? SESSIONS_ROWID ", *" : "*";
  int nSql = -1;
  int i;

+
  SessionBuffer cols = {0, 0, 0};
  SessionBuffer nooptest = {0, 0, 0};
  SessionBuffer pkfield = {0, 0, 0};
  SessionBuffer pkvar = {0, 0, 0};
@@ -229068,9 +229608,16 @@ static int sessionSelectStmt(
    sessionAppendStr(&pkvar,
        "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
    );
-
    zCols = "tbl, ?2, stat";
+
    sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
  }else{
+
  #if 0
+
    if( bRowid ){
+
      sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
+
    }
+
    #endif
    for(i=0; i<nCol; i++){
+
      if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
+
      sessionAppendIdent(&cols, azCol[i], &rc);
      if( abPK[i] ){
        sessionAppendStr(&pkfield, zSep, &rc);
        sessionAppendStr(&pkvar, zSep, &rc);
@@ -229088,7 +229635,7 @@ static int sessionSelectStmt(
  if( rc==SQLITE_OK ){
    zSql = sqlite3_mprintf(
        "SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)",
-
        zCols, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
+
        (char*)cols.aBuf, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
        zDb, zTab, (char*)pkfield.aBuf, (char*)pkvar.aBuf
    );
    if( zSql==0 ) rc = SQLITE_NOMEM;
@@ -229131,6 +229678,7 @@ static int sessionSelectStmt(
  sqlite3_free(nooptest.aBuf);
  sqlite3_free(pkfield.aBuf);
  sqlite3_free(pkvar.aBuf);
+
  sqlite3_free(cols.aBuf);
  return rc;
}

@@ -231471,7 +232019,8 @@ static int sessionChangesetApply(

        sqlite3changeset_pk(pIter, &abPK, 0);
        rc = sessionTableInfo(0, db, "main", zNew,
-
            &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid
+
            &sApply.nCol, 0, &zTab, &sApply.azCol, 0, 0,
+
            &sApply.abPK, &sApply.bRowid
        );
        if( rc!=SQLITE_OK ) break;
        for(i=0; i<sApply.nCol; i++){
@@ -231551,12 +232100,17 @@ static int sessionChangesetApply(
      }
    }
  }
-
  sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
+

+
  {
+
    int rc2 = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
+
    if( rc==SQLITE_OK ) rc = rc2;
+
  }

  if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
    if( rc==SQLITE_OK ){
      rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
-
    }else{
+
    }
+
    if( rc!=SQLITE_OK ){
      sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
      sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
    }
@@ -232806,7 +233360,27 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
/************** End of sqlite3session.c **************************************/
/************** Begin file fts5.c ********************************************/

-

+
/*
+
** This, the "fts5.c" source file, is a composite file that is itself
+
** assembled from the following files:
+
**
+
**    fts5.h
+
**    fts5Int.h
+
**    fts5parse.h          <--- Generated from fts5parse.y by Lemon
+
**    fts5parse.c          <--- Generated from fts5parse.y by Lemon
+
**    fts5_aux.c
+
**    fts5_buffer.c
+
**    fts5_config.c
+
**    fts5_expr.c
+
**    fts5_hash.c
+
**    fts5_index.c
+
**    fts5_main.c
+
**    fts5_storage.c
+
**    fts5_tokenize.c
+
**    fts5_unicode2.c
+
**    fts5_varint.c
+
**    fts5_vocab.c
+
*/
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5)

#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -232816,6 +233390,12 @@ SQLITE_API int sqlite3session_config(int op, void *pArg){
# undef NDEBUG
#endif

+
#ifdef HAVE_STDINT_H
+
/* #include <stdint.h> */
+
#endif
+
#ifdef HAVE_INTTYPES_H
+
/* #include <inttypes.h> */
+
#endif
/*
** 2014 May 31
**
@@ -233116,14 +233696,29 @@ struct Fts5PhraseIter {
**   value returned by xInstCount(), SQLITE_RANGE is returned.  Otherwise,
**   output variable (*ppToken) is set to point to a buffer containing the
**   matching document token, and (*pnToken) to the size of that buffer in
-
**   bytes. This API is not available if the specified token matches a
-
**   prefix query term. In that case both output variables are always set
-
**   to 0.
+
**   bytes.
**
**   The output text is not a copy of the document text that was tokenized.
**   It is the output of the tokenizer module. For tokendata=1 tables, this
**   includes any embedded 0x00 and trailing data.
**
+
**   This API may be slow in some cases if the token identified by parameters
+
**   iIdx and iToken matched a prefix token in the query. In most cases, the
+
**   first call to this API for each prefix token in the query is forced
+
**   to scan the portion of the full-text index that matches the prefix
+
**   token to collect the extra data required by this API. If the prefix
+
**   token matches a large number of token instances in the document set,
+
**   this may be a performance problem.
+
**
+
**   If the user knows in advance that a query may use this API for a
+
**   prefix token, FTS5 may be configured to collect all required data as part
+
**   of the initial querying of the full-text index, avoiding the second scan
+
**   entirely. This also causes prefix queries that do not use this API to
+
**   run more slowly and use more memory. FTS5 may be configured in this way
+
**   either on a per-table basis using the [FTS5 insttoken | 'insttoken']
+
**   option, or on a per-query basis using the
+
**   [fts5_insttoken | fts5_insttoken()] user function.
+
**
**   This API can be quite slow if used with an FTS5 table created with the
**   "detail=none" or "detail=column" option.
**
@@ -233805,7 +234400,8 @@ struct Fts5Config {
  char *zRank;                    /* Name of rank function */
  char *zRankArgs;                /* Arguments to rank function */
  int bSecureDelete;              /* 'secure-delete' */
-
  int nDeleteMerge;           /* 'deletemerge' */
+
  int nDeleteMerge;               /* 'deletemerge' */
+
  int bPrefixInsttoken;           /* 'prefix-insttoken' */

  /* If non-NULL, points to sqlite3_vtab.base.zErrmsg. Often NULL. */
  char **pzErrmsg;
@@ -234062,7 +234658,14 @@ static int sqlite3Fts5StructureTest(Fts5Index*, void*);
/*
** Used by xInstToken():
*/
-
static int sqlite3Fts5IterToken(Fts5IndexIter*, i64, int, int, const char**, int*);
+
static int sqlite3Fts5IterToken(
+
  Fts5IndexIter *pIndexIter,
+
  const char *pToken, int nToken,
+
  i64 iRowid,
+
  int iCol,
+
  int iOff,
+
  const char **ppOut, int *pnOut
+
);

/*
** Insert or remove data to or from the index. Each time a document is
@@ -238276,6 +238879,19 @@ static int sqlite3Fts5ConfigSetValue(
    }else{
      pConfig->bSecureDelete = (bVal ? 1 : 0);
    }
+
  }
+

+
  else if( 0==sqlite3_stricmp(zKey, "insttoken") ){
+
    int bVal = -1;
+
    if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){
+
      bVal = sqlite3_value_int(pVal);
+
    }
+
    if( bVal<0 ){
+
      *pbBadkey = 1;
+
    }else{
+
      pConfig->bPrefixInsttoken = (bVal ? 1 : 0);
+
    }
+

  }else{
    *pbBadkey = 1;
  }
@@ -241411,7 +242027,7 @@ static int fts5ExprPopulatePoslistsCb(
        int rc = sqlite3Fts5PoslistWriterAppend(
            &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff
        );
-
        if( rc==SQLITE_OK && pExpr->pConfig->bTokendata && !pT->bPrefix ){
+
        if( rc==SQLITE_OK && (pExpr->pConfig->bTokendata || pT->bPrefix) ){
          int iCol = p->iOff>>32;
          int iTokOff = p->iOff & 0x7FFFFFFF;
          rc = sqlite3Fts5IndexIterWriteTokendata(
@@ -241604,15 +242220,14 @@ static int sqlite3Fts5ExprInstToken(
    return SQLITE_RANGE;
  }
  pTerm = &pPhrase->aTerm[iToken];
-
  if( pTerm->bPrefix==0 ){
-
    if( pExpr->pConfig->bTokendata ){
-
      rc = sqlite3Fts5IterToken(
-
          pTerm->pIter, iRowid, iCol, iOff+iToken, ppOut, pnOut
-
      );
-
    }else{
-
      *ppOut = pTerm->pTerm;
-
      *pnOut = pTerm->nFullTerm;
-
    }
+
  if( pExpr->pConfig->bTokendata || pTerm->bPrefix ){
+
    rc = sqlite3Fts5IterToken(
+
        pTerm->pIter, pTerm->pTerm, pTerm->nQueryTerm,
+
        iRowid, iCol, iOff+iToken, ppOut, pnOut
+
    );
+
  }else{
+
    *ppOut = pTerm->pTerm;
+
    *pnOut = pTerm->nFullTerm;
  }
  return rc;
}
@@ -243002,11 +243617,13 @@ static int fts5LeafFirstTermOff(Fts5Data *pLeaf){
/*
** Close the read-only blob handle, if it is open.
*/
-
static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
+
static void fts5IndexCloseReader(Fts5Index *p){
  if( p->pReader ){
+
    int rc;
    sqlite3_blob *pReader = p->pReader;
    p->pReader = 0;
-
    sqlite3_blob_close(pReader);
+
    rc = sqlite3_blob_close(pReader);
+
    if( p->rc==SQLITE_OK ) p->rc = rc;
  }
}

@@ -243031,7 +243648,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){
      assert( p->pReader==0 );
      p->pReader = pBlob;
      if( rc!=SQLITE_OK ){
-
        sqlite3Fts5IndexCloseReader(p);
+
        fts5IndexCloseReader(p);
      }
      if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
    }
@@ -243115,9 +243732,13 @@ static int fts5IndexPrepareStmt(
){
  if( p->rc==SQLITE_OK ){
    if( zSql ){
-
      p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
+
      int rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
          SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
          ppStmt, 0);
+
      /* If this prepare() call fails with SQLITE_ERROR, then one of the
+
      ** %_idx or %_data tables has been removed or modified. Call this
+
      ** corruption.  */
+
      p->rc = (rc==SQLITE_ERROR ? SQLITE_CORRUPT : rc);
    }else{
      p->rc = SQLITE_NOMEM;
    }
@@ -247229,6 +247850,14 @@ static int fts5IndexReturn(Fts5Index *p){
  return rc;
}

+
/*
+
** Close the read-only blob handle, if it is open.
+
*/
+
static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
+
  fts5IndexCloseReader(p);
+
  fts5IndexReturn(p);
+
}
+

typedef struct Fts5FlushCtx Fts5FlushCtx;
struct Fts5FlushCtx {
  Fts5Index *pIdx;
@@ -247686,8 +248315,11 @@ static void fts5DoSecureDelete(
** This is called as part of flushing a delete to disk in 'secure-delete'
** mode. It edits the segments within the database described by argument
** pStruct to remove the entries for term zTerm, rowid iRowid.
+
**
+
** Return SQLITE_OK if successful, or an SQLite error code if an error
+
** has occurred. Any error code is also stored in the Fts5Index handle.
*/
-
static void fts5FlushSecureDelete(
+
static int fts5FlushSecureDelete(
  Fts5Index *p,
  Fts5Structure *pStruct,
  const char *zTerm,
@@ -247697,6 +248329,24 @@ static void fts5FlushSecureDelete(
  const int f = FTS5INDEX_QUERY_SKIPHASH;
  Fts5Iter *pIter = 0;            /* Used to find term instance */

+
  /* If the version number has not been set to SECUREDELETE, do so now. */
+
  if( p->pConfig->iVersion!=FTS5_CURRENT_VERSION_SECUREDELETE ){
+
    Fts5Config *pConfig = p->pConfig;
+
    sqlite3_stmt *pStmt = 0;
+
    fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
+
          "REPLACE INTO %Q.'%q_config' VALUES ('version', %d)",
+
          pConfig->zDb, pConfig->zName, FTS5_CURRENT_VERSION_SECUREDELETE
+
    ));
+
    if( p->rc==SQLITE_OK ){
+
      int rc;
+
      sqlite3_step(pStmt);
+
      rc = sqlite3_finalize(pStmt);
+
      if( p->rc==SQLITE_OK ) p->rc = rc;
+
      pConfig->iCookie++;
+
      pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
+
    }
+
  }
+

  fts5MultiIterNew(p, pStruct, f, 0, (const u8*)zTerm, nTerm, -1, 0, &pIter);
  if( fts5MultiIterEof(p, pIter)==0 ){
    i64 iThis = fts5MultiIterRowid(pIter);
@@ -247714,6 +248364,7 @@ static void fts5FlushSecureDelete(
  }

  fts5MultiIterFree(pIter);
+
  return p->rc;
}


@@ -247797,8 +248448,9 @@ static void fts5FlushOneHash(Fts5Index *p){
            ** using fts5FlushSecureDelete().  */
            if( bSecureDelete ){
              if( eDetail==FTS5_DETAIL_NONE ){
-
                if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
-
                  fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
+
                if( iOff<nDoclist && pDoclist[iOff]==0x00
+
                 && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
+
                ){
                  iOff++;
                  if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
                    iOff++;
@@ -247807,8 +248459,9 @@ static void fts5FlushOneHash(Fts5Index *p){
                    continue;
                  }
                }
-
              }else if( (pDoclist[iOff] & 0x01) ){
-
                fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
+
              }else if( (pDoclist[iOff] & 0x01)
+
                && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
+
              ){
                if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){
                  iOff++;
                  continue;
@@ -248427,6 +249080,383 @@ static void fts5MergePrefixLists(
  *p1 = out;
}

+

+
/*
+
** Iterate through a range of entries in the FTS index, invoking the xVisit
+
** callback for each of them.
+
**
+
** Parameter pToken points to an nToken buffer containing an FTS index term
+
** (i.e. a document term with the preceding 1 byte index identifier -
+
** FTS5_MAIN_PREFIX or similar). If bPrefix is true, then the call visits
+
** all entries for terms that have pToken/nToken as a prefix. If bPrefix
+
** is false, then only entries with pToken/nToken as the entire key are
+
** visited.
+
**
+
** If the current table is a tokendata=1 table, then if bPrefix is true then
+
** each index term is treated separately. However, if bPrefix is false, then
+
** all index terms corresponding to pToken/nToken are collapsed into a single
+
** term before the callback is invoked.
+
**
+
** The callback invoked for each entry visited is specified by paramter xVisit.
+
** Each time it is invoked, it is passed a pointer to the Fts5Index object,
+
** a copy of the 7th paramter to this function (pCtx) and a pointer to the
+
** iterator that indicates the current entry. If the current entry is the
+
** first with a new term (i.e. different from that of the previous entry,
+
** including the very first term), then the final two parameters are passed
+
** a pointer to the term and its size in bytes, respectively. If the current
+
** entry is not the first associated with its term, these two parameters
+
** are passed 0.
+
**
+
** If parameter pColset is not NULL, then it is used to filter entries before
+
** the callback is invoked.
+
*/
+
static int fts5VisitEntries(
+
  Fts5Index *p,                   /* Fts5 index object */
+
  Fts5Colset *pColset,            /* Columns filter to apply, or NULL */
+
  u8 *pToken,                     /* Buffer containing token */
+
  int nToken,                     /* Size of buffer pToken in bytes */
+
  int bPrefix,                    /* True for a prefix scan */
+
  void (*xVisit)(Fts5Index*, void *pCtx, Fts5Iter *pIter, const u8*, int),
+
  void *pCtx                      /* Passed as second argument to xVisit() */
+
){
+
  const int flags = (bPrefix ? FTS5INDEX_QUERY_SCAN : 0)
+
                  | FTS5INDEX_QUERY_SKIPEMPTY
+
                  | FTS5INDEX_QUERY_NOOUTPUT;
+
  Fts5Iter *p1 = 0;     /* Iterator used to gather data from index */
+
  int bNewTerm = 1;
+
  Fts5Structure *pStruct = fts5StructureRead(p);
+

+
  fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1);
+
  fts5IterSetOutputCb(&p->rc, p1);
+
  for( /* no-op */ ;
+
      fts5MultiIterEof(p, p1)==0;
+
      fts5MultiIterNext2(p, p1, &bNewTerm)
+
  ){
+
    Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];
+
    int nNew = 0;
+
    const u8 *pNew = 0;
+

+
    p1->xSetOutputs(p1, pSeg);
+
    if( p->rc ) break;
+

+
    if( bNewTerm ){
+
      nNew = pSeg->term.n;
+
      pNew = pSeg->term.p;
+
      if( nNew<nToken || memcmp(pToken, pNew, nToken) ) break;
+
    }
+

+
    xVisit(p, pCtx, p1, pNew, nNew);
+
  }
+
  fts5MultiIterFree(p1);
+

+
  fts5StructureRelease(pStruct);
+
  return p->rc;
+
}
+

+

+
/*
+
** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an
+
** array of these for each row it visits (so all iRowid fields are the same).
+
** Or, for an iterator used by an "ORDER BY rank" query, it accumulates an
+
** array of these for the entire query (in which case iRowid fields may take
+
** a variety of values).
+
**
+
** Each instance in the array indicates the iterator (and therefore term)
+
** associated with position iPos of rowid iRowid. This is used by the
+
** xInstToken() API.
+
**
+
** iRowid:
+
**   Rowid for the current entry.
+
**
+
** iPos:
+
**   Position of current entry within row. In the usual ((iCol<<32)+iOff)
+
**   format (e.g. see macros FTS5_POS2COLUMN() and FTS5_POS2OFFSET()).
+
**
+
** iIter:
+
**   If the Fts5TokenDataIter iterator that the entry is part of is
+
**   actually an iterator (i.e. with nIter>0, not just a container for
+
**   Fts5TokenDataMap structures), then this variable is an index into
+
**   the apIter[] array. The corresponding term is that which the iterator
+
**   at apIter[iIter] currently points to.
+
**
+
**   Or, if the Fts5TokenDataIter iterator is just a container object
+
**   (nIter==0), then iIter is an index into the term.p[] buffer where
+
**   the term is stored.
+
**
+
** nByte:
+
**   In the case where iIter is an index into term.p[], this variable
+
**   is the size of the term in bytes. If iIter is an index into apIter[],
+
**   this variable is unused.
+
*/
+
struct Fts5TokenDataMap {
+
  i64 iRowid;                     /* Row this token is located in */
+
  i64 iPos;                       /* Position of token */
+
  int iIter;                      /* Iterator token was read from */
+
  int nByte;                      /* Length of token in bytes (or 0) */
+
};
+

+
/*
+
** An object used to supplement Fts5Iter for tokendata=1 iterators.
+
**
+
** This object serves two purposes. The first is as a container for an array
+
** of Fts5TokenDataMap structures, which are used to find the token required
+
** when the xInstToken() API is used. This is done by the nMapAlloc, nMap and
+
** aMap[] variables.
+
*/
+
struct Fts5TokenDataIter {
+
  int nMapAlloc;                  /* Allocated size of aMap[] in entries */
+
  int nMap;                       /* Number of valid entries in aMap[] */
+
  Fts5TokenDataMap *aMap;         /* Array of (rowid+pos -> token) mappings */
+

+
  /* The following are used for prefix-queries only. */
+
  Fts5Buffer terms;
+

+
  /* The following are used for other full-token tokendata queries only. */
+
  int nIter;
+
  int nIterAlloc;
+
  Fts5PoslistReader *aPoslistReader;
+
  int *aPoslistToIter;
+
  Fts5Iter *apIter[1];
+
};
+

+
/*
+
** The two input arrays - a1[] and a2[] - are in sorted order. This function
+
** merges the two arrays together and writes the result to output array
+
** aOut[]. aOut[] is guaranteed to be large enough to hold the result.
+
**
+
** Duplicate entries are copied into the output. So the size of the output
+
** array is always (n1+n2) entries.
+
*/
+
static void fts5TokendataMerge(
+
  Fts5TokenDataMap *a1, int n1,   /* Input array 1 */
+
  Fts5TokenDataMap *a2, int n2,   /* Input array 2 */
+
  Fts5TokenDataMap *aOut          /* Output array */
+
){
+
  int i1 = 0;
+
  int i2 = 0;
+

+
  assert( n1>=0 && n2>=0 );
+
  while( i1<n1 || i2<n2 ){
+
    Fts5TokenDataMap *pOut = &aOut[i1+i2];
+
    if( i2>=n2 || (i1<n1 && (
+
        a1[i1].iRowid<a2[i2].iRowid
+
     || (a1[i1].iRowid==a2[i2].iRowid && a1[i1].iPos<=a2[i2].iPos)
+
    ))){
+
      memcpy(pOut, &a1[i1], sizeof(Fts5TokenDataMap));
+
      i1++;
+
    }else{
+
      memcpy(pOut, &a2[i2], sizeof(Fts5TokenDataMap));
+
      i2++;
+
    }
+
  }
+
}
+

+

+
/*
+
** Append a mapping to the token-map belonging to object pT.
+
*/
+
static void fts5TokendataIterAppendMap(
+
  Fts5Index *p,
+
  Fts5TokenDataIter *pT,
+
  int iIter,
+
  int nByte,
+
  i64 iRowid,
+
  i64 iPos
+
){
+
  if( p->rc==SQLITE_OK ){
+
    if( pT->nMap==pT->nMapAlloc ){
+
      int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64;
+
      int nAlloc = nNew * sizeof(Fts5TokenDataMap);
+
      Fts5TokenDataMap *aNew;
+

+
      aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nAlloc);
+
      if( aNew==0 ){
+
        p->rc = SQLITE_NOMEM;
+
        return;
+
      }
+

+
      pT->aMap = aNew;
+
      pT->nMapAlloc = nNew;
+
    }
+

+
    pT->aMap[pT->nMap].iRowid = iRowid;
+
    pT->aMap[pT->nMap].iPos = iPos;
+
    pT->aMap[pT->nMap].iIter = iIter;
+
    pT->aMap[pT->nMap].nByte = nByte;
+
    pT->nMap++;
+
  }
+
}
+

+
/*
+
** Sort the contents of the pT->aMap[] array.
+
**
+
** The sorting algorithm requries a malloc(). If this fails, an error code
+
** is left in Fts5Index.rc before returning.
+
*/
+
static void fts5TokendataIterSortMap(Fts5Index *p, Fts5TokenDataIter *pT){
+
  Fts5TokenDataMap *aTmp = 0;
+
  int nByte = pT->nMap * sizeof(Fts5TokenDataMap);
+

+
  aTmp = (Fts5TokenDataMap*)sqlite3Fts5MallocZero(&p->rc, nByte);
+
  if( aTmp ){
+
    Fts5TokenDataMap *a1 = pT->aMap;
+
    Fts5TokenDataMap *a2 = aTmp;
+
    i64 nHalf;
+

+
    for(nHalf=1; nHalf<pT->nMap; nHalf=nHalf*2){
+
      int i1;
+
      for(i1=0; i1<pT->nMap; i1+=(nHalf*2)){
+
        int n1 = MIN(nHalf, pT->nMap-i1);
+
        int n2 = MIN(nHalf, pT->nMap-i1-n1);
+
        fts5TokendataMerge(&a1[i1], n1, &a1[i1+n1], n2, &a2[i1]);
+
      }
+
      SWAPVAL(Fts5TokenDataMap*, a1, a2);
+
    }
+

+
    if( a1!=pT->aMap ){
+
      memcpy(pT->aMap, a1, pT->nMap*sizeof(Fts5TokenDataMap));
+
    }
+
    sqlite3_free(aTmp);
+

+
#ifdef SQLITE_DEBUG
+
    {
+
      int ii;
+
      for(ii=1; ii<pT->nMap; ii++){
+
        Fts5TokenDataMap *p1 = &pT->aMap[ii-1];
+
        Fts5TokenDataMap *p2 = &pT->aMap[ii];
+
        assert( p1->iRowid<p2->iRowid
+
             || (p1->iRowid==p2->iRowid && p1->iPos<=p2->iPos)
+
        );
+
      }
+
    }
+
#endif
+
  }
+
}
+

+
/*
+
** Delete an Fts5TokenDataIter structure and its contents.
+
*/
+
static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){
+
  if( pSet ){
+
    int ii;
+
    for(ii=0; ii<pSet->nIter; ii++){
+
      fts5MultiIterFree(pSet->apIter[ii]);
+
    }
+
    fts5BufferFree(&pSet->terms);
+
    sqlite3_free(pSet->aPoslistReader);
+
    sqlite3_free(pSet->aMap);
+
    sqlite3_free(pSet);
+
  }
+
}
+

+

+
/*
+
** fts5VisitEntries() context object used by fts5SetupPrefixIterTokendata()
+
** to pass data to prefixIterSetupTokendataCb().
+
*/
+
typedef struct TokendataSetupCtx TokendataSetupCtx;
+
struct TokendataSetupCtx {
+
  Fts5TokenDataIter *pT;          /* Object being populated with mappings */
+
  int iTermOff;                   /* Offset of current term in terms.p[] */
+
  int nTermByte;                  /* Size of current term in bytes */
+
};
+

+
/*
+
** fts5VisitEntries() callback used by fts5SetupPrefixIterTokendata(). This
+
** callback adds an entry to the Fts5TokenDataIter.aMap[] array for each
+
** position in the current position-list. It doesn't matter that some of
+
** these may be out of order - they will be sorted later.
+
*/
+
static void prefixIterSetupTokendataCb(
+
  Fts5Index *p,
+
  void *pCtx,
+
  Fts5Iter *p1,
+
  const u8 *pNew,
+
  int nNew
+
){
+
  TokendataSetupCtx *pSetup = (TokendataSetupCtx*)pCtx;
+
  int iPosOff = 0;
+
  i64 iPos = 0;
+

+
  if( pNew ){
+
    pSetup->nTermByte = nNew-1;
+
    pSetup->iTermOff = pSetup->pT->terms.n;
+
    fts5BufferAppendBlob(&p->rc, &pSetup->pT->terms, nNew-1, pNew+1);
+
  }
+

+
  while( 0==sqlite3Fts5PoslistNext64(
+
     p1->base.pData, p1->base.nData, &iPosOff, &iPos
+
  ) ){
+
    fts5TokendataIterAppendMap(p,
+
        pSetup->pT, pSetup->iTermOff, pSetup->nTermByte, p1->base.iRowid, iPos
+
    );
+
  }
+
}
+

+

+
/*
+
** Context object passed by fts5SetupPrefixIter() to fts5VisitEntries().
+
*/
+
typedef struct PrefixSetupCtx PrefixSetupCtx;
+
struct PrefixSetupCtx {
+
  void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*);
+
  void (*xAppend)(Fts5Index*, u64, Fts5Iter*, Fts5Buffer*);
+
  i64 iLastRowid;
+
  int nMerge;
+
  Fts5Buffer *aBuf;
+
  int nBuf;
+
  Fts5Buffer doclist;
+
  TokendataSetupCtx *pTokendata;
+
};
+

+
/*
+
** fts5VisitEntries() callback used by fts5SetupPrefixIter()
+
*/
+
static void prefixIterSetupCb(
+
  Fts5Index *p,
+
  void *pCtx,
+
  Fts5Iter *p1,
+
  const u8 *pNew,
+
  int nNew
+
){
+
  PrefixSetupCtx *pSetup = (PrefixSetupCtx*)pCtx;
+
  const int nMerge = pSetup->nMerge;
+

+
  if( p1->base.nData>0 ){
+
    if( p1->base.iRowid<=pSetup->iLastRowid && pSetup->doclist.n>0 ){
+
      int i;
+
      for(i=0; p->rc==SQLITE_OK && pSetup->doclist.n; i++){
+
        int i1 = i*nMerge;
+
        int iStore;
+
        assert( i1+nMerge<=pSetup->nBuf );
+
        for(iStore=i1; iStore<i1+nMerge; iStore++){
+
          if( pSetup->aBuf[iStore].n==0 ){
+
            fts5BufferSwap(&pSetup->doclist, &pSetup->aBuf[iStore]);
+
            fts5BufferZero(&pSetup->doclist);
+
            break;
+
          }
+
        }
+
        if( iStore==i1+nMerge ){
+
          pSetup->xMerge(p, &pSetup->doclist, nMerge, &pSetup->aBuf[i1]);
+
          for(iStore=i1; iStore<i1+nMerge; iStore++){
+
            fts5BufferZero(&pSetup->aBuf[iStore]);
+
          }
+
        }
+
      }
+
      pSetup->iLastRowid = 0;
+
    }
+

+
    pSetup->xAppend(
+
        p, (u64)p1->base.iRowid-(u64)pSetup->iLastRowid, p1, &pSetup->doclist
+
    );
+
    pSetup->iLastRowid = p1->base.iRowid;
+
  }
+

+
  if( pSetup->pTokendata ){
+
    prefixIterSetupTokendataCb(p, (void*)pSetup->pTokendata, p1, pNew, nNew);
+
  }
+
}
+

static void fts5SetupPrefixIter(
  Fts5Index *p,                   /* Index to read from */
  int bDesc,                      /* True for "ORDER BY rowid DESC" */
@@ -248437,38 +249467,41 @@ static void fts5SetupPrefixIter(
  Fts5Iter **ppIter               /* OUT: New iterator */
){
  Fts5Structure *pStruct;
-
  Fts5Buffer *aBuf;
-
  int nBuf = 32;
-
  int nMerge = 1;
+
  PrefixSetupCtx s;
+
  TokendataSetupCtx s2;
+

+
  memset(&s, 0, sizeof(s));
+
  memset(&s2, 0, sizeof(s2));
+

+
  s.nMerge = 1;
+
  s.iLastRowid = 0;
+
  s.nBuf = 32;
+
  if( iIdx==0
+
   && p->pConfig->eDetail==FTS5_DETAIL_FULL
+
   && p->pConfig->bPrefixInsttoken
+
  ){
+
    s.pTokendata = &s2;
+
    s2.pT = (Fts5TokenDataIter*)fts5IdxMalloc(p, sizeof(*s2.pT));
+
  }

-
  void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*);
-
  void (*xAppend)(Fts5Index*, u64, Fts5Iter*, Fts5Buffer*);
  if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){
-
    xMerge = fts5MergeRowidLists;
-
    xAppend = fts5AppendRowid;
+
    s.xMerge = fts5MergeRowidLists;
+
    s.xAppend = fts5AppendRowid;
  }else{
-
    nMerge = FTS5_MERGE_NLIST-1;
-
    nBuf = nMerge*8;   /* Sufficient to merge (16^8)==(2^32) lists */
-
    xMerge = fts5MergePrefixLists;
-
    xAppend = fts5AppendPoslist;
+
    s.nMerge = FTS5_MERGE_NLIST-1;
+
    s.nBuf = s.nMerge*8;   /* Sufficient to merge (16^8)==(2^32) lists */
+
    s.xMerge = fts5MergePrefixLists;
+
    s.xAppend = fts5AppendPoslist;
  }

-
  aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*nBuf);
+
  s.aBuf = (Fts5Buffer*)fts5IdxMalloc(p, sizeof(Fts5Buffer)*s.nBuf);
  pStruct = fts5StructureRead(p);
-
  assert( p->rc!=SQLITE_OK || (aBuf && pStruct) );
+
  assert( p->rc!=SQLITE_OK || (s.aBuf && pStruct) );

  if( p->rc==SQLITE_OK ){
-
    const int flags = FTS5INDEX_QUERY_SCAN
-
                    | FTS5INDEX_QUERY_SKIPEMPTY
-
                    | FTS5INDEX_QUERY_NOOUTPUT;
+
    void *pCtx = (void*)&s;
    int i;
-
    i64 iLastRowid = 0;
-
    Fts5Iter *p1 = 0;     /* Iterator used to gather data from index */
    Fts5Data *pData;
-
    Fts5Buffer doclist;
-
    int bNewTerm = 1;
-

-
    memset(&doclist, 0, sizeof(doclist));

    /* If iIdx is non-zero, then it is the number of a prefix-index for
    ** prefixes 1 character longer than the prefix being queried for. That
@@ -248476,94 +249509,45 @@ static void fts5SetupPrefixIter(
    ** corresponding to the prefix itself. That one is extracted from the
    ** main term index here.  */
    if( iIdx!=0 ){
-
      int dummy = 0;
-
      const int f2 = FTS5INDEX_QUERY_SKIPEMPTY|FTS5INDEX_QUERY_NOOUTPUT;
      pToken[0] = FTS5_MAIN_PREFIX;
-
      fts5MultiIterNew(p, pStruct, f2, pColset, pToken, nToken, -1, 0, &p1);
-
      fts5IterSetOutputCb(&p->rc, p1);
-
      for(;
-
        fts5MultiIterEof(p, p1)==0;
-
        fts5MultiIterNext2(p, p1, &dummy)
-
      ){
-
        Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];
-
        p1->xSetOutputs(p1, pSeg);
-
        if( p1->base.nData ){
-
          xAppend(p, (u64)p1->base.iRowid-(u64)iLastRowid, p1, &doclist);
-
          iLastRowid = p1->base.iRowid;
-
        }
-
      }
-
      fts5MultiIterFree(p1);
+
      fts5VisitEntries(p, pColset, pToken, nToken, 0, prefixIterSetupCb, pCtx);
    }

    pToken[0] = FTS5_MAIN_PREFIX + iIdx;
-
    fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1);
-
    fts5IterSetOutputCb(&p->rc, p1);
-

-
    for( /* no-op */ ;
-
        fts5MultiIterEof(p, p1)==0;
-
        fts5MultiIterNext2(p, p1, &bNewTerm)
-
    ){
-
      Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ];
-
      int nTerm = pSeg->term.n;
-
      const u8 *pTerm = pSeg->term.p;
-
      p1->xSetOutputs(p1, pSeg);
-

-
      assert_nc( memcmp(pToken, pTerm, MIN(nToken, nTerm))<=0 );
-
      if( bNewTerm ){
-
        if( nTerm<nToken || memcmp(pToken, pTerm, nToken) ) break;
-
      }
-

-
      if( p1->base.nData==0 ) continue;
-
      if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){
-
        for(i=0; p->rc==SQLITE_OK && doclist.n; i++){
-
          int i1 = i*nMerge;
-
          int iStore;
-
          assert( i1+nMerge<=nBuf );
-
          for(iStore=i1; iStore<i1+nMerge; iStore++){
-
            if( aBuf[iStore].n==0 ){
-
              fts5BufferSwap(&doclist, &aBuf[iStore]);
-
              fts5BufferZero(&doclist);
-
              break;
-
            }
-
          }
-
          if( iStore==i1+nMerge ){
-
            xMerge(p, &doclist, nMerge, &aBuf[i1]);
-
            for(iStore=i1; iStore<i1+nMerge; iStore++){
-
              fts5BufferZero(&aBuf[iStore]);
-
            }
-
          }
-
        }
-
        iLastRowid = 0;
-
      }
+
    fts5VisitEntries(p, pColset, pToken, nToken, 1, prefixIterSetupCb, pCtx);

-
      xAppend(p, (u64)p1->base.iRowid-(u64)iLastRowid, p1, &doclist);
-
      iLastRowid = p1->base.iRowid;
-
    }
-

-
    assert( (nBuf%nMerge)==0 );
-
    for(i=0; i<nBuf; i+=nMerge){
+
    assert( (s.nBuf%s.nMerge)==0 );
+
    for(i=0; i<s.nBuf; i+=s.nMerge){
      int iFree;
      if( p->rc==SQLITE_OK ){
-
        xMerge(p, &doclist, nMerge, &aBuf[i]);
+
        s.xMerge(p, &s.doclist, s.nMerge, &s.aBuf[i]);
      }
-
      for(iFree=i; iFree<i+nMerge; iFree++){
-
        fts5BufferFree(&aBuf[iFree]);
+
      for(iFree=i; iFree<i+s.nMerge; iFree++){
+
        fts5BufferFree(&s.aBuf[iFree]);
      }
    }
-
    fts5MultiIterFree(p1);

-
    pData = fts5IdxMalloc(p, sizeof(*pData)+doclist.n+FTS5_DATA_ZERO_PADDING);
+
    pData = fts5IdxMalloc(p, sizeof(*pData)+s.doclist.n+FTS5_DATA_ZERO_PADDING);
+
    assert( pData!=0 || p->rc!=SQLITE_OK );
    if( pData ){
      pData->p = (u8*)&pData[1];
-
      pData->nn = pData->szLeaf = doclist.n;
-
      if( doclist.n ) memcpy(pData->p, doclist.p, doclist.n);
+
      pData->nn = pData->szLeaf = s.doclist.n;
+
      if( s.doclist.n ) memcpy(pData->p, s.doclist.p, s.doclist.n);
      fts5MultiIterNew2(p, pData, bDesc, ppIter);
    }
-
    fts5BufferFree(&doclist);
+

+
    assert( (*ppIter)!=0 || p->rc!=SQLITE_OK );
+
    if( p->rc==SQLITE_OK && s.pTokendata ){
+
      fts5TokendataIterSortMap(p, s2.pT);
+
      (*ppIter)->pTokenDataIter = s2.pT;
+
      s2.pT = 0;
+
    }
  }

+
  fts5TokendataIterDelete(s2.pT);
+
  fts5BufferFree(&s.doclist);
  fts5StructureRelease(pStruct);
-
  sqlite3_free(aBuf);
+
  sqlite3_free(s.aBuf);
}


@@ -248601,7 +249585,7 @@ static int sqlite3Fts5IndexBeginWrite(Fts5Index *p, int bDelete, i64 iRowid){
static int sqlite3Fts5IndexSync(Fts5Index *p){
  assert( p->rc==SQLITE_OK );
  fts5IndexFlush(p);
-
  sqlite3Fts5IndexCloseReader(p);
+
  fts5IndexCloseReader(p);
  return fts5IndexReturn(p);
}

@@ -248612,11 +249596,10 @@ static int sqlite3Fts5IndexSync(Fts5Index *p){
** records must be invalidated.
*/
static int sqlite3Fts5IndexRollback(Fts5Index *p){
-
  sqlite3Fts5IndexCloseReader(p);
+
  fts5IndexCloseReader(p);
  fts5IndexDiscardData(p);
  fts5StructureInvalidate(p);
-
  /* assert( p->rc==SQLITE_OK ); */
-
  return SQLITE_OK;
+
  return fts5IndexReturn(p);
}

/*
@@ -248817,37 +249800,15 @@ static void fts5SegIterSetEOF(Fts5SegIter *pSeg){
  pSeg->pLeaf = 0;
}

-
/*
-
** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an
-
** array of these for each row it visits. Or, for an iterator used by an
-
** "ORDER BY rank" query, it accumulates an array of these for the entire
-
** query.
-
**
-
** Each instance in the array indicates the iterator (and therefore term)
-
** associated with position iPos of rowid iRowid. This is used by the
-
** xInstToken() API.
-
*/
-
struct Fts5TokenDataMap {
-
  i64 iRowid;                     /* Row this token is located in */
-
  i64 iPos;                       /* Position of token */
-
  int iIter;                      /* Iterator token was read from */
-
};
-

-
/*
-
** An object used to supplement Fts5Iter for tokendata=1 iterators.
-
*/
-
struct Fts5TokenDataIter {
-
  int nIter;
-
  int nIterAlloc;
-

-
  int nMap;
-
  int nMapAlloc;
-
  Fts5TokenDataMap *aMap;
-

-
  Fts5PoslistReader *aPoslistReader;
-
  int *aPoslistToIter;
-
  Fts5Iter *apIter[1];
-
};
+
static void fts5IterClose(Fts5IndexIter *pIndexIter){
+
  if( pIndexIter ){
+
    Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
+
    Fts5Index *pIndex = pIter->pIndex;
+
    fts5TokendataIterDelete(pIter->pTokenDataIter);
+
    fts5MultiIterFree(pIter);
+
    fts5IndexCloseReader(pIndex);
+
  }
+
}

/*
** This function appends iterator pAppend to Fts5TokenDataIter pIn and
@@ -248876,7 +249837,7 @@ static Fts5TokenDataIter *fts5AppendTokendataIter(
    }
  }
  if( p->rc ){
-
    sqlite3Fts5IterClose((Fts5IndexIter*)pAppend);
+
    fts5IterClose((Fts5IndexIter*)pAppend);
  }else{
    pRet->apIter[pRet->nIter++] = pAppend;
  }
@@ -248886,54 +249847,6 @@ static Fts5TokenDataIter *fts5AppendTokendataIter(
}

/*
-
** Delete an Fts5TokenDataIter structure and its contents.
-
*/
-
static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){
-
  if( pSet ){
-
    int ii;
-
    for(ii=0; ii<pSet->nIter; ii++){
-
      fts5MultiIterFree(pSet->apIter[ii]);
-
    }
-
    sqlite3_free(pSet->aPoslistReader);
-
    sqlite3_free(pSet->aMap);
-
    sqlite3_free(pSet);
-
  }
-
}
-

-
/*
-
** Append a mapping to the token-map belonging to object pT.
-
*/
-
static void fts5TokendataIterAppendMap(
-
  Fts5Index *p,
-
  Fts5TokenDataIter *pT,
-
  int iIter,
-
  i64 iRowid,
-
  i64 iPos
-
){
-
  if( p->rc==SQLITE_OK ){
-
    if( pT->nMap==pT->nMapAlloc ){
-
      int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64;
-
      int nByte = nNew * sizeof(Fts5TokenDataMap);
-
      Fts5TokenDataMap *aNew;
-

-
      aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nByte);
-
      if( aNew==0 ){
-
        p->rc = SQLITE_NOMEM;
-
        return;
-
      }
-

-
      pT->aMap = aNew;
-
      pT->nMapAlloc = nNew;
-
    }
-

-
    pT->aMap[pT->nMap].iRowid = iRowid;
-
    pT->aMap[pT->nMap].iPos = iPos;
-
    pT->aMap[pT->nMap].iIter = iIter;
-
    pT->nMap++;
-
  }
-
}
-

-
/*
** The iterator passed as the only argument must be a tokendata=1 iterator
** (pIter->pTokenDataIter!=0). This function sets the iterator output
** variables (pIter->base.*) according to the contents of the current
@@ -248973,7 +249886,7 @@ static void fts5IterSetOutputsTokendata(Fts5Iter *pIter){
    pIter->base.iRowid = iRowid;

    if( nHit==1 && eDetail==FTS5_DETAIL_FULL ){
-
      fts5TokendataIterAppendMap(pIter->pIndex, pT, iMin, iRowid, -1);
+
      fts5TokendataIterAppendMap(pIter->pIndex, pT, iMin, 0, iRowid, -1);
    }else
    if( nHit>1 && eDetail!=FTS5_DETAIL_NONE ){
      int nReader = 0;
@@ -249137,7 +250050,7 @@ static Fts5Iter *fts5SetupTokendataIter(
      fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
    }
    if( p->rc ){
-
      sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
+
      fts5IterClose((Fts5IndexIter*)pNew);
      break;
    }

@@ -249202,7 +250115,7 @@ static Fts5Iter *fts5SetupTokendataIter(
    ** not point to any terms that match the query. So delete it and break
    ** out of the loop - all required iterators have been collected.  */
    if( pSmall==0 ){
-
      sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
+
      fts5IterClose((Fts5IndexIter*)pNew);
      break;
    }

@@ -249226,6 +250139,7 @@ static Fts5Iter *fts5SetupTokendataIter(
    pRet = fts5MultiIterAlloc(p, 0);
  }
  if( pRet ){
+
    pRet->nSeg = 0;
    pRet->pTokenDataIter = pSet;
    if( pSet ){
      fts5IterSetOutputsTokendata(pRet);
@@ -249241,7 +250155,6 @@ static Fts5Iter *fts5SetupTokendataIter(
  return pRet;
}

-

/*
** Open a new iterator to iterate though all rowid that match the
** specified token or token prefix.
@@ -249264,8 +250177,14 @@ static int sqlite3Fts5IndexQuery(
    int iIdx = 0;                 /* Index to search */
    int iPrefixIdx = 0;           /* +1 prefix index */
    int bTokendata = pConfig->bTokendata;
+
    assert( buf.p!=0 );
    if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);

+
    /* The NOTOKENDATA flag is set when each token in a tokendata=1 table
+
    ** should be treated individually, instead of merging all those with
+
    ** a common prefix into a single entry. This is used, for example, by
+
    ** queries performed as part of an integrity-check, or by the fts5vocab
+
    ** module.  */
    if( flags & (FTS5INDEX_QUERY_NOTOKENDATA|FTS5INDEX_QUERY_SCAN) ){
      bTokendata = 0;
    }
@@ -249296,7 +250215,7 @@ static int sqlite3Fts5IndexQuery(
    }

    if( bTokendata && iIdx==0 ){
-
      buf.p[0] = '0';
+
      buf.p[0] = FTS5_MAIN_PREFIX;
      pRet = fts5SetupTokendataIter(p, buf.p, nToken+1, pColset);
    }else if( iIdx<=pConfig->nPrefix ){
      /* Straight index lookup */
@@ -249309,7 +250228,7 @@ static int sqlite3Fts5IndexQuery(
        fts5StructureRelease(pStruct);
      }
    }else{
-
      /* Scan multiple terms in the main index */
+
      /* Scan multiple terms in the main index for a prefix query. */
      int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0;
      fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet);
      if( pRet==0 ){
@@ -249325,9 +250244,9 @@ static int sqlite3Fts5IndexQuery(
    }

    if( p->rc ){
-
      sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
+
      fts5IterClose((Fts5IndexIter*)pRet);
      pRet = 0;
-
      sqlite3Fts5IndexCloseReader(p);
+
      fts5IndexCloseReader(p);
    }

    *ppIter = (Fts5IndexIter*)pRet;
@@ -249345,7 +250264,8 @@ static int sqlite3Fts5IndexQuery(
static int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){
  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
  assert( pIter->pIndex->rc==SQLITE_OK );
-
  if( pIter->pTokenDataIter ){
+
  if( pIter->nSeg==0 ){
+
    assert( pIter->pTokenDataIter );
    fts5TokendataIterNext(pIter, 0, 0);
  }else{
    fts5MultiIterNext(pIter->pIndex, pIter, 0, 0);
@@ -249382,7 +250302,8 @@ static int sqlite3Fts5IterNextScan(Fts5IndexIter *pIndexIter){
*/
static int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){
  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
-
  if( pIter->pTokenDataIter ){
+
  if( pIter->nSeg==0 ){
+
    assert( pIter->pTokenDataIter );
    fts5TokendataIterNext(pIter, 1, iMatch);
  }else{
    fts5MultiIterNextFrom(pIter->pIndex, pIter, iMatch);
@@ -249402,13 +250323,60 @@ static const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){
}

/*
+
** pIter is a prefix query. This function populates pIter->pTokenDataIter
+
** with an Fts5TokenDataIter object containing mappings for all rows
+
** matched by the query.
+
*/
+
static int fts5SetupPrefixIterTokendata(
+
  Fts5Iter *pIter,
+
  const char *pToken,             /* Token prefix to search for */
+
  int nToken                      /* Size of pToken in bytes */
+
){
+
  Fts5Index *p = pIter->pIndex;
+
  Fts5Buffer token = {0, 0, 0};
+
  TokendataSetupCtx ctx;
+

+
  memset(&ctx, 0, sizeof(ctx));
+

+
  fts5BufferGrow(&p->rc, &token, nToken+1);
+
  assert( token.p!=0 || p->rc!=SQLITE_OK );
+
  ctx.pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*ctx.pT));
+

+
  if( p->rc==SQLITE_OK ){
+

+
    /* Fill in the token prefix to search for */
+
    token.p[0] = FTS5_MAIN_PREFIX;
+
    memcpy(&token.p[1], pToken, nToken);
+
    token.n = nToken+1;
+

+
    fts5VisitEntries(
+
        p, 0, token.p, token.n, 1, prefixIterSetupTokendataCb, (void*)&ctx
+
    );
+

+
    fts5TokendataIterSortMap(p, ctx.pT);
+
  }
+

+
  if( p->rc==SQLITE_OK ){
+
    pIter->pTokenDataIter = ctx.pT;
+
  }else{
+
    fts5TokendataIterDelete(ctx.pT);
+
  }
+
  fts5BufferFree(&token);
+

+
  return fts5IndexReturn(p);
+
}
+

+
/*
** This is used by xInstToken() to access the token at offset iOff, column
** iCol of row iRowid. The token is returned via output variables *ppOut
** and *pnOut. The iterator passed as the first argument must be a tokendata=1
** iterator (pIter->pTokenDataIter!=0).
+
**
+
** pToken/nToken:
*/
static int sqlite3Fts5IterToken(
  Fts5IndexIter *pIndexIter,
+
  const char *pToken, int nToken,
  i64 iRowid,
  int iCol,
  int iOff,
@@ -249416,13 +250384,22 @@ static int sqlite3Fts5IterToken(
){
  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
  Fts5TokenDataIter *pT = pIter->pTokenDataIter;
-
  Fts5TokenDataMap *aMap = pT->aMap;
  i64 iPos = (((i64)iCol)<<32) + iOff;
-

+
  Fts5TokenDataMap *aMap = 0;
  int i1 = 0;
-
  int i2 = pT->nMap;
+
  int i2 = 0;
  int iTest = 0;

+
  assert( pT || (pToken && pIter->nSeg>0) );
+
  if( pT==0 ){
+
    int rc = fts5SetupPrefixIterTokendata(pIter, pToken, nToken);
+
    if( rc!=SQLITE_OK ) return rc;
+
    pT = pIter->pTokenDataIter;
+
  }
+

+
  i2 = pT->nMap;
+
  aMap = pT->aMap;
+

  while( i2>i1 ){
    iTest = (i1 + i2) / 2;

@@ -249445,9 +250422,15 @@ static int sqlite3Fts5IterToken(
  }

  if( i2>i1 ){
-
    Fts5Iter *pMap = pT->apIter[aMap[iTest].iIter];
-
    *ppOut = (const char*)pMap->aSeg[0].term.p+1;
-
    *pnOut = pMap->aSeg[0].term.n-1;
+
    if( pIter->nSeg==0 ){
+
      Fts5Iter *pMap = pT->apIter[aMap[iTest].iIter];
+
      *ppOut = (const char*)pMap->aSeg[0].term.p+1;
+
      *pnOut = pMap->aSeg[0].term.n-1;
+
    }else{
+
      Fts5TokenDataMap *p = &aMap[iTest];
+
      *ppOut = (const char*)&pT->terms.p[p->iIter];
+
      *pnOut = aMap[iTest].nByte;
+
    }
  }

  return SQLITE_OK;
@@ -249459,7 +250442,9 @@ static int sqlite3Fts5IterToken(
*/
static void sqlite3Fts5IndexIterClearTokendata(Fts5IndexIter *pIndexIter){
  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
-
  if( pIter && pIter->pTokenDataIter ){
+
  if( pIter && pIter->pTokenDataIter
+
   && (pIter->nSeg==0 || pIter->pIndex->pConfig->eDetail!=FTS5_DETAIL_FULL)
+
  ){
    pIter->pTokenDataIter->nMap = 0;
  }
}
@@ -249479,17 +250464,29 @@ static int sqlite3Fts5IndexIterWriteTokendata(
  Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
  Fts5TokenDataIter *pT = pIter->pTokenDataIter;
  Fts5Index *p = pIter->pIndex;
-
  int ii;
+
  i64 iPos = (((i64)iCol)<<32) + iOff;

  assert( p->pConfig->eDetail!=FTS5_DETAIL_FULL );
-
  assert( pIter->pTokenDataIter );
-

-
  for(ii=0; ii<pT->nIter; ii++){
-
    Fts5Buffer *pTerm = &pT->apIter[ii]->aSeg[0].term;
-
    if( nToken==pTerm->n-1 && memcmp(pToken, pTerm->p+1, nToken)==0 ) break;
-
  }
-
  if( ii<pT->nIter ){
-
    fts5TokendataIterAppendMap(p, pT, ii, iRowid, (((i64)iCol)<<32) + iOff);
+
  assert( pIter->pTokenDataIter || pIter->nSeg>0 );
+
  if( pIter->nSeg>0 ){
+
    /* This is a prefix term iterator. */
+
    if( pT==0 ){
+
      pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*pT));
+
      pIter->pTokenDataIter = pT;
+
    }
+
    if( pT ){
+
      fts5TokendataIterAppendMap(p, pT, pT->terms.n, nToken, iRowid, iPos);
+
      fts5BufferAppendBlob(&p->rc, &pT->terms, nToken, (const u8*)pToken);
+
    }
+
  }else{
+
    int ii;
+
    for(ii=0; ii<pT->nIter; ii++){
+
      Fts5Buffer *pTerm = &pT->apIter[ii]->aSeg[0].term;
+
      if( nToken==pTerm->n-1 && memcmp(pToken, pTerm->p+1, nToken)==0 ) break;
+
    }
+
    if( ii<pT->nIter ){
+
      fts5TokendataIterAppendMap(p, pT, ii, 0, iRowid, iPos);
+
    }
  }
  return fts5IndexReturn(p);
}
@@ -249499,11 +250496,9 @@ static int sqlite3Fts5IndexIterWriteTokendata(
*/
static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
  if( pIndexIter ){
-
    Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
-
    Fts5Index *pIndex = pIter->pIndex;
-
    fts5TokendataIterDelete(pIter->pTokenDataIter);
-
    fts5MultiIterFree(pIter);
-
    sqlite3Fts5IndexCloseReader(pIndex);
+
    Fts5Index *pIndex = ((Fts5Iter*)pIndexIter)->pIndex;
+
    fts5IterClose(pIndexIter);
+
    fts5IndexReturn(pIndex);
  }
}

@@ -250033,7 +251028,7 @@ static int fts5QueryCksum(
      rc = sqlite3Fts5IterNext(pIter);
    }
  }
-
  sqlite3Fts5IterClose(pIter);
+
  fts5IterClose(pIter);

  *pCksum = cksum;
  return rc;
@@ -251394,6 +252389,7 @@ struct Fts5Global {
#define FTS5_LOCALE_HDR_SIZE ((int)sizeof( ((Fts5Global*)0)->aLocaleHdr ))
#define FTS5_LOCALE_HDR(pConfig) ((const u8*)(pConfig->pGlobal->aLocaleHdr))

+
#define FTS5_INSTTOKEN_SUBTYPE 73

/*
** Each auxiliary function registered with the FTS5 module is represented
@@ -251933,6 +252929,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
      if( p->usable==0 || iCol<0 ){
        /* As there exists an unusable MATCH constraint this is an
        ** unusable plan. Return SQLITE_CONSTRAINT. */
+
        idxStr[iIdxStr] = 0;
        return SQLITE_CONSTRAINT;
      }else{
        if( iCol==nCol+1 ){
@@ -252718,6 +253715,7 @@ static int fts5FilterMethod(
  sqlite3_value *pRowidGe = 0;    /* rowid >= ? expression (or NULL) */
  int iCol;                       /* Column on LHS of MATCH operator */
  char **pzErrmsg = pConfig->pzErrmsg;
+
  int bPrefixInsttoken = pConfig->bPrefixInsttoken;
  int i;
  int iIdxStr = 0;
  Fts5Expr *pExpr = 0;
@@ -252753,6 +253751,9 @@ static int fts5FilterMethod(
        rc = fts5ExtractExprText(pConfig, apVal[i], &zText, &bFreeAndReset);
        if( rc!=SQLITE_OK ) goto filter_out;
        if( zText==0 ) zText = "";
+
        if( sqlite3_value_subtype(apVal[i])==FTS5_INSTTOKEN_SUBTYPE ){
+
          pConfig->bPrefixInsttoken = 1;
+
        }

        iCol = 0;
        do{
@@ -252893,6 +253894,7 @@ static int fts5FilterMethod(
 filter_out:
  sqlite3Fts5ExprFree(pExpr);
  pConfig->pzErrmsg = pzErrmsg;
+
  pConfig->bPrefixInsttoken = bPrefixInsttoken;
  return rc;
}

@@ -253195,7 +254197,6 @@ static int fts5UpdateMethod(
  Fts5Config *pConfig = pTab->p.pConfig;
  int eType0;                     /* value_type() of apVal[0] */
  int rc = SQLITE_OK;             /* Return code */
-
  int bUpdateOrDelete = 0;

  /* A transaction must be open when this is called. */
  assert( pTab->ts.eState==1 || pTab->ts.eState==2 );
@@ -253207,7 +254208,7 @@ static int fts5UpdateMethod(
  );
  assert( pTab->p.pConfig->pzErrmsg==0 );
  if( pConfig->pgsz==0 ){
-
    rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
+
    rc = sqlite3Fts5ConfigLoad(pTab->p.pConfig, pTab->p.pConfig->iCookie);
    if( rc!=SQLITE_OK ) return rc;
  }

@@ -253232,7 +254233,6 @@ static int fts5UpdateMethod(
        rc = SQLITE_ERROR;
      }else{
        rc = fts5SpecialDelete(pTab, apVal);
-
        bUpdateOrDelete = 1;
      }
    }else{
      rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
@@ -253269,7 +254269,6 @@ static int fts5UpdateMethod(
      }else{
        i64 iDel = sqlite3_value_int64(apVal[0]);  /* Rowid to delete */
        rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
-
        bUpdateOrDelete = 1;
      }
    }

@@ -253297,7 +254296,6 @@ static int fts5UpdateMethod(
        if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
          i64 iNew = sqlite3_value_int64(apVal[1]);  /* Rowid to delete */
          rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
-
          bUpdateOrDelete = 1;
        }
        fts5StorageInsert(&rc, pTab, apVal, pRowid);
      }
@@ -253351,23 +254349,8 @@ static int fts5UpdateMethod(
          rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
          fts5StorageInsert(&rc, pTab, apVal, pRowid);
        }
-
        bUpdateOrDelete = 1;
        sqlite3Fts5StorageReleaseDeleteRow(pStorage);
      }
-

-
    }
-
  }
-

-
  if( rc==SQLITE_OK
-
   && bUpdateOrDelete
-
   && pConfig->bSecureDelete
-
   && pConfig->iVersion==FTS5_CURRENT_VERSION
-
  ){
-
    rc = sqlite3Fts5StorageConfigValue(
-
        pTab->pStorage, "version", 0, FTS5_CURRENT_VERSION_SECUREDELETE
-
    );
-
    if( rc==SQLITE_OK ){
-
      pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
    }
  }

@@ -253420,6 +254403,7 @@ static int fts5RollbackMethod(sqlite3_vtab *pVtab){
  Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
  fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
  rc = sqlite3Fts5StorageRollback(pTab->pStorage);
+
  pTab->p.pConfig->pgsz = 0;
  return rc;
}

@@ -254888,7 +255872,7 @@ static void fts5SourceIdFunc(
){
  assert( nArg==0 );
  UNUSED_PARAM2(nArg, apUnused);
-
  sqlite3_result_text(pCtx, "fts5: 2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e", -1, SQLITE_TRANSIENT);
+
  sqlite3_result_text(pCtx, "fts5: 2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde", -1, SQLITE_TRANSIENT);
}

/*
@@ -254953,6 +255937,20 @@ static void fts5LocaleFunc(
}

/*
+
** Implementation of fts5_insttoken() function.
+
*/
+
static void fts5InsttokenFunc(
+
  sqlite3_context *pCtx,          /* Function call context */
+
  int nArg,                       /* Number of args */
+
  sqlite3_value **apArg           /* Function arguments */
+
){
+
  assert( nArg==1 );
+
  (void)nArg;
+
  sqlite3_result_value(pCtx, apArg[0]);
+
  sqlite3_result_subtype(pCtx, FTS5_INSTTOKEN_SUBTYPE);
+
}
+

+
/*
** Return true if zName is the extension on one of the shadow tables used
** by this module.
*/
@@ -255081,10 +256079,17 @@ static int fts5Init(sqlite3 *db){
    if( rc==SQLITE_OK ){
      rc = sqlite3_create_function(
          db, "fts5_locale", 2,
-
          SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE,
+
          SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE|SQLITE_SUBTYPE,
          p, fts5LocaleFunc, 0, 0
      );
    }
+
    if( rc==SQLITE_OK ){
+
      rc = sqlite3_create_function(
+
          db, "fts5_insttoken", 1,
+
          SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_RESULT_SUBTYPE,
+
          p, fts5InsttokenFunc, 0, 0
+
      );
+
    }
  }

  /* If SQLITE_FTS5_ENABLE_TEST_MI is defined, assume that the file
@@ -255348,6 +256353,11 @@ static int fts5StorageGetStmt(
      if( rc!=SQLITE_OK && pzErrMsg ){
        *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
      }
+
      if( rc==SQLITE_ERROR && eStmt>FTS5_STMT_LOOKUP2 && eStmt<FTS5_STMT_SCAN ){
+
        /* One of the internal tables - not the %_content table - is missing.
+
        ** This counts as a corrupted table.  */
+
       rc = SQLITE_CORRUPT;
+
      }
    }
  }

@@ -258009,8 +259019,8 @@ static int fts5TriTokenize(
  char *zOut = aBuf;
  int ii;
  const unsigned char *zIn = (const unsigned char*)pText;
-
  const unsigned char *zEof = &zIn[nText];
-
  u32 iCode;
+
  const unsigned char *zEof = (zIn ? &zIn[nText] : 0);
+
  u32 iCode = 0;
  int aStart[3];                  /* Input offset of each character in aBuf[] */

  UNUSED_PARAM(unusedFlags);
@@ -258019,8 +259029,8 @@ static int fts5TriTokenize(
  for(ii=0; ii<3; ii++){
    do {
      aStart[ii] = zIn - (const unsigned char*)pText;
+
      if( zIn>=zEof ) return SQLITE_OK;
      READ_UTF8(zIn, zEof, iCode);
-
      if( iCode==0 ) return SQLITE_OK;
      if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam);
    }while( iCode==0 );
    WRITE_UTF8(zOut, iCode);
@@ -258041,8 +259051,11 @@ static int fts5TriTokenize(
    /* Read characters from the input up until the first non-diacritic */
    do {
      iNext = zIn - (const unsigned char*)pText;
+
      if( zIn>=zEof ){
+
        iCode = 0;
+
        break;
+
      }
      READ_UTF8(zIn, zEof, iCode);
-
      if( iCode==0 ) break;
      if( p->bFold ) iCode = sqlite3Fts5UnicodeFold(iCode, p->iFoldParam);
    }while( iCode==0 );

@@ -260079,7 +261092,7 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
}


-

+
/* Here ends the fts5.c composite file. */
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */

/************** End of fts5.c ************************************************/
@@ -260435,4 +261448,5 @@ SQLITE_API int sqlite3_stmt_init(
/************** End of stmt.c ************************************************/
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
+
#endif /* SQLITE_AMALGAMATION */
/************************** End of sqlite3.c ******************************/
modified external/sqlite/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-
#define SQLITE_VERSION        "3.47.0"
-
#define SQLITE_VERSION_NUMBER 3047000
-
#define SQLITE_SOURCE_ID      "2024-10-21 16:30:22 03a9703e27c44437c39363d0baf82db4ebc94538a0f28411c85dda156f82636e"
+
#define SQLITE_VERSION        "3.49.0"
+
#define SQLITE_VERSION_NUMBER 3049000
+
#define SQLITE_SOURCE_ID      "2025-02-06 11:55:18 4a7dd425dc2a0e5082a9049c9b4a9d4f199a71583d014c24b4cfe276c5a77cde"

/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -652,6 +652,13 @@ SQLITE_API int sqlite3_exec(
** filesystem supports doing multiple write operations atomically when those
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
+
**
+
** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read
+
** from the database file in amounts that are not a multiple of the
+
** page size and that do not begin at a page boundary.  Without this
+
** property, SQLite is careful to only do full-page reads and write
+
** on aligned pages, with the one exception that it will do a sub-page
+
** read of the first page to access the database header.
*/
#define SQLITE_IOCAP_ATOMIC                 0x00000001
#define SQLITE_IOCAP_ATOMIC512              0x00000002
@@ -668,6 +675,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE    0x00001000
#define SQLITE_IOCAP_IMMUTABLE              0x00002000
#define SQLITE_IOCAP_BATCH_ATOMIC           0x00004000
+
#define SQLITE_IOCAP_SUBPAGE_READ           0x00008000

/*
** CAPI3REF: File Locking Levels
@@ -814,6 +822,7 @@ struct sqlite3_file {
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
** <li> [SQLITE_IOCAP_IMMUTABLE]
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
+
** <li> [SQLITE_IOCAP_SUBPAGE_READ]
** </ul>
**
** The SQLITE_IOCAP_ATOMIC property means that all writes of
@@ -1091,6 +1100,11 @@ struct sqlite3_io_methods {
** pointed to by the pArg argument.  This capability is used during testing
** and only needs to be supported when SQLITE_TEST is defined.
**
+
** <li>[[SQLITE_FCNTL_NULL_IO]]
+
** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor
+
** or file handle for the [sqlite3_file] object such that it will no longer
+
** read or write to the database file.
+
**
** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
** be advantageous to block on the next WAL lock if the lock is not immediately
@@ -1244,6 +1258,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_EXTERNAL_READER        40
#define SQLITE_FCNTL_CKSM_FILE              41
#define SQLITE_FCNTL_RESET_CACHE            42
+
#define SQLITE_FCNTL_NULL_IO                43

/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -2196,7 +2211,15 @@ struct sqlite3_mem_methods {
** CAPI3REF: Database Connection Configuration Options
**
** These constants are the available integer configuration options that
-
** can be passed as the second argument to the [sqlite3_db_config()] interface.
+
** can be passed as the second parameter to the [sqlite3_db_config()] interface.
+
**
+
** The [sqlite3_db_config()] interface is a var-args functions.  It takes a
+
** variable number of parameters, though always at least two.  The number of
+
** parameters passed into sqlite3_db_config() depends on which of these
+
** constants is given as the second parameter.  This documentation page
+
** refers to parameters beyond the second as "arguments".  Thus, when this
+
** page says "the N-th argument" it means "the N-th parameter past the
+
** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
**
** New configuration options may be added in future releases of SQLite.
** Existing configuration options might be discontinued.  Applications
@@ -2208,8 +2231,14 @@ struct sqlite3_mem_methods {
** <dl>
** [[SQLITE_DBCONFIG_LOOKASIDE]]
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
-
** <dd> ^This option takes three additional arguments that determine the
-
** [lookaside memory allocator] configuration for the [database connection].
+
** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
+
** configuration of the lookaside memory allocator within a database
+
** connection.
+
** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
+
** in the [DBCONFIG arguments|usual format].
+
** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
+
** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
+
** should have a total of five parameters.
** ^The first argument (the third parameter to [sqlite3_db_config()] is a
** pointer to a memory buffer to use for lookaside memory.
** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
@@ -2232,7 +2261,8 @@ struct sqlite3_mem_methods {
** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
** <dd> ^This option is used to enable or disable the enforcement of
-
** [foreign key constraints].  There should be two additional arguments.
+
** [foreign key constraints].  This is the same setting that is
+
** enabled or disabled by the [PRAGMA foreign_keys] statement.
** The first argument is an integer which is 0 to disable FK enforcement,
** positive to enable FK enforcement or negative to leave FK enforcement
** unchanged.  The second parameter is a pointer to an integer into which
@@ -2254,13 +2284,13 @@ struct sqlite3_mem_methods {
** <p>Originally this option disabled all triggers.  ^(However, since
** SQLite version 3.35.0, TEMP triggers are still allowed even if
** this option is off.  So, in other words, this option now only disables
-
** triggers in the main database schema or in the schemas of ATTACH-ed
+
** triggers in the main database schema or in the schemas of [ATTACH]-ed
** databases.)^ </dd>
**
** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** The first argument is an integer which is 0 to disable views,
** positive to enable views or negative to leave the setting unchanged.
** The second parameter is a pointer to an integer into which
@@ -2279,7 +2309,7 @@ struct sqlite3_mem_methods {
** <dd> ^This option is used to enable or disable the
** [fts3_tokenizer()] function which is part of the
** [FTS3] full-text search engine extension.
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
** positive to enable fts3_tokenizer() or negative to leave the setting
** unchanged.
@@ -2294,7 +2324,7 @@ struct sqlite3_mem_methods {
** interface independently of the [load_extension()] SQL function.
** The [sqlite3_enable_load_extension()] API enables or disables both the
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
-
** There should be two additional arguments.
+
** There must be two additional arguments.
** When the first argument to this interface is 1, then only the C-API is
** enabled and the SQL function remains disabled.  If the first argument to
** this interface is 0, then both the C-API and the SQL function are disabled.
@@ -2308,23 +2338,30 @@ struct sqlite3_mem_methods {
**
** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
** <dd> ^This option is used to change the name of the "main" database
-
** schema.  ^The sole argument is a pointer to a constant UTF8 string
-
** which will become the new schema name in place of "main".  ^SQLite
-
** does not make a copy of the new main schema name string, so the application
-
** must ensure that the argument passed into this DBCONFIG option is unchanged
-
** until after the database connection closes.
+
** schema.  This option does not follow the
+
** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
+
** This option takes exactly one additional argument so that the
+
** [sqlite3_db_config()] call has a total of three parameters.  The
+
** extra argument must be a pointer to a constant UTF8 string which
+
** will become the new schema name in place of "main".  ^SQLite does
+
** not make a copy of the new main schema name string, so the application
+
** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
+
** is unchanged until after the database connection closes.
** </dd>
**
** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
-
** <dd> Usually, when a database in wal mode is closed or detached from a
-
** database handle, SQLite checks if this will mean that there are now no
-
** connections at all to the database. If so, it performs a checkpoint
-
** operation before closing the connection. This option may be used to
-
** override this behavior. The first parameter passed to this operation
-
** is an integer - positive to disable checkpoints-on-close, or zero (the
-
** default) to enable them, and negative to leave the setting unchanged.
-
** The second parameter is a pointer to an integer
+
** <dd> Usually, when a database in [WAL mode] is closed or detached from a
+
** database handle, SQLite checks if if there are other connections to the
+
** same database, and if there are no other database connection (if the
+
** connection being closed is the last open connection to the database),
+
** then SQLite performs a [checkpoint] before closing the connection and
+
** deletes the WAL file.  The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
+
** be used to override that behavior. The first argument passed to this
+
** operation (the third parameter to [sqlite3_db_config()]) is an integer
+
** which is positive to disable checkpoints-on-close, or zero (the default)
+
** to enable them, and negative to leave the setting unchanged.
+
** The second argument (the fourth parameter) is a pointer to an integer
** into which is written 0 or 1 to indicate whether checkpoints-on-close
** have been disabled - 0 if they are not disabled, 1 if they are.
** </dd>
@@ -2485,7 +2522,7 @@ struct sqlite3_mem_methods {
** statistics. For statistics to be collected, the flag must be set on
** the database handle both when the SQL statement is prepared and when it
** is stepped. The flag is set (collection of statistics is enabled)
-
** by default.  This option takes two arguments: an integer and a pointer to
+
** by default. <p>This option takes two arguments: an integer and a pointer to
** an integer..  The first argument is 1, 0, or -1 to enable, disable, or
** leave unchanged the statement scanstatus option.  If the second argument
** is not NULL, then the value of the statement scanstatus setting after
@@ -2499,7 +2536,7 @@ struct sqlite3_mem_methods {
** in which tables and indexes are scanned so that the scans start at the end
** and work toward the beginning rather than starting at the beginning and
** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
-
** same as setting [PRAGMA reverse_unordered_selects].  This option takes
+
** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
** two arguments which are an integer and a pointer to an integer.  The first
** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
** reverse scan order flag, respectively.  If the second argument is not NULL,
@@ -2508,7 +2545,76 @@ struct sqlite3_mem_methods {
** first argument.
** </dd>
**
+
** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
+
** the ability of the [ATTACH DATABASE] SQL command to create a new database
+
** file if the database filed named in the ATTACH command does not already
+
** exist.  This ability of ATTACH to create a new database is enabled by
+
** default.  Applications can disable or reenable the ability for ATTACH to
+
** create new database files using this DBCONFIG option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the attach-create flag, respectively.  If the second
+
** argument is not NULL, then 0 or 1 is written into the integer that the
+
** second argument points to depending on if the attach-create flag is set
+
** after processing the first argument.
+
** </dd>
+
**
+
** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
+
** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
+
** This capability is enabled by default.  Applications can disable or
+
** reenable this capability using the current DBCONFIG option.  If the
+
** the this capability is disabled, the [ATTACH] command will still work,
+
** but the database will be opened read-only.  If this option is disabled,
+
** then the ability to create a new database using [ATTACH] is also disabled,
+
** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
+
** option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the ability to ATTACH another database for writing,
+
** respectively.  If the second argument is not NULL, then 0 or 1 is written
+
** into the integer to which the second argument points, depending on whether
+
** the ability to ATTACH a read/write database is enabled or disabled
+
** after processing the first argument.
+
** </dd>
+
**
+
** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
+
** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
+
** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
+
** ability to include comments in SQL text.  Comments are enabled by default.
+
** An application can disable or reenable comments in SQL text using this
+
** DBCONFIG option.<p>
+
** This option takes two arguments which are an integer and a pointer
+
** to an integer.  The first argument is 1, 0, or -1 to enable, disable, or
+
** leave unchanged the ability to use comments in SQL text,
+
** respectively.  If the second argument is not NULL, then 0 or 1 is written
+
** into the integer that the second argument points to depending on if
+
** comments are allowed in SQL text after processing the first argument.
+
** </dd>
+
**
** </dl>
+
**
+
** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
+
**
+
** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
+
** overall call to [sqlite3_db_config()] has a total of four parameters.
+
** The first argument (the third parameter to sqlite3_db_config()) is a integer.
+
** The second argument is a pointer to an integer.  If the first argument is 1,
+
** then the option becomes enabled.  If the first integer argument is 0, then the
+
** option is disabled.  If the first argument is -1, then the option setting
+
** is unchanged.  The second argument, the pointer to an integer, may be NULL.
+
** If the second argument is not NULL, then a value of 0 or 1 is written into
+
** the integer to which the second argument points, depending on whether the
+
** setting is disabled or enabled after applying any changes specified by
+
** the first argument.
+
**
+
** <p>While most SQLITE_DBCONFIG options use the argument format
+
** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
+
** and [SQLITE_DBCONFIG_LOOKASIDE] options are different.  See the
+
** documentation of those exceptional options for details.
*/
#define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
#define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
@@ -2530,7 +2636,10 @@ struct sqlite3_mem_methods {
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA        1017 /* int int* */
#define SQLITE_DBCONFIG_STMT_SCANSTATUS       1018 /* int int* */
#define SQLITE_DBCONFIG_REVERSE_SCANORDER     1019 /* int int* */
-
#define SQLITE_DBCONFIG_MAX                   1019 /* Largest DBCONFIG */
+
#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE  1020 /* int int* */
+
#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE   1021 /* int int* */
+
#define SQLITE_DBCONFIG_ENABLE_COMMENTS       1022 /* int int* */
+
#define SQLITE_DBCONFIG_MAX                   1022 /* Largest DBCONFIG */

/*
** CAPI3REF: Enable Or Disable Extended Result Codes
@@ -2622,10 +2731,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
** deleted by the most recently completed INSERT, UPDATE or DELETE
** statement on the database connection specified by the only parameter.
** The two functions are identical except for the type of the return value
-
** and that if the number of rows modified by the most recent INSERT, UPDATE
+
** and that if the number of rows modified by the most recent INSERT, UPDATE,
** or DELETE is greater than the maximum value supported by type "int", then
** the return value of sqlite3_changes() is undefined. ^Executing any other
** type of SQL statement does not modify the value returned by these functions.
+
** For the purposes of this interface, a CREATE TABLE AS SELECT statement
+
** does not count as an INSERT, UPDATE or DELETE statement and hence the rows
+
** added to the new table by the CREATE TABLE AS SELECT statement are not
+
** counted.
**
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
@@ -4185,11 +4298,22 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
** to return an error (error code SQLITE_ERROR) if the statement uses
** any virtual tables.
+
**
+
** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt>
+
** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler
+
** errors from being sent to the error log defined by
+
** [SQLITE_CONFIG_LOG].  This can be used, for example, to do test
+
** compiles to see if some SQL syntax is well-formed, without generating
+
** messages on the global error log when it is not.  If the test compile
+
** fails, the sqlite3_prepare_v3() call returns the same error indications
+
** with or without this flag; it just omits the call to [sqlite3_log()] that
+
** logs the error.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT              0x01
#define SQLITE_PREPARE_NORMALIZE               0x02
#define SQLITE_PREPARE_NO_VTAB                 0x04
+
#define SQLITE_PREPARE_DONT_LOG                0x10

/*
** CAPI3REF: Compiling An SQL Statement
@@ -10718,8 +10842,9 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
/*
** CAPI3REF: Serialize a database
**
-
** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
-
** that is a serialization of the S database on [database connection] D.
+
** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
+
** memory that is a serialization of the S database on
+
** [database connection] D.  If S is a NULL pointer, the main database is used.
** If P is not a NULL pointer, then the size of the database in bytes
** is written into *P.
**
@@ -10880,7 +11005,7 @@ SQLITE_API int sqlite3_deserialize(
#ifdef __cplusplus
}  /* End of the 'extern "C"' block */
#endif
-
#endif /* SQLITE3_H */
+
/* #endif for SQLITE3_H will be added by mksqlite3.tcl */

/******** Begin file sqlite3rtree.h *********/
/*
@@ -13131,14 +13256,29 @@ struct Fts5PhraseIter {
**   value returned by xInstCount(), SQLITE_RANGE is returned.  Otherwise,
**   output variable (*ppToken) is set to point to a buffer containing the
**   matching document token, and (*pnToken) to the size of that buffer in
-
**   bytes. This API is not available if the specified token matches a
-
**   prefix query term. In that case both output variables are always set
-
**   to 0.
+
**   bytes.
**
**   The output text is not a copy of the document text that was tokenized.
**   It is the output of the tokenizer module. For tokendata=1 tables, this
**   includes any embedded 0x00 and trailing data.
**
+
**   This API may be slow in some cases if the token identified by parameters
+
**   iIdx and iToken matched a prefix token in the query. In most cases, the
+
**   first call to this API for each prefix token in the query is forced
+
**   to scan the portion of the full-text index that matches the prefix
+
**   token to collect the extra data required by this API. If the prefix
+
**   token matches a large number of token instances in the document set,
+
**   this may be a performance problem.
+
**
+
**   If the user knows in advance that a query may use this API for a
+
**   prefix token, FTS5 may be configured to collect all required data as part
+
**   of the initial querying of the full-text index, avoiding the second scan
+
**   entirely. This also causes prefix queries that do not use this API to
+
**   run more slowly and use more memory. FTS5 may be configured in this way
+
**   either on a per-table basis using the [FTS5 insttoken | 'insttoken']
+
**   option, or on a per-query basis using the
+
**   [fts5_insttoken | fts5_insttoken()] user function.
+
**
**   This API can be quite slow if used with an FTS5 table created with the
**   "detail=none" or "detail=column" option.
**
@@ -13572,3 +13712,4 @@ struct fts5_api {
#endif /* _FTS5_H */

/******** End of fts5.h *********/
+
#endif /* SQLITE3_H */