Fossil

Check-in [de76c92a]
Login

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

Overview
Comment:Update the built-in SQLite to the latest 3.24.0 alpha version.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:de76c92a63e9e009804cbdbad9622137260f1e3621f0e1b1c98c7469789dc896
User & Date: drh 2018-04-25 13:34:17
Context
2018-04-26
19:02
Improved handling of the the yw= query parameter on /timeline. check-in: 881b4646 user: drh tags: trunk
2018-04-25
13:34
Update the built-in SQLite to the latest 3.24.0 alpha version. check-in: de76c92a user: drh tags: trunk
2018-04-21
22:58
Fix minor typo in the fossil-v-git document. check-in: 2e8f2887 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.mk.

   587    587                   -DSQLITE_HAVE_ZLIB \
   588    588                   -DSQLITE_INTROSPECTION_PRAGMAS \
   589    589                   -DSQLITE_ENABLE_DBPAGE_VTAB \
   590    590                   -Dmain=sqlite3_shell \
   591    591                   -DSQLITE_SHELL_IS_UTF8=1 \
   592    592                   -DSQLITE_OMIT_LOAD_EXTENSION=1 \
   593    593                   -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
   594         -                -DSQLITE_SHELL_DBNAME_PROC=fossil_open
          594  +                -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
          595  +                -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
   595    596   
   596    597   # Setup the options used to compile the included miniz library.
   597    598   MINIZ_OPTIONS = -DMINIZ_NO_STDIO \
   598    599                   -DMINIZ_NO_TIME \
   599    600                   -DMINIZ_NO_ARCHIVE_APIS
   600    601   
   601    602   # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set

Changes to src/makemake.tcl.

   204    204   # Options used to compile the included SQLite shell.
   205    205   #
   206    206   set SHELL_OPTIONS [concat $SQLITE_OPTIONS {
   207    207     -Dmain=sqlite3_shell
   208    208     -DSQLITE_SHELL_IS_UTF8=1
   209    209     -DSQLITE_OMIT_LOAD_EXTENSION=1
   210    210     -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
   211         -  -DSQLITE_SHELL_DBNAME_PROC=fossil_open
          211  +  -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname
          212  +  -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
   212    213   }]
   213    214   
   214    215   # miniz (libz drop-in alternative) precompiler flags.
   215    216   #
   216    217   set MINIZ_OPTIONS {
   217    218     -DMINIZ_NO_STDIO
   218    219     -DMINIZ_NO_TIME

Changes to src/shell.c.

   449    449   /*
   450    450   ** Render output like fprintf().  This should not be used on anything that
   451    451   ** includes string formatting (e.g. "%s").
   452    452   */
   453    453   #if !defined(raw_printf)
   454    454   # define raw_printf fprintf
   455    455   #endif
          456  +
          457  +/* Indicate out-of-memory and exit. */
          458  +static void shell_out_of_memory(void){
          459  +  raw_printf(stderr,"Error: out of memory\n");
          460  +  exit(1);
          461  +}
   456    462   
   457    463   /*
   458    464   ** Write I/O traces to the following stream.
   459    465   */
   460    466   #ifdef SQLITE_ENABLE_IOTRACE
   461    467   static FILE *iotrace = 0;
   462    468   #endif
................................................................................
  8525   8531   
  8526   8532   typedef struct ExpertInfo ExpertInfo;
  8527   8533   struct ExpertInfo {
  8528   8534     sqlite3expert *pExpert;
  8529   8535     int bVerbose;
  8530   8536   };
  8531   8537   
         8538  +/* A single line in the EQP output */
         8539  +typedef struct EQPGraphRow EQPGraphRow;
         8540  +struct EQPGraphRow {
         8541  +  int iSelectId;        /* The SelectID for this row */
         8542  +  EQPGraphRow *pNext;   /* Next row in sequence */
         8543  +  char zText[1];        /* Text to display for this row */
         8544  +};
         8545  +
         8546  +/* All EQP output is collected into an instance of the following */
         8547  +typedef struct EQPGraph EQPGraph;
         8548  +struct EQPGraph {
         8549  +  EQPGraphRow *pRow;    /* Linked list of all rows of the EQP output */
         8550  +  EQPGraphRow *pLast;   /* Last element of the pRow list */
         8551  +  char zPrefix[100];    /* Graph prefix */
         8552  +};
         8553  +
  8532   8554   /*
  8533   8555   ** State information about the database connection is contained in an
  8534   8556   ** instance of the following structure.
  8535   8557   */
  8536   8558   typedef struct ShellState ShellState;
  8537   8559   struct ShellState {
  8538   8560     sqlite3 *db;           /* The database */
  8539   8561     u8 autoExplain;        /* Automatically turn on .explain mode */
  8540   8562     u8 autoEQP;            /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
  8541   8563     u8 statsOn;            /* True to display memory stats before each finalize */
  8542   8564     u8 scanstatsOn;        /* True to display scan stats before each finalize */
  8543   8565     u8 openMode;           /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */
  8544   8566     u8 doXdgOpen;          /* Invoke start/open/xdg-open in output_reset() */
         8567  +  u8 nEqpLevel;          /* Depth of the EQP output graph */
         8568  +  unsigned mEqpLines;    /* Mask of veritical lines in the EQP output graph */
  8545   8569     int outCount;          /* Revert to stdout when reaching zero */
  8546   8570     int cnt;               /* Number of records displayed so far */
  8547   8571     FILE *out;             /* Write results here */
  8548   8572     FILE *traceOut;        /* Output for sqlite3_trace() */
  8549   8573     int nErr;              /* Number of errors seen */
  8550   8574     int mode;              /* An output mode setting */
  8551   8575     int modePrior;         /* Saved mode */
................................................................................
  8571   8595     char *zFreeOnClose;         /* Filename to free when closing */
  8572   8596     const char *zVfs;           /* Name of VFS to use */
  8573   8597     sqlite3_stmt *pStmt;   /* Current statement if any. */
  8574   8598     FILE *pLog;            /* Write log output here */
  8575   8599     int *aiIndent;         /* Array of indents used in MODE_Explain */
  8576   8600     int nIndent;           /* Size of array aiIndent[] */
  8577   8601     int iIndent;           /* Index of current op in aiIndent[] */
         8602  +  EQPGraph sGraph;       /* Information for the graphical EXPLAIN QUERY PLAN */
  8578   8603   #if defined(SQLITE_ENABLE_SESSION)
  8579   8604     int nSession;             /* Number of active sessions */
  8580   8605     OpenSession aSession[4];  /* Array of sessions.  [0] is in focus. */
  8581   8606   #endif
  8582   8607     ExpertInfo expert;        /* Valid if previous command was ".expert OPT..." */
  8583   8608   };
  8584   8609   
................................................................................
  8627   8652   #define MODE_Insert   5  /* Generate SQL "insert" statements */
  8628   8653   #define MODE_Quote    6  /* Quote values as for SQL */
  8629   8654   #define MODE_Tcl      7  /* Generate ANSI-C or TCL quoted elements */
  8630   8655   #define MODE_Csv      8  /* Quote strings, numbers are plain */
  8631   8656   #define MODE_Explain  9  /* Like MODE_Column, but do not truncate data */
  8632   8657   #define MODE_Ascii   10  /* Use ASCII unit and record separators (0x1F/0x1E) */
  8633   8658   #define MODE_Pretty  11  /* Pretty-print schemas */
         8659  +#define MODE_EQP     12  /* Converts EXPLAIN QUERY PLAN output into a graph */
  8634   8660   
  8635   8661   static const char *modeDescr[] = {
  8636   8662     "line",
  8637   8663     "column",
  8638   8664     "list",
  8639   8665     "semi",
  8640   8666     "html",
................................................................................
  8641   8667     "insert",
  8642   8668     "quote",
  8643   8669     "tcl",
  8644   8670     "csv",
  8645   8671     "explain",
  8646   8672     "ascii",
  8647   8673     "prettyprint",
         8674  +  "eqp"
  8648   8675   };
  8649   8676   
  8650   8677   /*
  8651   8678   ** These are the column/row/line separators used by the various
  8652   8679   ** import/export modes.
  8653   8680   */
  8654   8681   #define SEP_Column    "|"
................................................................................
  9189   9216       if( z[i]=='\n' ) return 1;
  9190   9217       if( IsSpace(z[i]) ) continue;
  9191   9218       if( z[i]=='-' && z[i+1]=='-' ) return 1;
  9192   9219       return 0;
  9193   9220     }
  9194   9221     return 1;
  9195   9222   }
  9196         -    
         9223  +
         9224  +/*
         9225  +** Add a new entry to the EXPLAIN QUERY PLAN data
         9226  +*/
         9227  +static void eqp_append(ShellState *p, int iSelectId, const char *zText){
         9228  +  EQPGraphRow *pNew;
         9229  +  int nText = strlen30(zText);
         9230  +  pNew = sqlite3_malloc64( sizeof(*pNew) + nText );
         9231  +  if( pNew==0 ) shell_out_of_memory();
         9232  +  pNew->iSelectId = iSelectId;
         9233  +  memcpy(pNew->zText, zText, nText+1);
         9234  +  pNew->pNext = 0;
         9235  +  if( p->sGraph.pLast ){
         9236  +    p->sGraph.pLast->pNext = pNew;
         9237  +  }else{
         9238  +    p->sGraph.pRow = pNew;
         9239  +  }
         9240  +  p->sGraph.pLast = pNew;
         9241  +}
         9242  +
         9243  +/*
         9244  +** Free and reset the EXPLAIN QUERY PLAN data that has been collected
         9245  +** in p->sGraph.
         9246  +*/
         9247  +static void eqp_reset(ShellState *p){
         9248  +  EQPGraphRow *pRow, *pNext;
         9249  +  for(pRow = p->sGraph.pRow; pRow; pRow = pNext){
         9250  +    pNext = pRow->pNext;
         9251  +    sqlite3_free(pRow);
         9252  +  }
         9253  +  memset(&p->sGraph, 0, sizeof(p->sGraph));
         9254  +}
         9255  +
         9256  +/* Return the next EXPLAIN QUERY PLAN line with iSelectId that occurs after
         9257  +** pOld, or return the first such line if pOld is NULL
         9258  +*/
         9259  +static EQPGraphRow *eqp_next_row(ShellState *p, int iSelectId, EQPGraphRow *pOld){
         9260  +  EQPGraphRow *pRow = pOld ? pOld->pNext : p->sGraph.pRow;
         9261  +  while( pRow && pRow->iSelectId!=iSelectId ) pRow = pRow->pNext;
         9262  +  return pRow;
         9263  +}
         9264  +
         9265  +/* Render a single level of the graph shell having iSelectId.  Called
         9266  +** recursively to render sublevels.
         9267  +*/
         9268  +static void eqp_render_level(ShellState *p, int iSelectId){
         9269  +  EQPGraphRow *pRow, *pNext;
         9270  +  int i;
         9271  +  int n = strlen30(p->sGraph.zPrefix);
         9272  +  char *z;
         9273  +  for(pRow = eqp_next_row(p, iSelectId, 0); pRow; pRow = pNext){
         9274  +    pNext = eqp_next_row(p, iSelectId, pRow);
         9275  +    z = pRow->zText;
         9276  +    utf8_printf(p->out, "%s%s%s\n", p->sGraph.zPrefix, pNext ? "|--" : "`--", z);
         9277  +    if( n<sizeof(p->sGraph.zPrefix)-7 && (z = strstr(z, " SUBQUER"))!=0 ){
         9278  +      memcpy(&p->sGraph.zPrefix[n], pNext ? "|  " : "   ", 4);
         9279  +      if( strncmp(z, " SUBQUERY ", 9)==0 && (i = atoi(z+10))>iSelectId ){
         9280  +        eqp_render_level(p, i);
         9281  +      }else if( strncmp(z, " SUBQUERIES ", 12)==0 ){
         9282  +        i = atoi(z+12);
         9283  +        if( i>iSelectId ){
         9284  +          utf8_printf(p->out, "%s|--SUBQUERY %d\n", p->sGraph.zPrefix, i);
         9285  +          memcpy(&p->sGraph.zPrefix[n+3],"|  ",4);
         9286  +          eqp_render_level(p, i);
         9287  +        }
         9288  +        z = strstr(z, " AND ");
         9289  +        if( z && (i = atoi(z+5))>iSelectId ){
         9290  +          p->sGraph.zPrefix[n+3] = 0;
         9291  +          utf8_printf(p->out, "%s`--SUBQUERY %d\n", p->sGraph.zPrefix, i);
         9292  +          memcpy(&p->sGraph.zPrefix[n+3],"   ",4);
         9293  +          eqp_render_level(p, i);
         9294  +        }
         9295  +      }
         9296  +      p->sGraph.zPrefix[n] = 0;
         9297  +    }
         9298  +  }
         9299  +}
         9300  +
         9301  +/*
         9302  +** Display and reset the EXPLAIN QUERY PLAN data
         9303  +*/
         9304  +static void eqp_render(ShellState *p){
         9305  +  EQPGraphRow *pRow = p->sGraph.pRow;
         9306  +  if( pRow ){
         9307  +    if( pRow->zText[0]=='-' ){
         9308  +      if( pRow->pNext==0 ){
         9309  +        eqp_reset(p);
         9310  +        return;
         9311  +      }
         9312  +      utf8_printf(p->out, "%s\n", pRow->zText+3);
         9313  +      p->sGraph.pRow = pRow->pNext;
         9314  +      sqlite3_free(pRow);
         9315  +    }else{
         9316  +      utf8_printf(p->out, "QUERY PLAN\n");
         9317  +    }
         9318  +    p->sGraph.zPrefix[0] = 0;
         9319  +    eqp_render_level(p, 0);
         9320  +    eqp_reset(p);
         9321  +  }
         9322  +}
  9197   9323   
  9198   9324   /*
  9199   9325   ** This is the callback routine that the shell
  9200   9326   ** invokes for each row of a query result.
  9201   9327   */
  9202   9328   static int shell_callback(
  9203   9329     void *pArg,
................................................................................
  9540   9666         for(i=0; i<nArg; i++){
  9541   9667           if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
  9542   9668           utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
  9543   9669         }
  9544   9670         utf8_printf(p->out, "%s", p->rowSeparator);
  9545   9671         break;
  9546   9672       }
         9673  +    case MODE_EQP: {
         9674  +      eqp_append(p, atoi(azArg[0]), azArg[3]);
         9675  +      break;
         9676  +    }
  9547   9677     }
  9548   9678     return 0;
  9549   9679   }
  9550   9680   
  9551   9681   /*
  9552   9682   ** This is the callback routine that the SQLite library
  9553   9683   ** invokes for each row of a query result.
................................................................................
  9638   9768       p->zDestTable = 0;
  9639   9769     }
  9640   9770     if( zName==0 ) return;
  9641   9771     cQuote = quoteChar(zName);
  9642   9772     n = strlen30(zName);
  9643   9773     if( cQuote ) n += n+2;
  9644   9774     z = p->zDestTable = malloc( n+1 );
  9645         -  if( z==0 ){
  9646         -    raw_printf(stderr,"Error: out of memory\n");
  9647         -    exit(1);
  9648         -  }
         9775  +  if( z==0 ) shell_out_of_memory();
  9649   9776     n = 0;
  9650   9777     if( cQuote ) z[n++] = cQuote;
  9651   9778     for(i=0; zName[i]; i++){
  9652   9779       z[n++] = zName[i];
  9653   9780       if( zName[i]==cQuote ) z[n++] = cQuote;
  9654   9781     }
  9655   9782     if( cQuote ) z[n++] = cQuote;
................................................................................
 10381  10508           if( pArg->autoEQP>=AUTOEQP_trigger ){
 10382  10509             sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
 10383  10510           }
 10384  10511           zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
 10385  10512           rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
 10386  10513           if( rc==SQLITE_OK ){
 10387  10514             while( sqlite3_step(pExplain)==SQLITE_ROW ){
 10388         -            raw_printf(pArg->out,"--EQP-- %d,",sqlite3_column_int(pExplain, 0));
 10389         -            raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
 10390         -            raw_printf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
 10391         -            utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
        10515  +            const char *zEQPLine = (const char*)sqlite3_column_text(pExplain,3);
        10516  +            int iSelectId = sqlite3_column_int(pExplain, 0);
        10517  +            if( zEQPLine[0]=='-' ) eqp_render(pArg);
        10518  +            eqp_append(pArg, iSelectId, zEQPLine);
 10392  10519             }
        10520  +          eqp_render(pArg);
 10393  10521           }
 10394  10522           sqlite3_finalize(pExplain);
 10395  10523           sqlite3_free(zEQP);
 10396  10524           if( pArg->autoEQP>=AUTOEQP_full ){
 10397  10525             /* Also do an EXPLAIN for ".eqp full" mode */
 10398  10526             zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
 10399  10527             rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
................................................................................
 10413  10541             sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
 10414  10542           }
 10415  10543           restore_debug_trace_modes();
 10416  10544         }
 10417  10545   
 10418  10546         if( pArg ){
 10419  10547           pArg->cMode = pArg->mode;
 10420         -        if( pArg->autoExplain
 10421         -         && sqlite3_column_count(pStmt)==8
 10422         -         && sqlite3_strlike("EXPLAIN%", zStmtSql,0)==0
 10423         -        ){
 10424         -          pArg->cMode = MODE_Explain;
        10548  +        if( pArg->autoExplain ){
        10549  +          if( sqlite3_column_count(pStmt)==8
        10550  +           && sqlite3_strlike("EXPLAIN%", zStmtSql,0)==0
        10551  +          ){
        10552  +            pArg->cMode = MODE_Explain;
        10553  +          }
        10554  +          if( sqlite3_column_count(pStmt)==4
        10555  +           && sqlite3_strlike("EXPLAIN QUERY PLAN%", zStmtSql,0)==0 ){
        10556  +            pArg->cMode = MODE_EQP;
        10557  +          }
 10425  10558           }
 10426  10559   
 10427  10560           /* If the shell is currently in ".explain" mode, gather the extra
 10428  10561           ** data required to add indents to the output.*/
 10429  10562           if( pArg->cMode==MODE_Explain ){
 10430  10563             explain_data_prepare(pArg, pStmt);
 10431  10564           }
 10432  10565         }
 10433  10566   
 10434  10567         exec_prepared_stmt(pArg, pStmt);
 10435  10568         explain_data_delete(pArg);
        10569  +      eqp_render(pArg);
 10436  10570   
 10437  10571         /* print usage stats if stats on */
 10438  10572         if( pArg && pArg->statsOn ){
 10439  10573           display_stats(db, pArg, 0);
 10440  10574         }
 10441  10575   
 10442  10576         /* print loop-counters if required */
................................................................................
 10506  10640     rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
 10507  10641     sqlite3_free(zSql);
 10508  10642     if( rc ) return 0;
 10509  10643     while( sqlite3_step(pStmt)==SQLITE_ROW ){
 10510  10644       if( nCol>=nAlloc-2 ){
 10511  10645         nAlloc = nAlloc*2 + nCol + 10;
 10512  10646         azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
 10513         -      if( azCol==0 ){
 10514         -        raw_printf(stderr, "Error: out of memory\n");
 10515         -        exit(1);
 10516         -      }
        10647  +      if( azCol==0 ) shell_out_of_memory();
 10517  10648       }
 10518  10649       azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
 10519  10650       if( sqlite3_column_int(pStmt, 5) ){
 10520  10651         nPK++;
 10521  10652         if( nPK==1
 10522  10653          && sqlite3_stricmp((const char*)sqlite3_column_text(pStmt,2),
 10523  10654                             "INTEGER")==0
................................................................................
 11004  11135   
 11005  11136   /*
 11006  11137   ** Make sure the database is open.  If it is not, then open it.  If
 11007  11138   ** the database fails to open, print an error message and exit.
 11008  11139   */
 11009  11140   static void open_db(ShellState *p, int keepAlive){
 11010  11141     if( p->db==0 ){
 11011         -    sqlite3_initialize();
 11012  11142       if( p->openMode==SHELL_OPEN_UNSPEC && access(p->zDbFilename,0)==0 ){
 11013  11143         p->openMode = (u8)deduceDatabaseType(p->zDbFilename, 0);
 11014  11144       }
 11015  11145       switch( p->openMode ){
 11016  11146         case SHELL_OPEN_APPENDVFS: {
 11017  11147           sqlite3_open_v2(p->zDbFilename, &p->db, 
 11018  11148              SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
................................................................................
 11307  11437   };
 11308  11438   
 11309  11439   /* Append a single byte to z[] */
 11310  11440   static void import_append_char(ImportCtx *p, int c){
 11311  11441     if( p->n+1>=p->nAlloc ){
 11312  11442       p->nAlloc += p->nAlloc + 100;
 11313  11443       p->z = sqlite3_realloc64(p->z, p->nAlloc);
 11314         -    if( p->z==0 ){
 11315         -      raw_printf(stderr, "out of memory\n");
 11316         -      exit(1);
 11317         -    }
        11444  +    if( p->z==0 ) shell_out_of_memory();
 11318  11445     }
 11319  11446     p->z[p->n++] = (char)c;
 11320  11447   }
 11321  11448   
 11322  11449   /* Read a single field of CSV text.  Compatible with rfc4180 and extended
 11323  11450   ** with the option of having a separator other than ",".
 11324  11451   **
................................................................................
 11471  11598       utf8_printf(stderr, "Error %d: %s on [%s]\n",
 11472  11599               sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
 11473  11600               zQuery);
 11474  11601       goto end_data_xfer;
 11475  11602     }
 11476  11603     n = sqlite3_column_count(pQuery);
 11477  11604     zInsert = sqlite3_malloc64(200 + nTable + n*3);
 11478         -  if( zInsert==0 ){
 11479         -    raw_printf(stderr, "out of memory\n");
 11480         -    goto end_data_xfer;
 11481         -  }
        11605  +  if( zInsert==0 ) shell_out_of_memory();
 11482  11606     sqlite3_snprintf(200+nTable,zInsert,
 11483  11607                      "INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
 11484  11608     i = strlen30(zInsert);
 11485  11609     for(j=1; j<n; j++){
 11486  11610       memcpy(zInsert+i, ",?", 2);
 11487  11611       i += 2;
 11488  11612     }
................................................................................
 11815  11939   */
 11816  11940   static int shellDatabaseError(sqlite3 *db){
 11817  11941     const char *zErr = sqlite3_errmsg(db);
 11818  11942     utf8_printf(stderr, "Error: %s\n", zErr);
 11819  11943     return 1;
 11820  11944   }
 11821  11945   
 11822         -/*
 11823         -** Print an out-of-memory message to stderr and return 1.
 11824         -*/
 11825         -static int shellNomemError(void){
 11826         -  raw_printf(stderr, "Error: out of memory\n");
 11827         -  return 1;
 11828         -}
 11829         -
 11830  11946   /*
 11831  11947   ** Compare the pattern in zGlob[] against the text in z[].  Return TRUE
 11832  11948   ** if they match and FALSE (0) if they do not match.
 11833  11949   **
 11834  11950   ** Globbing rules:
 11835  11951   **
 11836  11952   **      '*'       Matches any sequence of zero or more characters.
................................................................................
 13516  13632         utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
 13517  13633         return 1;
 13518  13634       }
 13519  13635       sCtx.cColSep = p->colSeparator[0];
 13520  13636       sCtx.cRowSep = p->rowSeparator[0];
 13521  13637       zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
 13522  13638       if( zSql==0 ){
 13523         -      raw_printf(stderr, "Error: out of memory\n");
 13524  13639         xCloser(sCtx.in);
 13525         -      return 1;
        13640  +      shell_out_of_memory();
 13526  13641       }
 13527  13642       nByte = strlen30(zSql);
 13528  13643       rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
 13529  13644       import_append_char(&sCtx, 0);    /* To ensure sCtx.z is allocated */
 13530  13645       if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
 13531  13646         char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
 13532  13647         char cSep = '(';
................................................................................
 13563  13678       }
 13564  13679       nCol = sqlite3_column_count(pStmt);
 13565  13680       sqlite3_finalize(pStmt);
 13566  13681       pStmt = 0;
 13567  13682       if( nCol==0 ) return 0; /* no columns, no error */
 13568  13683       zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
 13569  13684       if( zSql==0 ){
 13570         -      raw_printf(stderr, "Error: out of memory\n");
 13571  13685         xCloser(sCtx.in);
 13572         -      return 1;
        13686  +      shell_out_of_memory();
 13573  13687       }
 13574  13688       sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
 13575  13689       j = strlen30(zSql);
 13576  13690       for(i=1; i<nCol; i++){
 13577  13691         zSql[j++] = ',';
 13578  13692         zSql[j++] = '?';
 13579  13693       }
................................................................................
 13641  13755   #ifndef SQLITE_UNTESTABLE
 13642  13756     if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
 13643  13757       char *zSql;
 13644  13758       char *zCollist = 0;
 13645  13759       sqlite3_stmt *pStmt;
 13646  13760       int tnum = 0;
 13647  13761       int i;
 13648         -    if( nArg!=3 ){
 13649         -      utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n");
        13762  +    if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
        13763  +      utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
        13764  +                          "       .imposter off\n");
 13650  13765         rc = 1;
 13651  13766         goto meta_command_exit;
 13652  13767       }
 13653  13768       open_db(p, 0);
        13769  +    if( nArg==2 ){
        13770  +      sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, p->db, "main", 0, 1);
        13771  +      goto meta_command_exit;
        13772  +    }
 13654  13773       zSql = sqlite3_mprintf("SELECT rootpage FROM sqlite_master"
 13655  13774                              " WHERE name='%q' AND type='index'", azArg[1]);
 13656  13775       sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
 13657  13776       sqlite3_free(zSql);
 13658  13777       if( sqlite3_step(pStmt)==SQLITE_ROW ){
 13659  13778         tnum = sqlite3_column_int(pStmt, 0);
 13660  13779       }
................................................................................
 14831  14950         sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
 14832  14951       }
 14833  14952       while( sqlite3_step(pStmt)==SQLITE_ROW ){
 14834  14953         if( nRow>=nAlloc ){
 14835  14954           char **azNew;
 14836  14955           int n2 = nAlloc*2 + 10;
 14837  14956           azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
 14838         -        if( azNew==0 ){
 14839         -          rc = shellNomemError();
 14840         -          break;
 14841         -        }
        14957  +        if( azNew==0 ) shell_out_of_memory();
 14842  14958           nAlloc = n2;
 14843  14959           azResult = azNew;
 14844  14960         }
 14845  14961         azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
 14846         -      if( 0==azResult[nRow] ){
 14847         -        rc = shellNomemError();
 14848         -        break;
 14849         -      }
        14962  +      if( 0==azResult[nRow] ) shell_out_of_memory();
 14850  14963         nRow++;
 14851  14964       }
 14852  14965       if( sqlite3_finalize(pStmt)!=SQLITE_OK ){
 14853  14966         rc = shellDatabaseError(p->db);
 14854  14967       }
 14855  14968   
 14856  14969       /* Pretty-print the contents of array azResult[] to the output */
................................................................................
 15413  15526       if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){
 15414  15527         memcpy(zLine,";",2);
 15415  15528       }
 15416  15529       nLine = strlen30(zLine);
 15417  15530       if( nSql+nLine+2>=nAlloc ){
 15418  15531         nAlloc = nSql+nLine+100;
 15419  15532         zSql = realloc(zSql, nAlloc);
 15420         -      if( zSql==0 ){
 15421         -        raw_printf(stderr, "Error: out of memory\n");
 15422         -        exit(1);
 15423         -      }
        15533  +      if( zSql==0 ) shell_out_of_memory();
 15424  15534       }
 15425  15535       nSqlPrior = nSql;
 15426  15536       if( nSql==0 ){
 15427  15537         int i;
 15428  15538         for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
 15429  15539         assert( nAlloc>0 && zSql!=0 );
 15430  15540         memcpy(zSql, zLine+i, nLine+1-i);
................................................................................
 15545  15655     if (sqliterc == NULL) {
 15546  15656       home_dir = find_home_dir(0);
 15547  15657       if( home_dir==0 ){
 15548  15658         raw_printf(stderr, "-- warning: cannot find home directory;"
 15549  15659                         " cannot read ~/.sqliterc\n");
 15550  15660         return;
 15551  15661       }
 15552         -    sqlite3_initialize();
 15553  15662       zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
 15554  15663       sqliterc = zBuf;
 15555  15664     }
 15556  15665     in = fopen(sqliterc,"rb");
 15557  15666     if( in ){
 15558  15667       if( stdin_is_interactive ){
 15559  15668         utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc);
................................................................................
 15596  15705   #endif
 15597  15706     "   -newline SEP         set output row separator. Default: '\\n'\n"
 15598  15707     "   -nullvalue TEXT      set text string for NULL values. Default ''\n"
 15599  15708     "   -pagecache SIZE N    use N slots of SZ bytes each for page cache memory\n"
 15600  15709     "   -quote               set output mode to 'quote'\n"
 15601  15710     "   -readonly            open the database read-only\n"
 15602  15711     "   -separator SEP       set output column separator. Default: '|'\n"
        15712  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
        15713  +  "   -sorterref SIZE      sorter references threshold size\n"
        15714  +#endif
 15603  15715     "   -stats               print memory stats before each finalize\n"
 15604  15716     "   -version             show SQLite version\n"
 15605  15717     "   -vfs NAME            use NAME as the default VFS\n"
 15606  15718   #ifdef SQLITE_ENABLE_VFSTRACE
 15607  15719     "   -vfstrace            enable tracing of all VFS calls\n"
 15608  15720   #endif
 15609  15721   #ifdef SQLITE_HAVE_ZLIB
................................................................................
 15618  15730     if( showDetail ){
 15619  15731       utf8_printf(stderr, "OPTIONS include:\n%s", zOptions);
 15620  15732     }else{
 15621  15733       raw_printf(stderr, "Use the -help option for additional information\n");
 15622  15734     }
 15623  15735     exit(1);
 15624  15736   }
        15737  +
        15738  +/*
        15739  +** Internal check:  Verify that the SQLite is uninitialized.  Print a
        15740  +** error message if it is initialized.
        15741  +*/
        15742  +static void verify_uninitialized(void){
        15743  +  if( sqlite3_config(-1)==SQLITE_MISUSE ){
        15744  +    utf8_printf(stdout, "WARNING: attempt to configuration SQLite after"
        15745  +                        " initialization.\n");
        15746  +  }
        15747  +}
 15625  15748   
 15626  15749   /*
 15627  15750   ** Initialize the state information in data
 15628  15751   */
 15629  15752   static void main_init(ShellState *data) {
 15630  15753     memset(data, 0, sizeof(*data));
 15631  15754     data->normalMode = data->cMode = data->mode = MODE_List;
 15632  15755     data->autoExplain = 1;
 15633  15756     memcpy(data->colSeparator,SEP_Column, 2);
 15634  15757     memcpy(data->rowSeparator,SEP_Row, 2);
 15635  15758     data->showHeader = 0;
 15636  15759     data->shellFlgs = SHFLG_Lookaside;
        15760  +  verify_uninitialized();
 15637  15761     sqlite3_config(SQLITE_CONFIG_URI, 1);
 15638  15762     sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
 15639  15763     sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
 15640  15764     sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
 15641  15765     sqlite3_snprintf(sizeof(continuePrompt), continuePrompt,"   ...> ");
 15642  15766   }
 15643  15767   
................................................................................
 15693  15817     const char *zInitFile = 0;
 15694  15818     int i;
 15695  15819     int rc = 0;
 15696  15820     int warnInmemoryDb = 0;
 15697  15821     int readStdin = 1;
 15698  15822     int nCmd = 0;
 15699  15823     char **azCmd = 0;
        15824  +  const char *zVfs = 0;           /* Value of -vfs command-line option */
 15700  15825   
 15701  15826     setBinaryMode(stdin, 0);
 15702  15827     setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
 15703  15828     stdin_is_interactive = isatty(0);
 15704  15829     stdout_is_console = isatty(1);
 15705  15830   
 15706  15831   #if USE_SYSTEM_SQLITE+0!=1
................................................................................
 15717  15842     ** do this.  But we want to run an sqlite3_shutdown() afterwards so that
 15718  15843     ** subsequent sqlite3_config() calls will work.  So copy all results into
 15719  15844     ** memory that does not come from the SQLite memory allocator.
 15720  15845     */
 15721  15846   #if !SQLITE_SHELL_IS_UTF8
 15722  15847     sqlite3_initialize();
 15723  15848     argv = malloc(sizeof(argv[0])*argc);
 15724         -  if( argv==0 ){
 15725         -    raw_printf(stderr, "out of memory\n");
 15726         -    exit(1);
 15727         -  }
        15849  +  if( argv==0 ) shell_out_of_memory();
 15728  15850     for(i=0; i<argc; i++){
 15729  15851       char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
 15730  15852       int n;
 15731         -    if( z==0 ){
 15732         -      raw_printf(stderr, "out of memory\n");
 15733         -      exit(1);
 15734         -    }
        15853  +    if( z==0 ) shell_out_of_memory();
 15735  15854       n = (int)strlen(z);
 15736  15855       argv[i] = malloc( n+1 );
 15737         -    if( argv[i]==0 ){
 15738         -      raw_printf(stderr, "out of memory\n");
 15739         -      exit(1);
 15740         -    }
        15856  +    if( argv[i]==0 ) shell_out_of_memory();
 15741  15857       memcpy(argv[i], z, n+1);
 15742  15858       sqlite3_free(z);
 15743  15859     }
 15744  15860     sqlite3_shutdown();
 15745  15861   #endif
 15746  15862   
 15747  15863     assert( argc>=1 && argv && argv[0] );
................................................................................
 15769  15885   #endif
 15770  15886   
 15771  15887     /* Do an initial pass through the command-line argument to locate
 15772  15888     ** the name of the database file, the name of the initialization file,
 15773  15889     ** the size of the alternative malloc heap,
 15774  15890     ** and the first command to execute.
 15775  15891     */
        15892  +  verify_uninitialized();
 15776  15893     for(i=1; i<argc; i++){
 15777  15894       char *z;
 15778  15895       z = argv[i];
 15779  15896       if( z[0]!='-' ){
 15780  15897         if( data.zDbFilename==0 ){
 15781  15898           data.zDbFilename = z;
 15782  15899         }else{
 15783  15900           /* Excesss arguments are interpreted as SQL (or dot-commands) and
 15784  15901           ** mean that nothing is read from stdin */
 15785  15902           readStdin = 0;
 15786  15903           nCmd++;
 15787  15904           azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
 15788         -        if( azCmd==0 ){
 15789         -          raw_printf(stderr, "out of memory\n");
 15790         -          exit(1);
 15791         -        }
        15905  +        if( azCmd==0 ) shell_out_of_memory();
 15792  15906           azCmd[nCmd-1] = z;
 15793  15907         }
 15794  15908       }
 15795  15909       if( z[1]=='-' ) z++;
 15796  15910       if( strcmp(z,"-separator")==0
 15797  15911        || strcmp(z,"-nullvalue")==0
 15798  15912        || strcmp(z,"-newline")==0
................................................................................
 15851  15965       }else if( strcmp(z,"-multiplex")==0 ){
 15852  15966         extern int sqlite3_multiple_initialize(const char*,int);
 15853  15967         sqlite3_multiplex_initialize(0, 1);
 15854  15968   #endif
 15855  15969       }else if( strcmp(z,"-mmap")==0 ){
 15856  15970         sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));
 15857  15971         sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, sz, sz);
        15972  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
        15973  +    }else if( strcmp(z,"-sorterref")==0 ){
        15974  +      sqlite3_int64 sz = integerValue(cmdline_option_value(argc,argv,++i));
        15975  +      sqlite3_config(SQLITE_CONFIG_SORTERREF_SIZE, (int)sz);
        15976  +#endif
 15858  15977       }else if( strcmp(z,"-vfs")==0 ){
 15859         -      sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
 15860         -      if( pVfs ){
 15861         -        sqlite3_vfs_register(pVfs, 1);
 15862         -      }else{
 15863         -        utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]);
 15864         -        exit(1);
 15865         -      }
        15978  +      zVfs = cmdline_option_value(argc, argv, ++i);
 15866  15979   #ifdef SQLITE_HAVE_ZLIB
 15867  15980       }else if( strcmp(z,"-zip")==0 ){
 15868  15981         data.openMode = SHELL_OPEN_ZIPFILE;
 15869  15982   #endif
 15870  15983       }else if( strcmp(z,"-append")==0 ){
 15871  15984         data.openMode = SHELL_OPEN_APPENDVFS;
 15872  15985       }else if( strcmp(z,"-readonly")==0 ){
................................................................................
 15875  15988       }else if( strncmp(z, "-A",2)==0 ){
 15876  15989         /* All remaining command-line arguments are passed to the ".archive"
 15877  15990         ** command, so ignore them */
 15878  15991         break;
 15879  15992   #endif
 15880  15993       }
 15881  15994     }
        15995  +  verify_uninitialized();
        15996  +
        15997  +
        15998  +#ifdef SQLITE_SHELL_INIT_PROC
        15999  +  {
        16000  +    /* If the SQLITE_SHELL_INIT_PROC macro is defined, then it is the name
        16001  +    ** of a C-function that will perform initialization actions on SQLite that
        16002  +    ** occur just before or after sqlite3_initialize(). Use this compile-time
        16003  +    ** option to embed this shell program in larger applications. */
        16004  +    extern void SQLITE_SHELL_INIT_PROC(void);
        16005  +    SQLITE_SHELL_INIT_PROC();
        16006  +  }
        16007  +#else
        16008  +  /* All the sqlite3_config() calls have now been made. So it is safe
        16009  +  ** to call sqlite3_initialize() and process any command line -vfs option. */
        16010  +  sqlite3_initialize();
        16011  +#endif
        16012  +
        16013  +  if( zVfs ){
        16014  +    sqlite3_vfs *pVfs = sqlite3_vfs_find(zVfs);
        16015  +    if( pVfs ){
        16016  +      sqlite3_vfs_register(pVfs, 1);
        16017  +    }else{
        16018  +      utf8_printf(stderr, "no such VFS: \"%s\"\n", argv[i]);
        16019  +      exit(1);
        16020  +    }
        16021  +  }
        16022  +
 15882  16023     if( data.zDbFilename==0 ){
 15883  16024   #ifndef SQLITE_OMIT_MEMORYDB
 15884  16025       data.zDbFilename = ":memory:";
 15885  16026       warnInmemoryDb = argc==1;
 15886  16027   #else
 15887  16028       utf8_printf(stderr,"%s: Error: no database filename specified\n", Argv0);
 15888  16029       return 1;
................................................................................
 15987  16128         i++;
 15988  16129       }else if( strcmp(z,"-pagecache")==0 ){
 15989  16130         i+=2;
 15990  16131       }else if( strcmp(z,"-lookaside")==0 ){
 15991  16132         i+=2;
 15992  16133       }else if( strcmp(z,"-mmap")==0 ){
 15993  16134         i++;
        16135  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
        16136  +    }else if( strcmp(z,"-sorterref")==0 ){
        16137  +      i++;
        16138  +#endif
 15994  16139       }else if( strcmp(z,"-vfs")==0 ){
 15995  16140         i++;
 15996  16141   #ifdef SQLITE_ENABLE_VFSTRACE
 15997  16142       }else if( strcmp(z,"-vfstrace")==0 ){
 15998  16143         i++;
 15999  16144   #endif
 16000  16145   #ifdef SQLITE_ENABLE_MULTIPLEX

Changes to src/sqlcmd.c.

   173    173   ** atexit() handler that cleans up global state modified by this module.
   174    174   */
   175    175   static void sqlcmd_atexit(void) {
   176    176     g.zConfigDbName = 0; /* prevent panic */
   177    177   }
   178    178   
   179    179   /*
   180         -** This routine is called by the patched sqlite3 command-line shell in order
   181         -** to load the name and database connection for the open Fossil database.
          180  +** This routine is called by the sqlite3 command-line shell to
          181  +** to load the name the Fossil repository database.
   182    182   */
   183         -void fossil_open(const char **pzRepoName){
   184         -  sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
          183  +void sqlcmd_get_dbname(const char **pzRepoName){
   185    184     *pzRepoName = g.zRepositoryName;
   186    185   }
          186  +
          187  +/*
          188  +** This routine is called by the sqlite3 command-line shell to do
          189  +** extra initialization prior to starting up the shell.
          190  +*/
          191  +void sqlcmd_init_proc(void){
          192  +  sqlite3_initialize();
          193  +  sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
          194  +}
   187    195   
   188    196   #if USE_SEE
   189    197   /*
   190    198   ** This routine is called by the patched sqlite3 command-line shell in order
   191    199   ** to load the encryption key for the open Fossil database.  The memory that
   192    200   ** is pointed to by the value placed in pzKey must be obtained from SQLite.
   193    201   */

Changes to src/sqlite3.c.

     1      1   /******************************************************************************
     2      2   ** This file is an amalgamation of many separate C source files from SQLite
     3         -** version 3.23.1.  By combining all the individual C code files into this
            3  +** version 3.24.0.  By combining all the individual C code files into this
     4      4   ** single large file, the entire code can be compiled as a single translation
     5      5   ** unit.  This allows many compilers to do optimizations that would not be
     6      6   ** possible if the files were compiled separately.  Performance improvements
     7      7   ** of 5% or more are commonly seen when SQLite is compiled as a single
     8      8   ** translation unit.
     9      9   **
    10     10   ** This file is all you need to compile SQLite.  To use SQLite in other
................................................................................
   306    306     "ENABLE_SELECTTRACE",
   307    307   #endif
   308    308   #if SQLITE_ENABLE_SESSION
   309    309     "ENABLE_SESSION",
   310    310   #endif
   311    311   #if SQLITE_ENABLE_SNAPSHOT
   312    312     "ENABLE_SNAPSHOT",
          313  +#endif
          314  +#if SQLITE_ENABLE_SORTER_REFERENCES
          315  +  "ENABLE_SORTER_REFERENCES",
   313    316   #endif
   314    317   #if SQLITE_ENABLE_SQLLOG
   315    318     "ENABLE_SQLLOG",
   316    319   #endif
   317    320   #if defined(SQLITE_ENABLE_STAT4)
   318    321     "ENABLE_STAT4",
   319    322   #elif defined(SQLITE_ENABLE_STAT3)
................................................................................
  1143   1146   ** been edited in any way since it was last checked in, then the last
  1144   1147   ** four hexadecimal digits of the hash may be modified.
  1145   1148   **
  1146   1149   ** See also: [sqlite3_libversion()],
  1147   1150   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
  1148   1151   ** [sqlite_version()] and [sqlite_source_id()].
  1149   1152   */
  1150         -#define SQLITE_VERSION        "3.23.1"
  1151         -#define SQLITE_VERSION_NUMBER 3023001
  1152         -#define SQLITE_SOURCE_ID      "2018-04-10 17:39:29 4bb2294022060e61de7da5c227a69ccd846ba330e31626ebcd59a94efd148b3b"
         1153  +#define SQLITE_VERSION        "3.24.0"
         1154  +#define SQLITE_VERSION_NUMBER 3024000
         1155  +#define SQLITE_SOURCE_ID      "2018-04-25 13:27:07 3bcdbccf530e2a5aab7b91f4b9e5535cced91f242c49ff69b05a75d643b8b4a3"
  1153   1156   
  1154   1157   /*
  1155   1158   ** CAPI3REF: Run-Time Library Version Numbers
  1156   1159   ** KEYWORDS: sqlite3_version sqlite3_sourceid
  1157   1160   **
  1158   1161   ** These interfaces provide the same information as the [SQLITE_VERSION],
  1159   1162   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
  2950   2953   ** Or if the threshold is -1, statement journals are always held
  2951   2954   ** exclusively in memory.
  2952   2955   ** Since many statement journals never become large, setting the spill
  2953   2956   ** threshold to a value such as 64KiB can greatly reduce the amount of
  2954   2957   ** I/O required to support statement rollback.
  2955   2958   ** The default value for this setting is controlled by the
  2956   2959   ** [SQLITE_STMTJRNL_SPILL] compile-time option.
         2960  +**
         2961  +** [[SQLITE_CONFIG_SORTERREF_SIZE]]
         2962  +** <dt>SQLITE_CONFIG_SORTERREF_SIZE
         2963  +** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter
         2964  +** of type (int) - the new value of the sorter-reference size threshold.
         2965  +** Usually, when SQLite uses an external sort to order records according
         2966  +** to an ORDER BY clause, all fields required by the caller are present in the
         2967  +** sorted records. However, if SQLite determines based on the declared type
         2968  +** of a table column that its values are likely to be very large - larger
         2969  +** than the configured sorter-reference size threshold - then a reference
         2970  +** is stored in each sorted record and the required column values loaded
         2971  +** from the database as records are returned in sorted order. The default
         2972  +** value for this option is to never use this optimization. Specifying a 
         2973  +** negative value for this option restores the default behaviour.
         2974  +** This option is only available if SQLite is compiled with the
         2975  +** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
  2957   2976   ** </dl>
  2958   2977   */
  2959   2978   #define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
  2960   2979   #define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
  2961   2980   #define SQLITE_CONFIG_SERIALIZED    3  /* nil */
  2962   2981   #define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
  2963   2982   #define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
................................................................................
  2979   2998   #define SQLITE_CONFIG_SQLLOG       21  /* xSqllog, void* */
  2980   2999   #define SQLITE_CONFIG_MMAP_SIZE    22  /* sqlite3_int64, sqlite3_int64 */
  2981   3000   #define SQLITE_CONFIG_WIN32_HEAPSIZE      23  /* int nByte */
  2982   3001   #define SQLITE_CONFIG_PCACHE_HDRSZ        24  /* int *psz */
  2983   3002   #define SQLITE_CONFIG_PMASZ               25  /* unsigned int szPma */
  2984   3003   #define SQLITE_CONFIG_STMTJRNL_SPILL      26  /* int nByte */
  2985   3004   #define SQLITE_CONFIG_SMALL_MALLOC        27  /* boolean */
         3005  +#define SQLITE_CONFIG_SORTERREF_SIZE      28  /* int nByte */
  2986   3006   
  2987   3007   /*
  2988   3008   ** CAPI3REF: Database Connection Configuration Options
  2989   3009   **
  2990   3010   ** These constants are the available integer configuration options that
  2991   3011   ** can be passed as the second argument to the [sqlite3_db_config()] interface.
  2992   3012   **
................................................................................
 12937  12957   #define TK_GT                              54
 12938  12958   #define TK_LE                              55
 12939  12959   #define TK_LT                              56
 12940  12960   #define TK_GE                              57
 12941  12961   #define TK_ESCAPE                          58
 12942  12962   #define TK_ID                              59
 12943  12963   #define TK_COLUMNKW                        60
 12944         -#define TK_FOR                             61
 12945         -#define TK_IGNORE                          62
 12946         -#define TK_INITIALLY                       63
 12947         -#define TK_INSTEAD                         64
 12948         -#define TK_NO                              65
 12949         -#define TK_KEY                             66
 12950         -#define TK_OF                              67
 12951         -#define TK_OFFSET                          68
 12952         -#define TK_PRAGMA                          69
 12953         -#define TK_RAISE                           70
 12954         -#define TK_RECURSIVE                       71
 12955         -#define TK_REPLACE                         72
 12956         -#define TK_RESTRICT                        73
 12957         -#define TK_ROW                             74
 12958         -#define TK_TRIGGER                         75
 12959         -#define TK_VACUUM                          76
 12960         -#define TK_VIEW                            77
 12961         -#define TK_VIRTUAL                         78
 12962         -#define TK_WITH                            79
 12963         -#define TK_REINDEX                         80
 12964         -#define TK_RENAME                          81
 12965         -#define TK_CTIME_KW                        82
 12966         -#define TK_ANY                             83
 12967         -#define TK_BITAND                          84
 12968         -#define TK_BITOR                           85
 12969         -#define TK_LSHIFT                          86
 12970         -#define TK_RSHIFT                          87
 12971         -#define TK_PLUS                            88
 12972         -#define TK_MINUS                           89
 12973         -#define TK_STAR                            90
 12974         -#define TK_SLASH                           91
 12975         -#define TK_REM                             92
 12976         -#define TK_CONCAT                          93
 12977         -#define TK_COLLATE                         94
 12978         -#define TK_BITNOT                          95
 12979         -#define TK_INDEXED                         96
 12980         -#define TK_STRING                          97
 12981         -#define TK_JOIN_KW                         98
 12982         -#define TK_CONSTRAINT                      99
 12983         -#define TK_DEFAULT                        100
 12984         -#define TK_NULL                           101
 12985         -#define TK_PRIMARY                        102
 12986         -#define TK_UNIQUE                         103
 12987         -#define TK_CHECK                          104
 12988         -#define TK_REFERENCES                     105
 12989         -#define TK_AUTOINCR                       106
 12990         -#define TK_ON                             107
 12991         -#define TK_INSERT                         108
 12992         -#define TK_DELETE                         109
 12993         -#define TK_UPDATE                         110
 12994         -#define TK_SET                            111
 12995         -#define TK_DEFERRABLE                     112
 12996         -#define TK_FOREIGN                        113
 12997         -#define TK_DROP                           114
 12998         -#define TK_UNION                          115
 12999         -#define TK_ALL                            116
 13000         -#define TK_EXCEPT                         117
 13001         -#define TK_INTERSECT                      118
 13002         -#define TK_SELECT                         119
 13003         -#define TK_VALUES                         120
 13004         -#define TK_DISTINCT                       121
 13005         -#define TK_DOT                            122
 13006         -#define TK_FROM                           123
 13007         -#define TK_JOIN                           124
 13008         -#define TK_USING                          125
 13009         -#define TK_ORDER                          126
 13010         -#define TK_GROUP                          127
 13011         -#define TK_HAVING                         128
 13012         -#define TK_LIMIT                          129
 13013         -#define TK_WHERE                          130
 13014         -#define TK_INTO                           131
 13015         -#define TK_FLOAT                          132
 13016         -#define TK_BLOB                           133
 13017         -#define TK_INTEGER                        134
 13018         -#define TK_VARIABLE                       135
 13019         -#define TK_CASE                           136
 13020         -#define TK_WHEN                           137
 13021         -#define TK_THEN                           138
 13022         -#define TK_ELSE                           139
 13023         -#define TK_INDEX                          140
 13024         -#define TK_ALTER                          141
 13025         -#define TK_ADD                            142
 13026         -#define TK_TRUEFALSE                      143
 13027         -#define TK_ISNOT                          144
 13028         -#define TK_FUNCTION                       145
 13029         -#define TK_COLUMN                         146
 13030         -#define TK_AGG_FUNCTION                   147
 13031         -#define TK_AGG_COLUMN                     148
 13032         -#define TK_UMINUS                         149
 13033         -#define TK_UPLUS                          150
 13034         -#define TK_TRUTH                          151
 13035         -#define TK_REGISTER                       152
 13036         -#define TK_VECTOR                         153
 13037         -#define TK_SELECT_COLUMN                  154
 13038         -#define TK_IF_NULL_ROW                    155
 13039         -#define TK_ASTERISK                       156
 13040         -#define TK_SPAN                           157
 13041         -#define TK_END_OF_FILE                    158
 13042         -#define TK_UNCLOSED_STRING                159
 13043         -#define TK_SPACE                          160
 13044         -#define TK_ILLEGAL                        161
        12964  +#define TK_DO                              61
        12965  +#define TK_FOR                             62
        12966  +#define TK_IGNORE                          63
        12967  +#define TK_INITIALLY                       64
        12968  +#define TK_INSTEAD                         65
        12969  +#define TK_NO                              66
        12970  +#define TK_KEY                             67
        12971  +#define TK_OF                              68
        12972  +#define TK_OFFSET                          69
        12973  +#define TK_PRAGMA                          70
        12974  +#define TK_RAISE                           71
        12975  +#define TK_RECURSIVE                       72
        12976  +#define TK_REPLACE                         73
        12977  +#define TK_RESTRICT                        74
        12978  +#define TK_ROW                             75
        12979  +#define TK_TRIGGER                         76
        12980  +#define TK_VACUUM                          77
        12981  +#define TK_VIEW                            78
        12982  +#define TK_VIRTUAL                         79
        12983  +#define TK_WITH                            80
        12984  +#define TK_REINDEX                         81
        12985  +#define TK_RENAME                          82
        12986  +#define TK_CTIME_KW                        83
        12987  +#define TK_ANY                             84
        12988  +#define TK_BITAND                          85
        12989  +#define TK_BITOR                           86
        12990  +#define TK_LSHIFT                          87
        12991  +#define TK_RSHIFT                          88
        12992  +#define TK_PLUS                            89
        12993  +#define TK_MINUS                           90
        12994  +#define TK_STAR                            91
        12995  +#define TK_SLASH                           92
        12996  +#define TK_REM                             93
        12997  +#define TK_CONCAT                          94
        12998  +#define TK_COLLATE                         95
        12999  +#define TK_BITNOT                          96
        13000  +#define TK_ON                              97
        13001  +#define TK_INDEXED                         98
        13002  +#define TK_STRING                          99
        13003  +#define TK_JOIN_KW                        100
        13004  +#define TK_CONSTRAINT                     101
        13005  +#define TK_DEFAULT                        102
        13006  +#define TK_NULL                           103
        13007  +#define TK_PRIMARY                        104
        13008  +#define TK_UNIQUE                         105
        13009  +#define TK_CHECK                          106
        13010  +#define TK_REFERENCES                     107
        13011  +#define TK_AUTOINCR                       108
        13012  +#define TK_INSERT                         109
        13013  +#define TK_DELETE                         110
        13014  +#define TK_UPDATE                         111
        13015  +#define TK_SET                            112
        13016  +#define TK_DEFERRABLE                     113
        13017  +#define TK_FOREIGN                        114
        13018  +#define TK_DROP                           115
        13019  +#define TK_UNION                          116
        13020  +#define TK_ALL                            117
        13021  +#define TK_EXCEPT                         118
        13022  +#define TK_INTERSECT                      119
        13023  +#define TK_SELECT                         120
        13024  +#define TK_VALUES                         121
        13025  +#define TK_DISTINCT                       122
        13026  +#define TK_DOT                            123
        13027  +#define TK_FROM                           124
        13028  +#define TK_JOIN                           125
        13029  +#define TK_USING                          126
        13030  +#define TK_ORDER                          127
        13031  +#define TK_GROUP                          128
        13032  +#define TK_HAVING                         129
        13033  +#define TK_LIMIT                          130
        13034  +#define TK_WHERE                          131
        13035  +#define TK_INTO                           132
        13036  +#define TK_NOTHING                        133
        13037  +#define TK_FLOAT                          134
        13038  +#define TK_BLOB                           135
        13039  +#define TK_INTEGER                        136
        13040  +#define TK_VARIABLE                       137
        13041  +#define TK_CASE                           138
        13042  +#define TK_WHEN                           139
        13043  +#define TK_THEN                           140
        13044  +#define TK_ELSE                           141
        13045  +#define TK_INDEX                          142
        13046  +#define TK_ALTER                          143
        13047  +#define TK_ADD                            144
        13048  +#define TK_TRUEFALSE                      145
        13049  +#define TK_ISNOT                          146
        13050  +#define TK_FUNCTION                       147
        13051  +#define TK_COLUMN                         148
        13052  +#define TK_AGG_FUNCTION                   149
        13053  +#define TK_AGG_COLUMN                     150
        13054  +#define TK_UMINUS                         151
        13055  +#define TK_UPLUS                          152
        13056  +#define TK_TRUTH                          153
        13057  +#define TK_REGISTER                       154
        13058  +#define TK_VECTOR                         155
        13059  +#define TK_SELECT_COLUMN                  156
        13060  +#define TK_IF_NULL_ROW                    157
        13061  +#define TK_ASTERISK                       158
        13062  +#define TK_SPAN                           159
        13063  +#define TK_END_OF_FILE                    160
        13064  +#define TK_UNCLOSED_STRING                161
        13065  +#define TK_SPACE                          162
        13066  +#define TK_ILLEGAL                        163
 13045  13067   
 13046  13068   /* The token codes above must all fit in 8 bits */
 13047  13069   #define TKFLG_MASK           0xff  
 13048  13070   
 13049  13071   /* Flags that can be added to a token code when it is not
 13050  13072   ** being stored in a u8: */
 13051  13073   #define TKFLG_DONTFOLD       0x100  /* Omit constant folding optimizations */
................................................................................
 13157  13179   ** The default value of "20" was choosen to minimize the run-time of the
 13158  13180   ** speedtest1 test program with options: --shrink-memory --reprepare
 13159  13181   */
 13160  13182   #ifndef SQLITE_DEFAULT_PCACHE_INITSZ
 13161  13183   # define SQLITE_DEFAULT_PCACHE_INITSZ 20
 13162  13184   #endif
 13163  13185   
        13186  +/*
        13187  +** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option.
        13188  +*/
        13189  +#ifndef SQLITE_DEFAULT_SORTERREF_SIZE
        13190  +# define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff
        13191  +#endif
        13192  +
 13164  13193   /*
 13165  13194   ** The compile-time options SQLITE_MMAP_READWRITE and 
 13166  13195   ** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.
 13167  13196   ** You must choose one or the other (or neither) but not both.
 13168  13197   */
 13169  13198   #if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
 13170  13199   #error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE
................................................................................
 13615  13644   typedef struct TableLock TableLock;
 13616  13645   typedef struct Token Token;
 13617  13646   typedef struct TreeView TreeView;
 13618  13647   typedef struct Trigger Trigger;
 13619  13648   typedef struct TriggerPrg TriggerPrg;
 13620  13649   typedef struct TriggerStep TriggerStep;
 13621  13650   typedef struct UnpackedRecord UnpackedRecord;
        13651  +typedef struct Upsert Upsert;
 13622  13652   typedef struct VTable VTable;
 13623  13653   typedef struct VtabCtx VtabCtx;
 13624  13654   typedef struct Walker Walker;
 13625  13655   typedef struct WhereInfo WhereInfo;
 13626  13656   typedef struct With With;
 13627  13657   
 13628  13658   /* A VList object records a mapping between parameters/variables/wildcards
................................................................................
 14272  14302   #define OP_IntCopy        77 /* synopsis: r[P2]=r[P1]                      */
 14273  14303   #define OP_ResultRow      78 /* synopsis: output=r[P1@P2]                  */
 14274  14304   #define OP_CollSeq        79
 14275  14305   #define OP_AddImm         80 /* synopsis: r[P1]=r[P1]+P2                   */
 14276  14306   #define OP_RealAffinity   81
 14277  14307   #define OP_Cast           82 /* synopsis: affinity(r[P1])                  */
 14278  14308   #define OP_Permutation    83
 14279         -#define OP_BitAnd         84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
 14280         -#define OP_BitOr          85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
 14281         -#define OP_ShiftLeft      86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
 14282         -#define OP_ShiftRight     87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
 14283         -#define OP_Add            88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
 14284         -#define OP_Subtract       89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
 14285         -#define OP_Multiply       90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
 14286         -#define OP_Divide         91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
 14287         -#define OP_Remainder      92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
 14288         -#define OP_Concat         93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
 14289         -#define OP_Compare        94 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
 14290         -#define OP_BitNot         95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
 14291         -#define OP_IsTrue         96 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
 14292         -#define OP_String8        97 /* same as TK_STRING, synopsis: r[P2]='P4'    */
 14293         -#define OP_Offset         98 /* synopsis: r[P3] = sqlite_offset(P1)        */
 14294         -#define OP_Column         99 /* synopsis: r[P3]=PX                         */
        14309  +#define OP_Compare        84 /* synopsis: r[P1@P3] <-> r[P2@P3]            */
        14310  +#define OP_BitAnd         85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
        14311  +#define OP_BitOr          86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
        14312  +#define OP_ShiftLeft      87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
        14313  +#define OP_ShiftRight     88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
        14314  +#define OP_Add            89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
        14315  +#define OP_Subtract       90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
        14316  +#define OP_Multiply       91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
        14317  +#define OP_Divide         92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
        14318  +#define OP_Remainder      93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
        14319  +#define OP_Concat         94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
        14320  +#define OP_IsTrue         95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
        14321  +#define OP_BitNot         96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
        14322  +#define OP_Offset         97 /* synopsis: r[P3] = sqlite_offset(P1)        */
        14323  +#define OP_Column         98 /* synopsis: r[P3]=PX                         */
        14324  +#define OP_String8        99 /* same as TK_STRING, synopsis: r[P2]='P4'    */
 14295  14325   #define OP_Affinity      100 /* synopsis: affinity(r[P1@P2])               */
 14296  14326   #define OP_MakeRecord    101 /* synopsis: r[P3]=mkrec(r[P1@P2])            */
 14297  14327   #define OP_Count         102 /* synopsis: r[P2]=count()                    */
 14298  14328   #define OP_ReadCookie    103
 14299  14329   #define OP_SetCookie     104
 14300  14330   #define OP_ReopenIdx     105 /* synopsis: root=P2 iDb=P3                   */
 14301  14331   #define OP_OpenRead      106 /* synopsis: root=P2 iDb=P3                   */
................................................................................
 14320  14350   #define OP_Rowid         125 /* synopsis: r[P2]=rowid                      */
 14321  14351   #define OP_NullRow       126
 14322  14352   #define OP_SeekEnd       127
 14323  14353   #define OP_SorterInsert  128 /* synopsis: key=r[P2]                        */
 14324  14354   #define OP_IdxInsert     129 /* synopsis: key=r[P2]                        */
 14325  14355   #define OP_IdxDelete     130 /* synopsis: key=r[P2@P3]                     */
 14326  14356   #define OP_DeferredSeek  131 /* synopsis: Move P3 to P1.rowid if needed    */
 14327         -#define OP_Real          132 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
 14328         -#define OP_IdxRowid      133 /* synopsis: r[P2]=rowid                      */
 14329         -#define OP_Destroy       134
        14357  +#define OP_IdxRowid      132 /* synopsis: r[P2]=rowid                      */
        14358  +#define OP_Destroy       133
        14359  +#define OP_Real          134 /* same as TK_FLOAT, synopsis: r[P2]=P4       */
 14330  14360   #define OP_Clear         135
 14331  14361   #define OP_ResetSorter   136
 14332  14362   #define OP_CreateBtree   137 /* synopsis: r[P2]=root iDb=P1 flags=P3       */
 14333  14363   #define OP_SqlExec       138
 14334  14364   #define OP_ParseSchema   139
 14335  14365   #define OP_LoadAnalysis  140
 14336  14366   #define OP_DropTable     141
................................................................................
 14381  14411   /*  24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
 14382  14412   /*  32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
 14383  14413   /*  40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\
 14384  14414   /*  48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
 14385  14415   /*  56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\
 14386  14416   /*  64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\
 14387  14417   /*  72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
 14388         -/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x26, 0x26, 0x26, 0x26,\
 14389         -/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
 14390         -/*  96 */ 0x12, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\
        14418  +/*  80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\
        14419  +/*  88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\
        14420  +/*  96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\
 14391  14421   /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
 14392  14422   /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
 14393  14423   /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
 14394  14424   /* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
 14395  14425   /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
 14396  14426   /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\
 14397  14427   /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
................................................................................
 14457  14487   SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
 14458  14488   SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);
 14459  14489   SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
 14460  14490   SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
 14461  14491   SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
 14462  14492   SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
 14463  14493   SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
        14494  +#ifdef SQLITE_COVERAGE_TEST
        14495  +SQLITE_PRIVATE   int sqlite3VdbeLabelHasBeenResolved(Vdbe*,int);
        14496  +#endif
 14464  14497   SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
 14465  14498   #ifdef SQLITE_DEBUG
 14466  14499   SQLITE_PRIVATE   int sqlite3VdbeAssertMayAbort(Vdbe *, int);
 14467  14500   #endif
 14468  14501   SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*);
 14469  14502   SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*);
 14470  14503   SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*);
................................................................................
 15591  15624     u8 bBenignMalloc;             /* Do not require OOMs if true */
 15592  15625     u8 dfltLockMode;              /* Default locking-mode for attached dbs */
 15593  15626     signed char nextAutovac;      /* Autovac setting after VACUUM if >=0 */
 15594  15627     u8 suppressErr;               /* Do not issue error messages if true */
 15595  15628     u8 vtabOnConflict;            /* Value to return for s3_vtab_on_conflict() */
 15596  15629     u8 isTransactionSavepoint;    /* True if the outermost savepoint is a TS */
 15597  15630     u8 mTrace;                    /* zero or more SQLITE_TRACE flags */
 15598         -  u8 skipBtreeMutex;            /* True if no shared-cache backends */
        15631  +  u8 noSharedCache;             /* True if no shared-cache backends */
 15599  15632     u8 nSqlExec;                  /* Number of pending OP_SqlExec opcodes */
 15600  15633     int nextPagesize;             /* Pagesize after VACUUM if >0 */
 15601  15634     u32 magic;                    /* Magic number for detect library misuse */
 15602  15635     int nChange;                  /* Value returned by sqlite3_changes() */
 15603  15636     int nTotalChange;             /* Value returned by sqlite3_total_changes() */
 15604  15637     int aLimit[SQLITE_N_LIMIT];   /* Limits */
 15605  15638     int nMaxSorterMmap;           /* Maximum size of regions mapped by sorter */
................................................................................
 15751  15784   
 15752  15785   /*
 15753  15786   ** Allowed values for sqlite3.mDbFlags
 15754  15787   */
 15755  15788   #define DBFLAG_SchemaChange   0x0001  /* Uncommitted Hash table changes */
 15756  15789   #define DBFLAG_PreferBuiltin  0x0002  /* Preference to built-in funcs */
 15757  15790   #define DBFLAG_Vacuum         0x0004  /* Currently in a VACUUM */
        15791  +#define DBFLAG_SchemaKnownOk  0x0008  /* Schema is known to be valid */
 15758  15792   
 15759  15793   /*
 15760  15794   ** Bits of the sqlite3.dbOptFlags field that are used by the
 15761  15795   ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
 15762  15796   ** selectively disable various optimizations.
 15763  15797   */
 15764  15798   #define SQLITE_QueryFlattener 0x0001   /* Query flattening */
................................................................................
 15996  16030   
 15997  16031   /* Allowed values for Column.colFlags:
 15998  16032   */
 15999  16033   #define COLFLAG_PRIMKEY  0x0001    /* Column is part of the primary key */
 16000  16034   #define COLFLAG_HIDDEN   0x0002    /* A hidden column in a virtual table */
 16001  16035   #define COLFLAG_HASTYPE  0x0004    /* Type name follows column name */
 16002  16036   #define COLFLAG_UNIQUE   0x0008    /* Column def contains "UNIQUE" or "PK" */
        16037  +#define COLFLAG_SORTERREF 0x0010   /* Use sorter-refs with this column */
 16003  16038   
 16004  16039   /*
 16005  16040   ** A "Collating Sequence" is defined by an instance of the following
 16006  16041   ** structure. Conceptually, a collating sequence consists of a name and
 16007  16042   ** a comparison routine that defines the order of that sequence.
 16008  16043   **
 16009  16044   ** If CollSeq.xCmp is NULL, it means that the
................................................................................
 16283  16318   */
 16284  16319   #define OE_None     0   /* There is no constraint to check */
 16285  16320   #define OE_Rollback 1   /* Fail the operation and rollback the transaction */
 16286  16321   #define OE_Abort    2   /* Back out changes but do no rollback transaction */
 16287  16322   #define OE_Fail     3   /* Stop the operation but leave all prior changes */
 16288  16323   #define OE_Ignore   4   /* Ignore the error. Do not do the INSERT or UPDATE */
 16289  16324   #define OE_Replace  5   /* Delete existing record, then do INSERT or UPDATE */
 16290         -
 16291         -#define OE_Restrict 6   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
 16292         -#define OE_SetNull  7   /* Set the foreign key value to NULL */
 16293         -#define OE_SetDflt  8   /* Set the foreign key value to its default */
 16294         -#define OE_Cascade  9   /* Cascade the changes */
 16295         -
 16296         -#define OE_Default  10  /* Do whatever the default action is */
        16325  +#define OE_Update   6   /* Process as a DO UPDATE in an upsert */
        16326  +#define OE_Restrict 7   /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */
        16327  +#define OE_SetNull  8   /* Set the foreign key value to NULL */
        16328  +#define OE_SetDflt  9   /* Set the foreign key value to its default */
        16329  +#define OE_Cascade  10  /* Cascade the changes */
        16330  +#define OE_Default  11  /* Do whatever the default action is */
 16297  16331   
 16298  16332   
 16299  16333   /*
 16300  16334   ** An instance of the following structure is passed as the first
 16301  16335   ** argument to sqlite3VdbeKeyCompare and is used to control the
 16302  16336   ** comparison of the two index keys.
 16303  16337   **
................................................................................
 16736  16770       Expr *pExpr;            /* The parse tree for this expression */
 16737  16771       char *zName;            /* Token associated with this expression */
 16738  16772       char *zSpan;            /* Original text of the expression */
 16739  16773       u8 sortOrder;           /* 1 for DESC or 0 for ASC */
 16740  16774       unsigned done :1;       /* A flag to indicate when processing is finished */
 16741  16775       unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
 16742  16776       unsigned reusable :1;   /* Constant expression is reusable */
        16777  +    unsigned bSorterRef :1; /* Defer evaluation until after sorting */
 16743  16778       union {
 16744  16779         struct {
 16745  16780           u16 iOrderByCol;      /* For ORDER BY, column number in result set */
 16746  16781           u16 iAlias;           /* Index into Parse.aAlias[] for zName */
 16747  16782         } x;
 16748  16783         int iConstExprReg;      /* Register in which Expr value is cached */
 16749  16784       } u;
................................................................................
 16919  16954   ** NameContext in the parent query.  Thus the process of scanning the
 16920  16955   ** NameContext list corresponds to searching through successively outer
 16921  16956   ** subqueries looking for a match.
 16922  16957   */
 16923  16958   struct NameContext {
 16924  16959     Parse *pParse;       /* The parser */
 16925  16960     SrcList *pSrcList;   /* One or more tables used to resolve names */
 16926         -  ExprList *pEList;    /* Optional list of result-set columns */
 16927         -  AggInfo *pAggInfo;   /* Information about aggregates at this level */
        16961  +  union {
        16962  +    ExprList *pEList;    /* Optional list of result-set columns */
        16963  +    AggInfo *pAggInfo;   /* Information about aggregates at this level */
        16964  +    Upsert *pUpsert;     /* ON CONFLICT clause information from an upsert */
        16965  +  } uNC;
 16928  16966     NameContext *pNext;  /* Next outer name context.  NULL for outermost */
 16929  16967     int nRef;            /* Number of names resolved by this context */
 16930  16968     int nErr;            /* Number of errors encountered while resolving names */
 16931  16969     u16 ncFlags;         /* Zero or more NC_* flags defined below */
 16932  16970   };
 16933  16971   
 16934  16972   /*
................................................................................
 16942  16980   #define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
 16943  16981   #define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */
 16944  16982   #define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
 16945  16983   #define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
 16946  16984   #define NC_HasAgg    0x0010  /* One or more aggregate functions seen */
 16947  16985   #define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
 16948  16986   #define NC_VarSelect 0x0040  /* A correlated subquery has been seen */
        16987  +#define NC_UEList    0x0080  /* True if uNC.pEList is used */
        16988  +#define NC_UAggInfo  0x0100  /* True if uNC.pAggInfo is used */
        16989  +#define NC_UUpsert   0x0200  /* True if uNC.pUpsert is used */
 16949  16990   #define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
 16950  16991   #define NC_Complex   0x2000  /* True if a function or subquery seen */
        16992  +
        16993  +/*
        16994  +** An instance of the following object describes a single ON CONFLICT
        16995  +** clause in an upsert.
        16996  +**
        16997  +** The pUpsertTarget field is only set if the ON CONFLICT clause includes
        16998  +** conflict-target clause.  (In "ON CONFLICT(a,b)" the "(a,b)" is the
        16999  +** conflict-target clause.)  The pUpsertTargetWhere is the optional
        17000  +** WHERE clause used to identify partial unique indexes.
        17001  +**
        17002  +** pUpsertSet is the list of column=expr terms of the UPDATE statement. 
        17003  +** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING.  The
        17004  +** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the
        17005  +** WHERE clause is omitted.
        17006  +*/
        17007  +struct Upsert {
        17008  +  ExprList *pUpsertTarget;  /* Optional description of conflicting index */
        17009  +  Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */
        17010  +  ExprList *pUpsertSet;     /* The SET clause from an ON CONFLICT UPDATE */
        17011  +  Expr *pUpsertWhere;       /* WHERE clause for the ON CONFLICT UPDATE */
        17012  +  /* The fields above comprise the parse tree for the upsert clause.
        17013  +  ** The fields below are used to transfer information from the INSERT
        17014  +  ** processing down into the UPDATE processing while generating code.
        17015  +  ** Upsert owns the memory allocated above, but not the memory below. */
        17016  +  Index *pUpsertIdx;        /* Constraint that pUpsertTarget identifies */
        17017  +  SrcList *pUpsertSrc;      /* Table to be updated */
        17018  +  int regData;              /* First register holding array of VALUES */
        17019  +  int iDataCur;             /* Index of the data cursor */
        17020  +  int iIdxCur;              /* Index of the first index cursor */
        17021  +};
 16951  17022   
 16952  17023   /*
 16953  17024   ** An instance of the following structure contains all information
 16954  17025   ** needed to generate code for a single SELECT statement.
 16955  17026   **
 16956  17027   ** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.
 16957  17028   ** If there is a LIMIT clause, the parser sets nLimit to the value of the
................................................................................
 16973  17044     ExprList *pEList;      /* The fields of the result */
 16974  17045     u8 op;                 /* One of: TK_UNION TK_ALL TK_INTERSECT TK_EXCEPT */
 16975  17046     LogEst nSelectRow;     /* Estimated number of result rows */
 16976  17047     u32 selFlags;          /* Various SF_* values */
 16977  17048     int iLimit, iOffset;   /* Memory registers holding LIMIT & OFFSET counters */
 16978  17049   #if SELECTTRACE_ENABLED
 16979  17050     char zSelName[12];     /* Symbolic name of this SELECT use for debugging */
        17051  +  u32 iSelectId;         /* EXPLAIN QUERY PLAN select ID */
 16980  17052   #endif
 16981  17053     int addrOpenEphm[2];   /* OP_OpenEphem opcodes related to this select */
 16982  17054     SrcList *pSrc;         /* The FROM clause */
 16983  17055     Expr *pWhere;          /* The WHERE clause */
 16984  17056     ExprList *pGroupBy;    /* The GROUP BY clause */
 16985  17057     Expr *pHaving;         /* The HAVING clause */
 16986  17058     ExprList *pOrderBy;    /* The ORDER BY clause */
................................................................................
 17444  17516   struct TriggerStep {
 17445  17517     u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
 17446  17518     u8 orconf;           /* OE_Rollback etc. */
 17447  17519     Trigger *pTrig;      /* The trigger that this step is a part of */
 17448  17520     Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */
 17449  17521     char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */
 17450  17522     Expr *pWhere;        /* The WHERE clause for DELETE or UPDATE steps */
 17451         -  ExprList *pExprList; /* SET clause for UPDATE. */
        17523  +  ExprList *pExprList; /* SET clause for UPDATE */
 17452  17524     IdList *pIdList;     /* Column names for INSERT */
        17525  +  Upsert *pUpsert;     /* Upsert clauses on an INSERT */
 17453  17526     char *zSpan;         /* Original SQL text of this command */
 17454  17527     TriggerStep *pNext;  /* Next in the link-list */
 17455  17528     TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */
 17456  17529   };
 17457  17530   
 17458  17531   /*
 17459  17532   ** The following structure contains information used by the sqliteFix...
................................................................................
 17557  17630     void *pVdbeBranchArg;                                     /* 1st argument */
 17558  17631   #endif
 17559  17632   #ifndef SQLITE_UNTESTABLE
 17560  17633     int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */
 17561  17634   #endif
 17562  17635     int bLocaltimeFault;              /* True to fail localtime() calls */
 17563  17636     int iOnceResetThreshold;          /* When to reset OP_Once counters */
        17637  +  u32 szSorterRef;                  /* Min size in bytes to use sorter-refs */
 17564  17638   };
 17565  17639   
 17566  17640   /*
 17567  17641   ** This macro is used inside of assert() statements to indicate that
 17568  17642   ** the assert is only valid on a well-formed database.  Instead of:
 17569  17643   **
 17570  17644   **     assert( X );
................................................................................
 17977  18051   #ifndef SQLITE_OMIT_AUTOINCREMENT
 17978  18052   SQLITE_PRIVATE   void sqlite3AutoincrementBegin(Parse *pParse);
 17979  18053   SQLITE_PRIVATE   void sqlite3AutoincrementEnd(Parse *pParse);
 17980  18054   #else
 17981  18055   # define sqlite3AutoincrementBegin(X)
 17982  18056   # define sqlite3AutoincrementEnd(X)
 17983  18057   #endif
 17984         -SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int);
        18058  +SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
 17985  18059   SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
 17986  18060   SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*);
 17987  18061   SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
 17988  18062   SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
 17989  18063   SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
 17990  18064   SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
 17991  18065                                         Token*, Select*, Expr*, IdList*);
................................................................................
 18007  18081   SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
 18008  18082   SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int);
 18009  18083   SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
 18010  18084   #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
 18011  18085   SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
 18012  18086   #endif
 18013  18087   SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
 18014         -SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*);
        18088  +SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
        18089  +                   Upsert*);
 18015  18090   SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
 18016  18091   SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
 18017  18092   SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
 18018  18093   SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
 18019  18094   SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*);
 18020  18095   SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*);
 18021  18096   SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*);
................................................................................
 18100  18175   SQLITE_PRIVATE int sqlite3IsRowid(const char*);
 18101  18176   SQLITE_PRIVATE void sqlite3GenerateRowDelete(
 18102  18177       Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
 18103  18178   SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
 18104  18179   SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int);
 18105  18180   SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
 18106  18181   SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
 18107         -                                     u8,u8,int,int*,int*);
        18182  +                                     u8,u8,int,int*,int*,Upsert*);
 18108  18183   #ifdef SQLITE_ENABLE_NULL_TRIM
 18109  18184   SQLITE_PRIVATE   void sqlite3SetMakeRecordP5(Vdbe*,Table*);
 18110  18185   #else
 18111  18186   # define sqlite3SetMakeRecordP5(A,B)
 18112  18187   #endif
 18113  18188   SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
 18114  18189   SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
................................................................................
 18153  18228                               int, int, int);
 18154  18229   SQLITE_PRIVATE   void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
 18155  18230     void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
 18156  18231   SQLITE_PRIVATE   void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
 18157  18232   SQLITE_PRIVATE   TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
 18158  18233                                           const char*,const char*);
 18159  18234   SQLITE_PRIVATE   TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
 18160         -                                        Select*,u8,const char*,const char*);
        18235  +                                        Select*,u8,Upsert*,
        18236  +                                        const char*,const char*);
 18161  18237   SQLITE_PRIVATE   TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
 18162  18238                                           const char*,const char*);
 18163  18239   SQLITE_PRIVATE   TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
 18164  18240                                           const char*,const char*);
 18165  18241   SQLITE_PRIVATE   void sqlite3DeleteTrigger(sqlite3*, Trigger*);
 18166  18242   SQLITE_PRIVATE   void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
 18167  18243   SQLITE_PRIVATE   u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
................................................................................
 18339  18415   SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
 18340  18416   SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
 18341  18417   SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
 18342  18418   SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
 18343  18419   SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
 18344  18420   SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *);
 18345  18421   SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*);
 18346         -SQLITE_PRIVATE char sqlite3AffinityType(const char*, u8*);
        18422  +SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*);
 18347  18423   SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*);
 18348  18424   SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*);
 18349  18425   SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*);
 18350  18426   SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *);
 18351  18427   SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB);
 18352  18428   SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*);
 18353  18429   SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*);
................................................................................
 18401  18477   SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int);
 18402  18478   #endif
 18403  18479   
 18404  18480   /*
 18405  18481   ** The interface to the LEMON-generated parser
 18406  18482   */
 18407  18483   #ifndef SQLITE_AMALGAMATION
 18408         -SQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64));
        18484  +SQLITE_PRIVATE   void *sqlite3ParserAlloc(void*(*)(u64), Parse*);
 18409  18485   SQLITE_PRIVATE   void sqlite3ParserFree(void*, void(*)(void*));
 18410  18486   #endif
 18411         -SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
        18487  +SQLITE_PRIVATE void sqlite3Parser(void*, int, Token);
 18412  18488   #ifdef YYTRACKMAXSTACKDEPTH
 18413  18489   SQLITE_PRIVATE   int sqlite3ParserStackPeak(void*);
 18414  18490   #endif
 18415  18491   
 18416  18492   SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*);
 18417  18493   #ifndef SQLITE_OMIT_LOAD_EXTENSION
 18418  18494   SQLITE_PRIVATE   void sqlite3CloseExtensions(sqlite3*);
................................................................................
 18492  18568   SQLITE_PRIVATE   With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*);
 18493  18569   SQLITE_PRIVATE   void sqlite3WithDelete(sqlite3*,With*);
 18494  18570   SQLITE_PRIVATE   void sqlite3WithPush(Parse*, With*, u8);
 18495  18571   #else
 18496  18572   #define sqlite3WithPush(x,y,z)
 18497  18573   #define sqlite3WithDelete(x,y)
 18498  18574   #endif
        18575  +#ifndef SQLITE_OMIT_UPSERT
        18576  +SQLITE_PRIVATE   Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*);
        18577  +SQLITE_PRIVATE   void sqlite3UpsertDelete(sqlite3*,Upsert*);
        18578  +SQLITE_PRIVATE   Upsert *sqlite3UpsertDup(sqlite3*,Upsert*);
        18579  +SQLITE_PRIVATE   int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*);
        18580  +SQLITE_PRIVATE   void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int);
        18581  +#else
        18582  +#define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0)
        18583  +#define sqlite3UpsertDelete(x,y)
        18584  +#define sqlite3UpsertDup(x,y)       ((Upsert*)0)
        18585  +#endif
        18586  +
 18499  18587   
 18500  18588   /* Declarations for functions in fkey.c. All of these are replaced by
 18501  18589   ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
 18502  18590   ** key functionality is available. If OMIT_TRIGGER is defined but
 18503  18591   ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
 18504  18592   ** this case foreign keys are parsed, but no other functionality is
 18505  18593   ** provided (enforcement of FK constraints requires the triggers sub-system).
................................................................................
 18924  19012      0,                         /* xVdbeBranch */
 18925  19013      0,                         /* pVbeBranchArg */
 18926  19014   #endif
 18927  19015   #ifndef SQLITE_UNTESTABLE
 18928  19016      0,                         /* xTestCallback */
 18929  19017   #endif
 18930  19018      0,                         /* bLocaltimeFault */
 18931         -   0x7ffffffe                 /* iOnceResetThreshold */
        19019  +   0x7ffffffe,                /* iOnceResetThreshold */
        19020  +   SQLITE_DEFAULT_SORTERREF_SIZE   /* szSorterRef */
 18932  19021   };
 18933  19022   
 18934  19023   /*
 18935  19024   ** Hash table for global functions - functions common to all
 18936  19025   ** database connections.  After initialization, this table is
 18937  19026   ** read-only.
 18938  19027   */
................................................................................
 27497  27586     sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
 27498  27587     if( p ){
 27499  27588       for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
 27500  27589         sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|   " : "    ", 4);
 27501  27590       }
 27502  27591       sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
 27503  27592     }
 27504         -  va_start(ap, zFormat);
 27505         -  sqlite3VXPrintf(&acc, zFormat, ap);
 27506         -  va_end(ap);
 27507         -  assert( acc.nChar>0 );
 27508         -  if( zBuf[acc.nChar-1]!='\n' ) sqlite3StrAccumAppend(&acc, "\n", 1);
        27593  +  if( zFormat!=0 ){
        27594  +    va_start(ap, zFormat);
        27595  +    sqlite3VXPrintf(&acc, zFormat, ap);
        27596  +    va_end(ap);
        27597  +    assert( acc.nChar>0 );
        27598  +    sqlite3StrAccumAppend(&acc, "\n", 1);
        27599  +  }
 27509  27600     sqlite3StrAccumFinish(&acc);
 27510  27601     fprintf(stdout,"%s", zBuf);
 27511  27602     fflush(stdout);
 27512  27603   }
 27513  27604   
 27514  27605   /*
 27515  27606   ** Shorthand for starting a new tree item that consists of a single label
................................................................................
 27574  27665       sqlite3TreeViewWith(pView, p->pWith, 1);
 27575  27666       cnt = 1;
 27576  27667       sqlite3TreeViewPush(pView, 1);
 27577  27668     }
 27578  27669     do{
 27579  27670   #if SELECTTRACE_ENABLED
 27580  27671       sqlite3TreeViewLine(pView,
 27581         -      "SELECT%s%s (%s/%p) selFlags=0x%x nSelectRow=%d",
        27672  +      "SELECT%s%s (%s/%d/%p) selFlags=0x%x nSelectRow=%d",
 27582  27673         ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
 27583  27674         ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""),
 27584         -      p->zSelName, p, p->selFlags,
        27675  +      p->zSelName, p->iSelectId, p, p->selFlags,
 27585  27676         (int)p->nSelectRow
 27586  27677       );
 27587  27678   #else
 27588  27679       sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p) selFlags=0x%x nSelectRow=%d",
 27589  27680         ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
 27590  27681         ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p, p->selFlags,
 27591  27682         (int)p->nSelectRow
................................................................................
 27971  28062       sqlite3TreeViewLine(pView, "%s (empty)", zLabel);
 27972  28063     }else{
 27973  28064       int i;
 27974  28065       sqlite3TreeViewLine(pView, "%s", zLabel);
 27975  28066       for(i=0; i<pList->nExpr; i++){
 27976  28067         int j = pList->a[i].u.x.iOrderByCol;
 27977  28068         char *zName = pList->a[i].zName;
        28069  +      int moreToFollow = i<pList->nExpr - 1;
 27978  28070         if( j || zName ){
 27979         -        sqlite3TreeViewPush(pView, 0);
        28071  +        sqlite3TreeViewPush(pView, moreToFollow);
        28072  +        moreToFollow = 0;
        28073  +        sqlite3TreeViewLine(pView, 0);
        28074  +        if( zName ){
        28075  +          fprintf(stdout, "AS %s ", zName);
        28076  +        }
        28077  +        if( j ){
        28078  +          fprintf(stdout, "iOrderByCol=%d", j);
        28079  +        }
        28080  +        fprintf(stdout, "\n");
        28081  +        fflush(stdout);
 27980  28082         }
 27981         -      if( zName ){
 27982         -        sqlite3TreeViewLine(pView, "AS %s", zName);
 27983         -      }
 27984         -      if( j ){
 27985         -        sqlite3TreeViewLine(pView, "iOrderByCol=%d", j);
 27986         -      }
 27987         -      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
        28083  +      sqlite3TreeViewExpr(pView, pList->a[i].pExpr, moreToFollow);
 27988  28084         if( j || zName ){
 27989  28085           sqlite3TreeViewPop(pView);
 27990  28086         }
 27991  28087       }
 27992  28088     }
 27993  28089   }
 27994  28090   SQLITE_PRIVATE void sqlite3TreeViewExprList(
................................................................................
 30946  31042       /*  77 */ "IntCopy"          OpHelp("r[P2]=r[P1]"),
 30947  31043       /*  78 */ "ResultRow"        OpHelp("output=r[P1@P2]"),
 30948  31044       /*  79 */ "CollSeq"          OpHelp(""),
 30949  31045       /*  80 */ "AddImm"           OpHelp("r[P1]=r[P1]+P2"),
 30950  31046       /*  81 */ "RealAffinity"     OpHelp(""),
 30951  31047       /*  82 */ "Cast"             OpHelp("affinity(r[P1])"),
 30952  31048       /*  83 */ "Permutation"      OpHelp(""),
 30953         -    /*  84 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
 30954         -    /*  85 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
 30955         -    /*  86 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
 30956         -    /*  87 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
 30957         -    /*  88 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
 30958         -    /*  89 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
 30959         -    /*  90 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
 30960         -    /*  91 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
 30961         -    /*  92 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
 30962         -    /*  93 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
 30963         -    /*  94 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
 30964         -    /*  95 */ "BitNot"           OpHelp("r[P1]= ~r[P1]"),
 30965         -    /*  96 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
 30966         -    /*  97 */ "String8"          OpHelp("r[P2]='P4'"),
 30967         -    /*  98 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
 30968         -    /*  99 */ "Column"           OpHelp("r[P3]=PX"),
        31049  +    /*  84 */ "Compare"          OpHelp("r[P1@P3] <-> r[P2@P3]"),
        31050  +    /*  85 */ "BitAnd"           OpHelp("r[P3]=r[P1]&r[P2]"),
        31051  +    /*  86 */ "BitOr"            OpHelp("r[P3]=r[P1]|r[P2]"),
        31052  +    /*  87 */ "ShiftLeft"        OpHelp("r[P3]=r[P2]<<r[P1]"),
        31053  +    /*  88 */ "ShiftRight"       OpHelp("r[P3]=r[P2]>>r[P1]"),
        31054  +    /*  89 */ "Add"              OpHelp("r[P3]=r[P1]+r[P2]"),
        31055  +    /*  90 */ "Subtract"         OpHelp("r[P3]=r[P2]-r[P1]"),
        31056  +    /*  91 */ "Multiply"         OpHelp("r[P3]=r[P1]*r[P2]"),
        31057  +    /*  92 */ "Divide"           OpHelp("r[P3]=r[P2]/r[P1]"),
        31058  +    /*  93 */ "Remainder"        OpHelp("r[P3]=r[P2]%r[P1]"),
        31059  +    /*  94 */ "Concat"           OpHelp("r[P3]=r[P2]+r[P1]"),
        31060  +    /*  95 */ "IsTrue"           OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
        31061  +    /*  96 */ "BitNot"           OpHelp("r[P1]= ~r[P1]"),
        31062  +    /*  97 */ "Offset"           OpHelp("r[P3] = sqlite_offset(P1)"),
        31063  +    /*  98 */ "Column"           OpHelp("r[P3]=PX"),
        31064  +    /*  99 */ "String8"          OpHelp("r[P2]='P4'"),
 30969  31065       /* 100 */ "Affinity"         OpHelp("affinity(r[P1@P2])"),
 30970  31066       /* 101 */ "MakeRecord"       OpHelp("r[P3]=mkrec(r[P1@P2])"),
 30971  31067       /* 102 */ "Count"            OpHelp("r[P2]=count()"),
 30972  31068       /* 103 */ "ReadCookie"       OpHelp(""),
 30973  31069       /* 104 */ "SetCookie"        OpHelp(""),
 30974  31070       /* 105 */ "ReopenIdx"        OpHelp("root=P2 iDb=P3"),
 30975  31071       /* 106 */ "OpenRead"         OpHelp("root=P2 iDb=P3"),
................................................................................
 30994  31090       /* 125 */ "Rowid"            OpHelp("r[P2]=rowid"),
 30995  31091       /* 126 */ "NullRow"          OpHelp(""),
 30996  31092       /* 127 */ "SeekEnd"          OpHelp(""),
 30997  31093       /* 128 */ "SorterInsert"     OpHelp("key=r[P2]"),
 30998  31094       /* 129 */ "IdxInsert"        OpHelp("key=r[P2]"),
 30999  31095       /* 130 */ "IdxDelete"        OpHelp("key=r[P2@P3]"),
 31000  31096       /* 131 */ "DeferredSeek"     OpHelp("Move P3 to P1.rowid if needed"),
 31001         -    /* 132 */ "Real"             OpHelp("r[P2]=P4"),
 31002         -    /* 133 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
 31003         -    /* 134 */ "Destroy"          OpHelp(""),
        31097  +    /* 132 */ "IdxRowid"         OpHelp("r[P2]=rowid"),
        31098  +    /* 133 */ "Destroy"          OpHelp(""),
        31099  +    /* 134 */ "Real"             OpHelp("r[P2]=P4"),
 31004  31100       /* 135 */ "Clear"            OpHelp(""),
 31005  31101       /* 136 */ "ResetSorter"      OpHelp(""),
 31006  31102       /* 137 */ "CreateBtree"      OpHelp("r[P2]=root iDb=P1 flags=P3"),
 31007  31103       /* 138 */ "SqlExec"          OpHelp(""),
 31008  31104       /* 139 */ "ParseSchema"      OpHelp(""),
 31009  31105       /* 140 */ "LoadAnalysis"     OpHelp(""),
 31010  31106       /* 141 */ "DropTable"        OpHelp(""),
................................................................................
 61478  61574     for(i=0; i<db->nDb; i++){
 61479  61575       p = db->aDb[i].pBt;
 61480  61576       if( p && p->sharable ){
 61481  61577         sqlite3BtreeEnter(p);
 61482  61578         skipOk = 0;
 61483  61579       }
 61484  61580     }
 61485         -  db->skipBtreeMutex = skipOk;
        61581  +  db->noSharedCache = skipOk;
 61486  61582   }
 61487  61583   SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
 61488         -  if( db->skipBtreeMutex==0 ) btreeEnterAll(db);
        61584  +  if( db->noSharedCache==0 ) btreeEnterAll(db);
 61489  61585   }
 61490  61586   static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){
 61491  61587     int i;
 61492  61588     Btree *p;
 61493  61589     assert( sqlite3_mutex_held(db->mutex) );
 61494  61590     for(i=0; i<db->nDb; i++){
 61495  61591       p = db->aDb[i].pBt;
 61496  61592       if( p ) sqlite3BtreeLeave(p);
 61497  61593     }
 61498  61594   }
 61499  61595   SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
 61500         -  if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);
        61596  +  if( db->noSharedCache==0 ) btreeLeaveAll(db);
 61501  61597   }
 61502  61598   
 61503  61599   #ifndef NDEBUG
 61504  61600   /*
 61505  61601   ** Return true if the current thread holds the database connection
 61506  61602   ** mutex and all required BtShared mutexes.
 61507  61603   **
................................................................................
 73869  73965       zVal = &pExpr->u.zToken[2];
 73870  73966       nVal = sqlite3Strlen30(zVal)-1;
 73871  73967       assert( zVal[nVal]=='\'' );
 73872  73968       sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2,
 73873  73969                            0, SQLITE_DYNAMIC);
 73874  73970     }
 73875  73971   #endif
 73876         -
 73877  73972   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
 73878  73973     else if( op==TK_FUNCTION && pCtx!=0 ){
 73879  73974       rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
 73880  73975     }
 73881  73976   #endif
        73977  +  else if( op==TK_TRUEFALSE ){
        73978  +     pVal = valueNew(db, pCtx);
        73979  +     pVal->flags = MEM_Int;
        73980  +     pVal->u.i = pExpr->u.zToken[4]==0;
        73981  +  }
 73882  73982   
 73883  73983     *ppVal = pVal;
 73884  73984     return rc;
 73885  73985   
 73886  73986   no_mem:
 73887  73987   #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
 73888  73988     if( pCtx==0 || pCtx->pParse->nErr==0 )
................................................................................
 74622  74722   SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){
 74623  74723     Parse *p = v->pParse;
 74624  74724     int j = ADDR(x);
 74625  74725     assert( v->magic==VDBE_MAGIC_INIT );
 74626  74726     assert( j<p->nLabel );
 74627  74727     assert( j>=0 );
 74628  74728     if( p->aLabel ){
        74729  +#ifdef SQLITE_DEBUG
        74730  +    if( p->db->flags & SQLITE_VdbeAddopTrace ){
        74731  +      printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
        74732  +    }
        74733  +#endif
        74734  +    assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
 74629  74735       p->aLabel[j] = v->nOp;
 74630  74736     }
 74631  74737   }
 74632  74738   
        74739  +#ifdef SQLITE_COVERAGE_TEST
        74740  +/*
        74741  +** Return TRUE if and only if the label x has already been resolved.
        74742  +** Return FALSE (zero) if label x is still unresolved.
        74743  +**
        74744  +** This routine is only used inside of testcase() macros, and so it
        74745  +** only exists when measuring test coverage.
        74746  +*/
        74747  +SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe *v, int x){
        74748  +  return v->pParse->aLabel && v->pParse->aLabel[ADDR(x)]>=0;
        74749  +}
        74750  +#endif /* SQLITE_COVERAGE_TEST */
        74751  +
 74633  74752   /*
 74634  74753   ** Mark the VDBE as one that can only be run one time.
 74635  74754   */
 74636  74755   SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){
 74637  74756     p->runOnlyOnce = 1;
 74638  74757   }
 74639  74758   
................................................................................
 75856  75975   ** running the code, it invokes the callback once for each instruction.
 75857  75976   ** This feature is used to implement "EXPLAIN".
 75858  75977   **
 75859  75978   ** When p->explain==1, each instruction is listed.  When
 75860  75979   ** p->explain==2, only OP_Explain instructions are listed and these
 75861  75980   ** are shown in a different format.  p->explain==2 is used to implement
 75862  75981   ** EXPLAIN QUERY PLAN.
        75982  +** 2018-04-24:  In p->explain==2 mode, the OP_Init opcodes of triggers
        75983  +** are also shown, so that the boundaries between the main program and
        75984  +** each trigger are clear.
 75863  75985   **
 75864  75986   ** When p->explain==1, first the main program is listed, then each of
 75865  75987   ** the trigger subprograms are listed one by one.
 75866  75988   */
 75867  75989   SQLITE_PRIVATE int sqlite3VdbeList(
 75868  75990     Vdbe *p                   /* The VDBE */
 75869  75991   ){
................................................................................
 75918  76040         apSub = (SubProgram **)pSub->z;
 75919  76041       }
 75920  76042       for(i=0; i<nSub; i++){
 75921  76043         nRow += apSub[i]->nOp;
 75922  76044       }
 75923  76045     }
 75924  76046   
 75925         -  do{
        76047  +  while(1){  /* Loop exits via break */
 75926  76048       i = p->pc++;
 75927  76049       if( i>=nRow ){
 75928  76050         p->rc = SQLITE_OK;
 75929  76051         rc = SQLITE_DONE;
 75930  76052         break;
 75931  76053       }
 75932  76054       if( i<p->nOp ){
................................................................................
 75964  76086           apSub = (SubProgram **)pSub->z;
 75965  76087           apSub[nSub++] = pOp->p4.pProgram;
 75966  76088           pSub->flags |= MEM_Blob;
 75967  76089           pSub->n = nSub*sizeof(SubProgram*);
 75968  76090           nRow += pOp->p4.pProgram->nOp;
 75969  76091         }
 75970  76092       }
 75971         -  }while( p->explain==2 && pOp->opcode!=OP_Explain );
        76093  +    if( p->explain<2 ) break;
        76094  +    if( pOp->opcode==OP_Explain ) break;
        76095  +    if( pOp->opcode==OP_Init && p->pc>1 ) break;
        76096  +  }
 75972  76097   
 75973  76098     if( rc==SQLITE_OK ){
 75974  76099       if( db->u1.isInterrupted ){
 75975  76100         p->rc = SQLITE_INTERRUPT;
 75976  76101         rc = SQLITE_ERROR;
 75977  76102         sqlite3VdbeError(p, sqlite3ErrStr(p->rc));
 75978  76103       }else{
................................................................................
 92642  92767     int cntTab = 0;                   /* Number of matching table names */
 92643  92768     int nSubquery = 0;                /* How many levels of subquery */
 92644  92769     sqlite3 *db = pParse->db;         /* The database connection */
 92645  92770     struct SrcList_item *pItem;       /* Use for looping over pSrcList items */
 92646  92771     struct SrcList_item *pMatch = 0;  /* The matching pSrcList item */
 92647  92772     NameContext *pTopNC = pNC;        /* First namecontext in the list */
 92648  92773     Schema *pSchema = 0;              /* Schema of the expression */
 92649         -  int isTrigger = 0;                /* True if resolved to a trigger column */
        92774  +  int eNewExprOp = TK_COLUMN;       /* New value for pExpr->op on success */
 92650  92775     Table *pTab = 0;                  /* Table hold the row */
 92651  92776     Column *pCol;                     /* A column of pTab */
 92652  92777   
 92653  92778     assert( pNC );     /* the name context cannot be NULL. */
 92654  92779     assert( zCol );    /* The Z in X.Y.Z cannot be NULL */
 92655  92780     assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
 92656  92781   
................................................................................
 92747  92872           if( (pMatch->fg.jointype & JT_LEFT)!=0 ){
 92748  92873             ExprSetProperty(pExpr, EP_CanBeNull);
 92749  92874           }
 92750  92875           pSchema = pExpr->pTab->pSchema;
 92751  92876         }
 92752  92877       } /* if( pSrcList ) */
 92753  92878   
 92754         -#ifndef SQLITE_OMIT_TRIGGER
        92879  +#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
 92755  92880       /* If we have not already resolved the name, then maybe 
 92756         -    ** it is a new.* or old.* trigger argument reference
        92881  +    ** it is a new.* or old.* trigger argument reference.  Or
        92882  +    ** maybe it is an excluded.* from an upsert.
 92757  92883       */
 92758         -    if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){
 92759         -      int op = pParse->eTriggerOp;
 92760         -      assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
 92761         -      if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
 92762         -        pExpr->iTable = 1;
 92763         -        pTab = pParse->pTriggerTab;
 92764         -      }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
 92765         -        pExpr->iTable = 0;
 92766         -        pTab = pParse->pTriggerTab;
 92767         -      }else{
 92768         -        pTab = 0;
        92884  +    if( zDb==0 && zTab!=0 && cntTab==0 ){
        92885  +      pTab = 0;
        92886  +#ifndef SQLITE_OMIT_TRIGGER
        92887  +      if( pParse->pTriggerTab!=0 ){
        92888  +        int op = pParse->eTriggerOp;
        92889  +        assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
        92890  +        if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
        92891  +          pExpr->iTable = 1;
        92892  +          pTab = pParse->pTriggerTab;
        92893  +        }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
        92894  +          pExpr->iTable = 0;
        92895  +          pTab = pParse->pTriggerTab;
        92896  +        }
 92769  92897         }
        92898  +#endif /* SQLITE_OMIT_TRIGGER */
        92899  +#ifndef SQLITE_OMIT_UPSERT
        92900  +      if( (pNC->ncFlags & NC_UUpsert)!=0 ){
        92901  +        Upsert *pUpsert = pNC->uNC.pUpsert;
        92902  +        if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){
        92903  +          pTab = pUpsert->pUpsertSrc->a[0].pTab;
        92904  +          pExpr->iTable = 2;
        92905  +        }
        92906  +      }
        92907  +#endif /* SQLITE_OMIT_UPSERT */
 92770  92908   
 92771  92909         if( pTab ){ 
 92772  92910           int iCol;
 92773  92911           pSchema = pTab->pSchema;
 92774  92912           cntTab++;
 92775  92913           for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){
 92776  92914             if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
................................................................................
 92782  92920           }
 92783  92921           if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
 92784  92922             /* IMP: R-51414-32910 */
 92785  92923             iCol = -1;
 92786  92924           }
 92787  92925           if( iCol<pTab->nCol ){
 92788  92926             cnt++;
 92789         -          if( iCol<0 ){
 92790         -            pExpr->affinity = SQLITE_AFF_INTEGER;
 92791         -          }else if( pExpr->iTable==0 ){
 92792         -            testcase( iCol==31 );
 92793         -            testcase( iCol==32 );
 92794         -            pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
 92795         -          }else{
 92796         -            testcase( iCol==31 );
 92797         -            testcase( iCol==32 );
 92798         -            pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
 92799         -          }
 92800         -          pExpr->iColumn = (i16)iCol;
 92801         -          pExpr->pTab = pTab;
 92802         -          isTrigger = 1;
 92803         -        }
 92804         -      }
 92805         -    }
 92806         -#endif /* !defined(SQLITE_OMIT_TRIGGER) */
        92927  +#ifndef SQLITE_OMIT_UPSERT
        92928  +          if( pExpr->iTable==2 ){
        92929  +            testcase( iCol==(-1) );
        92930  +            pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
        92931  +            eNewExprOp = TK_REGISTER;
        92932  +          }else
        92933  +#endif /* SQLITE_OMIT_UPSERT */
        92934  +          {
        92935  +#ifndef SQLITE_OMIT_TRIGGER
        92936  +            if( iCol<0 ){
        92937  +              pExpr->affinity = SQLITE_AFF_INTEGER;
        92938  +            }else if( pExpr->iTable==0 ){
        92939  +              testcase( iCol==31 );
        92940  +              testcase( iCol==32 );
        92941  +              pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
        92942  +            }else{
        92943  +              testcase( iCol==31 );
        92944  +              testcase( iCol==32 );
        92945  +              pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
        92946  +            }
        92947  +            pExpr->pTab = pTab;
        92948  +            pExpr->iColumn = (i16)iCol;
        92949  +            eNewExprOp = TK_TRIGGER;
        92950  +#endif /* SQLITE_OMIT_TRIGGER */
        92951  +          }
        92952  +        }
        92953  +      }
        92954  +    }
        92955  +#endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */
 92807  92956   
 92808  92957       /*
 92809  92958       ** Perhaps the name is a reference to the ROWID
 92810  92959       */
 92811  92960       if( cnt==0
 92812  92961        && cntTab==1
 92813  92962        && pMatch
................................................................................
 92834  92983       **
 92835  92984       ** The ability to use an output result-set column in the WHERE, GROUP BY,
 92836  92985       ** or HAVING clauses, or as part of a larger expression in the ORDER BY
 92837  92986       ** clause is not standard SQL.  This is a (goofy) SQLite extension, that
 92838  92987       ** is supported for backwards compatibility only. Hence, we issue a warning
 92839  92988       ** on sqlite3_log() whenever the capability is used.
 92840  92989       */
 92841         -    if( (pEList = pNC->pEList)!=0
 92842         -     && zTab==0
        92990  +    if( (pNC->ncFlags & NC_UEList)!=0
 92843  92991        && cnt==0
        92992  +     && zTab==0
 92844  92993       ){
        92994  +      pEList = pNC->uNC.pEList;
        92995  +      assert( pEList!=0 );
 92845  92996         for(j=0; j<pEList->nExpr; j++){
 92846  92997           char *zAs = pEList->a[j].zName;
 92847  92998           if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){
 92848  92999             Expr *pOrig;
 92849  93000             assert( pExpr->pLeft==0 && pExpr->pRight==0 );
 92850  93001             assert( pExpr->x.pList==0 );
 92851  93002             assert( pExpr->x.pSelect==0 );
................................................................................
 92934  93085   
 92935  93086     /* Clean up and return
 92936  93087     */
 92937  93088     sqlite3ExprDelete(db, pExpr->pLeft);
 92938  93089     pExpr->pLeft = 0;
 92939  93090     sqlite3ExprDelete(db, pExpr->pRight);
 92940  93091     pExpr->pRight = 0;
 92941         -  pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
        93092  +  pExpr->op = eNewExprOp;
 92942  93093     ExprSetProperty(pExpr, EP_Leaf);
 92943  93094   lookupname_end:
 92944  93095     if( cnt==1 ){
 92945  93096       assert( pNC!=0 );
 92946  93097       if( !ExprHasProperty(pExpr, EP_Alias) ){
 92947  93098         sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList);
 92948  93099       }
................................................................................
 93366  93517     pEList = pSelect->pEList;
 93367  93518   
 93368  93519     /* Resolve all names in the ORDER BY term expression
 93369  93520     */
 93370  93521     memset(&nc, 0, sizeof(nc));
 93371  93522     nc.pParse = pParse;
 93372  93523     nc.pSrcList = pSelect->pSrc;
 93373         -  nc.pEList = pEList;
 93374         -  nc.ncFlags = NC_AllowAgg;
        93524  +  nc.uNC.pEList = pEList;
        93525  +  nc.ncFlags = NC_AllowAgg|NC_UEList;
 93375  93526     nc.nErr = 0;
 93376  93527     db = pParse->db;
 93377  93528     savedSuppErr = db->suppressErr;
 93378  93529     db->suppressErr = 1;
 93379  93530     rc = sqlite3ResolveExprNames(&nc, pE);
 93380  93531     db->suppressErr = savedSuppErr;
 93381  93532     if( rc ) return 0;
................................................................................
 93750  93901       ** other expressions in the SELECT statement. This is so that
 93751  93902       ** expressions in the WHERE clause (etc.) can refer to expressions by
 93752  93903       ** aliases in the result set.
 93753  93904       **
 93754  93905       ** Minor point: If this is the case, then the expression will be
 93755  93906       ** re-evaluated for each reference to it.
 93756  93907       */
 93757         -    sNC.pEList = p->pEList;
        93908  +    assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 );
        93909  +    sNC.uNC.pEList = p->pEList;
        93910  +    sNC.ncFlags |= NC_UEList;
 93758  93911       if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
 93759  93912       if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort;
 93760  93913   
 93761  93914       /* Resolve names in table-valued-function arguments */
 93762  93915       for(i=0; i<p->pSrc->nSrc; i++){
 93763  93916         struct SrcList_item *pItem = &p->pSrc->a[i];
 93764  93917         if( pItem->fg.isTabFunc
................................................................................
 93983  94136   ** Any errors cause an error message to be set in pParse.
 93984  94137   */
 93985  94138   SQLITE_PRIVATE void sqlite3ResolveSelfReference(
 93986  94139     Parse *pParse,      /* Parsing context */
 93987  94140     Table *pTab,        /* The table being referenced */
 93988  94141     int type,           /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */
 93989  94142     Expr *pExpr,        /* Expression to resolve.  May be NULL. */
 93990         -  ExprList *pList     /* Expression list to resolve.  May be NUL. */
        94143  +  ExprList *pList     /* Expression list to resolve.  May be NULL. */
 93991  94144   ){
 93992  94145     SrcList sSrc;                   /* Fake SrcList for pParse->pNewTable */
 93993  94146     NameContext sNC;                /* Name context for pParse->pNewTable */
 93994  94147   
 93995  94148     assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );
 93996  94149     memset(&sNC, 0, sizeof(sNC));
 93997  94150     memset(&sSrc, 0, sizeof(sSrc));
................................................................................
 95369  95522         }
 95370  95523       }
 95371  95524       pItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
 95372  95525       pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan);
 95373  95526       pItem->sortOrder = pOldItem->sortOrder;
 95374  95527       pItem->done = 0;
 95375  95528       pItem->bSpanIsTab = pOldItem->bSpanIsTab;
        95529  +    pItem->bSorterRef = pOldItem->bSorterRef;
 95376  95530       pItem->u = pOldItem->u;
 95377  95531     }
 95378  95532     return pNew;
 95379  95533   }
 95380  95534   
 95381  95535   /*
 95382  95536   ** If cursors, triggers, views and subqueries are all omitted from
................................................................................
 95831  95985         testcase( pExpr->op==TK_AGG_FUNCTION );
 95832  95986         testcase( pExpr->op==TK_AGG_COLUMN );
 95833  95987         if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
 95834  95988           return WRC_Continue;
 95835  95989         }
 95836  95990         /* Fall through */
 95837  95991       case TK_IF_NULL_ROW:
        95992  +    case TK_REGISTER:
        95993  +      testcase( pExpr->op==TK_REGISTER );
 95838  95994         testcase( pExpr->op==TK_IF_NULL_ROW );
 95839  95995         pWalker->eCode = 0;
 95840  95996         return WRC_Abort;
 95841  95997       case TK_VARIABLE:
 95842  95998         if( pWalker->eCode==5 ){
 95843  95999           /* Silently convert bound parameters that appear inside of CREATE
 95844  96000           ** statements into a NULL when parsing the CREATE statement text out
................................................................................
 95848  96004           /* A bound parameter in a CREATE statement that originates from
 95849  96005           ** sqlite3_prepare() causes an error */
 95850  96006           pWalker->eCode = 0;
 95851  96007           return WRC_Abort;
 95852  96008         }
 95853  96009         /* Fall through */
 95854  96010       default:
 95855         -      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail will disallow */
 95856         -      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail will disallow */
        96011  +      testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */
        96012  +      testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */
 95857  96013         return WRC_Continue;
 95858  96014     }
 95859  96015   }
 95860  96016   static int exprIsConst(Expr *p, int initFlag, int iCur){
 95861  96017     Walker w;
 95862  96018     w.eCode = initFlag;
 95863  96019     w.xExprCallback = exprNodeIsConstant;
................................................................................
 96612  96768     ** If all of the above are false, then we can run this code just once
 96613  96769     ** save the results, and reuse the same result on subsequent invocations.
 96614  96770     */
 96615  96771     if( !ExprHasProperty(pExpr, EP_VarSelect) ){
 96616  96772       jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
 96617  96773     }
 96618  96774   
 96619         -#ifndef SQLITE_OMIT_EXPLAIN
 96620         -  if( pParse->explain==2 ){
 96621         -    char *zMsg = sqlite3MPrintf(pParse->db, "EXECUTE %s%s SUBQUERY %d",
 96622         -        jmpIfDynamic>=0?"":"CORRELATED ",
 96623         -        pExpr->op==TK_IN?"LIST":"SCALAR",
 96624         -        pParse->iNextSelectId
 96625         -    );
 96626         -    sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg, P4_DYNAMIC);
 96627         -  }
 96628         -#endif
 96629         -
 96630  96775     switch( pExpr->op ){
 96631  96776       case TK_IN: {
 96632  96777         int addr;                   /* Address of OP_OpenEphemeral instruction */
 96633  96778         Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
 96634  96779         KeyInfo *pKeyInfo = 0;      /* Key information */
 96635  96780         int nVal;                   /* Size of vector pLeft */
 96636  96781         
................................................................................
 96659  96804           /* Case 1:     expr IN (SELECT ...)
 96660  96805           **
 96661  96806           ** Generate code to write the results of the select into the temporary
 96662  96807           ** table allocated and opened above.
 96663  96808           */
 96664  96809           Select *pSelect = pExpr->x.pSelect;
 96665  96810           ExprList *pEList = pSelect->pEList;
        96811  +
        96812  +#ifndef SQLITE_OMIT_EXPLAIN
        96813  +        if( pParse->explain==2 ){
        96814  +          char *zMsg = sqlite3MPrintf(pParse->db, "EXECUTE %sLIST SUBQUERY %d",
        96815  +            jmpIfDynamic>=0?"":"CORRELATED ",
        96816  +            pParse->iNextSelectId
        96817  +          );
        96818  +          sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg,
        96819  +                            P4_DYNAMIC);
        96820  +        }
        96821  +#endif
 96666  96822   
 96667  96823           assert( !isRowid );
 96668  96824           /* If the LHS and RHS of the IN operator do not match, that
 96669  96825           ** error will have been caught long before we reach this point. */
 96670  96826           if( ALWAYS(pEList->nExpr==nVal) ){
 96671  96827             SelectDest dest;
 96672  96828             int i;
................................................................................
 96701  96857           ** a column, use numeric affinity.
 96702  96858           */
 96703  96859           char affinity;            /* Affinity of the LHS of the IN */
 96704  96860           int i;
 96705  96861           ExprList *pList = pExpr->x.pList;
 96706  96862           struct ExprList_item *pItem;
 96707  96863           int r1, r2, r3;
 96708         -
 96709  96864           affinity = sqlite3ExprAffinity(pLeft);
 96710  96865           if( !affinity ){
 96711  96866             affinity = SQLITE_AFF_BLOB;
 96712  96867           }
 96713  96868           if( pKeyInfo ){
 96714  96869             assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
 96715  96870             pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
................................................................................
 96780  96935         int nReg;                             /* Registers to allocate */
 96781  96936         Expr *pLimit;                         /* New limit expression */
 96782  96937   
 96783  96938         testcase( pExpr->op==TK_EXISTS );
 96784  96939         testcase( pExpr->op==TK_SELECT );
 96785  96940         assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
 96786  96941         assert( ExprHasProperty(pExpr, EP_xIsSelect) );
        96942  +
        96943  +#ifndef SQLITE_OMIT_EXPLAIN
        96944  +      if( pParse->explain==2 ){
        96945  +        char *zMsg = sqlite3MPrintf(pParse->db, "EXECUTE %sSCALAR SUBQUERY %d",
        96946  +            jmpIfDynamic>=0?"":"CORRELATED ",
        96947  +            pParse->iNextSelectId
        96948  +        );
        96949  +        sqlite3VdbeAddOp4(v, OP_Explain, pParse->iSelectId, 0, 0, zMsg,
        96950  +                          P4_DYNAMIC);
        96951  +      }
        96952  +#endif
 96787  96953   
 96788  96954         pSel = pExpr->x.pSelect;
 96789  96955         nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
 96790  96956         sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
 96791  96957         pParse->nMem += nReg;
 96792  96958         if( pExpr->op==TK_SELECT ){
 96793  96959           dest.eDest = SRT_Mem;
................................................................................
 98377  98543     assert( pList!=0 );
 98378  98544     assert( target>0 );
 98379  98545     assert( pParse->pVdbe!=0 );  /* Never gets this far otherwise */
 98380  98546     n = pList->nExpr;
 98381  98547     if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR;
 98382  98548     for(pItem=pList->a, i=0; i<n; i++, pItem++){
 98383  98549       Expr *pExpr = pItem->pExpr;
        98550  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
        98551  +    if( pItem->bSorterRef ){
        98552  +      i--;
        98553  +      n--;
        98554  +    }else
        98555  +#endif
 98384  98556       if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){
 98385  98557         if( flags & SQLITE_ECEL_OMITREF ){
 98386  98558           i--;
 98387  98559           n--;
 98388  98560         }else{
 98389  98561           sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i);
 98390  98562         }
................................................................................
 98905  99077         return 1;
 98906  99078       }
 98907  99079       return 2;
 98908  99080     }
 98909  99081     if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){
 98910  99082       if( pA->op==TK_FUNCTION ){
 98911  99083         if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
        99084  +    }else if( pA->op==TK_COLLATE ){
        99085  +      if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
 98912  99086       }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
 98913         -      return pA->op==TK_COLLATE ? 1 : 2;
        99087  +      return 2;
 98914  99088       }
 98915  99089     }
 98916  99090     if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
 98917  99091     if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
 98918  99092       if( combinedFlags & EP_xIsSelect ) return 2;
 98919  99093       if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
 98920  99094       if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
 98921  99095       if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
 98922         -    if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
        99096  +    assert( (combinedFlags & EP_Reduced)==0 );
        99097  +    if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
 98923  99098         if( pA->iColumn!=pB->iColumn ) return 2;
 98924  99099         if( pA->iTable!=pB->iTable 
 98925  99100          && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
 98926  99101       }
 98927  99102     }
 98928  99103     return 0;
 98929  99104   }
................................................................................
 99261  99436   ** for additional information.
 99262  99437   */
 99263  99438   static int analyzeAggregate(Walker *pWalker, Expr *pExpr){
 99264  99439     int i;
 99265  99440     NameContext *pNC = pWalker->u.pNC;
 99266  99441     Parse *pParse = pNC->pParse;
 99267  99442     SrcList *pSrcList = pNC->pSrcList;
 99268         -  AggInfo *pAggInfo = pNC->pAggInfo;
        99443  +  AggInfo *pAggInfo = pNC->uNC.pAggInfo;
 99269  99444   
        99445  +  assert( pNC->ncFlags & NC_UAggInfo );
 99270  99446     switch( pExpr->op ){
 99271  99447       case TK_AGG_COLUMN:
 99272  99448       case TK_COLUMN: {
 99273  99449         testcase( pExpr->op==TK_AGG_COLUMN );
 99274  99450         testcase( pExpr->op==TK_COLUMN );
 99275  99451         /* Check to see if the column is in one of the tables in the FROM
 99276  99452         ** clause of the aggregate query */
................................................................................
102432 102608       }
102433 102609       assert( pVfs );
102434 102610       flags |= SQLITE_OPEN_MAIN_DB;
102435 102611       rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
102436 102612       sqlite3_free( zPath );
102437 102613       db->nDb++;
102438 102614     }
102439         -  db->skipBtreeMutex = 0;
       102615  +  db->noSharedCache = 0;
102440 102616     if( rc==SQLITE_CONSTRAINT ){
102441 102617       rc = SQLITE_ERROR;
102442 102618       zErrDyn = sqlite3MPrintf(db, "database is already attached");
102443 102619     }else if( rc==SQLITE_OK ){
102444 102620       Pager *pPager;
102445 102621       pNew->pSchema = sqlite3SchemaGet(db, pNew->pBt);
102446 102622       if( !pNew->pSchema ){
................................................................................
102504 102680     ** If this fails, or if opening the file failed, then close the file and 
102505 102681     ** remove the entry from the db->aDb[] array. i.e. put everything back the
102506 102682     ** way we found it.
102507 102683     */
102508 102684     if( rc==SQLITE_OK ){
102509 102685       sqlite3BtreeEnterAll(db);
102510 102686       db->init.iDb = 0;
       102687  +    db->mDbFlags &= ~(DBFLAG_SchemaKnownOk);
102511 102688       rc = sqlite3Init(db, &zErrDyn);
102512 102689       sqlite3BtreeLeaveAll(db);
102513 102690       assert( zErrDyn==0 || rc!=SQLITE_OK );
102514 102691     }
102515 102692   #ifdef SQLITE_USER_AUTHENTICATION
102516 102693     if( rc==SQLITE_OK ){
102517 102694       u8 newAuth = 0;
................................................................................
102776 102953         pItem->zDatabase = 0;
102777 102954         pItem->pSchema = pFix->pSchema;
102778 102955       }
102779 102956   #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
102780 102957       if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1;
102781 102958       if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1;
102782 102959   #endif
       102960  +    if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){
       102961  +      return 1;
       102962  +    }
102783 102963     }
102784 102964     return 0;
102785 102965   }
102786 102966   #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER)
102787 102967   SQLITE_PRIVATE int sqlite3FixSelect(
102788 102968     DbFixer *pFix,       /* Context of the fixation */
102789 102969     Select *pSelect      /* The SELECT statement to be fixed to one database */
................................................................................
102875 103055       }
102876 103056       if( sqlite3FixExpr(pFix, pStep->pWhere) ){
102877 103057         return 1;
102878 103058       }
102879 103059       if( sqlite3FixExprList(pFix, pStep->pExprList) ){
102880 103060         return 1;
102881 103061       }
       103062  +#ifndef SQLITE_OMIT_UPSERT
       103063  +    if( pStep->pUpsert ){
       103064  +      Upsert *pUp = pStep->pUpsert;
       103065  +      if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
       103066  +       || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
       103067  +       || sqlite3FixExprList(pFix, pUp->pUpsertSet)
       103068  +       || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
       103069  +      ){
       103070  +        return 1;
       103071  +      }
       103072  +    }
       103073  +#endif
102882 103074       pStep = pStep->pNext;
102883 103075     }
102884 103076     return 0;
102885 103077   }
102886 103078   #endif
102887 103079   
102888 103080   /************** End of attach.c **********************************************/
................................................................................
103502 103694   SQLITE_PRIVATE Table *sqlite3LocateTable(
103503 103695     Parse *pParse,         /* context in which to report errors */
103504 103696     u32 flags,             /* LOCATE_VIEW or LOCATE_NOERR */
103505 103697     const char *zName,     /* Name of the table we are looking for */
103506 103698     const char *zDbase     /* Name of the database.  Might be NULL */
103507 103699   ){
103508 103700     Table *p;
       103701  +  sqlite3 *db = pParse->db;
103509 103702   
103510 103703     /* Read the database schema. If an error occurs, leave an error message
103511 103704     ** and code in pParse and return NULL. */
103512         -  if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
       103705  +  if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 
       103706  +   && SQLITE_OK!=sqlite3ReadSchema(pParse)
       103707  +  ){
103513 103708       return 0;
103514 103709     }
103515 103710   
103516         -  p = sqlite3FindTable(pParse->db, zName, zDbase);
       103711  +  p = sqlite3FindTable(db, zName, zDbase);
103517 103712     if( p==0 ){
103518 103713       const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
103519 103714   #ifndef SQLITE_OMIT_VIRTUALTABLE
103520         -    if( sqlite3FindDbName(pParse->db, zDbase)<1 ){
       103715  +    if( sqlite3FindDbName(db, zDbase)<1 ){
103521 103716         /* If zName is the not the name of a table in the schema created using
103522 103717         ** CREATE, then check to see if it is the name of an virtual table that
103523 103718         ** can be an eponymous virtual table. */
103524         -      Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName);
       103719  +      Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
103525 103720         if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
103526         -        pMod = sqlite3PragmaVtabRegister(pParse->db, zName);
       103721  +        pMod = sqlite3PragmaVtabRegister(db, zName);
103527 103722         }
103528 103723         if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
103529 103724           return pMod->pEpoTab;
103530 103725         }
103531 103726       }
103532 103727   #endif
103533 103728       if( (flags & LOCATE_NOERR)==0 ){
................................................................................
103684 103879     int i;
103685 103880     assert( iDb<db->nDb );
103686 103881   
103687 103882     if( iDb>=0 ){
103688 103883       assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
103689 103884       DbSetProperty(db, iDb, DB_ResetWanted);
103690 103885       DbSetProperty(db, 1, DB_ResetWanted);
       103886  +    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
103691 103887     }
103692 103888   
103693 103889     if( db->nSchemaLock==0 ){
103694 103890       for(i=0; i<db->nDb; i++){
103695 103891         if( DbHasProperty(db, i, DB_ResetWanted) ){
103696 103892           sqlite3SchemaClear(db->aDb[i].pSchema);
103697 103893         }
................................................................................
103709 103905     assert( db->nSchemaLock==0 );
103710 103906     for(i=0; i<db->nDb; i++){
103711 103907       Db *pDb = &db->aDb[i];
103712 103908       if( pDb->pSchema ){
103713 103909         sqlite3SchemaClear(pDb->pSchema);
103714 103910       }
103715 103911     }
103716         -  db->mDbFlags &= ~DBFLAG_SchemaChange;
       103912  +  db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);
103717 103913     sqlite3VtabUnlockList(db);
103718 103914     sqlite3BtreeLeaveAll(db);
103719 103915     sqlite3CollapseDatabaseArray(db);
103720 103916   }
103721 103917   
103722 103918   /*
103723 103919   ** This routine is called when a commit occurs.
................................................................................
104254 104450     pCol = &p->aCol[p->nCol];
104255 104451     memset(pCol, 0, sizeof(p->aCol[0]));
104256 104452     pCol->zName = z;
104257 104453     sqlite3ColumnPropertiesFromName(p, pCol);
104258 104454    
104259 104455     if( pType->n==0 ){
104260 104456       /* If there is no type specified, columns have the default affinity
104261         -    ** 'BLOB'. */
       104457  +    ** 'BLOB' with a default size of 4 bytes. */
104262 104458       pCol->affinity = SQLITE_AFF_BLOB;
104263 104459       pCol->szEst = 1;
       104460  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       104461  +    if( 4>=sqlite3GlobalConfig.szSorterRef ){
       104462  +      pCol->colFlags |= COLFLAG_SORTERREF;
       104463  +    }
       104464  +#endif
104264 104465     }else{
104265 104466       zType = z + sqlite3Strlen30(z) + 1;
104266 104467       memcpy(zType, pType->z, pType->n);
104267 104468       zType[pType->n] = 0;
104268 104469       sqlite3Dequote(zType);
104269         -    pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
       104470  +    pCol->affinity = sqlite3AffinityType(zType, pCol);
104270 104471       pCol->colFlags |= COLFLAG_HASTYPE;
104271 104472     }
104272 104473     p->nCol++;
104273 104474     pParse->constraintName.n = 0;
104274 104475   }
104275 104476   
104276 104477   /*
................................................................................
104322 104523   ** 'REAL'        | SQLITE_AFF_REAL
104323 104524   ** 'FLOA'        | SQLITE_AFF_REAL
104324 104525   ** 'DOUB'        | SQLITE_AFF_REAL
104325 104526   **
104326 104527   ** If none of the substrings in the above table are found,
104327 104528   ** SQLITE_AFF_NUMERIC is returned.
104328 104529   */
104329         -SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, u8 *pszEst){
       104530  +SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){
104330 104531     u32 h = 0;
104331 104532     char aff = SQLITE_AFF_NUMERIC;
104332 104533     const char *zChar = 0;
104333 104534   
104334 104535     assert( zIn!=0 );
104335 104536     while( zIn[0] ){
104336 104537       h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];
................................................................................
104359 104560   #endif
104360 104561       }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){    /* INT */
104361 104562         aff = SQLITE_AFF_INTEGER;
104362 104563         break;
104363 104564       }
104364 104565     }
104365 104566   
104366         -  /* If pszEst is not NULL, store an estimate of the field size.  The
       104567  +  /* If pCol is not NULL, store an estimate of the field size.  The
104367 104568     ** estimate is scaled so that the size of an integer is 1.  */
104368         -  if( pszEst ){
104369         -    *pszEst = 1;   /* default size is approx 4 bytes */
       104569  +  if( pCol ){
       104570  +    int v = 0;   /* default size is approx 4 bytes */
104370 104571       if( aff<SQLITE_AFF_NUMERIC ){
104371 104572         if( zChar ){
104372 104573           while( zChar[0] ){
104373 104574             if( sqlite3Isdigit(zChar[0]) ){
104374         -            int v = 0;
       104575  +            /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
104375 104576               sqlite3GetInt32(zChar, &v);
104376         -            v = v/4 + 1;
104377         -            if( v>255 ) v = 255;
104378         -            *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
104379 104577               break;
104380 104578             }
104381 104579             zChar++;
104382 104580           }
104383 104581         }else{
104384         -        *pszEst = 5;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/
       104582  +        v = 16;   /* BLOB, TEXT, CLOB -> r=5  (approx 20 bytes)*/
104385 104583         }
104386 104584       }
       104585  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       104586  +    if( v>=sqlite3GlobalConfig.szSorterRef ){
       104587  +      pCol->colFlags |= COLFLAG_SORTERREF;
       104588  +    }
       104589  +#endif
       104590  +    v = v/4 + 1;
       104591  +    if( v>255 ) v = 255;
       104592  +    pCol->szEst = v;
104387 104593     }
104388 104594     return aff;
104389 104595   }
104390 104596   
104391 104597   /*
104392 104598   ** The expression is the default value for the most recently added column
104393 104599   ** of the table currently under construction.
................................................................................
108364 108570     int iDataCur = 0;      /* VDBE cursor for the canonical data source */
108365 108571     int iIdxCur = 0;       /* Cursor number of the first index */
108366 108572     int nIdx;              /* Number of indices */
108367 108573     sqlite3 *db;           /* Main database structure */
108368 108574     AuthContext sContext;  /* Authorization context */
108369 108575     NameContext sNC;       /* Name context to resolve expressions in */
108370 108576     int iDb;               /* Database number */
108371         -  int memCnt = -1;       /* Memory cell used for change counting */
       108577  +  int memCnt = 0;        /* Memory cell used for change counting */
108372 108578     int rcauth;            /* Value returned by authorization callback */
108373 108579     int eOnePass;          /* ONEPASS_OFF or _SINGLE or _MULTI */
108374 108580     int aiCurOnePass[2];   /* The write cursors opened by WHERE_ONEPASS */
108375 108581     u8 *aToOpen = 0;       /* Open cursor iTabCur+j if aToOpen[j] is true */
108376 108582     Index *pPk;            /* The PRIMARY KEY index on the table */
108377 108583     int iPk = 0;           /* First of nPk registers holding PRIMARY KEY value */
108378 108584     i16 nPk = 1;           /* Number of columns in the PRIMARY KEY */
................................................................................
108469 108675     /* Begin generating code.
108470 108676     */
108471 108677     v = sqlite3GetVdbe(pParse);
108472 108678     if( v==0 ){
108473 108679       goto delete_from_cleanup;
108474 108680     }
108475 108681     if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
108476         -  sqlite3BeginWriteOperation(pParse, 1, iDb);
       108682  +  sqlite3BeginWriteOperation(pParse, bComplex, iDb);
108477 108683   
108478 108684     /* If we are trying to delete from a view, realize that view into
108479 108685     ** an ephemeral table.
108480 108686     */
108481 108687   #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER)
108482 108688     if( isView ){
108483 108689       sqlite3MaterializeView(pParse, pTab, 
................................................................................
108497 108703     if( sqlite3ResolveExprNames(&sNC, pWhere) ){
108498 108704       goto delete_from_cleanup;
108499 108705     }
108500 108706   
108501 108707     /* Initialize the counter of the number of rows deleted, if
108502 108708     ** we are counting rows.
108503 108709     */
108504         -  if( db->flags & SQLITE_CountRows ){
       108710  +  if( (db->flags & SQLITE_CountRows)!=0
       108711  +   && !pParse->nested
       108712  +   && !pParse->pTriggerTab
       108713  +  ){
108505 108714       memCnt = ++pParse->nMem;
108506 108715       sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);
108507 108716     }
108508 108717   
108509 108718   #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
108510 108719     /* Special case: A DELETE without a WHERE clause deletes everything.
108511 108720     ** It is easier just to erase the whole table. Prior to version 3.6.5,
................................................................................
108525 108734   #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
108526 108735      && db->xPreUpdateCallback==0
108527 108736   #endif
108528 108737     ){
108529 108738       assert( !isView );
108530 108739       sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);
108531 108740       if( HasRowid(pTab) ){
108532         -      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt,
       108741  +      sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt ? memCnt : -1,
108533 108742                           pTab->zName, P4_STATIC);
108534 108743       }
108535 108744       for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
108536 108745         assert( pIdx->pSchema==pTab->pSchema );
108537 108746         sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
108538 108747       }
108539 108748     }else
................................................................................
108570 108779       **  ONEPASS_MULTI:  One-pass approach - any number of rows may be deleted.
108571 108780       */
108572 108781       pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);
108573 108782       if( pWInfo==0 ) goto delete_from_cleanup;
108574 108783       eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
108575 108784       assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
108576 108785       assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF );
       108786  +    if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse);
108577 108787     
108578 108788       /* Keep track of the number of rows to be deleted */
108579         -    if( db->flags & SQLITE_CountRows ){
       108789  +    if( memCnt ){
108580 108790         sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
108581 108791       }
108582 108792     
108583 108793       /* Extract the rowid or primary key for the current row */
108584 108794       if( pPk ){
108585 108795         for(i=0; i<nPk; i++){
108586 108796           assert( pPk->aiColumn[i]>=0 );
................................................................................
108715 108925       sqlite3AutoincrementEnd(pParse);
108716 108926     }
108717 108927   
108718 108928     /* Return the number of rows that were deleted. If this routine is 
108719 108929     ** generating code because of a call to sqlite3NestedParse(), do not
108720 108930     ** invoke the callback function.
108721 108931     */
108722         -  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
       108932  +  if( memCnt ){
108723 108933       sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1);
108724 108934       sqlite3VdbeSetNumCols(v, 1);
108725 108935       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
108726 108936     }
108727 108937   
108728 108938   delete_from_cleanup:
108729 108939     sqlite3AuthContextPop(&sContext);
................................................................................
112897 113107   **      D: cleanup
112898 113108   */
112899 113109   SQLITE_PRIVATE void sqlite3Insert(
112900 113110     Parse *pParse,        /* Parser context */
112901 113111     SrcList *pTabList,    /* Name of table into which we are inserting */
112902 113112     Select *pSelect,      /* A SELECT statement to use as the data source */
112903 113113     IdList *pColumn,      /* Column names corresponding to IDLIST. */
112904         -  int onError           /* How to handle constraint errors */
       113114  +  int onError,          /* How to handle constraint errors */
       113115  +  Upsert *pUpsert       /* ON CONFLICT clauses for upsert, or NULL */
112905 113116   ){
112906 113117     sqlite3 *db;          /* The main database structure */
112907 113118     Table *pTab;          /* The table to insert into.  aka TABLE */
112908 113119     int i, j;             /* Loop counters */
112909 113120     Vdbe *v;              /* Generate code into this virtual machine */
112910 113121     Index *pIdx;          /* For looping over indices of the table */
112911 113122     int nColumn;          /* Number of columns in the data */
................................................................................
113192 113403     if( pColumn!=0 && nColumn!=pColumn->nId ){
113193 113404       sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);
113194 113405       goto insert_cleanup;
113195 113406     }
113196 113407       
113197 113408     /* Initialize the count of rows to be inserted
113198 113409     */
113199         -  if( db->flags & SQLITE_CountRows ){
       113410  +  if( (db->flags & SQLITE_CountRows)!=0
       113411  +   && !pParse->nested
       113412  +   && !pParse->pTriggerTab
       113413  +  ){
113200 113414       regRowCount = ++pParse->nMem;
113201 113415       sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
113202 113416     }
113203 113417   
113204 113418     /* If this is not a view, open the table and and all indices */
113205 113419     if( !isView ){
113206 113420       int nIdx;
................................................................................
113212 113426       }
113213 113427       for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){
113214 113428         assert( pIdx );
113215 113429         aRegIdx[i] = ++pParse->nMem;
113216 113430         pParse->nMem += pIdx->nColumn;
113217 113431       }
113218 113432     }
       113433  +#ifndef SQLITE_OMIT_UPSERT
       113434  +  if( pUpsert ){
       113435  +    pTabList->a[0].iCursor = iDataCur;
       113436  +    pUpsert->pUpsertSrc = pTabList;
       113437  +    pUpsert->regData = regData;
       113438  +    pUpsert->iDataCur = iDataCur;
       113439  +    pUpsert->iIdxCur = iIdxCur;
       113440  +    if( pUpsert->pUpsertTarget ){
       113441  +      sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);
       113442  +    }
       113443  +  }
       113444  +#endif
       113445  +
113219 113446   
113220 113447     /* This is the top of the main insertion loop */
113221 113448     if( useTempTable ){
113222 113449       /* This block codes the top of loop only.  The complete loop is the
113223 113450       ** following pseudocode (template 4):
113224 113451       **
113225 113452       **         rewind temp table, if empty goto D
................................................................................
113414 113641         sqlite3MayAbort(pParse);
113415 113642       }else
113416 113643   #endif
113417 113644       {
113418 113645         int isReplace;    /* Set to true if constraints may cause a replace */
113419 113646         int bUseSeek;     /* True to use OPFLAG_SEEKRESULT */
113420 113647         sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
113421         -          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0
       113648  +          regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert
113422 113649         );
113423 113650         sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0);
113424 113651   
113425 113652         /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE
113426 113653         ** constraints or (b) there are no triggers and this table is not a
113427 113654         ** parent table in a foreign key constraint. It is safe to set the
113428 113655         ** flag in the second case as if any REPLACE constraint is hit, an
................................................................................
113437 113664             regIns, aRegIdx, 0, appendFlag, bUseSeek
113438 113665         );
113439 113666       }
113440 113667     }
113441 113668   
113442 113669     /* Update the count of rows that are inserted
113443 113670     */
113444         -  if( (db->flags & SQLITE_CountRows)!=0 ){
       113671  +  if( regRowCount ){
113445 113672       sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
113446 113673     }
113447 113674   
113448 113675     if( pTrigger ){
113449 113676       /* Code AFTER triggers */
113450 113677       sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, 
113451 113678           pTab, regData-2-pTab->nCol, onError, endOfLoop);
................................................................................
113474 113701     }
113475 113702   
113476 113703     /*
113477 113704     ** Return the number of rows inserted. If this routine is 
113478 113705     ** generating code because of a call to sqlite3NestedParse(), do not
113479 113706     ** invoke the callback function.
113480 113707     */
113481         -  if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){
       113708  +  if( regRowCount ){
113482 113709       sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
113483 113710       sqlite3VdbeSetNumCols(v, 1);
113484 113711       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
113485 113712     }
113486 113713   
113487 113714   insert_cleanup:
113488 113715     sqlite3SrcListDelete(db, pTabList);
113489 113716     sqlite3ExprListDelete(db, pList);
       113717  +  sqlite3UpsertDelete(db, pUpsert);
113490 113718     sqlite3SelectDelete(db, pSelect);
113491 113719     sqlite3IdListDelete(db, pColumn);
113492 113720     sqlite3DbFree(db, aRegIdx);
113493 113721   }
113494 113722   
113495 113723   /* Make sure "isView" and other macros defined above are undefined. Otherwise
113496 113724   ** they may interfere with compilation of other functions in this file
................................................................................
113553 113781     }
113554 113782     testcase( w.eCode==0 );
113555 113783     testcase( w.eCode==CKCNSTRNT_COLUMN );
113556 113784     testcase( w.eCode==CKCNSTRNT_ROWID );
113557 113785     testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) );
113558 113786     return !w.eCode;
113559 113787   }
       113788  +
       113789  +/*
       113790  +** An instance of the ConstraintAddr object remembers the byte-code addresses
       113791  +** for sections of the constraint checks that deal with uniqueness constraints
       113792  +** on the rowid and on the upsert constraint.
       113793  +**
       113794  +** This information is passed into checkReorderConstraintChecks() to insert
       113795  +** some OP_Goto operations so that the rowid and upsert constraints occur
       113796  +** in the correct order relative to other constraints.
       113797  +*/
       113798  +typedef struct ConstraintAddr ConstraintAddr;
       113799  +struct ConstraintAddr {
       113800  +  int ipkTop;          /* Subroutine for rowid constraint check */
       113801  +  int upsertTop;       /* Label for upsert constraint check subroutine */
       113802  +  int upsertTop2;      /* Copy of upsertTop not cleared by the call */
       113803  +  int upsertBtm;       /* upsert constraint returns to this label */
       113804  +  int ipkBtm;          /* Return opcode rowid constraint check */
       113805  +};
       113806  +
       113807  +/*
       113808  +** Generate any OP_Goto operations needed to cause constraints to be
       113809  +** run that haven't already been run.
       113810  +*/
       113811  +static void reorderConstraintChecks(Vdbe *v, ConstraintAddr *p){
       113812  +  if( p->upsertTop ){
       113813  +    testcase( sqlite3VdbeLabelHasBeenResolved(v, p->upsertTop) );
       113814  +    sqlite3VdbeGoto(v, p->upsertTop);
       113815  +    VdbeComment((v, "call upsert subroutine"));
       113816  +    sqlite3VdbeResolveLabel(v, p->upsertBtm);
       113817  +    p->upsertTop = 0;
       113818  +  }
       113819  +  if( p->ipkTop ){
       113820  +    sqlite3VdbeGoto(v, p->ipkTop);
       113821  +    VdbeComment((v, "call rowid unique-check subroutine"));
       113822  +    sqlite3VdbeJumpHere(v, p->ipkBtm);
       113823  +    p->ipkTop = 0;
       113824  +  }
       113825  +}
113560 113826   
113561 113827   /*
113562 113828   ** Generate code to do constraint checks prior to an INSERT or an UPDATE
113563 113829   ** on table pTab.
113564 113830   **
113565 113831   ** The regNewData parameter is the first register in a range that contains
113566 113832   ** the data to be inserted or the data after the update.  There will be
................................................................................
113649 113915     int iIdxCur,         /* First index cursor */
113650 113916     int regNewData,      /* First register in a range holding values to insert */
113651 113917     int regOldData,      /* Previous content.  0 for INSERTs */
113652 113918     u8 pkChng,           /* Non-zero if the rowid or PRIMARY KEY changed */
113653 113919     u8 overrideError,    /* Override onError to this if not OE_Default */
113654 113920     int ignoreDest,      /* Jump to this label on an OE_Ignore resolution */
113655 113921     int *pbMayReplace,   /* OUT: Set to true if constraint may cause a replace */
113656         -  int *aiChng          /* column i is unchanged if aiChng[i]<0 */
       113922  +  int *aiChng,         /* column i is unchanged if aiChng[i]<0 */
       113923  +  Upsert *pUpsert      /* ON CONFLICT clauses, if any.  NULL otherwise */
113657 113924   ){
113658 113925     Vdbe *v;             /* VDBE under constrution */
113659 113926     Index *pIdx;         /* Pointer to one of the indices */
113660 113927     Index *pPk = 0;      /* The PRIMARY KEY index */
113661 113928     sqlite3 *db;         /* Database connection */
113662 113929     int i;               /* loop counter */
113663 113930     int ix;              /* Index loop counter */
113664 113931     int nCol;            /* Number of columns */
113665 113932     int onError;         /* Conflict resolution strategy */
113666 113933     int addr1;           /* Address of jump instruction */
113667 113934     int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
113668 113935     int nPkField;        /* Number of fields in PRIMARY KEY. 1 for ROWID tables */
113669         -  int ipkTop = 0;      /* Top of the rowid change constraint check */
113670         -  int ipkBottom = 0;   /* Bottom of the rowid change constraint check */
       113936  +  ConstraintAddr sAddr;/* Address information for constraint reordering */
       113937  +  Index *pUpIdx = 0;   /* Index to which to apply the upsert */
113671 113938     u8 isUpdate;         /* True if this is an UPDATE operation */
113672 113939     u8 bAffinityDone = 0;  /* True if the OP_Affinity operation has been run */
       113940  +  int upsertBypass = 0;  /* Address of Goto to bypass upsert subroutine */
113673 113941   
113674 113942     isUpdate = regOldData!=0;
113675 113943     db = pParse->db;
113676 113944     v = sqlite3GetVdbe(pParse);
113677 113945     assert( v!=0 );
113678 113946     assert( pTab->pSelect==0 );  /* This table is not a VIEW */
113679 113947     nCol = pTab->nCol;
       113948  +  memset(&sAddr, 0, sizeof(sAddr));
113680 113949     
113681 113950     /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
113682 113951     ** normal rowid tables.  nPkField is the number of key fields in the 
113683 113952     ** pPk index or 1 for a rowid table.  In other words, nPkField is the
113684 113953     ** number of fields in the true primary key of the table. */
113685 113954     if( HasRowid(pTab) ){
113686 113955       pPk = 0;
................................................................................
113771 114040                                 P5_ConstraintCheck);
113772 114041         }
113773 114042         sqlite3VdbeResolveLabel(v, allOk);
113774 114043       }
113775 114044       pParse->iSelfTab = 0;
113776 114045     }
113777 114046   #endif /* !defined(SQLITE_OMIT_CHECK) */
       114047  +
       114048  +  /* UNIQUE and PRIMARY KEY constraints should be handled in the following
       114049  +  ** order:
       114050  +  **
       114051  +  **   (1)  OE_Abort, OE_Fail, OE_Rollback, OE_Ignore
       114052  +  **   (2)  OE_Update
       114053  +  **   (3)  OE_Replace
       114054  +  **
       114055  +  ** OE_Fail and OE_Ignore must happen before any changes are made.
       114056  +  ** OE_Update guarantees that only a single row will change, so it
       114057  +  ** must happen before OE_Replace.  Technically, OE_Abort and OE_Rollback
       114058  +  ** could happen in any order, but they are grouped up front for
       114059  +  ** convenience.
       114060  +  **
       114061  +  ** Constraint checking code is generated in this order:
       114062  +  **   (A)  The rowid constraint
       114063  +  **   (B)  Unique index constraints that do not have OE_Replace as their
       114064  +  **        default conflict resolution strategy
       114065  +  **   (C)  Unique index that do use OE_Replace by default.
       114066  +  **
       114067  +  ** The ordering of (2) and (3) is accomplished by making sure the linked
       114068  +  ** list of indexes attached to a table puts all OE_Replace indexes last
       114069  +  ** in the list.  See sqlite3CreateIndex() for where that happens.
       114070  +  */
       114071  +
       114072  +  if( pUpsert ){
       114073  +    if( pUpsert->pUpsertTarget==0 ){
       114074  +      /* An ON CONFLICT DO NOTHING clause, without a constraint-target.
       114075  +      ** Make all unique constraint resolution be OE_Ignore */
       114076  +      assert( pUpsert->pUpsertSet==0 );
       114077  +      overrideError = OE_Ignore;
       114078  +      pUpsert = 0;
       114079  +    }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){
       114080  +      /* If the constraint-target is on some column other than
       114081  +      ** then ROWID, then we might need to move the UPSERT around
       114082  +      ** so that it occurs in the correct order. */
       114083  +      sAddr.upsertTop = sAddr.upsertTop2 = sqlite3VdbeMakeLabel(v);
       114084  +      sAddr.upsertBtm = sqlite3VdbeMakeLabel(v);
       114085  +    }
       114086  +  }
113778 114087   
113779 114088     /* If rowid is changing, make sure the new rowid does not previously
113780 114089     ** exist in the table.
113781 114090     */
113782 114091     if( pkChng && pPk==0 ){
113783 114092       int addrRowidOk = sqlite3VdbeMakeLabel(v);
113784 114093   
................................................................................
113785 114094       /* Figure out what action to take in case of a rowid collision */
113786 114095       onError = pTab->keyConf;
113787 114096       if( overrideError!=OE_Default ){
113788 114097         onError = overrideError;
113789 114098       }else if( onError==OE_Default ){
113790 114099         onError = OE_Abort;
113791 114100       }
       114101  +
       114102  +    /* figure out whether or not upsert applies in this case */
       114103  +    if( pUpsert && pUpsert->pUpsertIdx==0 ){
       114104  +      if( pUpsert->pUpsertSet==0 ){
       114105  +        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
       114106  +      }else{
       114107  +        onError = OE_Update;  /* DO UPDATE */
       114108  +      }
       114109  +    }
       114110  +
       114111  +    /* If the response to a rowid conflict is REPLACE but the response
       114112  +    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
       114113  +    ** to defer the running of the rowid conflict checking until after
       114114  +    ** the UNIQUE constraints have run.
       114115  +    */
       114116  +    assert( OE_Update>OE_Replace );
       114117  +    assert( OE_Ignore<OE_Replace );
       114118  +    assert( OE_Fail<OE_Replace );
       114119  +    assert( OE_Abort<OE_Replace );
       114120  +    assert( OE_Rollback<OE_Replace );
       114121  +    if( onError>=OE_Replace
       114122  +     && (pUpsert || onError!=overrideError)
       114123  +     && pTab->pIndex
       114124  +    ){
       114125  +      sAddr.ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1;
       114126  +    }
113792 114127   
113793 114128       if( isUpdate ){
113794 114129         /* pkChng!=0 does not mean that the rowid has changed, only that
113795 114130         ** it might have changed.  Skip the conflict logic below if the rowid
113796 114131         ** is unchanged. */
113797 114132         sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData);
113798 114133         sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
113799 114134         VdbeCoverage(v);
113800 114135       }
113801 114136   
113802         -    /* If the response to a rowid conflict is REPLACE but the response
113803         -    ** to some other UNIQUE constraint is FAIL or IGNORE, then we need
113804         -    ** to defer the running of the rowid conflict checking until after
113805         -    ** the UNIQUE constraints have run.
113806         -    */
113807         -    if( onError==OE_Replace && overrideError!=OE_Replace ){
113808         -      for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
113809         -        if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){
113810         -          ipkTop = sqlite3VdbeAddOp0(v, OP_Goto);
113811         -          break;
113812         -        }
113813         -      }
113814         -    }
113815         -
113816 114137       /* Check to see if the new rowid already exists in the table.  Skip
113817 114138       ** the following conflict logic if it does not. */
       114139  +    VdbeNoopComment((v, "uniqueness check for ROWID"));
113818 114140       sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData);
113819 114141       VdbeCoverage(v);
113820 114142   
113821         -    /* Generate code that deals with a rowid collision */
113822 114143       switch( onError ){
113823 114144         default: {
113824 114145           onError = OE_Abort;
113825 114146           /* Fall thru into the next case */
113826 114147         }
113827 114148         case OE_Rollback:
113828 114149         case OE_Abort:
113829 114150         case OE_Fail: {
       114151  +        testcase( onError==OE_Rollback );
       114152  +        testcase( onError==OE_Abort );
       114153  +        testcase( onError==OE_Fail );
113830 114154           sqlite3RowidConstraint(pParse, onError, pTab);
113831 114155           break;
113832 114156         }
113833 114157         case OE_Replace: {
113834 114158           /* If there are DELETE triggers on this table and the
113835 114159           ** recursive-triggers flag is set, call GenerateRowDelete() to
113836 114160           ** remove the conflicting row from the table. This will fire
................................................................................
113859 114183           }
113860 114184           if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
113861 114185             sqlite3MultiWrite(pParse);
113862 114186             sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
113863 114187                                      regNewData, 1, 0, OE_Replace, 1, -1);
113864 114188           }else{
113865 114189   #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
113866         -          if( HasRowid(pTab) ){
113867         -            /* This OP_Delete opcode fires the pre-update-hook only. It does
113868         -            ** not modify the b-tree. It is more efficient to let the coming
113869         -            ** OP_Insert replace the existing entry than it is to delete the
113870         -            ** existing entry and then insert a new one. */
113871         -            sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
113872         -            sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
113873         -          }
       114190  +          assert( HasRowid(pTab) );
       114191  +          /* This OP_Delete opcode fires the pre-update-hook only. It does
       114192  +          ** not modify the b-tree. It is more efficient to let the coming
       114193  +          ** OP_Insert replace the existing entry than it is to delete the
       114194  +          ** existing entry and then insert a new one. */
       114195  +          sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP);
       114196  +          sqlite3VdbeAppendP4(v, pTab, P4_TABLE);
113874 114197   #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */
113875 114198             if( pTab->pIndex ){
113876 114199               sqlite3MultiWrite(pParse);
113877 114200               sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1);
113878 114201             }
113879 114202           }
113880 114203           seenReplace = 1;
113881 114204           break;
113882 114205         }
       114206  +#ifndef SQLITE_OMIT_UPSERT
       114207  +      case OE_Update: {
       114208  +        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur);
       114209  +        /* Fall through */
       114210  +      }
       114211  +#endif
113883 114212         case OE_Ignore: {
113884         -        /*assert( seenReplace==0 );*/
       114213  +        testcase( onError==OE_Ignore );
113885 114214           sqlite3VdbeGoto(v, ignoreDest);
113886 114215           break;
113887 114216         }
113888 114217       }
113889 114218       sqlite3VdbeResolveLabel(v, addrRowidOk);
113890         -    if( ipkTop ){
113891         -      ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto);
113892         -      sqlite3VdbeJumpHere(v, ipkTop);
       114219  +    if( sAddr.ipkTop ){
       114220  +      sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto);
       114221  +      sqlite3VdbeJumpHere(v, sAddr.ipkTop-1);
113893 114222       }
113894 114223     }
113895 114224   
113896 114225     /* Test all UNIQUE constraints by creating entries for each UNIQUE
113897 114226     ** index and making sure that duplicate entries do not already exist.
113898 114227     ** Compute the revised record entries for indices as we go.
113899 114228     **
................................................................................
113903 114232     for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){
113904 114233       int regIdx;          /* Range of registers hold conent for pIdx */
113905 114234       int regR;            /* Range of registers holding conflicting PK */
113906 114235       int iThisCur;        /* Cursor for this UNIQUE index */
113907 114236       int addrUniqueOk;    /* Jump here if the UNIQUE constraint is satisfied */
113908 114237   
113909 114238       if( aRegIdx[ix]==0 ) continue;  /* Skip indices that do not change */
       114239  +    if( pUpIdx==pIdx ){
       114240  +      addrUniqueOk = sAddr.upsertBtm;
       114241  +      upsertBypass = sqlite3VdbeGoto(v, 0);
       114242  +      VdbeComment((v, "Skip upsert subroutine"));
       114243  +      sqlite3VdbeResolveLabel(v, sAddr.upsertTop2);
       114244  +    }else{
       114245  +      addrUniqueOk = sqlite3VdbeMakeLabel(v);
       114246  +    }
       114247  +    VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
113910 114248       if( bAffinityDone==0 ){
113911 114249         sqlite3TableAffinity(v, pTab, regNewData+1);
113912 114250         bAffinityDone = 1;
113913 114251       }
113914 114252       iThisCur = iIdxCur+ix;
113915         -    addrUniqueOk = sqlite3VdbeMakeLabel(v);
       114253  +
113916 114254   
113917 114255       /* Skip partial indices for which the WHERE clause is not true */
113918 114256       if( pIdx->pPartIdxWhere ){
113919 114257         sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]);
113920 114258         pParse->iSelfTab = -(regNewData+1);
113921 114259         sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk,
113922 114260                               SQLITE_JUMPIFNULL);
................................................................................
113967 114305         continue;  /* pIdx is not a UNIQUE index */
113968 114306       }
113969 114307       if( overrideError!=OE_Default ){
113970 114308         onError = overrideError;
113971 114309       }else if( onError==OE_Default ){
113972 114310         onError = OE_Abort;
113973 114311       }
       114312  +
       114313  +    /* Figure out if the upsert clause applies to this index */
       114314  +    if( pUpIdx==pIdx ){
       114315  +      if( pUpsert->pUpsertSet==0 ){
       114316  +        onError = OE_Ignore;  /* DO NOTHING is the same as INSERT OR IGNORE */
       114317  +      }else{
       114318  +        onError = OE_Update;  /* DO UPDATE */
       114319  +      }
       114320  +    }
       114321  +
       114322  +    /* Invoke subroutines to handle IPK replace and upsert prior to running
       114323  +    ** the first REPLACE constraint check. */
       114324  +    if( onError==OE_Replace ){
       114325  +      testcase( sAddr.ipkTop );
       114326  +      testcase( sAddr.upsertTop
       114327  +             && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
       114328  +      reorderConstraintChecks(v, &sAddr);
       114329  +    }
113974 114330   
113975 114331       /* Collision detection may be omitted if all of the following are true:
113976 114332       **   (1) The conflict resolution algorithm is REPLACE
113977 114333       **   (2) The table is a WITHOUT ROWID table
113978 114334       **   (3) There are no secondary indexes on the table
113979 114335       **   (4) No delete triggers need to be fired if there is a conflict
113980 114336       **   (5) No FK constraint counters need to be updated if a conflict occurs.
................................................................................
114050 114406             }
114051 114407           }
114052 114408         }
114053 114409       }
114054 114410   
114055 114411       /* Generate code that executes if the new index entry is not unique */
114056 114412       assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
114057         -        || onError==OE_Ignore || onError==OE_Replace );
       114413  +        || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update );
114058 114414       switch( onError ){
114059 114415         case OE_Rollback:
114060 114416         case OE_Abort:
114061 114417         case OE_Fail: {
       114418  +        testcase( onError==OE_Rollback );
       114419  +        testcase( onError==OE_Abort );
       114420  +        testcase( onError==OE_Fail );
114062 114421           sqlite3UniqueConstraint(pParse, onError, pIdx);
114063 114422           break;
114064 114423         }
       114424  +#ifndef SQLITE_OMIT_UPSERT
       114425  +      case OE_Update: {
       114426  +        sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix);
       114427  +        /* Fall through */
       114428  +      }
       114429  +#endif
114065 114430         case OE_Ignore: {
       114431  +        testcase( onError==OE_Ignore );
114066 114432           sqlite3VdbeGoto(v, ignoreDest);
114067 114433           break;
114068 114434         }
114069 114435         default: {
114070 114436           Trigger *pTrigger = 0;
114071 114437           assert( onError==OE_Replace );
114072 114438           sqlite3MultiWrite(pParse);
................................................................................
114076 114442           sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur,
114077 114443               regR, nPkField, 0, OE_Replace,
114078 114444               (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur);
114079 114445           seenReplace = 1;
114080 114446           break;
114081 114447         }
114082 114448       }
114083         -    sqlite3VdbeResolveLabel(v, addrUniqueOk);
       114449  +    if( pUpIdx==pIdx ){
       114450  +      sqlite3VdbeJumpHere(v, upsertBypass);
       114451  +    }else{
       114452  +      sqlite3VdbeResolveLabel(v, addrUniqueOk);
       114453  +    }
114084 114454       sqlite3ExprCachePop(pParse);
114085 114455       if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
       114456  +
114086 114457     }
114087         -  if( ipkTop ){
114088         -    sqlite3VdbeGoto(v, ipkTop+1);
114089         -    sqlite3VdbeJumpHere(v, ipkBottom);
114090         -  }
       114458  +  testcase( sAddr.ipkTop!=0 );
       114459  +  testcase( sAddr.upsertTop
       114460  +         && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) );
       114461  +  reorderConstraintChecks(v, &sAddr);
114091 114462     
114092 114463     *pbMayReplace = seenReplace;
114093 114464     VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace));
114094 114465   }
114095 114466   
114096 114467   #ifdef SQLITE_ENABLE_NULL_TRIM
114097 114468   /*
................................................................................
119509 119880     Db *pDb;
119510 119881     char const *azArg[4];
119511 119882     int meta[5];
119512 119883     InitData initData;
119513 119884     const char *zMasterName;
119514 119885     int openedTransaction = 0;
119515 119886   
       119887  +  assert( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0 );
119516 119888     assert( iDb>=0 && iDb<db->nDb );
119517 119889     assert( db->aDb[iDb].pSchema );
119518 119890     assert( sqlite3_mutex_held(db->mutex) );
119519 119891     assert( iDb==1 || sqlite3BtreeHoldsMutex(db->aDb[iDb].pBt) );
119520 119892   
119521 119893     db->init.busy = 1;
119522 119894   
................................................................................
119738 120110     /* Do the main schema first */
119739 120111     if( !DbHasProperty(db, 0, DB_SchemaLoaded) ){
119740 120112       rc = sqlite3InitOne(db, 0, pzErrMsg);
119741 120113       if( rc ) return rc;
119742 120114     }
119743 120115     /* All other schemas after the main schema. The "temp" schema must be last */
119744 120116     for(i=db->nDb-1; i>0; i--){
       120117  +    assert( i==1 || sqlite3BtreeHoldsMutex(db->aDb[i].pBt) );
119745 120118       if( !DbHasProperty(db, i, DB_SchemaLoaded) ){
119746 120119         rc = sqlite3InitOne(db, i, pzErrMsg);
119747 120120         if( rc ) return rc;
119748 120121       }
119749 120122     }
119750 120123     if( commit_internal ){
119751 120124       sqlite3CommitInternalChanges(db);
................................................................................
119759 120132   */
119760 120133   SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse){
119761 120134     int rc = SQLITE_OK;
119762 120135     sqlite3 *db = pParse->db;
119763 120136     assert( sqlite3_mutex_held(db->mutex) );
119764 120137     if( !db->init.busy ){
119765 120138       rc = sqlite3Init(db, &pParse->zErrMsg);
119766         -  }
119767         -  if( rc!=SQLITE_OK ){
119768         -    pParse->rc = rc;
119769         -    pParse->nErr++;
       120139  +    if( rc!=SQLITE_OK ){
       120140  +      pParse->rc = rc;
       120141  +      pParse->nErr++;
       120142  +    }else if( db->noSharedCache ){
       120143  +      db->mDbFlags |= DBFLAG_SchemaKnownOk;
       120144  +    }
119770 120145     }
119771 120146     return rc;
119772 120147   }
119773 120148   
119774 120149   
119775 120150   /*
119776 120151   ** Check schema cookies in all databases.  If any cookie is out
................................................................................
120287 120662   /*
120288 120663   ** Trace output macros
120289 120664   */
120290 120665   #if SELECTTRACE_ENABLED
120291 120666   /***/ int sqlite3SelectTrace = 0;
120292 120667   # define SELECTTRACE(K,P,S,X)  \
120293 120668     if(sqlite3SelectTrace&(K))   \
120294         -    sqlite3DebugPrintf("%s/%p: ",(S)->zSelName,(S)),\
       120669  +    sqlite3DebugPrintf("%s/%d/%p: ",(S)->zSelName,(P)->iSelectId,(S)),\
120295 120670       sqlite3DebugPrintf X
120296 120671   #else
120297 120672   # define SELECTTRACE(K,P,S,X)
120298 120673   #endif
120299 120674   
120300 120675   
120301 120676   /*
................................................................................
120310 120685     int tabTnct;    /* Ephemeral table used for DISTINCT processing */
120311 120686     int addrTnct;   /* Address of OP_OpenEphemeral opcode for tabTnct */
120312 120687   };
120313 120688   
120314 120689   /*
120315 120690   ** An instance of the following object is used to record information about
120316 120691   ** the ORDER BY (or GROUP BY) clause of query is being coded.
       120692  +**
       120693  +** The aDefer[] array is used by the sorter-references optimization. For
       120694  +** example, assuming there is no index that can be used for the ORDER BY,
       120695  +** for the query:
       120696  +**
       120697  +**     SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
       120698  +**
       120699  +** it may be more efficient to add just the "a" values to the sorter, and
       120700  +** retrieve the associated "bigblob" values directly from table t1 as the
       120701  +** 10 smallest "a" values are extracted from the sorter.
       120702  +**
       120703  +** When the sorter-reference optimization is used, there is one entry in the
       120704  +** aDefer[] array for each database table that may be read as values are
       120705  +** extracted from the sorter.
120317 120706   */
120318 120707   typedef struct SortCtx SortCtx;
120319 120708   struct SortCtx {
120320 120709     ExprList *pOrderBy;   /* The ORDER BY (or GROUP BY clause) */
120321 120710     int nOBSat;           /* Number of ORDER BY terms satisfied by indices */
120322 120711     int iECursor;         /* Cursor number for the sorter */
120323 120712     int regReturn;        /* Register holding block-output return address */
120324 120713     int labelBkOut;       /* Start label for the block-output subroutine */
120325 120714     int addrSortIndex;    /* Address of the OP_SorterOpen or OP_OpenEphemeral */
120326 120715     int labelDone;        /* Jump here when done, ex: LIMIT reached */
120327 120716     u8 sortFlags;         /* Zero or more SORTFLAG_* bits */
120328 120717     u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */
       120718  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       120719  +  u8 nDefer;            /* Number of valid entries in aDefer[] */
       120720  +  struct DeferredCsr {
       120721  +    Table *pTab;        /* Table definition */
       120722  +    int iCsr;           /* Cursor number for table */
       120723  +    int nKey;           /* Number of PK columns for table pTab (>=1) */
       120724  +  } aDefer[4];
       120725  +#endif
120329 120726   };
120330 120727   #define SORTFLAG_UseSorter  0x01   /* Use SorterOpen instead of OpenEphemeral */
120331 120728   
120332 120729   /*
120333 120730   ** Delete all the content of a Select structure.  Deallocate the structure
120334 120731   ** itself only if bFree is true.
120335 120732   */
................................................................................
120944 121341     sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v);
120945 121342     sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1);
120946 121343     sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N);
120947 121344     sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
120948 121345     sqlite3ReleaseTempReg(pParse, r1);
120949 121346   }
120950 121347   
       121348  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       121349  +/*
       121350  +** This function is called as part of inner-loop generation for a SELECT
       121351  +** statement with an ORDER BY that is not optimized by an index. It 
       121352  +** determines the expressions, if any, that the sorter-reference 
       121353  +** optimization should be used for. The sorter-reference optimization
       121354  +** is used for SELECT queries like:
       121355  +**
       121356  +**   SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10
       121357  +**
       121358  +** If the optimization is used for expression "bigblob", then instead of
       121359  +** storing values read from that column in the sorter records, the PK of
       121360  +** the row from table t1 is stored instead. Then, as records are extracted from
       121361  +** the sorter to return to the user, the required value of bigblob is
       121362  +** retrieved directly from table t1. If the values are very large, this 
       121363  +** can be more efficient than storing them directly in the sorter records.
       121364  +**
       121365  +** The ExprList_item.bSorterRef flag is set for each expression in pEList 
       121366  +** for which the sorter-reference optimization should be enabled. 
       121367  +** Additionally, the pSort->aDefer[] array is populated with entries
       121368  +** for all cursors required to evaluate all selected expressions. Finally.
       121369  +** output variable (*ppExtra) is set to an expression list containing
       121370  +** expressions for all extra PK values that should be stored in the
       121371  +** sorter records.
       121372  +*/
       121373  +static void selectExprDefer(
       121374  +  Parse *pParse,                  /* Leave any error here */
       121375  +  SortCtx *pSort,                 /* Sorter context */
       121376  +  ExprList *pEList,               /* Expressions destined for sorter */
       121377  +  ExprList **ppExtra              /* Expressions to append to sorter record */
       121378  +){
       121379  +  int i;
       121380  +  int nDefer = 0;
       121381  +  ExprList *pExtra = 0;
       121382  +  for(i=0; i<pEList->nExpr; i++){
       121383  +    struct ExprList_item *pItem = &pEList->a[i];
       121384  +    if( pItem->u.x.iOrderByCol==0 ){
       121385  +      Expr *pExpr = pItem->pExpr;
       121386  +      Table *pTab = pExpr->pTab;
       121387  +      if( pExpr->op==TK_COLUMN && pTab && !IsVirtual(pTab)
       121388  +       && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)
       121389  +#if 0
       121390  +          && pTab->pSchema && pTab->pSelect==0 && !IsVirtual(pTab)
       121391  +#endif
       121392  +      ){
       121393  +        int j;
       121394  +        for(j=0; j<nDefer; j++){
       121395  +          if( pSort->aDefer[j].iCsr==pExpr->iTable ) break;
       121396  +        }
       121397  +        if( j==nDefer ){
       121398  +          if( nDefer==ArraySize(pSort->aDefer) ){
       121399  +            continue;
       121400  +          }else{
       121401  +            int nKey = 1;
       121402  +            int k;
       121403  +            Index *pPk = 0;
       121404  +            if( !HasRowid(pTab) ){
       121405  +              pPk = sqlite3PrimaryKeyIndex(pTab);
       121406  +              nKey = pPk->nKeyCol;
       121407  +            }
       121408  +            for(k=0; k<nKey; k++){
       121409  +              Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0);
       121410  +              if( pNew ){
       121411  +                pNew->iTable = pExpr->iTable;
       121412  +                pNew->pTab = pExpr->pTab;
       121413  +                pNew->iColumn = pPk ? pPk->aiColumn[k] : -1;
       121414  +                pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew);
       121415  +              }
       121416  +            }
       121417  +            pSort->aDefer[nDefer].pTab = pExpr->pTab;
       121418  +            pSort->aDefer[nDefer].iCsr = pExpr->iTable;
       121419  +            pSort->aDefer[nDefer].nKey = nKey;
       121420  +            nDefer++;
       121421  +          }
       121422  +        }
       121423  +        pItem->bSorterRef = 1;
       121424  +      }
       121425  +    }
       121426  +  }
       121427  +  pSort->nDefer = (u8)nDefer;
       121428  +  *ppExtra = pExtra;
       121429  +}
       121430  +#endif
       121431  +
120951 121432   /*
120952 121433   ** This routine generates the code for the inside of the inner loop
120953 121434   ** of a SELECT.
120954 121435   **
120955 121436   ** If srcTab is negative, then the p->pEList expressions
120956 121437   ** are evaluated in order to get the data for this row.  If srcTab is
120957 121438   ** zero or more, then data is pulled from srcTab and p->pEList is used only 
................................................................................
121016 121497     regOrig = regResult = pDest->iSdst;
121017 121498     if( srcTab>=0 ){
121018 121499       for(i=0; i<nResultCol; i++){
121019 121500         sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i);
121020 121501         VdbeComment((v, "%s", p->pEList->a[i].zName));
121021 121502       }
121022 121503     }else if( eDest!=SRT_Exists ){
       121504  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       121505  +    ExprList *pExtra = 0;
       121506  +#endif
121023 121507       /* If the destination is an EXISTS(...) expression, the actual
121024 121508       ** values returned by the SELECT are not required.
121025 121509       */
121026 121510       u8 ecelFlags;
121027 121511       if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){
121028 121512         ecelFlags = SQLITE_ECEL_DUP;
121029 121513       }else{
................................................................................
121039 121523         ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF);
121040 121524         for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){
121041 121525           int j;
121042 121526           if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){
121043 121527             p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat;
121044 121528           }
121045 121529         }
       121530  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       121531  +      selectExprDefer(pParse, pSort, p->pEList, &pExtra);
       121532  +      if( pExtra && pParse->db->mallocFailed==0 ){
       121533  +        /* If there are any extra PK columns to add to the sorter records,
       121534  +        ** allocate extra memory cells and adjust the OpenEphemeral 
       121535  +        ** instruction to account for the larger records. This is only
       121536  +        ** required if there are one or more WITHOUT ROWID tables with
       121537  +        ** composite primary keys in the SortCtx.aDefer[] array.  */
       121538  +        VdbeOp *pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
       121539  +        pOp->p2 += (pExtra->nExpr - pSort->nDefer);
       121540  +        pOp->p4.pKeyInfo->nAllField += (pExtra->nExpr - pSort->nDefer);
       121541  +        pParse->nMem += pExtra->nExpr;
       121542  +      }
       121543  +#endif
121046 121544         regOrig = 0;
121047 121545         assert( eDest==SRT_Set || eDest==SRT_Mem 
121048 121546              || eDest==SRT_Coroutine || eDest==SRT_Output );
121049 121547       }
121050 121548       nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult,
121051 121549                                            0,ecelFlags);
       121550  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       121551  +    if( pExtra ){
       121552  +      nResultCol += sqlite3ExprCodeExprList(
       121553  +          pParse, pExtra, regResult + nResultCol, 0, 0
       121554  +      );
       121555  +      sqlite3ExprListDelete(pParse->db, pExtra);
       121556  +    }
       121557  +#endif
121052 121558     }
121053 121559   
121054 121560     /* If the DISTINCT keyword was present on the SELECT statement
121055 121561     ** and this row has been seen before, then do not make this row
121056 121562     ** part of the result.
121057 121563     */
121058 121564     if( hasDistinct ){
................................................................................
121502 122008     SortCtx *pSort,   /* Information on the ORDER BY clause */
121503 122009     int nColumn,      /* Number of columns of data */
121504 122010     SelectDest *pDest /* Write the sorted results here */
121505 122011   ){
121506 122012     Vdbe *v = pParse->pVdbe;                     /* The prepared statement */
121507 122013     int addrBreak = pSort->labelDone;            /* Jump here to exit loop */
121508 122014     int addrContinue = sqlite3VdbeMakeLabel(v);  /* Jump here for next cycle */
121509         -  int addr;
       122015  +  int addr;                       /* Top of output loop. Jump for Next. */
121510 122016     int addrOnce = 0;
121511 122017     int iTab;
121512 122018     ExprList *pOrderBy = pSort->pOrderBy;
121513 122019     int eDest = pDest->eDest;
121514 122020     int iParm = pDest->iSDParm;
121515 122021     int regRow;
121516 122022     int regRowid;
121517 122023     int iCol;
121518         -  int nKey;
       122024  +  int nKey;                       /* Number of key columns in sorter record */
121519 122025     int iSortTab;                   /* Sorter cursor to read from */
121520         -  int nSortData;                  /* Trailing values to read from sorter */
121521 122026     int i;
121522 122027     int bSeq;                       /* True if sorter record includes seq. no. */
       122028  +  int nRefKey = 0;
121523 122029     struct ExprList_item *aOutEx = p->pEList->a;
121524 122030   
121525 122031     assert( addrBreak<0 );
121526 122032     if( pSort->labelBkOut ){
121527 122033       sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
121528 122034       sqlite3VdbeGoto(v, addrBreak);
121529 122035       sqlite3VdbeResolveLabel(v, pSort->labelBkOut);
121530 122036     }
       122037  +
       122038  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       122039  +  /* Open any cursors needed for sorter-reference expressions */
       122040  +  for(i=0; i<pSort->nDefer; i++){
       122041  +    Table *pTab = pSort->aDefer[i].pTab;
       122042  +    int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
       122043  +    sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead);
       122044  +    nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey);
       122045  +  }
       122046  +#endif
       122047  +
121531 122048     iTab = pSort->iECursor;
121532 122049     if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
121533 122050       regRowid = 0;
121534 122051       regRow = pDest->iSdst;
121535         -    nSortData = nColumn;
121536 122052     }else{
121537 122053       regRowid = sqlite3GetTempReg(pParse);
121538 122054       regRow = sqlite3GetTempRange(pParse, nColumn);
121539         -    nSortData = nColumn;
121540 122055     }
121541 122056     nKey = pOrderBy->nExpr - pSort->nOBSat;
121542 122057     if( pSort->sortFlags & SORTFLAG_UseSorter ){
121543 122058       int regSortOut = ++pParse->nMem;
121544 122059       iSortTab = pParse->nTab++;
121545 122060       if( pSort->labelBkOut ){
121546 122061         addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
121547 122062       }
121548         -    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nSortData);
       122063  +    sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, 
       122064  +        nKey+1+nColumn+nRefKey);
121549 122065       if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
121550 122066       addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
121551 122067       VdbeCoverage(v);
121552 122068       codeOffset(v, p->iOffset, addrContinue);
121553 122069       sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);
121554 122070       bSeq = 0;
121555 122071     }else{
121556 122072       addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v);
121557 122073       codeOffset(v, p->iOffset, addrContinue);
121558 122074       iSortTab = iTab;
121559 122075       bSeq = 1;
121560 122076     }
121561         -  for(i=0, iCol=nKey+bSeq-1; i<nSortData; i++){
       122077  +  for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){
       122078  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       122079  +    if( aOutEx[i].bSorterRef ) continue;
       122080  +#endif
121562 122081       if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++;
121563 122082     }
121564         -  for(i=nSortData-1; i>=0; i--){
121565         -    int iRead;
121566         -    if( aOutEx[i].u.x.iOrderByCol ){
121567         -      iRead = aOutEx[i].u.x.iOrderByCol-1;
121568         -    }else{
121569         -      iRead = iCol--;
121570         -    }
121571         -    sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
121572         -    VdbeComment((v, "%s", aOutEx[i].zName ? aOutEx[i].zName : aOutEx[i].zSpan));
       122083  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       122084  +  if( pSort->nDefer ){
       122085  +    int iKey = iCol+1;
       122086  +    int regKey = sqlite3GetTempRange(pParse, nRefKey);
       122087  +
       122088  +    for(i=0; i<pSort->nDefer; i++){
       122089  +      int iCsr = pSort->aDefer[i].iCsr;
       122090  +      Table *pTab = pSort->aDefer[i].pTab;
       122091  +      int nKey = pSort->aDefer[i].nKey;
       122092  +
       122093  +      sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
       122094  +      if( HasRowid(pTab) ){
       122095  +        sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey);
       122096  +        sqlite3VdbeAddOp3(v, OP_SeekRowid, iCsr, 
       122097  +            sqlite3VdbeCurrentAddr(v)+1, regKey);
       122098  +      }else{
       122099  +        int k;
       122100  +        int iJmp;
       122101  +        assert( sqlite3PrimaryKeyIndex(pTab)->nKeyCol==nKey );
       122102  +        for(k=0; k<nKey; k++){
       122103  +          sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey+k);
       122104  +        }
       122105  +        iJmp = sqlite3VdbeCurrentAddr(v);
       122106  +        sqlite3VdbeAddOp4Int(v, OP_SeekGE, iCsr, iJmp+2, regKey, nKey);
       122107  +        sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp+3, regKey, nKey);
       122108  +        sqlite3VdbeAddOp1(v, OP_NullRow, iCsr);
       122109  +      }
       122110  +    }
       122111  +    sqlite3ReleaseTempRange(pParse, regKey, nRefKey);
       122112  +  }
       122113  +#endif
       122114  +  for(i=nColumn-1; i>=0; i--){
       122115  +#ifdef SQLITE_ENABLE_SORTER_REFERENCES
       122116  +    if( aOutEx[i].bSorterRef ){
       122117  +      sqlite3ExprCode(pParse, aOutEx[i].pExpr, regRow+i);
       122118  +    }else
       122119  +#endif
       122120  +    {
       122121  +      int iRead;
       122122  +      if( aOutEx[i].u.x.iOrderByCol ){
       122123  +        iRead = aOutEx[i].u.x.iOrderByCol-1;
       122124  +      }else{
       122125  +        iRead = iCol--;
       122126  +      }
       122127  +      sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i);
       122128  +      VdbeComment((v, "%s", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan));
       122129  +    }
121573 122130     }
121574 122131     switch( eDest ){
121575 122132       case SRT_Table:
121576 122133       case SRT_EphemTab: {
121577 122134         sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
121578 122135         sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
121579 122136         sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
................................................................................
123903 124460       if( pNew==0 ){
123904 124461         p->pPrior = pPrior;
123905 124462       }else{
123906 124463         pNew->pPrior = pPrior;
123907 124464         if( pPrior ) pPrior->pNext = pNew;
123908 124465         pNew->pNext = p;
123909 124466         p->pPrior = pNew;
123910         -      SELECTTRACE(2,pParse,p,
123911         -         ("compound-subquery flattener creates %s.%p as peer\n",
123912         -         pNew->zSelName, pNew));
       124467  +      SELECTTRACE(2,pParse,p,("compound-subquery flattener"
       124468  +                              " creates %s.%p as peer\n",pNew->zSelName, pNew));
123913 124469       }
123914 124470       if( db->mallocFailed ) return 1;
123915 124471     }
123916 124472   
123917 124473     /* Begin flattening the iFrom-th entry of the FROM clause 
123918 124474     ** in the outer query.
123919 124475     */
................................................................................
125437 125993     db = pParse->db;
125438 125994     if( p==0 || db->mallocFailed || pParse->nErr ){
125439 125995       return 1;
125440 125996     }
125441 125997     if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
125442 125998     memset(&sAggInfo, 0, sizeof(sAggInfo));
125443 125999   #if SELECTTRACE_ENABLED
125444         -  SELECTTRACE(1,pParse,p, ("begin processing:\n"));
       126000  +#ifndef SQLITE_OMIT_EXPLAIN
       126001  +  p->iSelectId = pParse->iSelectId;
       126002  +#endif
       126003  +  SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->iSelectId));
125445 126004     if( sqlite3SelectTrace & 0x100 ){
125446 126005       sqlite3TreeViewSelect(0, p, 0);
125447 126006     }
125448 126007   #endif
125449 126008   
125450 126009     assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistFifo );
125451 126010     assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );
................................................................................
125468 126027     pTabList = p->pSrc;
125469 126028     if( pParse->nErr || db->mallocFailed ){
125470 126029       goto select_end;
125471 126030     }
125472 126031     assert( p->pEList!=0 );
125473 126032     isAgg = (p->selFlags & SF_Aggregate)!=0;
125474 126033   #if SELECTTRACE_ENABLED
125475         -  if( sqlite3SelectTrace & 0x100 ){
125476         -    SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
       126034  +  if( sqlite3SelectTrace & 0x104 ){
       126035  +    SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
125477 126036       sqlite3TreeViewSelect(0, p, 0);
125478 126037     }
125479 126038   #endif
125480 126039   
125481 126040     /* Get a pointer the VDBE under construction, allocating a new VDBE if one
125482 126041     ** does not already exist */
125483 126042     v = sqlite3GetVdbe(pParse);
................................................................................
125570 126129   
125571 126130   #ifndef SQLITE_OMIT_COMPOUND_SELECT
125572 126131     /* Handle compound SELECT statements using the separate multiSelect()
125573 126132     ** procedure.
125574 126133     */
125575 126134     if( p->pPrior ){
125576 126135       rc = multiSelect(pParse, p, pDest);
125577         -    explainSetInteger(pParse->iSelectId, iRestoreSelectId);
125578 126136   #if SELECTTRACE_ENABLED
125579         -    SELECTTRACE(1,pParse,p,("end compound-select processing\n"));
       126137  +    SELECTTRACE(0x1,pParse,p,("end compound-select processing\n"));
       126138  +    if( pParse->iSelectId==0 && (sqlite3SelectTrace & 0x2000)!=0 ){
       126139  +      sqlite3TreeViewSelect(0, p, 0);
       126140  +    }
125580 126141   #endif
       126142  +    explainSetInteger(pParse->iSelectId, iRestoreSelectId);
125581 126143       return rc;
125582 126144     }
125583 126145   #endif
125584 126146   
125585 126147     /* For each term in the FROM clause, do two things:
125586 126148     ** (1) Authorized unreferenced tables
125587 126149     ** (2) Generate code for all sub-queries
................................................................................
125952 126514       /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in
125953 126515       ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the
125954 126516       ** SELECT statement.
125955 126517       */
125956 126518       memset(&sNC, 0, sizeof(sNC));
125957 126519       sNC.pParse = pParse;
125958 126520       sNC.pSrcList = pTabList;
125959         -    sNC.pAggInfo = &sAggInfo;
       126521  +    sNC.uNC.pAggInfo = &sAggInfo;
       126522  +    VVA_ONLY( sNC.ncFlags = NC_UAggInfo; )
125960 126523       sAggInfo.mnReg = pParse->nMem+1;
125961 126524       sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0;
125962 126525       sAggInfo.pGroupBy = pGroupBy;
125963 126526       sqlite3ExprAnalyzeAggList(&sNC, pEList);
125964 126527       sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy);
125965 126528       if( pHaving ){
125966 126529         if( pGroupBy ){
................................................................................
126341 126904   
126342 126905     /* If there is an ORDER BY clause, then we need to sort the results
126343 126906     ** and send them to the callback one by one.
126344 126907     */
126345 126908     if( sSort.pOrderBy ){
126346 126909       explainTempTable(pParse,
126347 126910                        sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY");
       126911  +    assert( p->pEList==pEList );
126348 126912       generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest);
126349 126913     }
126350 126914   
126351 126915     /* Jump here to skip this query
126352 126916     */
126353 126917     sqlite3VdbeResolveLabel(v, iEnd);
126354 126918   
................................................................................
126356 126920     ** set the return code to 1. Otherwise 0. */
126357 126921     rc = (pParse->nErr>0);
126358 126922   
126359 126923     /* Control jumps to here if an error is encountered above, or upon
126360 126924     ** successful coding of the SELECT.
126361 126925     */
126362 126926   select_end:
126363         -  explainSetInteger(pParse->iSelectId, iRestoreSelectId);
126364 126927     sqlite3ExprListDelete(db, pMinMaxOrderBy);
126365 126928     sqlite3DbFree(db, sAggInfo.aCol);
126366 126929     sqlite3DbFree(db, sAggInfo.aFunc);
126367 126930   #if SELECTTRACE_ENABLED
126368         -  SELECTTRACE(1,pParse,p,("end processing\n"));
       126931  +  SELECTTRACE(0x1,pParse,p,("end processing\n"));
       126932  +  if( pParse->iSelectId==0 && (sqlite3SelectTrace & 0x2000)!=0 ){
       126933  +    sqlite3TreeViewSelect(0, p, 0);
       126934  +  }
126369 126935   #endif
       126936  +  explainSetInteger(pParse->iSelectId, iRestoreSelectId);
126370 126937     return rc;
126371 126938   }
126372 126939   
126373 126940   /************** End of select.c **********************************************/
126374 126941   /************** Begin file table.c *******************************************/
126375 126942   /*
126376 126943   ** 2001 September 15
................................................................................
126596 127163       TriggerStep * pTmp = pTriggerStep;
126597 127164       pTriggerStep = pTriggerStep->pNext;
126598 127165   
126599 127166       sqlite3ExprDelete(db, pTmp->pWhere);
126600 127167       sqlite3ExprListDelete(db, pTmp->pExprList);
126601 127168       sqlite3SelectDelete(db, pTmp->pSelect);
126602 127169       sqlite3IdListDelete(db, pTmp->pIdList);
       127170  +    sqlite3UpsertDelete(db, pTmp->pUpsert);
126603 127171       sqlite3DbFree(db, pTmp->zSpan);
126604 127172   
126605 127173       sqlite3DbFree(db, pTmp);
126606 127174     }
126607 127175   }
126608 127176   
126609 127177   /*
................................................................................
126987 127555   */
126988 127556   SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(
126989 127557     sqlite3 *db,        /* The database connection */
126990 127558     Token *pTableName,  /* Name of the table into which we insert */
126991 127559     IdList *pColumn,    /* List of columns in pTableName to insert into */
126992 127560     Select *pSelect,    /* A SELECT statement that supplies values */
126993 127561     u8 orconf,          /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
       127562  +  Upsert *pUpsert,    /* ON CONFLICT clauses for upsert */
126994 127563     const char *zStart, /* Start of SQL text */
126995 127564     const char *zEnd    /* End of SQL text */
126996 127565   ){
126997 127566     TriggerStep *pTriggerStep;
126998 127567   
126999 127568     assert(pSelect != 0 || db->mallocFailed);
127000 127569   
127001 127570     pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd);
127002 127571     if( pTriggerStep ){
127003 127572       pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
127004 127573       pTriggerStep->pIdList = pColumn;
       127574  +    pTriggerStep->pUpsert = pUpsert;
127005 127575       pTriggerStep->orconf = orconf;
127006 127576     }else{
       127577  +    testcase( pColumn );
127007 127578       sqlite3IdListDelete(db, pColumn);
       127579  +    testcase( pUpsert );
       127580  +    sqlite3UpsertDelete(db, pUpsert);
127008 127581     }
127009 127582     sqlite3SelectDelete(db, pSelect);
127010 127583   
127011 127584     return pTriggerStep;
127012 127585   }
127013 127586   
127014 127587   /*
................................................................................
127317 127890   
127318 127891       switch( pStep->op ){
127319 127892         case TK_UPDATE: {
127320 127893           sqlite3Update(pParse, 
127321 127894             targetSrcList(pParse, pStep),
127322 127895             sqlite3ExprListDup(db, pStep->pExprList, 0), 
127323 127896             sqlite3ExprDup(db, pStep->pWhere, 0), 
127324         -          pParse->eOrconf, 0, 0
       127897  +          pParse->eOrconf, 0, 0, 0
127325 127898           );
127326 127899           break;
127327 127900         }
127328 127901         case TK_INSERT: {
127329 127902           sqlite3Insert(pParse, 
127330 127903             targetSrcList(pParse, pStep),
127331 127904             sqlite3SelectDup(db, pStep->pSelect, 0), 
127332 127905             sqlite3IdListDup(db, pStep->pIdList), 
127333         -          pParse->eOrconf
       127906  +          pParse->eOrconf,
       127907  +          sqlite3UpsertDup(db, pStep->pUpsert)
127334 127908           );
127335 127909           break;
127336 127910         }
127337 127911         case TK_DELETE: {
127338 127912           sqlite3DeleteFrom(pParse, 
127339 127913             targetSrcList(pParse, pStep),
127340 127914             sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0
................................................................................
127804 128378   SQLITE_PRIVATE void sqlite3Update(
127805 128379     Parse *pParse,         /* The parser context */
127806 128380     SrcList *pTabList,     /* The table in which we should change things */
127807 128381     ExprList *pChanges,    /* Things to be changed */
127808 128382     Expr *pWhere,          /* The WHERE clause.  May be null */
127809 128383     int onError,           /* How to handle constraint errors */
127810 128384     ExprList *pOrderBy,    /* ORDER BY clause. May be null */
127811         -  Expr *pLimit           /* LIMIT clause. May be null */
       128385  +  Expr *pLimit,          /* LIMIT clause. May be null */
       128386  +  Upsert *pUpsert        /* ON CONFLICT clause, or null */
127812 128387   ){
127813 128388     int i, j;              /* Loop counters */
127814 128389     Table *pTab;           /* The table to be updated */
127815 128390     int addrTop = 0;       /* VDBE instruction address of the start of the loop */
127816 128391     WhereInfo *pWInfo;     /* Information about the WHERE clause */
127817 128392     Vdbe *v;               /* The virtual database engine */
127818 128393     Index *pIdx;           /* For looping over indices */
................................................................................
127911 128486     }
127912 128487   
127913 128488     /* Allocate a cursors for the main database table and for all indices.
127914 128489     ** The index cursors might not be used, but if they are used they
127915 128490     ** need to occur right after the database cursor.  So go ahead and
127916 128491     ** allocate enough space, just in case.
127917 128492     */
127918         -  pTabList->a[0].iCursor = iBaseCur = iDataCur = pParse->nTab++;
       128493  +  iBaseCur = iDataCur = pParse->nTab++;
127919 128494     iIdxCur = iDataCur+1;
127920 128495     pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
       128496  +  testcase( pPk!=0 && pPk!=pTab->pIndex );
127921 128497     for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){
127922         -    if( IsPrimaryKeyIndex(pIdx) && pPk!=0 ){
       128498  +    if( pPk==pIdx ){
127923 128499         iDataCur = pParse->nTab;
127924         -      pTabList->a[0].iCursor = iDataCur;
127925 128500       }
127926 128501       pParse->nTab++;
127927 128502     }
       128503  +  if( pUpsert ){
       128504  +    /* On an UPSERT, reuse the same cursors already opened by INSERT */
       128505  +    iDataCur = pUpsert->iDataCur;
       128506  +    iIdxCur = pUpsert->iIdxCur;
       128507  +    pParse->nTab = iBaseCur;
       128508  +  }
       128509  +  pTabList->a[0].iCursor = iDataCur;
127928 128510   
127929 128511     /* Allocate space for aXRef[], aRegIdx[], and aToOpen[].  
127930 128512     ** Initialize aXRef[] and aToOpen[] to their default values.
127931 128513     */
127932 128514     aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 );
127933 128515     if( aXRef==0 ) goto update_cleanup;
127934 128516     aRegIdx = aXRef+pTab->nCol;
................................................................................
127937 128519     aToOpen[nIdx+1] = 0;
127938 128520     for(i=0; i<pTab->nCol; i++) aXRef[i] = -1;
127939 128521   
127940 128522     /* Initialize the name-context */
127941 128523     memset(&sNC, 0, sizeof(sNC));
127942 128524     sNC.pParse = pParse;
127943 128525     sNC.pSrcList = pTabList;
       128526  +  sNC.uNC.pUpsert = pUpsert;
       128527  +  sNC.ncFlags = NC_UUpsert;
127944 128528   
127945 128529     /* Resolve the column names in all the expressions of the
127946 128530     ** of the UPDATE statement.  Also find the column index
127947 128531     ** for each column to be updated in the pChanges array.  For each
127948 128532     ** column to be updated, make sure we have authorization to change
127949 128533     ** that column.
127950 128534     */
................................................................................
128040 128624       memset(aToOpen, 1, nIdx+1);
128041 128625     }
128042 128626   
128043 128627     /* Begin generating code. */
128044 128628     v = sqlite3GetVdbe(pParse);
128045 128629     if( v==0 ) goto update_cleanup;
128046 128630     if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
128047         -  sqlite3BeginWriteOperation(pParse, 1, iDb);
       128631  +  sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb);
128048 128632   
128049 128633     /* Allocate required registers. */
128050 128634     if( !IsVirtual(pTab) ){
128051 128635       regRowSet = ++pParse->nMem;
128052 128636       regOldRowid = regNewRowid = ++pParse->nMem;
128053 128637       if( chngPk || pTrigger || hasFK ){
128054 128638         regOld = pParse->nMem + 1;
................................................................................
128091 128675     if( IsVirtual(pTab) ){
128092 128676       updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef,
128093 128677                          pWhere, onError);
128094 128678       goto update_cleanup;
128095 128679     }
128096 128680   #endif
128097 128681   
128098         -  /* Initialize the count of updated rows */
128099         -  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){
       128682  +  /* Jump to labelBreak to abandon further processing of this UPDATE */
       128683  +  labelContinue = labelBreak = sqlite3VdbeMakeLabel(v);
       128684  +
       128685  +  /* Not an UPSERT.  Normal processing.  Begin by
       128686  +  ** initialize the count of updated rows */
       128687  +  if( (db->flags&SQLITE_CountRows)!=0
       128688  +   && !pParse->pTriggerTab
       128689  +   && !pParse->nested
       128690  +   && pUpsert==0
       128691  +  ){
128100 128692       regRowCount = ++pParse->nMem;
128101 128693       sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount);
128102 128694     }
128103 128695   
128104 128696     if( HasRowid(pTab) ){
128105 128697       sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid);
128106 128698     }else{
128107 128699       assert( pPk!=0 );
128108 128700       nPk = pPk->nKeyCol;
128109 128701       iPk = pParse->nMem+1;
128110 128702       pParse->nMem += nPk;
128111 128703       regKey = ++pParse->nMem;
128112         -    iEph = pParse->nTab++;
128113         -
128114         -    sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
128115         -    addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
128116         -    sqlite3VdbeSetP4KeyInfo(pParse, pPk);
128117         -  }
128118         -
128119         -  /* Begin the database scan. 
128120         -  **
128121         -  ** Do not consider a single-pass strategy for a multi-row update if
128122         -  ** there are any triggers or foreign keys to process, or rows may
128123         -  ** be deleted as a result of REPLACE conflict handling. Any of these
128124         -  ** things might disturb a cursor being used to scan through the table
128125         -  ** or index, causing a single-pass approach to malfunction.  */
128126         -  flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
128127         -  if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
128128         -    flags |= WHERE_ONEPASS_MULTIROW;
128129         -  }
128130         -  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
128131         -  if( pWInfo==0 ) goto update_cleanup;
128132         -
128133         -  /* A one-pass strategy that might update more than one row may not
128134         -  ** be used if any column of the index used for the scan is being
128135         -  ** updated. Otherwise, if there is an index on "b", statements like
128136         -  ** the following could create an infinite loop:
128137         -  **
128138         -  **   UPDATE t1 SET b=b+1 WHERE b>?
128139         -  **
128140         -  ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
128141         -  ** strategy that uses an index for which one or more columns are being
128142         -  ** updated.  */
128143         -  eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
128144         -  if( eOnePass==ONEPASS_MULTI ){
128145         -    int iCur = aiCurOnePass[1];
128146         -    if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
128147         -      eOnePass = ONEPASS_OFF;
128148         -    }
128149         -    assert( iCur!=iDataCur || !HasRowid(pTab) );
128150         -  }
128151         -  
       128704  +    if( pUpsert==0 ){
       128705  +      iEph = pParse->nTab++;
       128706  +        sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1);
       128707  +      addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk);
       128708  +      sqlite3VdbeSetP4KeyInfo(pParse, pPk);
       128709  +    }
       128710  +  }
       128711  +  
       128712  +  if( pUpsert ){
       128713  +    /* If this is an UPSERT, then all cursors have already been opened by
       128714  +    ** the outer INSERT and the data cursor should be pointing at the row
       128715  +    ** that is to be updated.  So bypass the code that searches for the
       128716  +    ** row(s) to be updated.
       128717  +    */
       128718  +    pWInfo = 0;
       128719  +    eOnePass = ONEPASS_SINGLE;
       128720  +    sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL);
       128721  +  }else{
       128722  +    /* Begin the database scan. 
       128723  +    **
       128724  +    ** Do not consider a single-pass strategy for a multi-row update if
       128725  +    ** there are any triggers or foreign keys to process, or rows may
       128726  +    ** be deleted as a result of REPLACE conflict handling. Any of these
       128727  +    ** things might disturb a cursor being used to scan through the table
       128728  +    ** or index, causing a single-pass approach to malfunction.  */
       128729  +    flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE;
       128730  +    if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
       128731  +      flags |= WHERE_ONEPASS_MULTIROW;
       128732  +    }
       128733  +    pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur);
       128734  +    if( pWInfo==0 ) goto update_cleanup;
       128735  +  
       128736  +    /* A one-pass strategy that might update more than one row may not
       128737  +    ** be used if any column of the index used for the scan is being
       128738  +    ** updated. Otherwise, if there is an index on "b", statements like
       128739  +    ** the following could create an infinite loop:
       128740  +    **
       128741  +    **   UPDATE t1 SET b=b+1 WHERE b>?
       128742  +    **
       128743  +    ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI
       128744  +    ** strategy that uses an index for which one or more columns are being
       128745  +    ** updated.  */
       128746  +    eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
       128747  +    if( eOnePass!=ONEPASS_SINGLE ){
       128748  +      sqlite3MultiWrite(pParse);
       128749  +      if( eOnePass==ONEPASS_MULTI ){
       128750  +        int iCur = aiCurOnePass[1];
       128751  +        if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){
       128752  +          eOnePass = ONEPASS_OFF;
       128753  +        }
       128754  +        assert( iCur!=iDataCur || !HasRowid(pTab) );
       128755  +      }
       128756  +    }
       128757  +  }
       128758  +
128152 128759     if( HasRowid(pTab) ){
128153 128760       /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF
128154 128761       ** mode, write the rowid into the FIFO. In either of the one-pass modes,
128155 128762       ** leave it in register regOldRowid.  */
128156 128763       sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid);
128157 128764       if( eOnePass==ONEPASS_OFF ){
128158 128765         sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid);
................................................................................
128164 128771       ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table 
128165 128772       ** is not required) and leave the PK fields in the array of registers.  */
128166 128773       for(i=0; i<nPk; i++){
128167 128774         assert( pPk->aiColumn[i]>=0 );
128168 128775         sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i);
128169 128776       }
128170 128777       if( eOnePass ){
128171         -      sqlite3VdbeChangeToNoop(v, addrOpen);
       128778  +      if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen);
128172 128779         nKey = nPk;
128173 128780         regKey = iPk;
128174 128781       }else{
128175 128782         sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey,
128176 128783                           sqlite3IndexAffinityStr(db, pPk), nPk);
128177 128784         sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk);
128178 128785       }
128179 128786     }
128180 128787   
128181         -  if( eOnePass!=ONEPASS_MULTI ){
128182         -    sqlite3WhereEnd(pWInfo);
128183         -  }
128184         -
128185         -  labelBreak = sqlite3VdbeMakeLabel(v);
128186         -  if( !isView ){
128187         -    int addrOnce = 0;
128188         -
128189         -    /* Open every index that needs updating. */
       128788  +  if( pUpsert==0 ){
       128789  +    if( eOnePass!=ONEPASS_MULTI ){
       128790  +      sqlite3WhereEnd(pWInfo);
       128791  +    }
       128792  +  
       128793  +    if( !isView ){
       128794  +      int addrOnce = 0;
       128795  +  
       128796  +      /* Open every index that needs updating. */
       128797  +      if( eOnePass!=ONEPASS_OFF ){
       128798  +        if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
       128799  +        if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
       128800  +      }
       128801  +  
       128802  +      if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
       128803  +        addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
       128804  +      }
       128805  +      sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur,
       128806  +                                 aToOpen, 0, 0);
       128807  +      if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
       128808  +    }
       128809  +  
       128810  +    /* Top of the update loop */
128190 128811       if( eOnePass!=ONEPASS_OFF ){
128191         -      if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0;
128192         -      if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0;
128193         -    }
128194         -
128195         -    if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){
128196         -      addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
128197         -    }
128198         -    sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen,
128199         -                               0, 0);
128200         -    if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
128201         -  }
128202         -
128203         -  /* Top of the update loop */
128204         -  if( eOnePass!=ONEPASS_OFF ){
128205         -    if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
128206         -      assert( pPk );
128207         -      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey, nKey);
128208         -      VdbeCoverageNeverTaken(v);
128209         -    }
128210         -    if( eOnePass==ONEPASS_SINGLE ){
128211         -      labelContinue = labelBreak;
128212         -    }else{
       128812  +      if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){
       128813  +        assert( pPk );
       128814  +        sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey);
       128815  +        VdbeCoverageNeverTaken(v);
       128816  +      }
       128817  +      if( eOnePass!=ONEPASS_SINGLE ){
       128818  +        labelContinue = sqlite3VdbeMakeLabel(v);
       128819  +      }
       128820  +      sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
       128821  +      VdbeCoverageIf(v, pPk==0);
       128822  +      VdbeCoverageIf(v, pPk!=0);
       128823  +    }else if( pPk ){
128213 128824         labelContinue = sqlite3VdbeMakeLabel(v);
       128825  +      sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
       128826  +      addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
       128827  +      sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
       128828  +      VdbeCoverage(v);
       128829  +    }else{
       128830  +      labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak,
       128831  +                               regOldRowid);
       128832  +      VdbeCoverage(v);
       128833  +      sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
       128834  +      VdbeCoverage(v);
128214 128835       }
128215         -    sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
128216         -    VdbeCoverageIf(v, pPk==0);
128217         -    VdbeCoverageIf(v, pPk!=0);
128218         -  }else if( pPk ){
128219         -    labelContinue = sqlite3VdbeMakeLabel(v);
128220         -    sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
128221         -    addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
128222         -    sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
128223         -    VdbeCoverage(v);
128224         -  }else{
128225         -    labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak,
128226         -                             regOldRowid);
128227         -    VdbeCoverage(v);
128228         -    sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid);
128229         -    VdbeCoverage(v);
128230 128836     }
128231 128837   
128232         -  /* If the record number will change, set register regNewRowid to
128233         -  ** contain the new value. If the record number is not being modified,
       128838  +  /* If the rowid value will change, set register regNewRowid to
       128839  +  ** contain the new value. If the rowid is not being modified,
128234 128840     ** then regNewRowid is the same register as regOldRowid, which is
128235 128841     ** already populated.  */
128236 128842     assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid );
128237 128843     if( chngRowid ){
128238 128844       sqlite3ExprCode(pParse, pRowidExpr, regNewRowid);
128239 128845       sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v);
128240 128846     }
................................................................................
128337 128943     if( !isView ){
128338 128944       int addr1 = 0;        /* Address of jump instruction */
128339 128945   
128340 128946       /* Do constraint checks. */
128341 128947       assert( regOldRowid>0 );
128342 128948       sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur,
128343 128949           regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace,
128344         -        aXRef);
       128950  +        aXRef, 0);
128345 128951   
128346 128952       /* Do FK constraint checks. */
128347 128953       if( hasFK ){
128348 128954         sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey);
128349 128955       }
128350 128956   
128351 128957       /* Delete the index entries associated with the current record.  */
................................................................................
128407 129013       if( hasFK ){
128408 129014         sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey);
128409 129015       }
128410 129016     }
128411 129017   
128412 129018     /* Increment the row counter 
128413 129019     */
128414         -  if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){
       129020  +  if( regRowCount ){
128415 129021       sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1);
128416 129022     }
128417 129023   
128418 129024     sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, 
128419 129025         TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue);
128420 129026   
128421 129027     /* Repeat the above with the next record to be updated, until
................................................................................
128434 129040     }
128435 129041     sqlite3VdbeResolveLabel(v, labelBreak);
128436 129042   
128437 129043     /* Update the sqlite_sequence table by storing the content of the
128438 129044     ** maximum rowid counter values recorded while inserting into
128439 129045     ** autoincrement tables.
128440 129046     */
128441         -  if( pParse->nested==0 && pParse->pTriggerTab==0 ){
       129047  +  if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){
128442 129048       sqlite3AutoincrementEnd(pParse);
128443 129049     }
128444 129050   
128445 129051     /*
128446         -  ** Return the number of rows that were changed. If this routine is 
128447         -  ** generating code because of a call to sqlite3NestedParse(), do not
128448         -  ** invoke the callback function.
       129052  +  ** Return the number of rows that were changed, if we are tracking
       129053  +  ** that information.
128449 129054     */
128450         -  if( (db->flags&SQLITE_CountRows) && !pParse->pTriggerTab && !pParse->nested ){
       129055  +  if( regRowCount ){
128451 129056       sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1);
128452 129057       sqlite3VdbeSetNumCols(v, 1);
128453 129058       sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
128454 129059     }
128455 129060   
128456 129061   update_cleanup:
128457 129062     sqlite3AuthContextPop(&sContext);
................................................................................
128564 129169       sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1);
128565 129170     }
128566 129171   
128567 129172     bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy);
128568 129173   
128569 129174     if( bOnePass ){
128570 129175       /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded
128571         -    ** above. Also, if this is a top-level parse (not a trigger), clear the
128572         -    ** multi-write flag so that the VM does not open a statement journal */
       129176  +    ** above. */
128573 129177       sqlite3VdbeChangeToNoop(v, addr);
128574         -    if( sqlite3IsToplevel(pParse) ){
128575         -      pParse->isMultiWrite = 0;
128576         -    }
128577 129178     }else{
128578 129179       /* Create a record from the argument register contents and insert it into
128579 129180       ** the ephemeral table. */
       129181  +    sqlite3MultiWrite(pParse);
128580 129182       sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec);
128581 129183   #ifdef SQLITE_DEBUG
128582 129184       /* Signal an assert() within OP_MakeRecord that it is allowed to
128583 129185       ** accept no-change records with serial_type 10 */
128584 129186       sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC);
128585 129187   #endif
128586 129188       sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid);
................................................................................
128615 129217     }else{
128616 129218       sqlite3WhereEnd(pWInfo);
128617 129219     }
128618 129220   }
128619 129221   #endif /* SQLITE_OMIT_VIRTUALTABLE */
128620 129222   
128621 129223   /************** End of update.c **********************************************/
       129224  +/************** Begin file upsert.c ******************************************/
       129225  +/*
       129226  +** 2018-04-12
       129227  +**
       129228  +** The author disclaims copyright to this source code.  In place of
       129229  +** a legal notice, here is a blessing:
       129230  +**
       129231  +**    May you do good and not evil.
       129232  +**    May you find forgiveness for yourself and forgive others.
       129233  +**    May you share freely, never taking more than you give.
       129234  +**
       129235  +*************************************************************************
       129236  +** This file contains code to implement various aspects of UPSERT
       129237  +** processing and handling of the Upsert object.
       129238  +*/
       129239  +/* #include "sqliteInt.h" */
       129240  +
       129241  +#ifndef SQLITE_OMIT_UPSERT
       129242  +/*
       129243  +** Free a list of Upsert objects
       129244  +*/
       129245  +SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){
       129246  +  if( p ){
       129247  +    sqlite3ExprListDelete(db, p->pUpsertTarget);
       129248  +    sqlite3ExprDelete(db, p->pUpsertTargetWhere);
       129249  +    sqlite3ExprListDelete(db, p->pUpsertSet);
       129250  +    sqlite3ExprDelete(db, p->pUpsertWhere);
       129251  +    sqlite3DbFree(db, p);
       129252  +  }
       129253  +}
       129254  +
       129255  +/*
       129256  +** Duplicate an Upsert object.
       129257  +*/
       129258  +SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){
       129259  +  if( p==0 ) return 0;
       129260  +  return sqlite3UpsertNew(db,
       129261  +           sqlite3ExprListDup(db, p->pUpsertTarget, 0),
       129262  +           sqlite3ExprDup(db, p->pUpsertTargetWhere, 0),
       129263  +           sqlite3ExprListDup(db, p->pUpsertSet, 0),
       129264  +           sqlite3ExprDup(db, p->pUpsertWhere, 0)
       129265  +         );
       129266  +}
       129267  +
       129268  +/*
       129269  +** Create a new Upsert object.
       129270  +*/
       129271  +SQLITE_PRIVATE Upsert *sqlite3UpsertNew(
       129272  +  sqlite3 *db,           /* Determines which memory allocator to use */
       129273  +  ExprList *pTarget,     /* Target argument to ON CONFLICT, or NULL */
       129274  +  Expr *pTargetWhere,    /* Optional WHERE clause on the target */
       129275  +  ExprList *pSet,        /* UPDATE columns, or NULL for a DO NOTHING */
       129276  +  Expr *pWhere           /* WHERE clause for the ON CONFLICT UPDATE */
       129277  +){
       129278  +  Upsert *pNew;
       129279  +  pNew = sqlite3DbMallocRaw(db, sizeof(Upsert));
       129280  +  if( pNew==0 ){
       129281  +    sqlite3ExprListDelete(db, pTarget);
       129282  +    sqlite3ExprDelete(db, pTargetWhere);
       129283  +    sqlite3ExprListDelete(db, pSet);
       129284  +    sqlite3ExprDelete(db, pWhere);
       129285  +    return 0;
       129286  +  }else{
       129287  +    pNew->pUpsertTarget = pTarget;
       129288  +    pNew->pUpsertTargetWhere = pTargetWhere;
       129289  +    pNew->pUpsertSet = pSet;
       129290  +    pNew->pUpsertWhere = pWhere;
       129291  +    pNew->pUpsertIdx = 0;
       129292  +  }
       129293  +  return pNew;
       129294  +}
       129295  +
       129296  +/*
       129297  +** Analyze the ON CONFLICT clause described by pUpsert.  Resolve all
       129298  +** symbols in the conflict-target.
       129299  +**
       129300  +** Return SQLITE_OK if everything works, or an error code is something
       129301  +** is wrong.
       129302  +*/
       129303  +SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(
       129304  +  Parse *pParse,     /* The parsing context */
       129305  +  SrcList *pTabList, /* Table into which we are inserting */
       129306  +  Upsert *pUpsert    /* The ON CONFLICT clauses */
       129307  +){
       129308  +  Table *pTab;            /* That table into which we are inserting */
       129309  +  int rc;                 /* Result code */
       129310  +  int iCursor;            /* Cursor used by pTab */
       129311  +  Index *pIdx;            /* One of the indexes of pTab */
       129312  +  ExprList *pTarget;      /* The conflict-target clause */
       129313  +  Expr *pTerm;            /* One term of the conflict-target clause */
       129314  +  NameContext sNC;        /* Context for resolving symbolic names */
       129315  +  Expr sCol[2];           /* Index column converted into an Expr */
       129316  +
       129317  +  assert( pTabList->nSrc==1 );
       129318  +  assert( pTabList->a[0].pTab!=0 );
       129319  +  assert( pUpsert!=0 );
       129320  +  assert( pUpsert->pUpsertTarget!=0 );
       129321  +
       129322  +  /* Resolve all symbolic names in the conflict-target clause, which
       129323  +  ** includes both the list of columns and the optional partial-index
       129324  +  ** WHERE clause.
       129325  +  */
       129326  +  memset(&sNC, 0, sizeof(sNC));
       129327  +  sNC.pParse = pParse;
       129328  +  sNC.pSrcList = pTabList;
       129329  +  rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
       129330  +  if( rc ) return rc;
       129331  +  rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere);
       129332  +  if( rc ) return rc;
       129333  +
       129334  +  /* Check to see if the conflict target matches the rowid. */  
       129335  +  pTab = pTabList->a[0].pTab;
       129336  +  pTarget = pUpsert->pUpsertTarget;
       129337  +  iCursor = pTabList->a[0].iCursor;
       129338  +  if( HasRowid(pTab) 
       129339  +   && pTarget->nExpr==1
       129340  +   && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN
       129341  +   && pTerm->iColumn==XN_ROWID
       129342  +  ){
       129343  +    /* The conflict-target is the rowid of the primary table */
       129344  +    assert( pUpsert->pUpsertIdx==0 );
       129345  +    return SQLITE_OK;
       129346  +  }
       129347  +
       129348  +  /* Initialize sCol[0..1] to be an expression parse tree for a
       129349  +  ** single column of an index.  The sCol[0] node will be the TK_COLLATE
       129350  +  ** operator and sCol[1] will be the TK_COLUMN operator.  Code below
       129351  +  ** will populate the specific collation and column number values
       129352  +  ** prior to comparing against the conflict-target expression.
       129353  +  */
       129354  +  memset(sCol, 0, sizeof(sCol));
       129355  +  sCol[0].op = TK_COLLATE;
       129356  +  sCol[0].pLeft = &sCol[1];
       129357  +  sCol[1].op = TK_COLUMN;
       129358  +  sCol[1].iTable = pTabList->a[0].iCursor;
       129359  +
       129360  +  /* Check for matches against other indexes */
       129361  +  for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
       129362  +    int ii, jj, nn;
       129363  +    if( !IsUniqueIndex(pIdx) ) continue;
       129364  +    if( pTarget->nExpr!=pIdx->nKeyCol ) continue;
       129365  +    if( pIdx->pPartIdxWhere ){
       129366  +      if( pUpsert->pUpsertTargetWhere==0 ) continue;
       129367  +      if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere,
       129368  +                             pIdx->pPartIdxWhere, iCursor)!=0 ){
       129369  +        continue;
       129370  +      }
       129371  +    }
       129372  +    nn = pIdx->nKeyCol;
       129373  +    for(ii=0; ii<nn; ii++){
       129374  +      Expr *pExpr;
       129375  +      sCol[0].u.zToken = (char*)pIdx->azColl[ii];
       129376  +      if( pIdx->aiColumn[ii]==XN_EXPR ){
       129377  +        assert( pIdx->aColExpr!=0 );
       129378  +        assert( pIdx->aColExpr->nExpr>ii );
       129379  +        pExpr = pIdx->aColExpr->a[ii].pExpr;
       129380  +        if( pExpr->op!=TK_COLLATE ){
       129381  +          sCol[0].pLeft = pExpr;
       129382  +          pExpr = &sCol[0];
       129383  +        }
       129384  +      }else{
       129385  +        sCol[0].pLeft = &sCol[1];
       129386  +        sCol[1].iColumn = pIdx->aiColumn[ii];
       129387  +        pExpr = &sCol[0];
       129388  +      }
       129389  +      for(jj=0; jj<nn; jj++){
       129390  +        if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){
       129391  +          break;  /* Column ii of the index matches column jj of target */
       129392  +        }
       129393  +      }
       129394  +      if( jj>=nn ){
       129395  +        /* The target contains no match for column jj of the index */
       129396  +        break;
       129397  +      }
       129398  +    }
       129399  +    if( ii<nn ){
       129400  +      /* Column ii of the index did not match any term of the conflict target.
       129401  +      ** Continue the search with the next index. */
       129402  +      continue;
       129403  +    }
       129404  +    pUpsert->pUpsertIdx = pIdx;
       129405  +    return SQLITE_OK;
       129406  +  }
       129407  +  sqlite3ErrorMsg(pParse, "ON CONFLICT clause does not match any "
       129408  +                          "PRIMARY KEY or UNIQUE constraint");
       129409  +  return SQLITE_ERROR;
       129410  +}
       129411  +
       129412  +/*
       129413  +** Generate bytecode that does an UPDATE as part of an upsert.
       129414  +**
       129415  +** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK.
       129416  +** In this case parameter iCur is a cursor open on the table b-tree that
       129417  +** currently points to the conflicting table row. Otherwise, if pIdx
       129418  +** is not NULL, then pIdx is the constraint that failed and iCur is a
       129419  +** cursor points to the conflicting row.
       129420  +*/
       129421  +SQLITE_PRIVATE void sqlite3UpsertDoUpdate(
       129422  +  Parse *pParse,        /* The parsing and code-generating context */
       129423  +  Upsert *pUpsert,      /* The ON CONFLICT clause for the upsert */
       129424  +  Table *pTab,          /* The table being updated */
       129425  +  Index *pIdx,          /* The UNIQUE constraint that failed */
       129426  +  int iCur              /* Cursor for pIdx (or pTab if pIdx==NULL) */
       129427  +){
       129428  +  Vdbe *v = pParse->pVdbe;
       129429  +  sqlite3 *db = pParse->db;
       129430  +  SrcList *pSrc;            /* FROM clause for the UPDATE */
       129431  +  int iDataCur = pUpsert->iDataCur;
       129432  +
       129433  +  assert( v!=0 );
       129434  +  VdbeNoopComment((v, "Begin DO UPDATE of UPSERT"));
       129435  +  if( pIdx && iCur!=iDataCur ){
       129436  +    if( HasRowid(pTab) ){
       129437  +      int regRowid = sqlite3GetTempReg(pParse);
       129438  +      sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid);
       129439  +      sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid);
       129440  +      VdbeCoverage(v);
       129441  +      sqlite3ReleaseTempReg(pParse, regRowid);
       129442  +    }else{
       129443  +      Index *pPk = sqlite3PrimaryKeyIndex(pTab);
       129444  +      int nPk = pPk->nKeyCol;
       129445  +      int iPk = pParse->nMem+1;
       129446  +      int i;
       129447  +      pParse->nMem += nPk;
       129448  +      for(i=0; i<nPk; i++){
       129449  +        int k;
       129450  +        assert( pPk->aiColumn[i]>=0 );
       129451  +        k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
       129452  +        sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i);
       129453  +        VdbeComment((v, "%s.%s", pIdx->zName,
       129454  +                    pTab->aCol[pPk->aiColumn[i]].zName));
       129455  +      }
       129456  +      i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk);
       129457  +      VdbeCoverage(v);
       129458  +      sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, 
       129459  +            "corrupt database", P4_STATIC);
       129460  +      sqlite3VdbeJumpHere(v, i);
       129461  +    }
       129462  +  }
       129463  +  /* pUpsert does not own pUpsertSrc - the outer INSERT statement does.  So
       129464  +  ** we have to make a copy before passing it down into sqlite3Update() */
       129465  +  pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
       129466  +  sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet,
       129467  +      pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert);
       129468  +  pUpsert->pUpsertSet = 0;    /* Will have been deleted by sqlite3Update() */
       129469  +  pUpsert->pUpsertWhere = 0;  /* Will have been deleted by sqlite3Update() */
       129470  +  VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
       129471  +}
       129472  +
       129473  +#endif /* SQLITE_OMIT_UPSERT */
       129474  +
       129475  +/************** End of upsert.c **********************************************/
128622 129476   /************** Begin file vacuum.c ******************************************/
128623 129477   /*
128624 129478   ** 2003 April 6
128625 129479   **
128626 129480   ** The author disclaims copyright to this source code.  In place of
128627 129481   ** a legal notice, here is a blessing:
128628 129482   **
................................................................................
132016 132870     addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
132017 132871     addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);
132018 132872   
132019 132873     /* If this is the right table of a LEFT OUTER JOIN, allocate and
132020 132874     ** initialize a memory cell that records if this table matches any
132021 132875     ** row of the left table of the join.
132022 132876     */
       132877  +  assert( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)
       132878  +       || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
       132879  +  );
132023 132880     if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
132024 132881       pLevel->iLeftJoin = ++pParse->nMem;
132025 132882       sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
132026 132883       VdbeComment((v, "init LEFT JOIN no-match flag"));
132027 132884     }
132028 132885   
132029 132886     /* Compute a safe address to jump to if we discover that the table for
................................................................................
132549 133406         sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont,
132550 133407                              iRowidReg, pPk->nKeyCol); VdbeCoverage(v);
132551 133408       }
132552 133409   
132553 133410       /* If pIdx is an index on one or more expressions, then look through
132554 133411       ** all the expressions in pWInfo and try to transform matching expressions
132555 133412       ** into reference to index columns.
       133413  +    **
       133414  +    ** Do not do this for the RHS of a LEFT JOIN. This is because the 
       133415  +    ** expression may be evaluated after OP_NullRow has been executed on
       133416  +    ** the cursor. In this case it is important to do the full evaluation,
       133417  +    ** as the result of the expression may not be NULL, even if all table
       133418  +    ** column values are.  https://www.sqlite.org/src/info/7fa8049685b50b5a
132556 133419       */
132557         -    whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
132558         -
       133420  +    if( pLevel->iLeftJoin==0 ){
       133421  +      whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
       133422  +    }
132559 133423   
132560 133424       /* Record the instruction used to terminate the loop. */
132561 133425       if( pLoop->wsFlags & WHERE_ONEROW ){
132562 133426         pLevel->op = OP_Noop;
132563 133427       }else if( bRev ){
132564 133428         pLevel->op = OP_Prev;
132565 133429       }else{
................................................................................
132707 133571       ** See ticket http://www.sqlite.org/src/info/f2369304e4
132708 133572       */
132709 133573       if( pWC->nTerm>1 ){
132710 133574         int iTerm;
132711 133575         for(iTerm=0; iTerm<pWC->nTerm; iTerm++){
132712 133576           Expr *pExpr = pWC->a[iTerm].pExpr;
132713 133577           if( &pWC->a[iTerm] == pTerm ) continue;
132714         -        if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
132715 133578           testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
132716 133579           testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
132717 133580           if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
132718 133581           if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
132719 133582           testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
132720 133583           pExpr = sqlite3ExprDup(db, pExpr, 0);
132721 133584           pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
................................................................................
132732 133595       wctrlFlags =  WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE);
132733 133596       for(ii=0; ii<pOrWc->nTerm; ii++){
132734 133597         WhereTerm *pOrTerm = &pOrWc->a[ii];
132735 133598         if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
132736 133599           WhereInfo *pSubWInfo;           /* Info for single OR-term scan */
132737 133600           Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
132738 133601           int jmp1 = 0;                   /* Address of jump operation */
132739         -        if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
       133602  +        assert( (pTabItem[0].fg.jointype & JT_LEFT)==0 
       133603  +             || ExprHasProperty(pOrExpr, EP_FromJoin) 
       133604  +        );
       133605  +        if( pAndExpr ){
132740 133606             pAndExpr->pLeft = pOrExpr;
132741 133607             pOrExpr = pAndExpr;
132742 133608           }
132743 133609           /* Loop through table entries that match term pOrTerm. */
132744 133610           WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
132745 133611           pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
132746 133612                                         wctrlFlags, iCovCur);
................................................................................
132915 133781           testcase( pWInfo->untestedTerms==0
132916 133782               && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 );
132917 133783           pWInfo->untestedTerms = 1;
132918 133784           continue;
132919 133785         }
132920 133786         pE = pTerm->pExpr;
132921 133787         assert( pE!=0 );
132922         -      if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
       133788  +      if( (pTabItem->fg.jointype&JT_LEFT) && !ExprHasProperty(pE,EP_FromJoin) ){
132923 133789           continue;
132924 133790         }
132925 133791         
132926 133792         if( iLoop==1 && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){
132927 133793           iNext = 2;
132928 133794           continue;
132929 133795         }
................................................................................
133842 134708           testcase( idxNew==0 );
133843 134709           exprAnalyze(pSrc, pWC, idxNew);
133844 134710           pTerm = &pWC->a[idxTerm];
133845 134711           markTermAsChild(pWC, idxNew, idxTerm);
133846 134712         }else{
133847 134713           sqlite3ExprListDelete(db, pList);
133848 134714         }
133849         -      pTerm->eOperator = WO_NOOP;  /* case 1 trumps case 3 */
133850 134715       }
133851 134716     }
133852 134717   }
133853 134718   #endif /* !SQLITE_OMIT_OR_OPTIMIZATION && !SQLITE_OMIT_SUBQUERY */
133854 134719   
133855 134720   /*
133856 134721   ** We already know that pExpr is a binary operator where both operands are
................................................................................
136979 137844       }
136980 137845       if( pTerm->prereqRight & pNew->maskSelf ) continue;
136981 137846   
136982 137847       /* Do not allow the upper bound of a LIKE optimization range constraint
136983 137848       ** to mix with a lower range bound from some other source */
136984 137849       if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
136985 137850   
136986         -    /* Do not allow IS constraints from the WHERE clause to be used by the
       137851  +    /* Do not allow constraints from the WHERE clause to be used by the
136987 137852       ** right table of a LEFT JOIN.  Only constraints in the ON clause are
136988 137853       ** allowed */
136989 137854       if( (pSrc->fg.jointype & JT_LEFT)!=0
136990 137855        && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
136991         -     && (eOp & (WO_IS|WO_ISNULL))!=0
136992 137856       ){
136993         -      testcase( eOp & WO_IS );
136994         -      testcase( eOp & WO_ISNULL );
136995 137857         continue;
136996 137858       }
136997 137859   
136998 137860       if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){
136999 137861         pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;
137000 137862       }else{
137001 137863         pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;
................................................................................
139981 140843   **                       This is typically a union of many types, one of
139982 140844   **                       which is sqlite3ParserTOKENTYPE.  The entry in the union
139983 140845   **                       for terminal symbols is called "yy0".
139984 140846   **    YYSTACKDEPTH       is the maximum depth of the parser's stack.  If
139985 140847   **                       zero the stack is dynamically sized using realloc()
139986 140848   **    sqlite3ParserARG_SDECL     A static variable declaration for the %extra_argument
139987 140849   **    sqlite3ParserARG_PDECL     A parameter declaration for the %extra_argument
       140850  +**    sqlite3ParserARG_PARAM     Code to pass %extra_argument as a subroutine parameter
139988 140851   **    sqlite3ParserARG_STORE     Code to store %extra_argument into yypParser
139989 140852   **    sqlite3ParserARG_FETCH     Code to extract %extra_argument from yypParser
       140853  +**    sqlite3ParserCTX_*         As sqlite3ParserARG_ except for %extra_context
139990 140854   **    YYERRORSYMBOL      is the code number of the error symbol.  If not
139991 140855   **                       defined, then do no error processing.
139992 140856   **    YYNSTATE           the combined number of states.
139993 140857   **    YYNRULE            the number of rules in the grammar
139994 140858   **    YYNTOKEN           Number of terminal symbols
139995 140859   **    YY_MAX_SHIFT       Maximum value for shift actions
139996 140860   **    YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
................................................................................
140002 140866   **    YY_MAX_REDUCE      Maximum value for reduce actions
140003 140867   */
140004 140868   #ifndef INTERFACE
140005 140869   # define INTERFACE 1
140006 140870   #endif
140007 140871   /************* Begin control #defines *****************************************/
140008 140872   #define YYCODETYPE unsigned char
140009         -#define YYNOCODE 253
       140873  +#define YYNOCODE 255
140010 140874   #define YYACTIONTYPE unsigned short int
140011         -#define YYWILDCARD 83
       140875  +#define YYWILDCARD 84
140012 140876   #define sqlite3ParserTOKENTYPE Token
140013 140877   typedef union {
140014 140878     int yyinit;
140015 140879     sqlite3ParserTOKENTYPE yy0;
140016         -  int yy4;
140017         -  struct TrigEvent yy90;
140018         -  TriggerStep* yy203;
140019         -  struct {int value; int mask;} yy215;
140020         -  SrcList* yy259;
140021         -  Expr* yy314;
140022         -  ExprList* yy322;
140023         -  const char* yy336;
140024         -  IdList* yy384;
140025         -  Select* yy387;
140026         -  With* yy451;
       140880  +  const char* yy36;
       140881  +  TriggerStep* yy47;
       140882  +  With* yy91;
       140883  +  struct {int value; int mask;} yy107;
       140884  +  Expr* yy182;
       140885  +  Upsert* yy198;
       140886  +  ExprList* yy232;
       140887  +  struct TrigEvent yy300;
       140888  +  Select* yy399;
       140889  +  SrcList* yy427;
       140890  +  int yy502;
       140891  +  IdList* yy510;
140027 140892   } YYMINORTYPE;
140028 140893   #ifndef YYSTACKDEPTH
140029 140894   #define YYSTACKDEPTH 100
140030 140895   #endif
140031         -#define sqlite3ParserARG_SDECL Parse *pParse;
140032         -#define sqlite3ParserARG_PDECL ,Parse *pParse
140033         -#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
140034         -#define sqlite3ParserARG_STORE yypParser->pParse = pParse
       140896  +#define sqlite3ParserARG_SDECL
       140897  +#define sqlite3ParserARG_PDECL
       140898  +#define sqlite3ParserARG_PARAM
       140899  +#define sqlite3ParserARG_FETCH
       140900  +#define sqlite3ParserARG_STORE
       140901  +#define sqlite3ParserCTX_SDECL Parse *pParse;
       140902  +#define sqlite3ParserCTX_PDECL ,Parse *pParse
       140903  +#define sqlite3ParserCTX_PARAM ,pParse
       140904  +#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
       140905  +#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
140035 140906   #define YYFALLBACK 1
140036         -#define YYNSTATE             472
140037         -#define YYNRULE              333
140038         -#define YYNTOKEN             143
140039         -#define YY_MAX_SHIFT         471
140040         -#define YY_MIN_SHIFTREDUCE   681
140041         -#define YY_MAX_SHIFTREDUCE   1013
140042         -#define YY_ERROR_ACTION      1014
140043         -#define YY_ACCEPT_ACTION     1015
140044         -#define YY_NO_ACTION         1016
140045         -#define YY_MIN_REDUCE        1017
140046         -#define YY_MAX_REDUCE        1349
       140907  +#define YYNSTATE             490
       140908  +#define YYNRULE              341
       140909  +#define YYNTOKEN             145
       140910  +#define YY_MAX_SHIFT         489
       140911  +#define YY_MIN_SHIFTREDUCE   705
       140912  +#define YY_MAX_SHIFTREDUCE   1045
       140913  +#define YY_ERROR_ACTION      1046
       140914  +#define YY_ACCEPT_ACTION     1047
       140915  +#define YY_NO_ACTION         1048
       140916  +#define YY_MIN_REDUCE        1049
       140917  +#define YY_MAX_REDUCE        1389
140047 140918   /************* End control #defines *******************************************/
140048 140919   
140049 140920   /* Define the yytestcase() macro to be a no-op if is not already defined
140050 140921   ** otherwise.
140051 140922   **
140052 140923   ** Applications can choose to define yytestcase() in the %include section
140053 140924   ** to a macro that can assist in verifying code coverage.  For production
................................................................................
140105 140976   **  yy_shift_ofst[]    For each state, the offset into yy_action for
140106 140977   **                     shifting terminals.
140107 140978   **  yy_reduce_ofst[]   For each state, the offset into yy_action for
140108 140979   **                     shifting non-terminals after a reduce.
140109 140980   **  yy_default[]       Default action for each state.
140110 140981   **
140111 140982   *********** Begin parsing tables **********************************************/
140112         -#define YY_ACTTAB_COUNT (1566)
       140983  +#define YY_ACTTAB_COUNT (1657)
140113 140984   static const YYACTIONTYPE yy_action[] = {
140114         - /*     0 */  1169, 1015,  167,  167,    1,  168,  466, 1313,  466, 1083,
140115         - /*    10 */  1062,  466,   97,   94,  183, 1057,  466,  329, 1083,  342,
140116         - /*    20 */    97,   94,  183,  459,  459,  459,  436,   57,   57,   57,
140117         - /*    30 */    57,  807,   57,   57,  367,  367,  367,   57,   57,  808,
140118         - /*    40 */  1270, 1088, 1088,  104,  105,   95,  991,  991,  868,  871,
140119         - /*    50 */   860,  860,  102,  102,  103,  103,  103,  103,  233,  233,
140120         - /*    60 */   326, 1011,  449,  437,  449,  446,  351,  449,  461, 1142,
140121         - /*    70 */   463,  342,  449,  426, 1316,  209,  180,  742,   80,  299,
140122         - /*    80 */   857,  857,  869,  872,  101,  101,  101,  101,  100,  100,
140123         - /*    90 */    99,   99,   99,   98,  368,  104,  105,   95,  991,  991,
140124         - /*   100 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
140125         - /*   110 */    99,   99,   99,   98,  368,  355,   97,   94,  183,  228,
140126         - /*   120 */   106, 1012,  407,  342,  101,  101,  101,  101,  100,  100,
140127         - /*   130 */    99,   99,   99,   98,  368,  861,  101,  101,  101,  101,
140128         - /*   140 */   100,  100,   99,   99,   99,   98,  368,  104,  105,   95,
140129         - /*   150 */   991,  991,  868,  871,  860,  860,  102,  102,  103,  103,
140130         - /*   160 */   103,  103,  201,  368,  375,  420,  417,  416,  387,  273,
140131         - /*   170 */    65,   97,   94,  183,  168,  342,  415,  951, 1343,  396,
140132         - /*   180 */    66, 1343,  320,  959,  371,  970,  334,  340,  101,  101,
140133         - /*   190 */   101,  101,  100,  100,   99,   99,   99,   98,  368,  104,
140134         - /*   200 */   105,   95,  991,  991,  868,  871,  860,  860,  102,  102,
140135         - /*   210 */   103,  103,  103,  103,  373,  100,  100,   99,   99,   99,
140136         - /*   220 */    98,  368,  970,  971,  972,  201, 1100,  342,  420,  417,
140137         - /*   230 */   416,  287,  366,  365,  337,  970, 1162,  463,  949,  415,
140138         - /*   240 */   101,  101,  101,  101,  100,  100,   99,   99,   99,   98,
140139         - /*   250 */   368,  104,  105,   95,  991,  991,  868,  871,  860,  860,
140140         - /*   260 */   102,  102,  103,  103,  103,  103,  777,  241,  233,  233,
140141         - /*   270 */     9,  847,  970,  971,  972,  390,  998, 1141,  998,  342,
140142         - /*   280 */   463,  252,  829,  719,   98,  368,  840,  298,  338,  142,
140143         - /*   290 */   839,  339,  101,  101,  101,  101,  100,  100,   99,   99,
140144         - /*   300 */    99,   98,  368,  104,  105,   95,  991,  991,  868,  871,
140145         - /*   310 */   860,  860,  102,  102,  103,  103,  103,  103,  272,  466,
140146         - /*   320 */   392,  839,  839,  841,   97,   94,  183,  390, 1317,  253,
140147         - /*   330 */   456,  342,  125,  166,  807,  712,  208,  407,  386,  970,
140148         - /*   340 */    57,   57,  808,  238,  101,  101,  101,  101,  100,  100,
140149         - /*   350 */    99,   99,   99,   98,  368,  104,  105,   95,  991,  991,
140150         - /*   360 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
140151         - /*   370 */   466,  108,  466,  267,  465,  442,  970,  971,  972,  261,
140152         - /*   380 */   951, 1344,  909,  342, 1344,  142,  829,  848, 1292,  959,
140153         - /*   390 */   371,   55,   55,   57,   57,  242,  101,  101,  101,  101,
140154         - /*   400 */   100,  100,   99,   99,   99,   98,  368,  104,  105,   95,
140155         - /*   410 */   991,  991,  868,  871,  860,  860,  102,  102,  103,  103,
140156         - /*   420 */   103,  103,  272,  382,  262,  253,  456,  310,  364,  253,
140157         - /*   430 */   456,   86,  264,   84,  266,  342,  441,  176,  175,  834,
140158         - /*   440 */   464,  949,  767,  767,  332,  313, 1094,  396,  101,  101,
140159         - /*   450 */   101,  101,  100,  100,   99,   99,   99,   98,  368,  104,
140160         - /*   460 */   105,   95,  991,  991,  868,  871,  860,  860,  102,  102,
140161         - /*   470 */   103,  103,  103,  103,  227,  227,  233,  233,  233,  233,
140162         - /*   480 */   387,  273,  234,  234,  326,  950,  463,  342,  463,  298,
140163         - /*   490 */   463,  914,  914,  404,  463, 1037,  123,  265,   27,  970,
140164         - /*   500 */   101,  101,  101,  101,  100,  100,   99,   99,   99,   98,
140165         - /*   510 */   368,  104,  105,   95,  991,  991,  868,  871,  860,  860,
140166         - /*   520 */   102,  102,  103,  103,  103,  103,  435,  233,  233,  466,
140167         - /*   530 */   285,  686,  687,  688,  127,  271,  970,  971,  972,  463,
140168         - /*   540 */  1345,  327,  342,  407,  157, 1012,  988,   13,   13,  181,
140169         - /*   550 */    41,   41,  101,  101,  101,  101,  100,  100,   99,   99,
140170         - /*   560 */    99,   98,  368,  715,  794,  378,  104,  105,   95,  991,
140171         - /*   570 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
140172         - /*   580 */   103,  970,  378,  377,  346,  239,  847, 1086, 1086,  280,
140173         - /*   590 */  1169,  283,  204,  203,  202,  177,  298,  342,  407,  298,
140174         - /*   600 */   715,  840,  169,  299,  407,  839,   82,  101,  101,  101,
140175         - /*   610 */   101,  100,  100,   99,   99,   99,   98,  368,  970,  971,
140176         - /*   620 */   972,  104,  105,   95,  991,  991,  868,  871,  860,  860,
140177         - /*   630 */   102,  102,  103,  103,  103,  103,  839,  839,  841,  362,
140178         - /*   640 */   240,  124, 1169,  172,  126,  378, 1269, 1169, 1066,  342,
140179         - /*   650 */   253,  456,  407,  407,  407,  396,  352,  401,  407,  429,
140180         - /*   660 */   398,   85,  101,  101,  101,  101,  100,  100,   99,   99,
140181         - /*   670 */    99,   98,  368,  104,  105,   95,  991,  991,  868,  871,
140182         - /*   680 */   860,  860,  102,  102,  103,  103,  103,  103, 1169,  466,
140183         - /*   690 */   230,  233,  233,  792, 1235, 1095, 1091, 1293,    1,   77,
140184         - /*   700 */   278,  342,  205,  463,  974,  911, 1040,  348,  353,  911,
140185         - /*   710 */    42,   42,   79,  403,  101,  101,  101,  101,  100,  100,
140186         - /*   720 */    99,   99,   99,   98,  368,  104,   93,   95,  991,  991,
140187         - /*   730 */   868,  871,  860,  860,  102,  102,  103,  103,  103,  103,
140188         - /*   740 */   402,    9,  974,  243,  772,  458,  348,  232,  180,  771,
140189         - /*   750 */   946,  312,  342,  328,  363,  349,  143,  831,  389, 1278,
140190         - /*   760 */   211,  211,   21,  347,  432,  182,  101,  101,  101,  101,
140191         - /*   770 */   100,  100,   99,   99,   99,   98,  368,  105,   95,  991,
140192         - /*   780 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
140193         - /*   790 */   103,  792,  724,   22,  732,  731,  233,  233, 1239,  256,
140194         - /*   800 */   391,  274,  342,  211,   79,  360,  257,  413,  463,  397,
140195         - /*   810 */   207,  288,  260,  450,   79, 1239, 1241,  101,  101,  101,
140196         - /*   820 */   101,  100,  100,   99,   99,   99,   98,  368,   95,  991,
140197         - /*   830 */   991,  868,  871,  860,  860,  102,  102,  103,  103,  103,
140198         - /*   840 */   103,   91,  457,  296,    3,  233,  233,    5,  438,  212,
140199         - /*   850 */   331,  394,  739,  740,  295,  898,  894,  463,  460,  207,
140200         - /*   860 */   801, 1237,  722,  211,  698,  843, 1283,  101,  101,  101,
140201         - /*   870 */   101,  100,  100,   99,   99,   99,   98,  368, 1239,  380,
140202         - /*   880 */   357,  369,  233,  233,  989,  219,  236,  297,  423,  292,
140203         - /*   890 */   422,  206,  454,  898,  463,  970,   91,  457,  290,    3,
140204         - /*   900 */   722,  142,  268,  843,  847,  466, 1258,  149,  388,  425,
140205         - /*   910 */    88,   89,  769,  460,  930,   87,  447,   90,  369,  468,
140206         - /*   920 */   467,  385,  989,  839, 1257,  439,   57,   57,  395,  931,
140207         - /*   930 */  1065,  158,  970,  971,  972,  772,  369,  471, 1019,  399,
140208         - /*   940 */   771,  253,  456,  254,  932,  119,  891,  454,  233,  233,
140209         - /*   950 */     4,  970, 1096,  275,  839,  839,  841,  842,   19,  847,
140210         - /*   960 */   463,  449,  448,  163,  453,   88,   89,  776,  970, 1127,
140211         - /*   970 */   279,  930,   90,  369,  468,  467,   91,  457,  839,    3,
140212         - /*   980 */   235, 1064,  466, 1228,  233,  233,  931,  970,  970,  971,
140213         - /*   990 */   972,  970,  908,  460,  908,    2,  463,   81,  457,  212,
140214         - /*  1000 */     3,  932,  282,   10,   10,  970,  971,  972,  189,  839,
140215         - /*  1010 */   839,  841,  842,   19,  460,  284,  369,  354,  907,  286,
140216         - /*  1020 */   907,  753,  466, 1079,  970,  971,  972,  454,  970,  971,
140217         - /*  1030 */   972,  754,  970, 1063,  989,  372,  792,  369, 1118,  847,
140218         - /*  1040 */   291,  452,  466,   10,   10,   88,   89,  142,  454,  168,
140219         - /*  1050 */   300,  412,   90,  369,  468,  467,  793,  356,  839,  706,
140220         - /*  1060 */   847,  341,  121,   10,   10,  301,   88,   89,  379,  970,
140221         - /*  1070 */   971,  972,  989,   90,  369,  468,  467,  244,  205,  839,
140222         - /*  1080 */  1306,  245, 1135,  245,  250, 1168, 1114,  253,  456,  839,
140223         - /*  1090 */   839,  841,  842,   19, 1125,  237,  122,  451, 1174,  733,
140224         - /*  1100 */   324,  324,  323,  222,  321,  466, 1046,  695,  182,  225,
140225         - /*  1110 */   839,  839,  841,  842,   19,  103,  103,  103,  103,   96,
140226         - /*  1120 */   185,  466,  259, 1039, 1028,  170,   10,   10, 1027,  421,
140227         - /*  1130 */   258, 1029, 1300,  708,  792,  466,  408,  734,    8,  347,
140228         - /*  1140 */   444,  174,   12,   12,  290,  101,  101,  101,  101,  100,
140229         - /*  1150 */   100,   99,   99,   99,   98,  368,   32,   32,  466,  187,
140230         - /*  1160 */   466, 1111,  103,  103,  103,  103,  188,  466,  325,  138,
140231         - /*  1170 */   186,  708,  303,  305,  307,  358,  970,  270,  393,   43,
140232         - /*  1180 */    43,   44,   44, 1157,  333,  178,  418,  294,   45,   45,
140233         - /*  1190 */  1232,  318,  101,  101,  101,  101,  100,  100,   99,   99,
140234         - /*  1200 */    99,   98,  368,  381,  343,  366,  365,  466,  263,  253,
140235         - /*  1210 */   456,  466, 1062,  970,  971,  972, 1231,  997,  309,  466,
140236         - /*  1220 */   455,  466,  427,  466,  995,  173,  996, 1303,   46,   46,
140237         - /*  1230 */   145,  376,   37,   37, 1006, 1277,  466,  214, 1275,   64,
140238         - /*  1240 */    47,   47,   33,   33,   34,   34, 1003,   67,  466,  998,
140239         - /*  1250 */   350,  998,  466,  155,  233,  233,  466,   36,   36,   24,
140240         - /*  1260 */   140,   77, 1154,  466,  383,  466,  463,  428,  466,   48,
140241         - /*  1270 */    48,  466,  147,   49,   49,  466,  150,   50,   50,  466,
140242         - /*  1280 */   151,  152,  466,  384,   11,   11,   51,   51,  466,  110,
140243         - /*  1290 */   110,  153,   52,   52,  411,  466,   38,   38,  466,  191,
140244         - /*  1300 */    53,   53,  466,   54,   54,  466,  400,  466,  330,   39,
140245         - /*  1310 */    39,  466, 1164,  466,   25,  466,   56,   56,  466,  131,
140246         - /*  1320 */   131,   72,  466,  132,  132,  159,  133,  133,   61,   61,
140247         - /*  1330 */  1226,  195,   40,   40,  111,  111,   58,   58,  406,  112,
140248         - /*  1340 */   112,  466,  277,  113,  113,  466,  226,  466, 1246,  466,
140249         - /*  1350 */   197,  466,  164,  466,  409,  466,  198,  466,  199,  466,
140250         - /*  1360 */   335,  281,  109,  109,  466, 1030,  130,  130,  129,  129,
140251         - /*  1370 */   117,  117,  116,  116,  114,  114,  115,  115,   60,   60,
140252         - /*  1380 */    62,   62,  466,  359,  466,   59,   59,  424, 1082, 1081,
140253         - /*  1390 */  1080,  724, 1073, 1054,  336,  293, 1053, 1052, 1315,  431,
140254         - /*  1400 */   361,   76,  248,   31,   31,   35,   35, 1072,  249,  440,
140255         - /*  1410 */   302,  434,  213, 1122,    6,  311, 1212,  107,   83,  251,
140256         - /*  1420 */    78, 1123,  445,  220,  443, 1036,  304,   23, 1121,  469,
140257         - /*  1430 */   965,  221,  223, 1104,  314,  224,  344,  317,  315,  316,
140258         - /*  1440 */   470,  306, 1025, 1120,  308, 1262, 1020,  134,  120,  246,
140259         - /*  1450 */   682,  370,  171,  255, 1263,  135,  184, 1261, 1260,  374,
140260         - /*  1460 */   118,  906,  904,  827, 1050,  146,  136,  137,  148, 1049,
140261         - /*  1470 */    63, 1047,  756,  190,  269,  920,  154,  156,   68,   69,
140262         - /*  1480 */    70,   71,  139,  923,  192,  193,  144,  919,  345,  128,
140263         - /*  1490 */    14,  194,  276,  211, 1000,  405,  196,  161,  912,  160,
140264         - /*  1500 */    26,  697,  410,  295,  200,  289,  414,  162,  419,   73,
140265         - /*  1510 */    15,   16,  141,   74,   28,  247,  846,  845,  735,  874,
140266         - /*  1520 */   954,   75,  430,  955,   29,  433,  179,  229,  231,  800,
140267         - /*  1530 */   165,  795,   87,  210,  889,   79,  875,   17,  873,  877,
140268         - /*  1540 */   929,   18,  928,  216,  215,  878,   20,   30,  462,  844,
140269         - /*  1550 */   707,   92,  766,  770,    7,  322,  217,  218,  319, 1308,
140270         - /*  1560 */   960, 1016, 1016, 1016, 1016, 1307,
       140985  + /*     0 */   349,   99,   96,  185,   99,   96,  185,  233, 1047,    1,
       140986  + /*    10 */     1,  489,    2, 1051,  484,  477,  477,  477,  260,  351,
       140987  + /*    20 */   121, 1310, 1120, 1120, 1178, 1115, 1094, 1128,  380,  380,
       140988  + /*    30 */   380,  835,  454,  410, 1115,   59,   59, 1357,  425,  836,
       140989  + /*    40 */   710,  711,  712,  106,  107,   97, 1023, 1023,  900,  903,
       140990  + /*    50 */   892,  892,  104,  104,  105,  105,  105,  105,  346,  238,
       140991  + /*    60 */   238,   99,   96,  185,  238,  238,  889,  889,  901,  904,
       140992  + /*    70 */   460,  481,  351,   99,   96,  185,  481,  347, 1177,   82,
       140993  + /*    80 */   388,  214,  182,   23,  194,  103,  103,  103,  103,  102,
       140994  + /*    90 */   102,  101,  101,  101,  100,  381,  106,  107,   97, 1023,
       140995  + /*   100 */  1023,  900,  903,  892,  892,  104,  104,  105,  105,  105,
       140996  + /*   110 */   105,   10,  385,  484,   24,  484, 1333,  489,    2, 1051,
       140997  + /*   120 */   335, 1043,  108,  893,  260,  351,  121,   99,   96,  185,
       140998  + /*   130 */   100,  381,  386, 1128,   59,   59,   59,   59,  103,  103,
       140999  + /*   140 */   103,  103,  102,  102,  101,  101,  101,  100,  381,  106,
       141000  + /*   150 */   107,   97, 1023, 1023,  900,  903,  892,  892,  104,  104,
       141001  + /*   160 */   105,  105,  105,  105,  360,  238,  238,  170,  170,  467,
       141002  + /*   170 */   455,  467,  464,   67,  381,  329,  169,  481,  351,  343,
       141003  + /*   180 */   338,  400, 1044,   68,  101,  101,  101,  100,  381,  393,
       141004  + /*   190 */   194,  103,  103,  103,  103,  102,  102,  101,  101,  101,
       141005  + /*   200 */   100,  381,  106,  107,   97, 1023, 1023,  900,  903,  892,
       141006  + /*   210 */   892,  104,  104,  105,  105,  105,  105,  483,  385,  103,
       141007  + /*   220 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
       141008  + /*   230 */   268,  351,  946,  946,  422,  296,  102,  102,  101,  101,
       141009  + /*   240 */   101,  100,  381,  861,  103,  103,  103,  103,  102,  102,
       141010  + /*   250 */   101,  101,  101,  100,  381,  106,  107,   97, 1023, 1023,
       141011  + /*   260 */   900,  903,  892,  892,  104,  104,  105,  105,  105,  105,
       141012  + /*   270 */   484,  983, 1383,  206, 1353, 1383,  438,  435,  434,  281,
       141013  + /*   280 */   396,  269, 1089,  941,  351, 1002,  433,  861,  743,  401,
       141014  + /*   290 */   282,   57,   57,  482,  145,  791,  791,  103,  103,  103,
       141015  + /*   300 */   103,  102,  102,  101,  101,  101,  100,  381,  106,  107,
       141016  + /*   310 */    97, 1023, 1023,  900,  903,  892,  892,  104,  104,  105,
       141017  + /*   320 */   105,  105,  105,  281, 1002, 1003, 1004,  206,  879,  319,
       141018  + /*   330 */   438,  435,  434,  981,  259,  474,  360,  351, 1118, 1118,
       141019  + /*   340 */   433,  736,  379,  378,  872, 1002, 1356,  322,  871,  766,
       141020  + /*   350 */   103,  103,  103,  103,  102,  102,  101,  101,  101,  100,
       141021  + /*   360 */   381,  106,  107,   97, 1023, 1023,  900,  903,  892,  892,
       141022  + /*   370 */   104,  104,  105,  105,  105,  105,  484,  801,  484,  871,
       141023  + /*   380 */   871,  873,  401,  282, 1002, 1003, 1004, 1030,  360, 1030,
       141024  + /*   390 */   351,  983, 1384,  213,  880, 1384,  145,   59,   59,   59,
       141025  + /*   400 */    59, 1002,  244,  103,  103,  103,  103,  102,  102,  101,
       141026  + /*   410 */   101,  101,  100,  381,  106,  107,   97, 1023, 1023,  900,
       141027  + /*   420 */   903,  892,  892,  104,  104,  105,  105,  105,  105,  274,
       141028  + /*   430 */   484,  110,  467,  479,  467,  444,  259,  474,  232,  232,
       141029  + /*   440 */  1002, 1003, 1004,  351,  210,  335,  982,  866, 1385,  336,
       141030  + /*   450 */   481,   59,   59,  981,  245,  307,  103,  103,  103,  103,
       141031  + /*   460 */   102,  102,  101,  101,  101,  100,  381,  106,  107,   97,
       141032  + /*   470 */  1023, 1023,  900,  903,  892,  892,  104,  104,  105,  105,
       141033  + /*   480 */   105,  105,  453,  459,  484,  408,  377,  259,  474,  271,
       141034  + /*   490 */   183,  273,  209,  208,  207,  356,  351,  307,  178,  177,
       141035  + /*   500 */   127, 1006, 1098,   14,   14,   43,   43, 1044,  425,  103,
       141036  + /*   510 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
       141037  + /*   520 */   106,  107,   97, 1023, 1023,  900,  903,  892,  892,  104,
       141038  + /*   530 */   104,  105,  105,  105,  105,  294, 1132,  408,  160,  484,
       141039  + /*   540 */   408, 1006,  129,  962, 1209,  239,  239,  481,  307,  425,
       141040  + /*   550 */  1309, 1097,  351,  235,  243,  272,  820,  481,  963,  425,
       141041  + /*   560 */    11,   11,  103,  103,  103,  103,  102,  102,  101,  101,
       141042  + /*   570 */   101,  100,  381,  964,  362, 1002,  106,  107,   97, 1023,
       141043  + /*   580 */  1023,  900,  903,  892,  892,  104,  104,  105,  105,  105,
       141044  + /*   590 */   105, 1275,  161,  126,  777,  289, 1209,  292, 1072,  357,
       141045  + /*   600 */  1209, 1127,  476,  357,  778,  425,  247,  425,  351,  248,
       141046  + /*   610 */   414,  364,  414,  171, 1002, 1003, 1004,   84,  103,  103,
       141047  + /*   620 */   103,  103,  102,  102,  101,  101,  101,  100,  381, 1002,
       141048  + /*   630 */   184,  484,  106,  107,   97, 1023, 1023,  900,  903,  892,
       141049  + /*   640 */   892,  104,  104,  105,  105,  105,  105, 1123, 1209,  287,
       141050  + /*   650 */   484, 1209,   11,   11,  179,  820,  259,  474,  307,  237,
       141051  + /*   660 */   182,  351,  321,  365,  414,  308,  367,  366, 1002, 1003,
       141052  + /*   670 */  1004,   44,   44,   87,  103,  103,  103,  103,  102,  102,
       141053  + /*   680 */   101,  101,  101,  100,  381,  106,  107,   97, 1023, 1023,
       141054  + /*   690 */   900,  903,  892,  892,  104,  104,  105,  105,  105,  105,
       141055  + /*   700 */   246,  368,  280,  128,   10,  358,  146,  796,  835,  258,
       141056  + /*   710 */  1020,   88,  795,   86,  351,  421,  836,  943,  376,  348,
       141057  + /*   720 */   191,  943, 1318,  267,  308,  279,  456,  103,  103,  103,
       141058  + /*   730 */   103,  102,  102,  101,  101,  101,  100,  381,  106,   95,
       141059  + /*   740 */    97, 1023, 1023,  900,  903,  892,  892,  104,  104,  105,
       141060  + /*   750 */   105,  105,  105,  420,  249,  238,  238,  238,  238,   79,
       141061  + /*   760 */   375,  125,  305,   29,  262,  978,  351,  481,  337,  481,
       141062  + /*   770 */   756,  755,  304,  278,  415,   15,   81,  940, 1126,  940,
       141063  + /*   780 */   103,  103,  103,  103,  102,  102,  101,  101,  101,  100,
       141064  + /*   790 */   381,  107,   97, 1023, 1023,  900,  903,  892,  892,  104,
       141065  + /*   800 */   104,  105,  105,  105,  105,  457,  263,  484,  174,  484,
       141066  + /*   810 */   238,  238,  863,  407,  402,  216,  216,  351,  409,  193,
       141067  + /*   820 */   283,  216,  481,   81,  763,  764,  266,    5,   13,   13,
       141068  + /*   830 */    34,   34,  103,  103,  103,  103,  102,  102,  101,  101,
       141069  + /*   840 */   101,  100,  381,   97, 1023, 1023,  900,  903,  892,  892,
       141070  + /*   850 */   104,  104,  105,  105,  105,  105,   93,  475, 1002,    4,
       141071  + /*   860 */   403, 1002,  340,  431, 1002,  297,  212, 1277,   81,  746,
       141072  + /*   870 */  1163,  152,  926,  478,  166,  212,  757,  829,  930,  939,
       141073  + /*   880 */   216,  939,  858,  103,  103,  103,  103,  102,  102,  101,
       141074  + /*   890 */   101,  101,  100,  381,  238,  238,  382, 1002, 1003, 1004,
       141075  + /*   900 */  1002, 1003, 1004, 1002, 1003, 1004,  481,  439,  472,  746,
       141076  + /*   910 */   105,  105,  105,  105,   98,  758, 1162,  145,  930,  412,
       141077  + /*   920 */   879,  406,  793,   81,  395,   89,   90,   91,  105,  105,
       141078  + /*   930 */   105,  105, 1323,   92,  484,  382,  486,  485,  240,  275,
       141079  + /*   940 */   871,  103,  103,  103,  103,  102,  102,  101,  101,  101,
       141080  + /*   950 */   100,  381, 1096,  371,  355,   45,   45,  259,  474,  103,
       141081  + /*   960 */   103,  103,  103,  102,  102,  101,  101,  101,  100,  381,
       141082  + /*   970 */  1150,  871,  871,  873,  874,   21, 1332,  991,  384,  730,
       141083  + /*   980 */   722,  242,  123, 1298,  124,  875,  333,  333,  332,  227,
       141084  + /*   990 */   330,  991,  384,  719,  256,  242,  484,  391,  413, 1297,
       141085  + /*  1000 */   333,  333,  332,  227,  330,  748,  187,  719,  265,  470,
       141086  + /*  1010 */  1279, 1002,  484,  417,  391,  390,  264,   11,   11,  284,
       141087  + /*  1020 */   187,  732,  265,   93,  475,  875,    4, 1279, 1281,  419,
       141088  + /*  1030 */   264,  369,  416,   11,   11, 1159,  288,  484,  399, 1346,
       141089  + /*  1040 */   478,  379,  378,  291,  484,  293,  189,  250,  295, 1027,
       141090  + /*  1050 */  1002, 1003, 1004,  190, 1029, 1111,  140,  188,   11,   11,
       141091  + /*  1060 */   189,  732, 1028,  382,  923,   46,   46,  190, 1095,  230,
       141092  + /*  1070 */   140,  188,  462,   93,  475,  472,    4,  300,  309,  391,
       141093  + /*  1080 */   373,    6, 1069,  217,  739,  310, 1030,  879, 1030, 1171,
       141094  + /*  1090 */   478,  352, 1279,   90,   91,  800,  259,  474, 1208,  484,
       141095  + /*  1100 */    92, 1268,  382,  486,  485,  352, 1002,  871,  879,  426,
       141096  + /*  1110 */   259,  474,  172,  382,  238,  238, 1146,  170, 1021,  389,
       141097  + /*  1120 */    47,   47, 1157,  739,  872,  472,  481,  469,  871,  350,
       141098  + /*  1130 */  1214,   83,  475,  389,    4, 1078, 1071,  879,  871,  871,
       141099  + /*  1140 */   873,  874,   21,   90,   91, 1002, 1003, 1004,  478,  251,
       141100  + /*  1150 */    92,  251,  382,  486,  485,  443,  370,  871, 1021,  871,
       141101  + /*  1160 */   871,  873,  224,  241,  306,  441,  301,  440,  211, 1060,
       141102  + /*  1170 */   820,  382,  822,  447,  299, 1059,  484, 1061, 1143,  962,
       141103  + /*  1180 */   430,  796,  484,  472, 1340,  312,  795,  465,  871,  871,
       141104  + /*  1190 */   873,  874,   21,  314,  963,  879,  316,   59,   59, 1002,
       141105  + /*  1200 */     9,   90,   91,   48,   48,  238,  238,  210,   92,  964,
       141106  + /*  1210 */   382,  486,  485,  176,  334,  871,  242,  481, 1193,  238,
       141107  + /*  1220 */   238,  333,  333,  332,  227,  330,  394,  270,  719,  277,
       141108  + /*  1230 */   471,  481,  467,  466,  484,  145,  217, 1201, 1002, 1003,
       141109  + /*  1240 */  1004,  187,    3,  265,  184,  445,  871,  871,  873,  874,
       141110  + /*  1250 */    21,  264, 1337,  450, 1051,   39,   39,  392,  356,  260,
       141111  + /*  1260 */   342,  121,  468,  411,  436,  821,  180, 1094, 1128,  820,
       141112  + /*  1270 */   303, 1021, 1272, 1271,  299,  259,  474,  238,  238, 1002,
       141113  + /*  1280 */   473,  189,  484,  318,  327,  238,  238,  484,  190,  481,
       141114  + /*  1290 */   446,  140,  188, 1343,  238,  238, 1038,  481,  148,  175,
       141115  + /*  1300 */   238,  238,  484,   49,   49,  219,  481,  484,   35,   35,
       141116  + /*  1310 */  1317, 1021,  481,  484, 1035,  484, 1315,  484, 1002, 1003,
       141117  + /*  1320 */  1004,  484,   66,   36,   36,  194,  352,  484,   38,   38,
       141118  + /*  1330 */   484,  259,  474,   69,   50,   50,   51,   51,   52,   52,
       141119  + /*  1340 */   359,  484,   12,   12,  484, 1198,  484,  158,   53,   53,
       141120  + /*  1350 */   405,  112,  112,  385,  389,  484,   26,  484,  143,  484,
       141121  + /*  1360 */   150,  484,   54,   54,  397,   40,   40,   55,   55,  484,
       141122  + /*  1370 */    79,  484,  153, 1190,  484,  154,   56,   56,   41,   41,
       141123  + /*  1380 */    58,   58,  133,  133,  484,  398,  484,  429,  484,  155,
       141124  + /*  1390 */   134,  134,  135,  135,  484,   63,   63,  484,  341,  484,
       141125  + /*  1400 */   339,  484,  196,  484,  156,   42,   42,  113,  113,   60,
       141126  + /*  1410 */    60,  484,  404,  484,   27,  114,  114, 1204,  115,  115,
       141127  + /*  1420 */   111,  111,  132,  132,  131,  131, 1266,  418,  484,  162,
       141128  + /*  1430 */   484,  200,  119,  119,  118,  118,  484,   74,  424,  484,
       141129  + /*  1440 */  1286,  484,  231,  484,  202,  484,  167,  286,  427,  116,
       141130  + /*  1450 */   116,  117,  117,  290,  203,  442, 1062,   62,   62,  204,
       141131  + /*  1460 */    64,   64,   61,   61,   33,   33,   37,   37,  344,  372,
       141132  + /*  1470 */  1114, 1105,  748, 1113,  374, 1112,  254,  458, 1086,  255,
       141133  + /*  1480 */   345, 1085,  302, 1084, 1355,   78, 1154,  311, 1104,  449,
       141134  + /*  1490 */   452, 1155, 1153,  218,    7,  313,  315,  320, 1152,   85,
       141135  + /*  1500 */  1252,  317,  109,   80,  463,  225,  461, 1068,   25,  487,
       141136  + /*  1510 */   997,  323,  257,  226,  229,  228, 1136,  324,  325,  326,
       141137  + /*  1520 */   488,  136, 1057, 1052, 1302, 1303, 1301,  706, 1300,  137,
       141138  + /*  1530 */   122,  138,  383,  173, 1082,  261,  186,  252, 1081,   65,
       141139  + /*  1540 */   387,  120,  938,  936,  855,  353,  149, 1079,  139,  151,
       141140  + /*  1550 */   192,  780,  195,  276,  952,  157,  141,  361,   70,  363,
       141141  + /*  1560 */   859,  159,   71,   72,  142,   73,  955,  354,  147,  197,
       141142  + /*  1570 */   198,  951,  130,   16,  199,  285,  216, 1032,  201,  423,
       141143  + /*  1580 */   164,  944,  163,   28,  721,  428,  304,  165,  205,  759,
       141144  + /*  1590 */    75,  432,  298,   17,   18,  437,   76,  253,  878,  144,
       141145  + /*  1600 */   877,  906,   77,  986,   30,  448,  987,   31,  451,  181,
       141146  + /*  1610 */   234,  236,  168,  828,  823,   89,  910,  921,   81,  907,
       141147  + /*  1620 */   215,  905,  909,  961,  960,   19,  221,   20,  220,   22,
       141148  + /*  1630 */    32,  331,  876,  731,   94,  790,  794,    8,  992,  222,
       141149  + /*  1640 */   480,  328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
       141150  + /*  1650 */   223, 1048, 1048, 1048, 1048, 1348, 1347,
140271 141151   };
140272 141152   static const YYCODETYPE yy_lookahead[] = {
140273         - /*     0 */   152,  144,  145,  146,  147,  152,  152,  172,  152,  180,
140274         - /*    10 */   181,  152,  223,  224,  225,  180,  152,  164,  189,   19,
140275         - /*    20 */   223,  224,  225,  168,  169,  170,  163,  173,  174,  173,
140276         - /*    30 */   174,   31,  173,  174,  168,  169,  170,  173,  174,   39,
140277         - /*    40 */   243,  191,  192,   43,   44,   45,   46,   47,   48,   49,
140278         - /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  195,  196,
140279         - /*    60 */    22,   23,  208,  209,  208,  209,  218,  208,  209,  176,
140280         - /*    70 */   207,   19,  208,  209,   23,  212,  213,   26,   26,  152,
140281         - /*    80 */    46,   47,   48,   49,   84,   85,   86,   87,   88,   89,
140282         - /*    90 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
140283         - /*   100 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
140284         - /*   110 */    90,   91,   92,   93,   94,  188,  223,  224,  225,  171,
140285         - /*   120 */    68,   83,  152,   19,   84,   85,   86,   87,   88,   89,
140286         - /*   130 */    90,   91,   92,   93,   94,  101,   84,   85,   86,   87,
140287         - /*   140 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
140288         - /*   150 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
140289         - /*   160 */    56,   57,   99,   94,  194,  102,  103,  104,  109,  110,
140290         - /*   170 */    66,  223,  224,  225,  152,   19,  113,   22,   23,  152,
140291         - /*   180 */    24,   26,  160,    1,    2,   59,  164,  173,   84,   85,
140292         - /*   190 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
140293         - /*   200 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
140294         - /*   210 */    54,   55,   56,   57,  244,   88,   89,   90,   91,   92,
140295         - /*   220 */    93,   94,   96,   97,   98,   99,  196,   19,  102,  103,
140296         - /*   230 */   104,   23,   88,   89,  173,   59,  163,  207,   83,  113,
140297         - /*   240 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
140298         - /*   250 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
140299         - /*   260 */    52,   53,   54,   55,   56,   57,   90,  240,  195,  196,
140300         - /*   270 */   171,   82,   96,   97,   98,  152,  132,  176,  134,   19,
140301         - /*   280 */   207,  200,   72,   23,   93,   94,   97,  152,  173,   79,
140302         - /*   290 */   101,  210,   84,   85,   86,   87,   88,   89,   90,   91,
140303         - /*   300 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
140304         - /*   310 */    50,   51,   52,   53,   54,   55,   56,   57,  108,  152,
140305         - /*   320 */   152,  132,  133,  134,  223,  224,  225,  152,  186,  119,
140306         - /*   330 */   120,   19,  197,  234,   31,   23,   26,  152,  239,   59,
140307         - /*   340 */   173,  174,   39,  220,   84,   85,   86,   87,   88,   89,
140308         - /*   350 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
140309         - /*   360 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
140310         - /*   370 */   152,   22,  152,   16,  152,  208,   96,   97,   98,  194,
140311         - /*   380 */    22,   23,   11,   19,   26,   79,   72,   23,    0,    1,
140312         - /*   390 */     2,  173,  174,  173,  174,  220,   84,   85,   86,   87,
140313         - /*   400 */    88,   89,   90,   91,   92,   93,   94,   43,   44,   45,
140314         - /*   410 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
140315         - /*   420 */    56,   57,  108,  109,  110,  119,  120,  152,  208,  119,
140316         - /*   430 */   120,  137,   75,  139,   77,   19,  152,   88,   89,   23,
140317         - /*   440 */   115,   83,  117,  118,  163,  227,  163,  152,   84,   85,
140318         - /*   450 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   43,
140319         - /*   460 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
140320         - /*   470 */    54,   55,   56,   57,  195,  196,  195,  196,  195,  196,
140321         - /*   480 */   109,  110,  195,  196,   22,   23,  207,   19,  207,  152,
140322         - /*   490 */   207,  108,  109,  110,  207,  163,   22,  140,   24,   59,
140323         - /*   500 */    84,   85,   86,   87,   88,   89,   90,   91,   92,   93,
140324         - /*   510 */    94,   43,   44,   45,   46,   47,   48,   49,   50,   51,
140325         - /*   520 */    52,   53,   54,   55,   56,   57,  152,  195,  196,  152,
140326         - /*   530 */    16,    7,    8,    9,  197,  240,   96,   97,   98,  207,
140327         - /*   540 */   249,  250,   19,  152,   22,   83,   26,  173,  174,  152,
140328         - /*   550 */   173,  174,   84,   85,   86,   87,   88,   89,   90,   91,
140329         - /*   560 */    92,   93,   94,   59,  124,  152,   43,   44,   45,   46,
140330         - /*   570 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
140331         - /*   580 */    57,   59,  169,  170,  157,  194,   82,  191,  192,   75,
140332         - /*   590 */   152,   77,  108,  109,  110,   26,  152,   19,  152,  152,
140333         - /*   600 */    96,   97,   24,  152,  152,  101,  138,   84,   85,   86,
140334         - /*   610 */    87,   88,   89,   90,   91,   92,   93,   94,   96,   97,
140335         - /*   620 */    98,   43,   44,   45,   46,   47,   48,   49,   50,   51,
140336         - /*   630 */    52,   53,   54,   55,   56,   57,  132,  133,  134,  188,
140337         - /*   640 */   194,  197,  152,  123,  197,  232,  194,  152,  182,   19,
140338         - /*   650 */   119,  120,  152,  152,  152,  152,  218,  230,  152,  163,
140339         - /*   660 */   233,  138,   84,   85,   86,   87,   88,   89,   90,   91,
140340         - /*   670 */    92,   93,   94,   43,   44,   45,   46,   47,   48,   49,
140341         - /*   680 */    50,   51,   52,   53,   54,   55,   56,   57,  152,  152,
140342         - /*   690 */    23,  195,  196,   26,  194,  194,  194,  146,  147,  130,
140343         - /*   700 */   194,   19,   46,  207,   59,   29,  166,  167,  218,   33,
140344         - /*   710 */   173,  174,   26,  218,   84,   85,   86,   87,   88,   89,
140345         - /*   720 */    90,   91,   92,   93,   94,   43,   44,   45,   46,   47,
140346         - /*   730 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
140347         - /*   740 */    64,  171,   97,  240,  116,  166,  167,  212,  213,  121,
140348         - /*   750 */    23,  152,   19,   26,  218,  247,  248,   23,   23,  152,
140349         - /*   760 */    26,   26,   22,  107,  163,   98,   84,   85,   86,   87,
140350         - /*   770 */    88,   89,   90,   91,   92,   93,   94,   44,   45,   46,
140351         - /*   780 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
140352         - /*   790 */    57,  124,  106,   53,  100,  101,  195,  196,  152,  152,
140353         - /*   800 */    23,   23,   19,   26,   26,   19,  152,   23,  207,  239,
140354         - /*   810 */    26,   23,  152,  163,   26,  169,  170,   84,   85,   86,
140355         - /*   820 */    87,   88,   89,   90,   91,   92,   93,   94,   45,   46,
140356         - /*   830 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
140357         - /*   840 */    57,   19,   20,  101,   22,  195,  196,   22,   19,   24,
140358         - /*   850 */   163,   19,    7,    8,  112,   59,   23,  207,   36,   26,
140359         - /*   860 */    23,  152,   59,   26,   21,   59,  152,   84,   85,   86,
140360         - /*   870 */    87,   88,   89,   90,   91,   92,   93,   94,  232,  221,
140361         - /*   880 */    94,   59,  195,  196,   59,   99,  100,  101,  102,  103,
140362         - /*   890 */   104,  105,   70,   97,  207,   59,   19,   20,  112,   22,
140363         - /*   900 */    97,   79,  152,   97,   82,  152,  152,   71,  221,   90,
140364         - /*   910 */    88,   89,   23,   36,   12,   26,  163,   95,   96,   97,
140365         - /*   920 */    98,   78,   97,  101,  152,   96,  173,  174,   96,   27,
140366         - /*   930 */   182,   22,   96,   97,   98,  116,   59,  148,  149,  152,
140367         - /*   940 */   121,  119,  120,  154,   42,  156,  103,   70,  195,  196,
140368         - /*   950 */    22,   59,  163,  152,  132,  133,  134,  135,  136,   82,
140369         - /*   960 */   207,  208,  209,   71,   62,   88,   89,   90,   59,  152,
140370         - /*   970 */   152,   12,   95,   96,   97,   98,   19,   20,  101,   22,
140371         - /*   980 */    22,  182,  152,  140,  195,  196,   27,   59,   96,   97,
140372         - /*   990 */    98,   59,  132,   36,  134,   22,  207,   19,   20,   24,
140373         - /*  1000 */    22,   42,  152,  173,  174,   96,   97,   98,  219,  132,
140374         - /*  1010 */   133,  134,  135,  136,   36,  152,   59,  187,  132,  152,
140375         - /*  1020 */   134,   62,  152,  152,   96,   97,   98,   70,   96,   97,
140376         - /*  1030 */    98,   72,   59,  152,   59,  246,   26,   59,  214,   82,
140377         - /*  1040 */   152,  192,  152,  173,  174,   88,   89,   79,   70,  152,
140378         - /*  1050 */   152,   19,   95,   96,   97,   98,  124,  187,  101,   23,
140379         - /*  1060 */    82,  164,   26,  173,  174,  152,   88,   89,  100,   96,
140380         - /*  1070 */    97,   98,   97,   95,   96,   97,   98,  187,   46,  101,
140381         - /*  1080 */   122,  184,  152,  186,  211,  152,  152,  119,  120,  132,
140382         - /*  1090 */   133,  134,  135,  136,  152,    5,   22,  152,  152,   35,
140383         - /*  1100 */    10,   11,   12,   13,   14,  152,  152,   17,   98,  235,
140384         - /*  1110 */   132,  133,  134,  135,  136,   54,   55,   56,   57,   58,
140385         - /*  1120 */    30,  152,   32,  152,  152,  198,  173,  174,  152,   65,
140386         - /*  1130 */    40,  152,  152,   59,  124,  152,  236,   73,  199,  107,
140387         - /*  1140 */   187,  171,  173,  174,  112,   84,   85,   86,   87,   88,
140388         - /*  1150 */    89,   90,   91,   92,   93,   94,  173,  174,  152,   69,
140389         - /*  1160 */   152,  211,   54,   55,   56,   57,   76,  152,  150,   79,
140390         - /*  1170 */    80,   97,  211,  211,  211,  111,   59,  241,  241,  173,
140391         - /*  1180 */   174,  173,  174,  202,  202,  185,  177,  176,  173,  174,
140392         - /*  1190 */   176,  201,   84,   85,   86,   87,   88,   89,   90,   91,
140393         - /*  1200 */    92,   93,   94,  215,  114,   88,   89,  152,  215,  119,
140394         - /*  1210 */   120,  152,  181,   96,   97,   98,  176,  100,  215,  152,
140395         - /*  1220 */   229,  152,  163,  152,  107,  199,  109,  155,  173,  174,
140396         - /*  1230 */   245,  141,  173,  174,   60,  159,  152,  122,  159,  242,
140397         - /*  1240 */   173,  174,  173,  174,  173,  174,   38,  242,  152,  132,
140398         - /*  1250 */   159,  134,  152,   22,  195,  196,  152,  173,  174,  222,
140399         - /*  1260 */    43,  130,  202,  152,   18,  152,  207,  208,  152,  173,
140400         - /*  1270 */   174,  152,  190,  173,  174,  152,  193,  173,  174,  152,
140401         - /*  1280 */   193,  193,  152,  159,  173,  174,  173,  174,  152,  173,
140402         - /*  1290 */   174,  193,  173,  174,   18,  152,  173,  174,  152,  158,
140403         - /*  1300 */   173,  174,  152,  173,  174,  152,  159,  152,  202,  173,
140404         - /*  1310 */   174,  152,  190,  152,  222,  152,  173,  174,  152,  173,
140405         - /*  1320 */   174,  137,  152,  173,  174,  190,  173,  174,  173,  174,
140406         - /*  1330 */   202,  158,  173,  174,  173,  174,  173,  174,   61,  173,
140407         - /*  1340 */   174,  152,  237,  173,  174,  152,  159,  152,  238,  152,
140408         - /*  1350 */   158,  152,   22,  152,  178,  152,  158,  152,  158,  152,
140409         - /*  1360 */   178,  159,  173,  174,  152,  159,  173,  174,  173,  174,
140410         - /*  1370 */   173,  174,  173,  174,  173,  174,  173,  174,  173,  174,
140411         - /*  1380 */   173,  174,  152,   63,  152,  173,  174,  107,  175,  175,
140412         - /*  1390 */   175,  106,  183,  175,  178,  175,  177,  175,  175,  178,
140413         - /*  1400 */    94,  107,  231,  173,  174,  173,  174,  183,  231,  125,
140414         - /*  1410 */   216,  178,  159,  217,   22,  159,  226,  129,  137,  228,
140415         - /*  1420 */   128,  217,  126,   25,  127,  162,  216,   26,  217,  161,
140416         - /*  1430 */    13,  153,  153,  206,  205,    6,  251,  202,  204,  203,
140417         - /*  1440 */   151,  216,  151,  217,  216,  171,  151,  165,  179,  179,
140418         - /*  1450 */     4,    3,   22,  142,  171,  165,   15,  171,  171,   81,
140419         - /*  1460 */    16,   23,   23,  120,  171,  131,  165,  111,  123,  171,
140420         - /*  1470 */   171,  171,   20,  125,   16,    1,  123,  131,   53,   53,
140421         - /*  1480 */    53,   53,  111,   96,   34,  122,  248,    1,  251,    5,
140422         - /*  1490 */    22,  107,  140,   26,   74,   41,  122,  107,   67,   67,
140423         - /*  1500 */    24,   20,   19,  112,  105,   23,   66,   22,   66,   22,
140424         - /*  1510 */    22,   22,   37,   22,   22,   66,   23,   23,   28,   23,
140425         - /*  1520 */    23,   26,   24,   23,   22,   24,  122,   23,   23,   96,
140426         - /*  1530 */    22,  124,   26,   34,   23,   26,   23,   34,   23,   23,
140427         - /*  1540 */    23,   34,   23,   22,   26,   11,   22,   22,   26,   23,
140428         - /*  1550 */    23,   22,  116,   23,   22,   15,  122,  122,   23,  122,
140429         - /*  1560 */     1,  252,  252,  252,  252,  122,  252,  252,  252,  252,
140430         - /*  1570 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140431         - /*  1580 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140432         - /*  1590 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140433         - /*  1600 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140434         - /*  1610 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140435         - /*  1620 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140436         - /*  1630 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140437         - /*  1640 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140438         - /*  1650 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140439         - /*  1660 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140440         - /*  1670 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140441         - /*  1680 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140442         - /*  1690 */   252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
140443         - /*  1700 */   252,  252,  252,  252,  252,  252,  252,  252,  252,
140444         -};
140445         -#define YY_SHIFT_COUNT    (471)
       141153  + /*     0 */   174,  226,  227,  228,  226,  227,  228,  172,  145,  146,
       141154  + /*    10 */   147,  148,  149,  150,  153,  169,  170,  171,  155,   19,
       141155  + /*    20 */   157,  246,  192,  193,  177,  181,  182,  164,  169,  170,
       141156  + /*    30 */   171,   31,  164,  153,  190,  174,  175,  187,  153,   39,
       141157  + /*    40 */     7,    8,    9,   43,   44,   45,   46,   47,   48,   49,
       141158  + /*    50 */    50,   51,   52,   53,   54,   55,   56,   57,  174,  196,
       141159  + /*    60 */   197,  226,  227,  228,  196,  197,   46,   47,   48,   49,
       141160  + /*    70 */   209,  208,   19,  226,  227,  228,  208,  174,  177,   26,
       141161  + /*    80 */   195,  213,  214,   22,  221,   85,   86,   87,   88,   89,
       141162  + /*    90 */    90,   91,   92,   93,   94,   95,   43,   44,   45,   46,
       141163  + /*   100 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
       141164  + /*   110 */    57,  172,  249,  153,   53,  153,  147,  148,  149,  150,
       141165  + /*   120 */    22,   23,   69,  103,  155,   19,  157,  226,  227,  228,
       141166  + /*   130 */    94,   95,  247,  164,  174,  175,  174,  175,   85,   86,
       141167  + /*   140 */    87,   88,   89,   90,   91,   92,   93,   94,   95,   43,
       141168  + /*   150 */    44,   45,   46,   47,   48,   49,   50,   51,   52,   53,
       141169  + /*   160 */    54,   55,   56,   57,  153,  196,  197,  153,  153,  209,
       141170  + /*   170 */   210,  209,  210,   67,   95,  161,  237,  208,   19,  165,
       141171  + /*   180 */   165,  242,   84,   24,   91,   92,   93,   94,   95,  223,
       141172  + /*   190 */   221,   85,   86,   87,   88,   89,   90,   91,   92,   93,
       141173  + /*   200 */    94,   95,   43,   44,   45,   46,   47,   48,   49,   50,
       141174  + /*   210 */    51,   52,   53,   54,   55,   56,   57,  153,  249,   85,
       141175  + /*   220 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
       141176  + /*   230 */   219,   19,  109,  110,  111,   23,   89,   90,   91,   92,
       141177  + /*   240 */    93,   94,   95,   73,   85,   86,   87,   88,   89,   90,
       141178  + /*   250 */    91,   92,   93,   94,   95,   43,   44,   45,   46,   47,
       141179  + /*   260 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
       141180  + /*   270 */   153,   22,   23,  101,  173,   26,  104,  105,  106,  109,
       141181  + /*   280 */   110,  111,  181,   11,   19,   59,  114,   73,   23,  110,
       141182  + /*   290 */   111,  174,  175,  116,   80,  118,  119,   85,   86,   87,
       141183  + /*   300 */    88,   89,   90,   91,   92,   93,   94,   95,   43,   44,
       141184  + /*   310 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
       141185  + /*   320 */    55,   56,   57,  109,   98,   99,  100,  101,   83,  153,
       141186  + /*   330 */   104,  105,  106,   84,  120,  121,  153,   19,  192,  193,
       141187  + /*   340 */   114,   23,   89,   90,   99,   59,   23,  230,  103,   26,
       141188  + /*   350 */    85,   86,   87,   88,   89,   90,   91,   92,   93,   94,
       141189  + /*   360 */    95,   43,   44,   45,   46,   47,   48,   49,   50,   51,
       141190  + /*   370 */    52,   53,   54,   55,   56,   57,  153,   91,  153,  134,
       141191  + /*   380 */   135,  136,  110,  111,   98,   99,  100,  134,  153,  136,
       141192  + /*   390 */    19,   22,   23,   26,   23,   26,   80,  174,  175,  174,
       141193  + /*   400 */   175,   59,  219,   85,   86,   87,   88,   89,   90,   91,
       141194  + /*   410 */    92,   93,   94,   95,   43,   44,   45,   46,   47,   48,
       141195  + /*   420 */    49,   50,   51,   52,   53,   54,   55,   56,   57,   16,
       141196  + /*   430 */   153,   22,  209,  210,  209,  210,  120,  121,  196,  197,
       141197  + /*   440 */    98,   99,  100,   19,   46,   22,   23,   23,  252,  253,
       141198  + /*   450 */   208,  174,  175,   84,  219,  153,   85,   86,   87,   88,
       141199  + /*   460 */    89,   90,   91,   92,   93,   94,   95,   43,   44,   45,
       141200  + /*   470 */    46,   47,   48,   49,   50,   51,   52,   53,   54,   55,
       141201  + /*   480 */    56,   57,  153,  153,  153,  153,  209,  120,  121,   76,
       141202  + /*   490 */   153,   78,  109,  110,  111,   97,   19,  153,   89,   90,
       141203  + /*   500 */   198,   59,  183,  174,  175,  174,  175,   84,  153,   85,
       141204  + /*   510 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
       141205  + /*   520 */    43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
       141206  + /*   530 */    53,   54,   55,   56,   57,   16,  197,  153,   22,  153,
       141207  + /*   540 */   153,   99,  198,   12,  153,  196,  197,  208,  153,  153,
       141208  + /*   550 */   195,  183,   19,   23,  222,  142,   26,  208,   27,  153,
       141209  + /*   560 */   174,  175,   85,   86,   87,   88,   89,   90,   91,   92,
       141210  + /*   570 */    93,   94,   95,   42,  188,   59,   43,   44,   45,   46,
       141211  + /*   580 */    47,   48,   49,   50,   51,   52,   53,   54,   55,   56,
       141212  + /*   590 */    57,  195,   22,  198,   63,   76,  153,   78,  167,  168,
       141213  + /*   600 */   153,  195,  167,  168,   73,  153,  222,  153,   19,  222,
       141214  + /*   610 */   153,  220,  153,   24,   98,   99,  100,  140,   85,   86,
       141215  + /*   620 */    87,   88,   89,   90,   91,   92,   93,   94,   95,   59,
       141216  + /*   630 */   100,  153,   43,   44,   45,   46,   47,   48,   49,   50,
       141217  + /*   640 */    51,   52,   53,   54,   55,   56,   57,  195,  153,  195,
       141218  + /*   650 */   153,  153,  174,  175,   26,  125,  120,  121,  153,  213,
       141219  + /*   660 */   214,   19,  153,  220,  153,  153,  188,  220,   98,   99,
       141220  + /*   670 */   100,  174,  175,  140,   85,   86,   87,   88,   89,   90,
       141221  + /*   680 */    91,   92,   93,   94,   95,   43,   44,   45,   46,   47,
       141222  + /*   690 */    48,   49,   50,   51,   52,   53,   54,   55,   56,   57,
       141223  + /*   700 */   243,  189,  243,  198,  172,  250,  251,  117,   31,  201,
       141224  + /*   710 */    26,  139,  122,  141,   19,  220,   39,   29,  220,  211,
       141225  + /*   720 */    24,   33,  153,  164,  153,  164,   19,   85,   86,   87,
       141226  + /*   730 */    88,   89,   90,   91,   92,   93,   94,   95,   43,   44,
       141227  + /*   740 */    45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
       141228  + /*   750 */    55,   56,   57,   65,  243,  196,  197,  196,  197,  131,
       141229  + /*   760 */   189,   22,  103,   24,  153,   23,   19,  208,   26,  208,
       141230  + /*   770 */   102,  103,  113,   23,  242,   22,   26,  134,  164,  136,
       141231  + /*   780 */    85,   86,   87,   88,   89,   90,   91,   92,   93,   94,
       141232  + /*   790 */    95,   44,   45,   46,   47,   48,   49,   50,   51,   52,
       141233  + /*   800 */    53,   54,   55,   56,   57,   98,  153,  153,  124,  153,
       141234  + /*   810 */   196,  197,   23,   23,   61,   26,   26,   19,   23,  123,
       141235  + /*   820 */    23,   26,  208,   26,    7,    8,  153,   22,  174,  175,
       141236  + /*   830 */   174,  175,   85,   86,   87,   88,   89,   90,   91,   92,
       141237  + /*   840 */    93,   94,   95,   45,   46,   47,   48,   49,   50,   51,
       141238  + /*   850 */    52,   53,   54,   55,   56,   57,   19,   20,   59,   22,
       141239  + /*   860 */   111,   59,  164,   23,   59,   23,   26,  153,   26,   59,
       141240  + /*   870 */   153,   72,   23,   36,   72,   26,   35,   23,   59,  134,
       141241  + /*   880 */    26,  136,  133,   85,   86,   87,   88,   89,   90,   91,
       141242  + /*   890 */    92,   93,   94,   95,  196,  197,   59,   98,   99,  100,
       141243  + /*   900 */    98,   99,  100,   98,   99,  100,  208,   66,   71,   99,
       141244  + /*   910 */    54,   55,   56,   57,   58,   74,  153,   80,   99,   19,
       141245  + /*   920 */    83,  223,   23,   26,  153,   26,   89,   90,   54,   55,
       141246  + /*   930 */    56,   57,  153,   96,  153,   98,   99,  100,   22,  153,
       141247  + /*   940 */   103,   85,   86,   87,   88,   89,   90,   91,   92,   93,
       141248  + /*   950 */    94,   95,  183,  112,  158,  174,  175,  120,  121,   85,
       141249  + /*   960 */    86,   87,   88,   89,   90,   91,   92,   93,   94,   95,
       141250  + /*   970 */   215,  134,  135,  136,  137,  138,    0,    1,    2,   23,
       141251  + /*   980 */    21,    5,   26,  153,   22,   59,   10,   11,   12,   13,
       141252  + /*   990 */    14,    1,    2,   17,  212,    5,  153,  153,   98,  153,
       141253  + /*  1000 */    10,   11,   12,   13,   14,  108,   30,   17,   32,  193,
       141254  + /*  1010 */   153,   59,  153,  153,  170,  171,   40,  174,  175,  153,
       141255  + /*  1020 */    30,   59,   32,   19,   20,   99,   22,  170,  171,  233,
       141256  + /*  1030 */    40,  188,  236,  174,  175,  153,  153,  153,   79,  123,
       141257  + /*  1040 */    36,   89,   90,  153,  153,  153,   70,  188,  153,   97,
       141258  + /*  1050 */    98,   99,  100,   77,  102,  153,   80,   81,  174,  175,
       141259  + /*  1060 */    70,   99,  110,   59,  105,  174,  175,   77,  153,  238,
       141260  + /*  1070 */    80,   81,  188,   19,   20,   71,   22,  153,  153,  235,
       141261  + /*  1080 */    19,   22,  164,   24,   59,  153,  134,   83,  136,  153,
       141262  + /*  1090 */    36,  115,  235,   89,   90,   91,  120,  121,  153,  153,
       141263  + /*  1100 */    96,  142,   98,   99,  100,  115,   59,  103,   83,  239,
       141264  + /*  1110 */   120,  121,  199,   59,  196,  197,  153,  153,   59,  143,
       141265  + /*  1120 */   174,  175,  153,   98,   99,   71,  208,  153,  103,  165,
       141266  + /*  1130 */   153,   19,   20,  143,   22,  153,  153,   83,  134,  135,
       141267  + /*  1140 */   136,  137,  138,   89,   90,   98,   99,  100,   36,  185,
       141268  + /*  1150 */    96,  187,   98,   99,  100,   91,   95,  103,   99,  134,
       141269  + /*  1160 */   135,  136,  101,  102,  103,  104,  105,  106,  107,  153,
       141270  + /*  1170 */    26,   59,  125,  164,  113,  153,  153,  153,  212,   12,
       141271  + /*  1180 */    19,  117,  153,   71,  153,  212,  122,  164,  134,  135,
       141272  + /*  1190 */   136,  137,  138,  212,   27,   83,  212,  174,  175,   59,
       141273  + /*  1200 */   200,   89,   90,  174,  175,  196,  197,   46,   96,   42,
       141274  + /*  1210 */    98,   99,  100,  172,  151,  103,    5,  208,  203,  196,
       141275  + /*  1220 */   197,   10,   11,   12,   13,   14,  216,  216,   17,  244,
       141276  + /*  1230 */    63,  208,  209,  210,  153,   80,   24,  203,   98,   99,
       141277  + /*  1240 */   100,   30,   22,   32,  100,  164,  134,  135,  136,  137,
       141278  + /*  1250 */   138,   40,  148,  164,  150,  174,  175,  102,   97,  155,
       141279  + /*  1260 */   203,  157,  164,  244,  178,  125,  186,  182,  164,  125,
       141280  + /*  1270 */   177,   59,  177,  177,  113,  120,  121,  196,  197,   59,
       141281  + /*  1280 */   232,   70,  153,  216,  202,  196,  197,  153,   77,  208,
       141282  + /*  1290 */   209,   80,   81,  156,  196,  197,   60,  208,  248,  200,
       141283  + /*  1300 */   196,  197,  153,  174,  175,  123,  208,  153,  174,  175,
       141284  + /*  1310 */   160,   99,  208,  153,   38,  153,  160,  153,   98,   99,
       141285  + /*  1320 */   100,  153,  245,  174,  175,  221,  115,  153,  174,  175,
       141286  + /*  1330 */   153,  120,  121,  245,  174,  175,  174,  175,  174,  175,
       141287  + /*  1340 */   160,  153,  174,  175,  153,  225,  153,   22,  174,  175,
       141288  + /*  1350 */    97,  174,  175,  249,  143,  153,  224,  153,   43,  153,
       141289  + /*  1360 */   191,  153,  174,  175,   18,  174,  175,  174,  175,  153,
       141290  + /*  1370 */   131,  153,  194,  203,  153,  194,  174,  175,  174,  175,
       141291  + /*  1380 */   174,  175,  174,  175,  153,  160,  153,   18,  153,  194,
       141292  + /*  1390 */   174,  175,  174,  175,  153,  174,  175,  153,  225,  153,
       141293  + /*  1400 */   203,  153,  159,  153,  194,  174,  175,  174,  175,  174,
       141294  + /*  1410 */   175,  153,  203,  153,  224,  174,  175,  191,  174,  175,
       141295  + /*  1420 */   174,  175,  174,  175,  174,  175,  203,  160,  153,  191,
       141296  + /*  1430 */   153,  159,  174,  175,  174,  175,  153,  139,   62,  153,
       141297  + /*  1440 */   241,  153,  160,  153,  159,  153,   22,  240,  179,  174,
       141298  + /*  1450 */   175,  174,  175,  160,  159,   97,  160,  174,  175,  159,
       141299  + /*  1460 */   174,  175,  174,  175,  174,  175,  174,  175,  179,   64,
       141300  + /*  1470 */   176,  184,  108,  176,   95,  176,  234,  126,  176,  234,
       141301  + /*  1480 */   179,  178,  176,  176,  176,   97,  218,  217,  184,  179,
       141302  + /*  1490 */   179,  218,  218,  160,   22,  217,  217,  160,  218,  139,
       141303  + /*  1500 */   229,  217,  130,  129,  127,   25,  128,  163,   26,  162,
       141304  + /*  1510 */    13,  206,  231,  154,    6,  154,  207,  205,  204,  203,
       141305  + /*  1520 */   152,  166,  152,  152,  172,  172,  172,    4,  172,  166,
       141306  + /*  1530 */   180,  166,    3,   22,  172,  144,   15,  180,  172,  172,
       141307  + /*  1540 */    82,   16,   23,   23,  121,  254,  132,  172,  112,  124,
       141308  + /*  1550 */    24,   20,  126,   16,    1,  124,  112,   61,   53,   37,
       141309  + /*  1560 */   133,  132,   53,   53,  112,   53,   98,  254,  251,   34,
       141310  + /*  1570 */   123,    1,    5,   22,   97,  142,   26,   75,  123,   41,
       141311  + /*  1580 */    97,   68,   68,   24,   20,   19,  113,   22,  107,   28,
       141312  + /*  1590 */    22,   67,   23,   22,   22,   67,   22,   67,   23,   37,
       141313  + /*  1600 */    23,   23,   26,   23,   22,   24,   23,   22,   24,  123,
       141314  + /*  1610 */    23,   23,   22,   98,  125,   26,   11,   23,   26,   23,
       141315  + /*  1620 */    34,   23,   23,   23,   23,   34,   22,   34,   26,   22,
       141316  + /*  1630 */    22,   15,   23,   23,   22,  117,   23,   22,    1,  123,
       141317  + /*  1640 */    26,   23,  255,  255,  255,  255,  255,  255,  255,  255,
       141318  + /*  1650 */   123,  255,  255,  255,  255,  123,  123,  255,  255,  255,
       141319  + /*  1660 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141320  + /*  1670 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141321  + /*  1680 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141322  + /*  1690 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141323  + /*  1700 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141324  + /*  1710 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141325  + /*  1720 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141326  + /*  1730 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141327  + /*  1740 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141328  + /*  1750 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141329  + /*  1760 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141330  + /*  1770 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141331  + /*  1780 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141332  + /*  1790 */   255,  255,  255,  255,  255,  255,  255,  255,  255,  255,
       141333  + /*  1800 */   255,  255,
       141334  +};
       141335  +#define YY_SHIFT_COUNT    (489)
140446 141336   #define YY_SHIFT_MIN      (0)
140447         -#define YY_SHIFT_MAX      (1559)
       141337  +#define YY_SHIFT_MAX      (1637)
140448 141338   static const unsigned short int yy_shift_ofst[] = {
140449         - /*     0 */   182, 1090,  822,  822,  306,  957,  957,  957,  957,  210,
140450         - /*    10 */     0,    0,  104,  630,  957,  957,  957,  957,  957,  957,
140451         - /*    20 */   957, 1117, 1117,  126,  968,  306,  306,  306,  306,  306,
140452         - /*    30 */   306,   52,  156,  208,  260,  312,  364,  416,  468,  523,
140453         - /*    40 */   578,  630,  630,  630,  630,  630,  630,  630,  630,  630,
140454         - /*    50 */   630,  630,  630,  630,  630,  630,  630,  630,  682,  630,
140455         - /*    60 */   733,  783,  783,  877,  957,  957,  957,  957,  957,  957,
140456         - /*    70 */   957,  957,  957,  957,  957,  957,  957,  957,  957,  957,
140457         - /*    80 */   957,  957,  957,  957,  957,  957,  957,  957,  957,  957,
140458         - /*    90 */   957,  957,  957,  957,  957,  978,  957,  957,  957,  957,
140459         - /*   100 */   957,  957,  957,  957,  957,  957,  957,  957,  957, 1061,
140460         - /*   110 */  1108, 1108, 1108, 1108, 1108,   40,  127,   20,  280,  843,
140461         - /*   120 */  1032,  144,  144,  280,  310,  310,  310,  310,   59,  191,
140462         - /*   130 */    69, 1566, 1566, 1566,  786,  786,  786,  522,  836,  522,
140463         - /*   140 */   959,  959,  892,  155,  358,  280,  280,  280,  280,  280,
140464         - /*   150 */   280,  280,  280,  280,  280,  280,  280,  280,  280,  280,
140465         - /*   160 */   280,  280,  280,  280,  280,  280,  371,  388,  645,  645,
140466         - /*   170 */   531, 1566, 1566, 1566,  504,  189,  189,  909,   63,  176,
140467         - /*   180 */   928,  440,  932,  973,  280,  280,  280,  280,  280,  314,
140468         - /*   190 */   280,  280,  280,  280,  280,  280,  280,  280,  280,  280,
140469         - /*   200 */   280,  280, 1064, 1064, 1064,  280,  280,  280,  280,  667,
140470         - /*   210 */   280,  280,  280,  825,  280,  280,  902,  280,  280,  280,
140471         - /*   220 */   280,  280,  280,  280,  280,  383,  676,  325,  975,  975,
140472         - /*   230 */   975,  975, 1010,  325,  325,  819,  349,  524,  569,  829,
140473         - /*   240 */   829,  832,  569,  832,  686,   51,  656,  303,  303,  303,
140474         - /*   250 */   829,  294,  520,  628,  474, 1174, 1115, 1115, 1208, 1208,
140475         - /*   260 */  1115, 1231, 1217, 1131, 1246, 1246, 1246, 1246, 1115, 1276,
140476         - /*   270 */  1131, 1231, 1217, 1217, 1131, 1115, 1276, 1184, 1277, 1115,
140477         - /*   280 */  1276, 1330, 1115, 1276, 1115, 1276, 1330, 1280, 1280, 1280,
140478         - /*   290 */  1320, 1330, 1280, 1285, 1280, 1320, 1280, 1280, 1330, 1306,
140479         - /*   300 */  1306, 1330, 1284, 1294, 1284, 1294, 1284, 1294, 1284, 1294,
140480         - /*   310 */  1115, 1392, 1115, 1281, 1288, 1296, 1292, 1297, 1131, 1398,
140481         - /*   320 */  1401, 1417, 1417, 1429, 1429, 1429, 1566, 1566, 1566, 1566,
140482         - /*   330 */  1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566, 1566,
140483         - /*   340 */  1566, 1566,   34,  357,   38,  462,  514,  484, 1074,  727,
140484         - /*   350 */   740,  734,  735,  777,  778,  784,  788,  803,  694,  845,
140485         - /*   360 */   742,  796,  833,  837,  889,  860,  886, 1036,  806,  958,
140486         - /*   370 */  1446, 1448, 1430, 1311, 1441, 1378, 1444, 1438, 1439, 1343,
140487         - /*   380 */  1334, 1356, 1345, 1452, 1348, 1458, 1474, 1353, 1346, 1425,
140488         - /*   390 */  1426, 1427, 1428, 1371, 1387, 1450, 1363, 1486, 1484, 1468,
140489         - /*   400 */  1384, 1352, 1431, 1467, 1432, 1420, 1454, 1374, 1390, 1476,
140490         - /*   410 */  1481, 1483, 1391, 1399, 1485, 1440, 1487, 1488, 1482, 1489,
140491         - /*   420 */  1442, 1490, 1491, 1449, 1475, 1493, 1494, 1496, 1495, 1497,
140492         - /*   430 */  1492, 1498, 1500, 1502, 1501, 1404, 1504, 1505, 1433, 1499,
140493         - /*   440 */  1508, 1407, 1506, 1503, 1509, 1507, 1511, 1513, 1515, 1506,
140494         - /*   450 */  1516, 1517, 1518, 1519, 1521, 1534, 1524, 1525, 1526, 1527,
140495         - /*   460 */  1529, 1530, 1532, 1522, 1436, 1434, 1435, 1437, 1443, 1535,
140496         - /*   470 */  1540, 1559,
140497         -};
140498         -#define YY_REDUCE_COUNT (341)
140499         -#define YY_REDUCE_MIN   (-211)
140500         -#define YY_REDUCE_MAX   (1301)
       141339  + /*     0 */   990,  976, 1211,  837,  837,  316, 1054, 1054, 1054, 1054,
       141340  + /*    10 */   214,    0,    0,  106,  642, 1054, 1054, 1054, 1054, 1054,
       141341  + /*    20 */  1054, 1054, 1054,  952,  952,  226, 1155,  316,  316,  316,
       141342  + /*    30 */   316,  316,  316,   53,  159,  212,  265,  318,  371,  424,
       141343  + /*    40 */   477,  533,  589,  642,  642,  642,  642,  642,  642,  642,
       141344  + /*    50 */   642,  642,  642,  642,  642,  642,  642,  642,  642,  642,
       141345  + /*    60 */   695,  642,  747,  798,  798, 1004, 1054, 1054, 1054, 1054,
       141346  + /*    70 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
       141347  + /*    80 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
       141348  + /*    90 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054,
       141349  + /*   100 */  1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054,
       141350  + /*   110 */  1054,  856,  874,  874,  874,  874,  874,  134,  147,   93,
       141351  + /*   120 */   342,  959, 1161,  253,  253,  342,  367,  367,  367,  367,
       141352  + /*   130 */   179,   36,   79, 1657, 1657, 1657, 1061, 1061, 1061,  516,
       141353  + /*   140 */   799,  516,  516,  531,  531,  802,  249,  369,  342,  342,
       141354  + /*   150 */   342,  342,  342,  342,  342,  342,  342,  342,  342,  342,
       141355  + /*   160 */   342,  342,  342,  342,  342,  342,  342,  342,  342,  272,
       141356  + /*   170 */   442,  442,  536, 1657, 1657, 1657, 1025,  245,  245,  570,
       141357  + /*   180 */   172,  286,  805, 1047, 1140, 1220,  342,  342,  342,  342,
       141358  + /*   190 */   342,  342,  342,  342,  170,  342,  342,  342,  342,  342,
       141359  + /*   200 */   342,  342,  342,  342,  342,  342,  342,  841,  841,  841,
       141360  + /*   210 */   342,  342,  342,  342,  530,  342,  342,  342, 1059,  342,
       141361  + /*   220 */   342, 1167,  342,  342,  342,  342,  342,  342,  342,  342,
       141362  + /*   230 */   123,  688,  177, 1212, 1212, 1212, 1212, 1144,  177,  177,
       141363  + /*   240 */  1064,  409,   33,  628,  707,  707,  900,  628,  628,  900,
       141364  + /*   250 */   897,  323,  398,  677,  677,  677,  707,  572,  684,  590,
       141365  + /*   260 */   739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315,
       141366  + /*   270 */  1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253,
       141367  + /*   280 */  1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369,
       141368  + /*   290 */  1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405,
       141369  + /*   300 */  1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379,
       141370  + /*   310 */  1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182,
       141371  + /*   320 */  1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482,
       141372  + /*   330 */  1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657,
       141373  + /*   340 */  1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
       141374  + /*   350 */  1657,   20,  413,   98,  423,  519,  383,  962,  742,   61,
       141375  + /*   360 */   696,  749,  750,  753,  789,  790,  795,  797,  840,  842,
       141376  + /*   370 */   810,  668,  817,  659,  819,  849,  854,  899,  643,  745,
       141377  + /*   380 */   956,  926,  916, 1523, 1529, 1511, 1391, 1521, 1458, 1525,
       141378  + /*   390 */  1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537,
       141379  + /*   400 */  1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510,
       141380  + /*   410 */  1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433,
       141381  + /*   420 */  1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566,
       141382  + /*   430 */  1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561,
       141383  + /*   440 */  1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581,
       141384  + /*   450 */  1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489,
       141385  + /*   460 */  1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600,
       141386  + /*   470 */  1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613,
       141387  + /*   480 */  1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637,
       141388  +};
       141389  +#define YY_REDUCE_COUNT (350)
       141390  +#define YY_REDUCE_MIN   (-225)
       141391  +#define YY_REDUCE_MAX   (1375)
140501 141392   static const short yy_reduce_ofst[] = {
140502         - /*     0 */  -143,  789,  753, 1059, -137, -146, -144, -141, -136,  687,
140503         - /*    10 */  -107,  101, -203,  -52,  830,  870,  890,  167,  953,  218,
140504         - /*    20 */   220,  413,  646,  897,   73,  281,  283,  332,  496,  601,
140505         - /*    30 */   650, -211, -211, -211, -211, -211, -211, -211, -211, -211,
140506         - /*    40 */  -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
140507         - /*    50 */  -211, -211, -211, -211, -211, -211, -211, -211, -211, -211,
140508         - /*    60 */  -211, -211, -211,  374,  377,  537,  969,  983, 1006, 1008,
140509         - /*    70 */  1015, 1055, 1067, 1069, 1071, 1084, 1096, 1100, 1104, 1111,
140510         - /*    80 */  1113, 1116, 1119, 1123, 1127, 1130, 1136, 1143, 1146, 1150,
140511         - /*    90 */  1153, 1155, 1159, 1161, 1163, 1166, 1170, 1189, 1193, 1195,
140512         - /*   100 */  1197, 1199, 1201, 1203, 1205, 1207, 1212, 1230, 1232, -211,
140513         - /*   110 */  -211, -211, -211, -211, -211, -211, -211, -211,  -30,  427,
140514         - /*   120 */  -171, -145, -134,   22,  279,  287,  279,  287,   99, -211,
140515         - /*   130 */  -211, -211, -211, -211, -165, -165, -165,  123,  135,  175,
140516         - /*   140 */  -150,  396,  337,  291,  291, -147,  185,  391,  446,  444,
140517         - /*   150 */   452,  500,  501,  502,   27, -152,  295,  438,  490,  503,
140518         - /*   160 */   495,  506,  -73,  447,  451,  536,  570,  551,  540,  579,
140519         - /*   170 */    30,  508,  535,   81,   14,   61,  115,  168,  142,  222,
140520         - /*   180 */   275,  284,  397,  599,  607,  647,  654,  660,  709,  658,
140521         - /*   190 */   714,  750,  754,  772,  787,  801,  817,  818,  850,  863,
140522         - /*   200 */   867,  871,  466,  748,  799,  881,  888,  898,  913,  824,
140523         - /*   210 */   930,  933,  934,  873,  942,  945,  849,  946,  222,  954,
140524         - /*   220 */   971,  972,  976,  979,  980,  900,  874,  927,  950,  961,
140525         - /*   230 */   962,  963,  824,  927,  927,  939,  970, 1018,  981,  988,
140526         - /*   240 */   993,  936,  982,  937, 1009, 1000, 1031, 1011, 1014, 1040,
140527         - /*   250 */  1003,  991,  990, 1026, 1072,  985, 1076, 1079,  997, 1005,
140528         - /*   260 */  1091, 1037, 1082, 1060, 1083, 1087, 1088, 1098, 1124, 1141,
140529         - /*   270 */  1106, 1092, 1122, 1135, 1128, 1147, 1173, 1110, 1105, 1187,
140530         - /*   280 */  1192, 1176, 1202, 1198, 1206, 1200, 1182, 1213, 1214, 1215,
140531         - /*   290 */  1209, 1216, 1218, 1219, 1220, 1224, 1222, 1223, 1221, 1171,
140532         - /*   300 */  1177, 1233, 1196, 1194, 1204, 1210, 1211, 1225, 1226, 1228,
140533         - /*   310 */  1253, 1190, 1256, 1191, 1227, 1229, 1234, 1236, 1235, 1263,
140534         - /*   320 */  1268, 1278, 1279, 1289, 1291, 1295, 1185, 1237, 1238, 1282,
140535         - /*   330 */  1274, 1283, 1286, 1287, 1290, 1269, 1270, 1293, 1298, 1299,
140536         - /*   340 */  1300, 1301,
       141393  + /*     0 */  -137,  -31, 1104, 1023, 1081, -132,  -40,  -38,  223,  225,
       141394  + /*    10 */   698, -153,  -99, -225, -165,  386,  478,  843,  859, -139,
       141395  + /*    20 */   884,  117,  277,  844,  857,  964,  559,  561,  614,  918,
       141396  + /*    30 */  1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222,
       141397  + /*    40 */  -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
       141398  + /*    50 */  -222, -222, -222, -222, -222, -222, -222, -222, -222, -222,
       141399  + /*    60 */  -222, -222, -222, -222, -222,  329,  331,  497,  654,  656,
       141400  + /*    70 */   781,  891,  946, 1029, 1129, 1134, 1149, 1154, 1160, 1162,
       141401  + /*    80 */  1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206,
       141402  + /*    90 */  1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246,
       141403  + /*   100 */  1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290,
       141404  + /*   110 */  1292, -222, -222, -222, -222, -222, -222, -222, -222, -222,
       141405  + /*   120 */  -115,  796, -156, -154, -141,   14,  242,  349,  242,  349,
       141406  + /*   130 */   -61, -222, -222, -222, -222, -222,  101,  101,  101,  332,
       141407  + /*   140 */   302,  384,  387, -170,  146,  344,  196,  196,   15,   11,
       141408  + /*   150 */   183,  235,  395,  355,  396,  406,  452,  457,  391,  459,
       141409  + /*   160 */   443,  447,  511,  495,  454,  512,  505,  571,  498,  532,
       141410  + /*   170 */   431,  435,  339,  455,  446,  508, -174, -116,  -97, -120,
       141411  + /*   180 */  -150,   64,  176,  330,  337,  509,  569,  611,  653,  673,
       141412  + /*   190 */   714,  717,  763,  771,  -34,  779,  786,  830,  846,  860,
       141413  + /*   200 */   866,  882,  883,  890,  892,  895,  902,  319,  368,  769,
       141414  + /*   210 */   915,  924,  925,  932,  755,  936,  945,  963,  782,  969,
       141415  + /*   220 */   974,  816,  977,   64,  982,  983, 1016, 1022, 1024, 1031,
       141416  + /*   230 */   870,  831,  913,  966,  973,  981,  984,  755,  913,  913,
       141417  + /*   240 */  1000, 1041, 1063, 1015, 1010, 1011,  985, 1034, 1057, 1019,
       141418  + /*   250 */  1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099,
       141419  + /*   260 */  1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169,
       141420  + /*   270 */  1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173,
       141421  + /*   280 */  1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285,
       141422  + /*   290 */  1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287,
       141423  + /*   300 */  1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245,
       141424  + /*   310 */  1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333,
       141425  + /*   320 */  1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347,
       141426  + /*   330 */  1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352,
       141427  + /*   340 */  1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375,
       141428  + /*   350 */  1365,
140537 141429   };
140538 141430   static const YYACTIONTYPE yy_default[] = {
140539         - /*     0 */  1297, 1349, 1221, 1014, 1119, 1221, 1221, 1221, 1221, 1014,
140540         - /*    10 */  1145, 1145, 1272, 1045, 1014, 1014, 1014, 1014, 1014, 1220,
140541         - /*    20 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140542         - /*    30 */  1014, 1151, 1014, 1014, 1014, 1014, 1222, 1223, 1014, 1014,
140543         - /*    40 */  1014, 1271, 1273, 1161, 1160, 1159, 1158, 1254, 1132, 1156,
140544         - /*    50 */  1149, 1153, 1216, 1217, 1215, 1219, 1222, 1223, 1014, 1152,
140545         - /*    60 */  1186, 1200, 1185, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140546         - /*    70 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140547         - /*    80 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140548         - /*    90 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140549         - /*   100 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1194,
140550         - /*   110 */  1199, 1206, 1198, 1195, 1188, 1187, 1189, 1190, 1014, 1035,
140551         - /*   120 */  1084, 1014, 1014, 1014, 1289, 1288, 1014, 1014, 1045, 1191,
140552         - /*   130 */  1192, 1203, 1202, 1201, 1279, 1305, 1304, 1014, 1014, 1014,
140553         - /*   140 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140554         - /*   150 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140555         - /*   160 */  1014, 1014, 1014, 1014, 1014, 1014, 1045, 1297, 1041, 1041,
140556         - /*   170 */  1014, 1284, 1119, 1110, 1014, 1014, 1014, 1014, 1014, 1014,
140557         - /*   180 */  1014, 1014, 1014, 1014, 1014, 1276, 1274, 1014, 1236, 1014,
140558         - /*   190 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140559         - /*   200 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140560         - /*   210 */  1014, 1014, 1014, 1115, 1014, 1014, 1014, 1014, 1014, 1014,
140561         - /*   220 */  1014, 1014, 1014, 1014, 1299, 1014, 1249, 1098, 1115, 1115,
140562         - /*   230 */  1115, 1115, 1117, 1099, 1097, 1109, 1045, 1021, 1155, 1134,
140563         - /*   240 */  1134, 1338, 1155, 1338, 1059, 1319, 1056, 1145, 1145, 1145,
140564         - /*   250 */  1134, 1218, 1116, 1109, 1014, 1341, 1124, 1124, 1340, 1340,
140565         - /*   260 */  1124, 1166, 1087, 1155, 1093, 1093, 1093, 1093, 1124, 1032,
140566         - /*   270 */  1155, 1166, 1087, 1087, 1155, 1124, 1032, 1253, 1335, 1124,
140567         - /*   280 */  1032, 1229, 1124, 1032, 1124, 1032, 1229, 1085, 1085, 1085,
140568         - /*   290 */  1074, 1229, 1085, 1059, 1085, 1074, 1085, 1085, 1229, 1233,
140569         - /*   300 */  1233, 1229, 1138, 1133, 1138, 1133, 1138, 1133, 1138, 1133,
140570         - /*   310 */  1124, 1224, 1124, 1014, 1150, 1139, 1148, 1146, 1155, 1038,
140571         - /*   320 */  1077, 1302, 1302, 1298, 1298, 1298, 1346, 1346, 1284, 1314,
140572         - /*   330 */  1045, 1045, 1045, 1045, 1314, 1061, 1061, 1045, 1045, 1045,
140573         - /*   340 */  1045, 1314, 1014, 1014, 1014, 1014, 1014, 1014, 1309, 1014,
140574         - /*   350 */  1238, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140575         - /*   360 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1171,
140576         - /*   370 */  1014, 1017, 1281, 1014, 1014, 1280, 1014, 1014, 1014, 1014,
140577         - /*   380 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140578         - /*   390 */  1014, 1014, 1014, 1014, 1014, 1014, 1337, 1014, 1014, 1014,
140579         - /*   400 */  1014, 1014, 1014, 1252, 1251, 1014, 1014, 1126, 1014, 1014,
140580         - /*   410 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140581         - /*   420 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140582         - /*   430 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140583         - /*   440 */  1014, 1014, 1147, 1014, 1140, 1014, 1014, 1014, 1014, 1328,
140584         - /*   450 */  1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014,
140585         - /*   460 */  1014, 1014, 1014, 1323, 1101, 1173, 1014, 1172, 1176, 1014,
140586         - /*   470 */  1026, 1014,
       141431  + /*     0 */  1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261,
       141432  + /*    10 */  1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046,
       141433  + /*    20 */  1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141434  + /*    30 */  1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263,
       141435  + /*    40 */  1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294,
       141436  + /*    50 */  1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263,
       141437  + /*    60 */  1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046,
       141438  + /*    70 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141439  + /*    80 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141440  + /*    90 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141441  + /*   100 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141442  + /*   110 */  1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230,
       141443  + /*   120 */  1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046,
       141444  + /*   130 */  1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046,
       141445  + /*   140 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141446  + /*   150 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141447  + /*   160 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077,
       141448  + /*   170 */  1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046,
       141449  + /*   180 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046,
       141450  + /*   190 */  1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141451  + /*   200 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141452  + /*   210 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046,
       141453  + /*   220 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339,
       141454  + /*   230 */  1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129,
       141455  + /*   240 */  1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378,
       141456  + /*   250 */  1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141,
       141457  + /*   260 */  1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119,
       141458  + /*   270 */  1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200,
       141459  + /*   280 */  1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064,
       141460  + /*   290 */  1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106,
       141461  + /*   300 */  1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273,
       141462  + /*   310 */  1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156,
       141463  + /*   320 */  1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109,
       141464  + /*   330 */  1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077,
       141465  + /*   340 */  1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077,
       141466  + /*   350 */  1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278,
       141467  + /*   360 */  1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141468  + /*   370 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141469  + /*   380 */  1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046,
       141470  + /*   390 */  1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046,
       141471  + /*   400 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141472  + /*   410 */  1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046,
       141473  + /*   420 */  1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046,
       141474  + /*   430 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141475  + /*   440 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141476  + /*   450 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141477  + /*   460 */  1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046,
       141478  + /*   470 */  1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046,
       141479  + /*   480 */  1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046,
140587 141480   };
140588 141481   /********** End of lemon-generated parsing tables *****************************/
140589 141482   
140590 141483   /* The next table maps tokens (terminal symbols) into fallback tokens.  
140591 141484   ** If a construct like the following:
140592 141485   ** 
140593 141486   **      %fallback ID X Y Z.
................................................................................
140660 141553       0,  /*         GT => nothing */
140661 141554       0,  /*         LE => nothing */
140662 141555       0,  /*         LT => nothing */
140663 141556       0,  /*         GE => nothing */
140664 141557       0,  /*     ESCAPE => nothing */
140665 141558       0,  /*         ID => nothing */
140666 141559      59,  /*   COLUMNKW => ID */
       141560  +   59,  /*         DO => ID */
140667 141561      59,  /*        FOR => ID */
140668 141562      59,  /*     IGNORE => ID */
140669 141563      59,  /*  INITIALLY => ID */
140670 141564      59,  /*    INSTEAD => ID */
140671 141565      59,  /*         NO => ID */
140672 141566      59,  /*        KEY => ID */
140673 141567      59,  /*         OF => ID */
................................................................................
140721 141615   #ifdef YYTRACKMAXSTACKDEPTH
140722 141616     int yyhwm;                    /* High-water mark of the stack */
140723 141617   #endif
140724 141618   #ifndef YYNOERRORRECOVERY
140725 141619     int yyerrcnt;                 /* Shifts left before out of the error */
140726 141620   #endif
140727 141621     sqlite3ParserARG_SDECL                /* A place to hold %extra_argument */
       141622  +  sqlite3ParserCTX_SDECL                /* A place to hold %extra_context */
140728 141623   #if YYSTACKDEPTH<=0
140729 141624     int yystksz;                  /* Current side of the stack */
140730 141625     yyStackEntry *yystack;        /* The parser's stack */
140731 141626     yyStackEntry yystk0;          /* First stack entry */
140732 141627   #else
140733 141628     yyStackEntry yystack[YYSTACKDEPTH];  /* The parser's stack */
140734 141629     yyStackEntry *yystackEnd;            /* Last entry in the stack */
................................................................................
140829 141724     /*   54 */ "GT",
140830 141725     /*   55 */ "LE",
140831 141726     /*   56 */ "LT",
140832 141727     /*   57 */ "GE",
140833 141728     /*   58 */ "ESCAPE",
140834 141729     /*   59 */ "ID",
140835 141730     /*   60 */ "COLUMNKW",
140836         -  /*   61 */ "FOR",
140837         -  /*   62 */ "IGNORE",
140838         -  /*   63 */ "INITIALLY",
140839         -  /*   64 */ "INSTEAD",
140840         -  /*   65 */ "NO",
140841         -  /*   66 */ "KEY",
140842         -  /*   67 */ "OF",
140843         -  /*   68 */ "OFFSET",
140844         -  /*   69 */ "PRAGMA",
140845         -  /*   70 */ "RAISE",
140846         -  /*   71 */ "RECURSIVE",
140847         -  /*   72 */ "REPLACE",
140848         -  /*   73 */ "RESTRICT",
140849         -  /*   74 */ "ROW",
140850         -  /*   75 */ "TRIGGER",
140851         -  /*   76 */ "VACUUM",
140852         -  /*   77 */ "VIEW",
140853         -  /*   78 */ "VIRTUAL",
140854         -  /*   79 */ "WITH",
140855         -  /*   80 */ "REINDEX",
140856         -  /*   81 */ "RENAME",
140857         -  /*   82 */ "CTIME_KW",
140858         -  /*   83 */ "ANY",
140859         -  /*   84 */ "BITAND",
140860         -  /*   85 */ "BITOR",
140861         -  /*   86 */ "LSHIFT",
140862         -  /*   87 */ "RSHIFT",
140863         -  /*   88 */ "PLUS",
140864         -  /*   89 */ "MINUS",
140865         -  /*   90 */ "STAR",
140866         -  /*   91 */ "SLASH",
140867         -  /*   92 */ "REM",
140868         -  /*   93 */ "CONCAT",
140869         -  /*   94 */ "COLLATE",
140870         -  /*   95 */ "BITNOT",
140871         -  /*   96 */ "INDEXED",
140872         -  /*   97 */ "STRING",
140873         -  /*   98 */ "JOIN_KW",
140874         -  /*   99 */ "CONSTRAINT",
140875         -  /*  100 */ "DEFAULT",
140876         -  /*  101 */ "NULL",
140877         -  /*  102 */ "PRIMARY",
140878         -  /*  103 */ "UNIQUE",
140879         -  /*  104 */ "CHECK",
140880         -  /*  105 */ "REFERENCES",
140881         -  /*  106 */ "AUTOINCR",
140882         -  /*  107 */ "ON",
140883         -  /*  108 */ "INSERT",
140884         -  /*  109 */ "DELETE",
140885         -  /*  110 */ "UPDATE",
140886         -  /*  111 */ "SET",
140887         -  /*  112 */ "DEFERRABLE",
140888         -  /*  113 */ "FOREIGN",
140889         -  /*  114 */ "DROP",
140890         -  /*  115 */ "UNION",
140891         -  /*  116 */ "ALL",
140892         -  /*  117 */ "EXCEPT",
140893         -  /*  118 */ "INTERSECT",
140894         -  /*  119 */ "SELECT",
140895         -  /*  120 */ "VALUES",
140896         -  /*  121 */ "DISTINCT",
140897         -  /*  122 */ "DOT",
140898         -  /*  123 */ "FROM",
140899         -  /*  124 */ "JOIN",
140900         -  /*  125 */ "USING",
140901         -  /*  126 */ "ORDER",
140902         -  /*  127 */ "GROUP",
140903         -  /*  128 */ "HAVING",
140904         -  /*  129 */ "LIMIT",
140905         -  /*  130 */ "WHERE",
140906         -  /*  131 */ "INTO",
140907         -  /*  132 */ "FLOAT",
140908         -  /*  133 */ "BLOB",
140909         -  /*  134 */ "INTEGER",
140910         -  /*  135 */ "VARIABLE",
140911         -  /*  136 */ "CASE",
140912         -  /*  137 */ "WHEN",
140913         -  /*  138 */ "THEN",
140914         -  /*  139 */ "ELSE",
140915         -  /*  140 */ "INDEX",
140916         -  /*  141 */ "ALTER",
140917         -  /*  142 */ "ADD",
140918         -  /*  143 */ "error",
140919         -  /*  144 */ "input",
140920         -  /*  145 */ "cmdlist",
140921         -  /*  146 */ "ecmd",
140922         -  /*  147 */ "explain",
       141731  +  /*   61 */ "DO",
       141732  +  /*   62 */ "FOR",
       141733  +  /*   63 */ "IGNORE",
       141734  +  /*   64 */ "INITIALLY",
       141735  +  /*   65 */ "INSTEAD",
       141736  +  /*   66 */ "NO",
       141737  +  /*   67 */ "KEY",
       141738  +  /*   68 */ "OF",
       141739  +  /*   69 */ "OFFSET",
       141740  +  /*   70 */ "PRAGMA",
       141741  +  /*   71 */ "RAISE",
       141742  +  /*   72 */ "RECURSIVE",
       141743  +  /*   73 */ "REPLACE",
       141744  +  /*   74 */ "RESTRICT",
       141745  +  /*   75 */ "ROW",
       141746  +  /*   76 */ "TRIGGER",
       141747  +  /*   77 */ "VACUUM",
       141748  +  /*   78 */ "VIEW",
       141749  +  /*   79 */ "VIRTUAL",
       141750  +  /*   80 */ "WITH",
       141751  +  /*   81 */ "REINDEX",
       141752  +  /*   82 */ "RENAME",
       141753  +  /*   83 */ "CTIME_KW",
       141754  +  /*   84 */ "ANY",
       141755  +  /*   85 */ "BITAND",
       141756  +  /*   86 */ "BITOR",
       141757  +  /*   87 */ "LSHIFT",
       141758  +  /*   88 */ "RSHIFT",
       141759  +  /*   89 */ "PLUS",
       141760  +  /*   90 */ "MINUS",
       141761  +  /*   91 */ "STAR",
       141762  +  /*   92 */ "SLASH",
       141763  +  /*   93 */ "REM",
       141764  +  /*   94 */ "CONCAT",
       141765  +  /*   95 */ "COLLATE",
       141766  +  /*   96 */ "BITNOT",
       141767  +  /*   97 */ "ON",
       141768  +  /*   98 */ "INDEXED",
       141769  +  /*   99 */ "STRING",
       141770  +  /*  100 */ "JOIN_KW",
       141771  +  /*  101 */ "CONSTRAINT",
       141772  +  /*  102 */ "DEFAULT",
       141773  +  /*  103 */ "NULL",
       141774  +  /*  104 */ "PRIMARY",
       141775  +  /*  105 */ "UNIQUE",
       141776  +  /*  106 */ "CHECK",
       141777  +  /*  107 */ "REFERENCES",
       141778  +  /*  108 */ "AUTOINCR",
       141779  +  /*  109 */ "INSERT",
       141780  +  /*  110 */ "DELETE",
       141781  +  /*  111 */ "UPDATE",
       141782  +  /*  112 */ "SET",
       141783  +  /*  113 */ "DEFERRABLE",
       141784  +  /*  114 */ "FOREIGN",
       141785  +  /*  115 */ "DROP",
       141786  +  /*  116 */ "UNION",
       141787  +  /*  117 */ "ALL",
       141788  +  /*  118 */ "EXCEPT",
       141789  +  /*  119 */ "INTERSECT",
       141790  +  /*  120 */ "SELECT",
       141791  +  /*  121 */ "VALUES",
       141792  +  /*  122 */ "DISTINCT",
       141793  +  /*  123 */ "DOT",
       141794  +  /*  124 */ "FROM",
       141795  +  /*  125 */ "JOIN",
       141796  +  /*  126 */ "USING",
       141797  +  /*  127 */ "ORDER",
       141798  +  /*  128 */ "GROUP",
       141799  +  /*  129 */ "HAVING",
       141800  +  /*  130 */ "LIMIT",
       141801  +  /*  131 */ "WHERE",
       141802  +  /*  132 */ "INTO",
       141803  +  /*  133 */ "NOTHING",
       141804  +  /*  134 */ "FLOAT",
       141805  +  /*  135 */ "BLOB",
       141806  +  /*  136 */ "INTEGER",
       141807  +  /*  137 */ "VARIABLE",
       141808  +  /*  138 */ "CASE",
       141809  +  /*  139 */ "WHEN",
       141810  +  /*  140 */ "THEN",
       141811  +  /*  141 */ "ELSE",
       141812  +  /*  142 */ "INDEX",
       141813  +  /*  143 */ "ALTER",
       141814  +  /*  144 */ "ADD",
       141815  +  /*  145 */ "input",
       141816  +  /*  146 */ "cmdlist",
       141817  +  /*  147 */ "ecmd",
140923 141818     /*  148 */ "cmdx",
140924         -  /*  149 */ "cmd",
140925         -  /*  150 */ "transtype",
140926         -  /*  151 */ "trans_opt",
140927         -  /*  152 */ "nm",
140928         -  /*  153 */ "savepoint_opt",
140929         -  /*  154 */ "create_table",
140930         -  /*  155 */ "create_table_args",
140931         -  /*  156 */ "createkw",
140932         -  /*  157 */ "temp",
140933         -  /*  158 */ "ifnotexists",
140934         -  /*  159 */ "dbnm",
140935         -  /*  160 */ "columnlist",
140936         -  /*  161 */ "conslist_opt",
140937         -  /*  162 */ "table_options",
140938         -  /*  163 */ "select",
140939         -  /*  164 */ "columnname",
140940         -  /*  165 */ "carglist",
140941         -  /*  166 */ "typetoken",
140942         -  /*  167 */ "typename",
140943         -  /*  168 */ "signed",
140944         -  /*  169 */ "plus_num",
140945         -  /*  170 */ "minus_num",
140946         -  /*  171 */ "scanpt",
140947         -  /*  172 */ "ccons",
140948         -  /*  173 */ "term",
140949         -  /*  174 */ "expr",
140950         -  /*  175 */ "onconf",
140951         -  /*  176 */ "sortorder",
140952         -  /*  177 */ "autoinc",
140953         -  /*  178 */ "eidlist_opt",
140954         -  /*  179 */ "refargs",
140955         -  /*  180 */ "defer_subclause",
140956         -  /*  181 */ "refarg",
140957         -  /*  182 */ "refact",
140958         -  /*  183 */ "init_deferred_pred_opt",
140959         -  /*  184 */ "conslist",
140960         -  /*  185 */ "tconscomma",
140961         -  /*  186 */ "tcons",
140962         -  /*  187 */ "sortlist",
140963         -  /*  188 */ "eidlist",
140964         -  /*  189 */ "defer_subclause_opt",
140965         -  /*  190 */ "orconf",
140966         -  /*  191 */ "resolvetype",
140967         -  /*  192 */ "raisetype",
140968         -  /*  193 */ "ifexists",
140969         -  /*  194 */ "fullname",
140970         -  /*  195 */ "selectnowith",
140971         -  /*  196 */ "oneselect",
140972         -  /*  197 */ "wqlist",
140973         -  /*  198 */ "multiselect_op",
140974         -  /*  199 */ "distinct",
140975         -  /*  200 */ "selcollist",
140976         -  /*  201 */ "from",
140977         -  /*  202 */ "where_opt",
140978         -  /*  203 */ "groupby_opt",
140979         -  /*  204 */ "having_opt",
140980         -  /*  205 */ "orderby_opt",
140981         -  /*  206 */ "limit_opt",
140982         -  /*  207 */ "values",
140983         -  /*  208 */ "nexprlist",
140984         -  /*  209 */ "exprlist",
140985         -  /*  210 */ "sclp",
140986         -  /*  211 */ "as",
140987         -  /*  212 */ "seltablist",
140988         -  /*  213 */ "stl_prefix",
140989         -  /*  214 */ "joinop",
140990         -  /*  215 */ "indexed_opt",
140991         -  /*  216 */ "on_opt",
140992         -  /*  217 */ "using_opt",
140993         -  /*  218 */ "idlist",
140994         -  /*  219 */ "with",
140995         -  /*  220 */ "setlist",
140996         -  /*  221 */ "insert_cmd",
140997         -  /*  222 */ "idlist_opt",
140998         -  /*  223 */ "likeop",
140999         -  /*  224 */ "between_op",
141000         -  /*  225 */ "in_op",
141001         -  /*  226 */ "paren_exprlist",
141002         -  /*  227 */ "case_operand",
141003         -  /*  228 */ "case_exprlist",
141004         -  /*  229 */ "case_else",
141005         -  /*  230 */ "uniqueflag",
141006         -  /*  231 */ "collate",
141007         -  /*  232 */ "nmnum",
141008         -  /*  233 */ "trigger_decl",
141009         -  /*  234 */ "trigger_cmd_list",
141010         -  /*  235 */ "trigger_time",
141011         -  /*  236 */ "trigger_event",
141012         -  /*  237 */ "foreach_clause",
141013         -  /*  238 */ "when_clause",
141014         -  /*  239 */ "trigger_cmd",
141015         -  /*  240 */ "trnm",
141016         -  /*  241 */ "tridxby",
141017         -  /*  242 */ "database_kw_opt",
141018         -  /*  243 */ "key_opt",
141019         -  /*  244 */ "add_column_fullname",
141020         -  /*  245 */ "kwcolumn_opt",
141021         -  /*  246 */ "create_vtab",
141022         -  /*  247 */ "vtabarglist",
141023         -  /*  248 */ "vtabarg",
141024         -  /*  249 */ "vtabargtoken",
141025         -  /*  250 */ "lp",
141026         -  /*  251 */ "anylist",
       141819  +  /*  149 */ "explain",
       141820  +  /*  150 */ "cmd",
       141821  +  /*  151 */ "transtype",
       141822  +  /*  152 */ "trans_opt",
       141823  +  /*  153 */ "nm",
       141824  +  /*  154 */ "savepoint_opt",
       141825  +  /*  155 */ "create_table",
       141826  +  /*  156 */ "create_table_args",
       141827  +  /*  157 */ "createkw",
       141828  +  /*  158 */ "temp",
       141829  +  /*  159 */ "ifnotexists",
       141830  +  /*  160 */ "dbnm",
       141831  +  /*  161 */ "columnlist",
       141832  +  /*  162 */ "conslist_opt",
       141833  +  /*  163 */ "table_options",
       141834  +  /*  164 */ "select",
       141835  +  /*  165 */ "columnname",
       141836  +  /*  166 */ "carglist",
       141837  +  /*  167 */ "typetoken",
       141838  +  /*  168 */ "typename",
       141839  +  /*  169 */ "signed",
       141840  +  /*  170 */ "plus_num",
       141841  +  /*  171 */ "minus_num",
       141842  +  /*  172 */ "scanpt",
       141843  +  /*  173 */ "ccons",
       141844  +  /*  174 */ "term",
       141845  +  /*  175 */ "expr",
       141846  +  /*  176 */ "onconf",
       141847  +  /*  177 */ "sortorder",
       141848  +  /*  178 */ "autoinc",
       141849  +  /*  179 */ "eidlist_opt",
       141850  +  /*  180 */ "refargs",
       141851  +  /*  181 */ "defer_subclause",
       141852  +  /*  182 */ "refarg",
       141853  +  /*  183 */ "refact",
       141854  +  /*  184 */ "init_deferred_pred_opt",
       141855  +  /*  185 */ "conslist",
       141856  +  /*  186 */ "tconscomma",
       141857  +  /*  187 */ "tcons",
       141858  +  /*  188 */ "sortlist",
       141859  +  /*  189 */ "eidlist",
       141860  +  /*  190 */ "defer_subclause_opt",
       141861  +  /*  191 */ "orconf",
       141862  +  /*  192 */ "resolvetype",
       141863  +  /*  193 */ "raisetype",
       141864  +  /*  194 */ "ifexists",
       141865  +  /*  195 */ "fullname",
       141866  +  /*  196 */ "selectnowith",
       141867  +  /*  197 */ "oneselect",
       141868  +  /*  198 */ "wqlist",
       141869  +  /*  199 */ "multiselect_op",
       141870  +  /*  200 */ "distinct",
       141871  +  /*  201 */ "selcollist",
       141872  +  /*  202 */ "from",
       141873  +  /*  203 */ "where_opt",
       141874  +  /*  204 */ "groupby_opt",
       141875  +  /*  205 */ "having_opt",
       141876  +  /*  206 */ "orderby_opt",
       141877  +  /*  207 */ "limit_opt",
       141878  +  /*  208 */ "values",
       141879  +  /*  209 */ "nexprlist",
       141880  +  /*  210 */ "exprlist",
       141881  +  /*  211 */ "sclp",
       141882  +  /*  212 */ "as",
       141883  +  /*  213 */ "seltablist",
       141884  +  /*  214 */ "stl_prefix",
       141885  +  /*  215 */ "joinop",
       141886  +  /*  216 */ "indexed_opt",
       141887  +  /*  217 */ "on_opt",
       141888  +  /*  218 */ "using_opt",
       141889  +  /*  219 */ "xfullname",
       141890  +  /*  220 */ "idlist",
       141891  +  /*  221 */ "with",
       141892  +  /*  222 */ "setlist",
       141893  +  /*  223 */ "insert_cmd",
       141894  +  /*  224 */ "idlist_opt",
       141895  +  /*  225 */ "upsert",
       141896  +  /*  226 */ "likeop",
       141897  +  /*  227 */ "between_op",
       141898  +  /*  228 */ "in_op",
       141899  +  /*  229 */ "paren_exprlist",
       141900  +  /*  230 */ "case_operand",
       141901  +  /*  231 */ "case_exprlist",
       141902  +  /*  232 */ "case_else",
       141903  +  /*  233 */ "uniqueflag",
       141904  +  /*  234 */ "collate",
       141905  +  /*  235 */ "nmnum",
       141906  +  /*  236 */ "trigger_decl",
       141907  +  /*  237 */ "trigger_cmd_list",
       141908  +  /*  238 */ "trigger_time",
       141909  +  /*  239 */ "trigger_event",
       141910  +  /*  240 */ "foreach_clause",
       141911  +  /*  241 */ "when_clause",
       141912  +  /*  242 */ "trigger_cmd",
       141913  +  /*  243 */ "trnm",
       141914  +  /*  244 */ "tridxby",
       141915  +  /*  245 */ "database_kw_opt",
       141916  +  /*  246 */ "key_opt",
       141917  +  /*  247 */ "add_column_fullname",
       141918  +  /*  248 */ "kwcolumn_opt",
       141919  +  /*  249 */ "create_vtab",
       141920  +  /*  250 */ "vtabarglist",
       141921  +  /*  251 */ "vtabarg",
       141922  +  /*  252 */ "vtabargtoken",
       141923  +  /*  253 */ "lp",
       141924  +  /*  254 */ "anylist",
141027 141925   };
141028 141926   #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
141029 141927   
141030 141928   #ifndef NDEBUG
141031 141929   /* For tracing reduce actions, the names of all rules are required.
141032 141930   */
141033 141931   static const char *const yyRuleName[] = {
................................................................................
141138 142036    /* 104 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
141139 142037    /* 105 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
141140 142038    /* 106 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
141141 142039    /* 107 */ "dbnm ::=",
141142 142040    /* 108 */ "dbnm ::= DOT nm",
141143 142041    /* 109 */ "fullname ::= nm",
141144 142042    /* 110 */ "fullname ::= nm DOT nm",
141145         - /* 111 */ "joinop ::= COMMA|JOIN",
141146         - /* 112 */ "joinop ::= JOIN_KW JOIN",
141147         - /* 113 */ "joinop ::= JOIN_KW nm JOIN",
141148         - /* 114 */ "joinop ::= JOIN_KW nm nm JOIN",
141149         - /* 115 */ "on_opt ::= ON expr",
141150         - /* 116 */ "on_opt ::=",
141151         - /* 117 */ "indexed_opt ::=",
141152         - /* 118 */ "indexed_opt ::= INDEXED BY nm",
141153         - /* 119 */ "indexed_opt ::= NOT INDEXED",
141154         - /* 120 */ "using_opt ::= USING LP idlist RP",
141155         - /* 121 */ "using_opt ::=",
141156         - /* 122 */ "orderby_opt ::=",
141157         - /* 123 */ "orderby_opt ::= ORDER BY sortlist",
141158         - /* 124 */ "sortlist ::= sortlist COMMA expr sortorder",
141159         - /* 125 */ "sortlist ::= expr sortorder",
141160         - /* 126 */ "sortorder ::= ASC",
141161         - /* 127 */ "sortorder ::= DESC",
141162         - /* 128 */ "sortorder ::=",
141163         - /* 129 */ "groupby_opt ::=",
141164         - /* 130 */ "groupby_opt ::= GROUP BY nexprlist",
141165         - /* 131 */ "having_opt ::=",
141166         - /* 132 */ "having_opt ::= HAVING expr",
141167         - /* 133 */ "limit_opt ::=",
141168         - /* 134 */ "limit_opt ::= LIMIT expr",
141169         - /* 135 */ "limit_opt ::= LIMIT expr OFFSET expr",
141170         - /* 136 */ "limit_opt ::= LIMIT expr COMMA expr",
141171         - /* 137 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt",
141172         - /* 138 */ "where_opt ::=",
141173         - /* 139 */ "where_opt ::= WHERE expr",
141174         - /* 140 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt",
141175         - /* 141 */ "setlist ::= setlist COMMA nm EQ expr",
141176         - /* 142 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
141177         - /* 143 */ "setlist ::= nm EQ expr",
141178         - /* 144 */ "setlist ::= LP idlist RP EQ expr",
141179         - /* 145 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select",
141180         - /* 146 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES",
141181         - /* 147 */ "insert_cmd ::= INSERT orconf",
141182         - /* 148 */ "insert_cmd ::= REPLACE",
141183         - /* 149 */ "idlist_opt ::=",
141184         - /* 150 */ "idlist_opt ::= LP idlist RP",
141185         - /* 151 */ "idlist ::= idlist COMMA nm",
141186         - /* 152 */ "idlist ::= nm",
141187         - /* 153 */ "expr ::= LP expr RP",
141188         - /* 154 */ "expr ::= ID|INDEXED",
141189         - /* 155 */ "expr ::= JOIN_KW",
141190         - /* 156 */ "expr ::= nm DOT nm",
141191         - /* 157 */ "expr ::= nm DOT nm DOT nm",
141192         - /* 158 */ "term ::= NULL|FLOAT|BLOB",
141193         - /* 159 */ "term ::= STRING",
141194         - /* 160 */ "term ::= INTEGER",
141195         - /* 161 */ "expr ::= VARIABLE",
141196         - /* 162 */ "expr ::= expr COLLATE ID|STRING",
141197         - /* 163 */ "expr ::= CAST LP expr AS typetoken RP",
141198         - /* 164 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
141199         - /* 165 */ "expr ::= ID|INDEXED LP STAR RP",
141200         - /* 166 */ "term ::= CTIME_KW",
141201         - /* 167 */ "expr ::= LP nexprlist COMMA expr RP",
141202         - /* 168 */ "expr ::= expr AND expr",
141203         - /* 169 */ "expr ::= expr OR expr",
141204         - /* 170 */ "expr ::= expr LT|GT|GE|LE expr",
141205         - /* 171 */ "expr ::= expr EQ|NE expr",
141206         - /* 172 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
141207         - /* 173 */ "expr ::= expr PLUS|MINUS expr",
141208         - /* 174 */ "expr ::= expr STAR|SLASH|REM expr",
141209         - /* 175 */ "expr ::= expr CONCAT expr",
141210         - /* 176 */ "likeop ::= NOT LIKE_KW|MATCH",
141211         - /* 177 */ "expr ::= expr likeop expr",
141212         - /* 178 */ "expr ::= expr likeop expr ESCAPE expr",
141213         - /* 179 */ "expr ::= expr ISNULL|NOTNULL",
141214         - /* 180 */ "expr ::= expr NOT NULL",
141215         - /* 181 */ "expr ::= expr IS expr",
141216         - /* 182 */ "expr ::= expr IS NOT expr",
141217         - /* 183 */ "expr ::= NOT expr",
141218         - /* 184 */ "expr ::= BITNOT expr",
141219         - /* 185 */ "expr ::= MINUS expr",
141220         - /* 186 */ "expr ::= PLUS expr",
141221         - /* 187 */ "between_op ::= BETWEEN",
141222         - /* 188 */ "between_op ::= NOT BETWEEN",
141223         - /* 189 */ "expr ::= expr between_op expr AND expr",
141224         - /* 190 */ "in_op ::= IN",
141225         - /* 191 */ "in_op ::= NOT IN",
141226         - /* 192 */ "expr ::= expr in_op LP exprlist RP",
141227         - /* 193 */ "expr ::= LP select RP",
141228         - /* 194 */ "expr ::= expr in_op LP select RP",
141229         - /* 195 */ "expr ::= expr in_op nm dbnm paren_exprlist",
141230         - /* 196 */ "expr ::= EXISTS LP select RP",
141231         - /* 197 */ "expr ::= CASE case_operand case_exprlist case_else END",
141232         - /* 198 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
141233         - /* 199 */ "case_exprlist ::= WHEN expr THEN expr",
141234         - /* 200 */ "case_else ::= ELSE expr",
141235         - /* 201 */ "case_else ::=",
141236         - /* 202 */ "case_operand ::= expr",
141237         - /* 203 */ "case_operand ::=",
141238         - /* 204 */ "exprlist ::=",
141239         - /* 205 */ "nexprlist ::= nexprlist COMMA expr",
141240         - /* 206 */ "nexprlist ::= expr",
141241         - /* 207 */ "paren_exprlist ::=",
141242         - /* 208 */ "paren_exprlist ::= LP exprlist RP",
141243         - /* 209 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
141244         - /* 210 */ "uniqueflag ::= UNIQUE",
141245         - /* 211 */ "uniqueflag ::=",
141246         - /* 212 */ "eidlist_opt ::=",
141247         - /* 213 */ "eidlist_opt ::= LP eidlist RP",
141248         - /* 214 */ "eidlist ::= eidlist COMMA nm collate sortorder",
141249         - /* 215 */ "eidlist ::= nm collate sortorder",
141250         - /* 216 */ "collate ::=",
141251         - /* 217 */ "collate ::= COLLATE ID|STRING",
141252         - /* 218 */ "cmd ::= DROP INDEX ifexists fullname",
141253         - /* 219 */ "cmd ::= VACUUM",
141254         - /* 220 */ "cmd ::= VACUUM nm",
141255         - /* 221 */ "cmd ::= PRAGMA nm dbnm",
141256         - /* 222 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
141257         - /* 223 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
141258         - /* 224 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
141259         - /* 225 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
141260         - /* 226 */ "plus_num ::= PLUS INTEGER|FLOAT",
141261         - /* 227 */ "minus_num ::= MINUS INTEGER|FLOAT",
141262         - /* 228 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
141263         - /* 229 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
141264         - /* 230 */ "trigger_time ::= BEFORE|AFTER",
141265         - /* 231 */ "trigger_time ::= INSTEAD OF",
141266         - /* 232 */ "trigger_time ::=",
141267         - /* 233 */ "trigger_event ::= DELETE|INSERT",
141268         - /* 234 */ "trigger_event ::= UPDATE",
141269         - /* 235 */ "trigger_event ::= UPDATE OF idlist",
141270         - /* 236 */ "when_clause ::=",
141271         - /* 237 */ "when_clause ::= WHEN expr",
141272         - /* 238 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
141273         - /* 239 */ "trigger_cmd_list ::= trigger_cmd SEMI",
141274         - /* 240 */ "trnm ::= nm DOT nm",
141275         - /* 241 */ "tridxby ::= INDEXED BY nm",
141276         - /* 242 */ "tridxby ::= NOT INDEXED",
141277         - /* 243 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
141278         - /* 244 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt",
141279         - /* 245 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
141280         - /* 246 */ "trigger_cmd ::= scanpt select scanpt",
141281         - /* 247 */ "expr ::= RAISE LP IGNORE RP",
141282         - /* 248 */ "expr ::= RAISE LP raisetype COMMA nm RP",
141283         - /* 249 */ "raisetype ::= ROLLBACK",
141284         - /* 250 */ "raisetype ::= ABORT",
141285         - /* 251 */ "raisetype ::= FAIL",
141286         - /* 252 */ "cmd ::= DROP TRIGGER ifexists fullname",
141287         - /* 253 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
141288         - /* 254 */ "cmd ::= DETACH database_kw_opt expr",
141289         - /* 255 */ "key_opt ::=",
141290         - /* 256 */ "key_opt ::= KEY expr",
141291         - /* 257 */ "cmd ::= REINDEX",
141292         - /* 258 */ "cmd ::= REINDEX nm dbnm",
141293         - /* 259 */ "cmd ::= ANALYZE",
141294         - /* 260 */ "cmd ::= ANALYZE nm dbnm",
141295         - /* 261 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
141296         - /* 262 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
141297         - /* 263 */ "add_column_fullname ::= fullname",
141298         - /* 264 */ "cmd ::= create_vtab",
141299         - /* 265 */ "cmd ::= create_vtab LP vtabarglist RP",
141300         - /* 266 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
141301         - /* 267 */ "vtabarg ::=",
141302         - /* 268 */ "vtabargtoken ::= ANY",
141303         - /* 269 */ "vtabargtoken ::= lp anylist RP",
141304         - /* 270 */ "lp ::= LP",
141305         - /* 271 */ "with ::= WITH wqlist",
141306         - /* 272 */ "with ::= WITH RECURSIVE wqlist",
141307         - /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
141308         - /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
141309         - /* 275 */ "input ::= cmdlist",
141310         - /* 276 */ "cmdlist ::= cmdlist ecmd",
141311         - /* 277 */ "cmdlist ::= ecmd",
141312         - /* 278 */ "ecmd ::= SEMI",
141313         - /* 279 */ "ecmd ::= explain cmdx SEMI",
141314         - /* 280 */ "explain ::=",
141315         - /* 281 */ "trans_opt ::=",
141316         - /* 282 */ "trans_opt ::= TRANSACTION",
141317         - /* 283 */ "trans_opt ::= TRANSACTION nm",
141318         - /* 284 */ "savepoint_opt ::= SAVEPOINT",
141319         - /* 285 */ "savepoint_opt ::=",
141320         - /* 286 */ "cmd ::= create_table create_table_args",
141321         - /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
141322         - /* 288 */ "columnlist ::= columnname carglist",
141323         - /* 289 */ "nm ::= ID|INDEXED",
141324         - /* 290 */ "nm ::= STRING",
141325         - /* 291 */ "nm ::= JOIN_KW",
141326         - /* 292 */ "typetoken ::= typename",
141327         - /* 293 */ "typename ::= ID|STRING",
141328         - /* 294 */ "signed ::= plus_num",
141329         - /* 295 */ "signed ::= minus_num",
141330         - /* 296 */ "carglist ::= carglist ccons",
141331         - /* 297 */ "carglist ::=",
141332         - /* 298 */ "ccons ::= NULL onconf",
141333         - /* 299 */ "conslist_opt ::= COMMA conslist",
141334         - /* 300 */ "conslist ::= conslist tconscomma tcons",
141335         - /* 301 */ "conslist ::= tcons",
141336         - /* 302 */ "tconscomma ::=",
141337         - /* 303 */ "defer_subclause_opt ::= defer_subclause",
141338         - /* 304 */ "resolvetype ::= raisetype",
141339         - /* 305 */ "selectnowith ::= oneselect",
141340         - /* 306 */ "oneselect ::= values",
141341         - /* 307 */ "sclp ::= selcollist COMMA",
141342         - /* 308 */ "as ::= ID|STRING",
141343         - /* 309 */ "expr ::= term",
141344         - /* 310 */ "likeop ::= LIKE_KW|MATCH",
141345         - /* 311 */ "exprlist ::= nexprlist",
141346         - /* 312 */ "nmnum ::= plus_num",
141347         - /* 313 */ "nmnum ::= nm",
141348         - /* 314 */ "nmnum ::= ON",
141349         - /* 315 */ "nmnum ::= DELETE",
141350         - /* 316 */ "nmnum ::= DEFAULT",
141351         - /* 317 */ "plus_num ::= INTEGER|FLOAT",
141352         - /* 318 */ "foreach_clause ::=",
141353         - /* 319 */ "foreach_clause ::= FOR EACH ROW",
141354         - /* 320 */ "trnm ::= nm",
141355         - /* 321 */ "tridxby ::=",
141356         - /* 322 */ "database_kw_opt ::= DATABASE",
141357         - /* 323 */ "database_kw_opt ::=",
141358         - /* 324 */ "kwcolumn_opt ::=",
141359         - /* 325 */ "kwcolumn_opt ::= COLUMNKW",
141360         - /* 326 */ "vtabarglist ::= vtabarg",
141361         - /* 327 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
141362         - /* 328 */ "vtabarg ::= vtabarg vtabargtoken",
141363         - /* 329 */ "anylist ::=",
141364         - /* 330 */ "anylist ::= anylist LP anylist RP",
141365         - /* 331 */ "anylist ::= anylist ANY",
141366         - /* 332 */ "with ::=",
       142043  + /* 111 */ "xfullname ::= nm",
       142044  + /* 112 */ "xfullname ::= nm DOT nm",
       142045  + /* 113 */ "xfullname ::= nm DOT nm AS nm",
       142046  + /* 114 */ "xfullname ::= nm AS nm",
       142047  + /* 115 */ "joinop ::= COMMA|JOIN",
       142048  + /* 116 */ "joinop ::= JOIN_KW JOIN",
       142049  + /* 117 */ "joinop ::= JOIN_KW nm JOIN",
       142050  + /* 118 */ "joinop ::= JOIN_KW nm nm JOIN",
       142051  + /* 119 */ "on_opt ::= ON expr",
       142052  + /* 120 */ "on_opt ::=",
       142053  + /* 121 */ "indexed_opt ::=",
       142054  + /* 122 */ "indexed_opt ::= INDEXED BY nm",
       142055  + /* 123 */ "indexed_opt ::= NOT INDEXED",
       142056  + /* 124 */ "using_opt ::= USING LP idlist RP",
       142057  + /* 125 */ "using_opt ::=",
       142058  + /* 126 */ "orderby_opt ::=",
       142059  + /* 127 */ "orderby_opt ::= ORDER BY sortlist",
       142060  + /* 128 */ "sortlist ::= sortlist COMMA expr sortorder",
       142061  + /* 129 */ "sortlist ::= expr sortorder",
       142062  + /* 130 */ "sortorder ::= ASC",
       142063  + /* 131 */ "sortorder ::= DESC",
       142064  + /* 132 */ "sortorder ::=",
       142065  + /* 133 */ "groupby_opt ::=",
       142066  + /* 134 */ "groupby_opt ::= GROUP BY nexprlist",
       142067  + /* 135 */ "having_opt ::=",
       142068  + /* 136 */ "having_opt ::= HAVING expr",
       142069  + /* 137 */ "limit_opt ::=",
       142070  + /* 138 */ "limit_opt ::= LIMIT expr",
       142071  + /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr",
       142072  + /* 140 */ "limit_opt ::= LIMIT expr COMMA expr",
       142073  + /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
       142074  + /* 142 */ "where_opt ::=",
       142075  + /* 143 */ "where_opt ::= WHERE expr",
       142076  + /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
       142077  + /* 145 */ "setlist ::= setlist COMMA nm EQ expr",
       142078  + /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
       142079  + /* 147 */ "setlist ::= nm EQ expr",
       142080  + /* 148 */ "setlist ::= LP idlist RP EQ expr",
       142081  + /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
       142082  + /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
       142083  + /* 151 */ "upsert ::=",
       142084  + /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
       142085  + /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
       142086  + /* 154 */ "upsert ::= ON CONFLICT DO NOTHING",
       142087  + /* 155 */ "insert_cmd ::= INSERT orconf",
       142088  + /* 156 */ "insert_cmd ::= REPLACE",
       142089  + /* 157 */ "idlist_opt ::=",
       142090  + /* 158 */ "idlist_opt ::= LP idlist RP",
       142091  + /* 159 */ "idlist ::= idlist COMMA nm",
       142092  + /* 160 */ "idlist ::= nm",
       142093  + /* 161 */ "expr ::= LP expr RP",
       142094  + /* 162 */ "expr ::= ID|INDEXED",
       142095  + /* 163 */ "expr ::= JOIN_KW",
       142096  + /* 164 */ "expr ::= nm DOT nm",
       142097  + /* 165 */ "expr ::= nm DOT nm DOT nm",
       142098  + /* 166 */ "term ::= NULL|FLOAT|BLOB",
       142099  + /* 167 */ "term ::= STRING",
       142100  + /* 168 */ "term ::= INTEGER",
       142101  + /* 169 */ "expr ::= VARIABLE",
       142102  + /* 170 */ "expr ::= expr COLLATE ID|STRING",
       142103  + /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
       142104  + /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
       142105  + /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
       142106  + /* 174 */ "term ::= CTIME_KW",
       142107  + /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
       142108  + /* 176 */ "expr ::= expr AND expr",
       142109  + /* 177 */ "expr ::= expr OR expr",
       142110  + /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
       142111  + /* 179 */ "expr ::= expr EQ|NE expr",
       142112  + /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
       142113  + /* 181 */ "expr ::= expr PLUS|MINUS expr",
       142114  + /* 182 */ "expr ::= expr STAR|SLASH|REM expr",
       142115  + /* 183 */ "expr ::= expr CONCAT expr",
       142116  + /* 184 */ "likeop ::= NOT LIKE_KW|MATCH",
       142117  + /* 185 */ "expr ::= expr likeop expr",
       142118  + /* 186 */ "expr ::= expr likeop expr ESCAPE expr",
       142119  + /* 187 */ "expr ::= expr ISNULL|NOTNULL",
       142120  + /* 188 */ "expr ::= expr NOT NULL",
       142121  + /* 189 */ "expr ::= expr IS expr",
       142122  + /* 190 */ "expr ::= expr IS NOT expr",
       142123  + /* 191 */ "expr ::= NOT expr",
       142124  + /* 192 */ "expr ::= BITNOT expr",
       142125  + /* 193 */ "expr ::= MINUS expr",
       142126  + /* 194 */ "expr ::= PLUS expr",
       142127  + /* 195 */ "between_op ::= BETWEEN",
       142128  + /* 196 */ "between_op ::= NOT BETWEEN",
       142129  + /* 197 */ "expr ::= expr between_op expr AND expr",
       142130  + /* 198 */ "in_op ::= IN",
       142131  + /* 199 */ "in_op ::= NOT IN",
       142132  + /* 200 */ "expr ::= expr in_op LP exprlist RP",
       142133  + /* 201 */ "expr ::= LP select RP",
       142134  + /* 202 */ "expr ::= expr in_op LP select RP",
       142135  + /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist",
       142136  + /* 204 */ "expr ::= EXISTS LP select RP",
       142137  + /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END",
       142138  + /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
       142139  + /* 207 */ "case_exprlist ::= WHEN expr THEN expr",
       142140  + /* 208 */ "case_else ::= ELSE expr",
       142141  + /* 209 */ "case_else ::=",
       142142  + /* 210 */ "case_operand ::= expr",
       142143  + /* 211 */ "case_operand ::=",
       142144  + /* 212 */ "exprlist ::=",
       142145  + /* 213 */ "nexprlist ::= nexprlist COMMA expr",
       142146  + /* 214 */ "nexprlist ::= expr",
       142147  + /* 215 */ "paren_exprlist ::=",
       142148  + /* 216 */ "paren_exprlist ::= LP exprlist RP",
       142149  + /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
       142150  + /* 218 */ "uniqueflag ::= UNIQUE",
       142151  + /* 219 */ "uniqueflag ::=",
       142152  + /* 220 */ "eidlist_opt ::=",
       142153  + /* 221 */ "eidlist_opt ::= LP eidlist RP",
       142154  + /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder",
       142155  + /* 223 */ "eidlist ::= nm collate sortorder",
       142156  + /* 224 */ "collate ::=",
       142157  + /* 225 */ "collate ::= COLLATE ID|STRING",
       142158  + /* 226 */ "cmd ::= DROP INDEX ifexists fullname",
       142159  + /* 227 */ "cmd ::= VACUUM",
       142160  + /* 228 */ "cmd ::= VACUUM nm",
       142161  + /* 229 */ "cmd ::= PRAGMA nm dbnm",
       142162  + /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
       142163  + /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
       142164  + /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
       142165  + /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
       142166  + /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT",
       142167  + /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT",
       142168  + /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
       142169  + /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
       142170  + /* 238 */ "trigger_time ::= BEFORE|AFTER",
       142171  + /* 239 */ "trigger_time ::= INSTEAD OF",
       142172  + /* 240 */ "trigger_time ::=",
       142173  + /* 241 */ "trigger_event ::= DELETE|INSERT",
       142174  + /* 242 */ "trigger_event ::= UPDATE",
       142175  + /* 243 */ "trigger_event ::= UPDATE OF idlist",
       142176  + /* 244 */ "when_clause ::=",
       142177  + /* 245 */ "when_clause ::= WHEN expr",
       142178  + /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
       142179  + /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI",
       142180  + /* 248 */ "trnm ::= nm DOT nm",
       142181  + /* 249 */ "tridxby ::= INDEXED BY nm",
       142182  + /* 250 */ "tridxby ::= NOT INDEXED",
       142183  + /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
       142184  + /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
       142185  + /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
       142186  + /* 254 */ "trigger_cmd ::= scanpt select scanpt",
       142187  + /* 255 */ "expr ::= RAISE LP IGNORE RP",
       142188  + /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP",
       142189  + /* 257 */ "raisetype ::= ROLLBACK",
       142190  + /* 258 */ "raisetype ::= ABORT",
       142191  + /* 259 */ "raisetype ::= FAIL",
       142192  + /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname",
       142193  + /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
       142194  + /* 262 */ "cmd ::= DETACH database_kw_opt expr",
       142195  + /* 263 */ "key_opt ::=",
       142196  + /* 264 */ "key_opt ::= KEY expr",
       142197  + /* 265 */ "cmd ::= REINDEX",
       142198  + /* 266 */ "cmd ::= REINDEX nm dbnm",
       142199  + /* 267 */ "cmd ::= ANALYZE",
       142200  + /* 268 */ "cmd ::= ANALYZE nm dbnm",
       142201  + /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
       142202  + /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
       142203  + /* 271 */ "add_column_fullname ::= fullname",
       142204  + /* 272 */ "cmd ::= create_vtab",
       142205  + /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
       142206  + /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
       142207  + /* 275 */ "vtabarg ::=",
       142208  + /* 276 */ "vtabargtoken ::= ANY",
       142209  + /* 277 */ "vtabargtoken ::= lp anylist RP",
       142210  + /* 278 */ "lp ::= LP",
       142211  + /* 279 */ "with ::= WITH wqlist",
       142212  + /* 280 */ "with ::= WITH RECURSIVE wqlist",
       142213  + /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
       142214  + /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
       142215  + /* 283 */ "input ::= cmdlist",
       142216  + /* 284 */ "cmdlist ::= cmdlist ecmd",
       142217  + /* 285 */ "cmdlist ::= ecmd",
       142218  + /* 286 */ "ecmd ::= SEMI",
       142219  + /* 287 */ "ecmd ::= cmdx SEMI",
       142220  + /* 288 */ "ecmd ::= explain cmdx",
       142221  + /* 289 */ "trans_opt ::=",
       142222  + /* 290 */ "trans_opt ::= TRANSACTION",
       142223  + /* 291 */ "trans_opt ::= TRANSACTION nm",
       142224  + /* 292 */ "savepoint_opt ::= SAVEPOINT",
       142225  + /* 293 */ "savepoint_opt ::=",
       142226  + /* 294 */ "cmd ::= create_table create_table_args",
       142227  + /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
       142228  + /* 296 */ "columnlist ::= columnname carglist",
       142229  + /* 297 */ "nm ::= ID|INDEXED",
       142230  + /* 298 */ "nm ::= STRING",
       142231  + /* 299 */ "nm ::= JOIN_KW",
       142232  + /* 300 */ "typetoken ::= typename",
       142233  + /* 301 */ "typename ::= ID|STRING",
       142234  + /* 302 */ "signed ::= plus_num",
       142235  + /* 303 */ "signed ::= minus_num",
       142236  + /* 304 */ "carglist ::= carglist ccons",
       142237  + /* 305 */ "carglist ::=",
       142238  + /* 306 */ "ccons ::= NULL onconf",
       142239  + /* 307 */ "conslist_opt ::= COMMA conslist",
       142240  + /* 308 */ "conslist ::= conslist tconscomma tcons",
       142241  + /* 309 */ "conslist ::= tcons",
       142242  + /* 310 */ "tconscomma ::=",
       142243  + /* 311 */ "defer_subclause_opt ::= defer_subclause",
       142244  + /* 312 */ "resolvetype ::= raisetype",
       142245  + /* 313 */ "selectnowith ::= oneselect",
       142246  + /* 314 */ "oneselect ::= values",
       142247  + /* 315 */ "sclp ::= selcollist COMMA",
       142248  + /* 316 */ "as ::= ID|STRING",
       142249  + /* 317 */ "expr ::= term",
       142250  + /* 318 */ "likeop ::= LIKE_KW|MATCH",
       142251  + /* 319 */ "exprlist ::= nexprlist",
       142252  + /* 320 */ "nmnum ::= plus_num",
       142253  + /* 321 */ "nmnum ::= nm",
       142254  + /* 322 */ "nmnum ::= ON",
       142255  + /* 323 */ "nmnum ::= DELETE",
       142256  + /* 324 */ "nmnum ::= DEFAULT",
       142257  + /* 325 */ "plus_num ::= INTEGER|FLOAT",
       142258  + /* 326 */ "foreach_clause ::=",
       142259  + /* 327 */ "foreach_clause ::= FOR EACH ROW",
       142260  + /* 328 */ "trnm ::= nm",
       142261  + /* 329 */ "tridxby ::=",
       142262  + /* 330 */ "database_kw_opt ::= DATABASE",
       142263  + /* 331 */ "database_kw_opt ::=",
       142264  + /* 332 */ "kwcolumn_opt ::=",
       142265  + /* 333 */ "kwcolumn_opt ::= COLUMNKW",
       142266  + /* 334 */ "vtabarglist ::= vtabarg",
       142267  + /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
       142268  + /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
       142269  + /* 337 */ "anylist ::=",
       142270  + /* 338 */ "anylist ::= anylist LP anylist RP",
       142271  + /* 339 */ "anylist ::= anylist ANY",
       142272  + /* 340 */ "with ::=",
141367 142273   };
141368 142274   #endif /* NDEBUG */
141369 142275   
141370 142276   
141371 142277   #if YYSTACKDEPTH<=0
141372 142278   /*
141373 142279   ** Try to increase the size of the parser stack.  Return the number
................................................................................
141408 142314   */
141409 142315   #ifndef YYMALLOCARGTYPE
141410 142316   # define YYMALLOCARGTYPE size_t
141411 142317   #endif
141412 142318   
141413 142319   /* Initialize a new parser that has already been allocated.
141414 142320   */
141415         -SQLITE_PRIVATE void sqlite3ParserInit(void *yypParser){
141416         -  yyParser *pParser = (yyParser*)yypParser;
       142321  +SQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL){
       142322  +  yyParser *yypParser = (yyParser*)yypRawParser;
       142323  +  sqlite3ParserCTX_STORE
141417 142324   #ifdef YYTRACKMAXSTACKDEPTH
141418         -  pParser->yyhwm = 0;
       142325  +  yypParser->yyhwm = 0;
141419 142326   #endif
141420 142327   #if YYSTACKDEPTH<=0
141421         -  pParser->yytos = NULL;
141422         -  pParser->yystack = NULL;
141423         -  pParser->yystksz = 0;
141424         -  if( yyGrowStack(pParser) ){
141425         -    pParser->yystack = &pParser->yystk0;
141426         -    pParser->yystksz = 1;
       142328  +  yypParser->yytos = NULL;
       142329  +  yypParser->yystack = NULL;
       142330  +  yypParser->yystksz = 0;
       142331  +  if( yyGrowStack(yypParser) ){
       142332  +    yypParser->yystack = &yypParser->yystk0;
       142333  +    yypParser->yystksz = 1;
141427 142334     }
141428 142335   #endif
141429 142336   #ifndef YYNOERRORRECOVERY
141430         -  pParser->yyerrcnt = -1;
       142337  +  yypParser->yyerrcnt = -1;
141431 142338   #endif
141432         -  pParser->yytos = pParser->yystack;
141433         -  pParser->yystack[0].stateno = 0;
141434         -  pParser->yystack[0].major = 0;
       142339  +  yypParser->yytos = yypParser->yystack;
       142340  +  yypParser->yystack[0].stateno = 0;
       142341  +  yypParser->yystack[0].major = 0;
141435 142342   #if YYSTACKDEPTH>0
141436         -  pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1];
       142343  +  yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1];
141437 142344   #endif
141438 142345   }
141439 142346   
141440 142347   #ifndef sqlite3Parser_ENGINEALWAYSONSTACK
141441 142348   /* 
141442 142349   ** This function allocates a new parser.
141443 142350   ** The only argument is a pointer to a function which works like
................................................................................
141446 142353   ** Inputs:
141447 142354   ** A pointer to the function used to allocate memory.
141448 142355   **
141449 142356   ** Outputs:
141450 142357   ** A pointer to a parser.  This pointer is used in subsequent calls
141451 142358   ** to sqlite3Parser and sqlite3ParserFree.
141452 142359   */
141453         -SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
141454         -  yyParser *pParser;
141455         -  pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
141456         -  if( pParser ) sqlite3ParserInit(pParser);
141457         -  return pParser;
       142360  +SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) sqlite3ParserCTX_PDECL){
       142361  +  yyParser *yypParser;
       142362  +  yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
       142363  +  if( yypParser ){
       142364  +    sqlite3ParserCTX_STORE
       142365  +    sqlite3ParserInit(yypParser sqlite3ParserCTX_PARAM);
       142366  +  }
       142367  +  return (void*)yypParser;
141458 142368   }
141459 142369   #endif /* sqlite3Parser_ENGINEALWAYSONSTACK */
141460 142370   
141461 142371   
141462 142372   /* The following function deletes the "minor type" or semantic value
141463 142373   ** associated with a symbol.  The symbol can be either a terminal
141464 142374   ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is
................................................................................
141467 142377   ** directives of the input grammar.
141468 142378   */
141469 142379   static void yy_destructor(
141470 142380     yyParser *yypParser,    /* The parser */
141471 142381     YYCODETYPE yymajor,     /* Type code for object to destroy */
141472 142382     YYMINORTYPE *yypminor   /* The object to be destroyed */
141473 142383   ){
141474         -  sqlite3ParserARG_FETCH;
       142384  +  sqlite3ParserARG_FETCH
       142385  +  sqlite3ParserCTX_FETCH
141475 142386     switch( yymajor ){
141476 142387       /* Here is inserted the actions which take place when a
141477 142388       ** terminal or non-terminal is destroyed.  This can happen
141478 142389       ** when the symbol is popped from the stack during a
141479 142390       ** reduce or during error processing or when a parser is 
141480 142391       ** being destroyed before it is finished parsing.
141481 142392       **
141482 142393       ** Note: during a reduce, the only symbols destroyed are those
141483 142394       ** which appear on the RHS of the rule, but which are *not* used
141484 142395       ** inside the C code.
141485 142396       */
141486 142397   /********* Begin destructor definitions ***************************************/
141487         -    case 163: /* select */
141488         -    case 195: /* selectnowith */
141489         -    case 196: /* oneselect */
141490         -    case 207: /* values */
141491         -{
141492         -sqlite3SelectDelete(pParse->db, (yypminor->yy387));
141493         -}
141494         -      break;
141495         -    case 173: /* term */
141496         -    case 174: /* expr */
141497         -    case 202: /* where_opt */
141498         -    case 204: /* having_opt */
141499         -    case 216: /* on_opt */
141500         -    case 227: /* case_operand */
141501         -    case 229: /* case_else */
141502         -    case 238: /* when_clause */
141503         -    case 243: /* key_opt */
141504         -{
141505         -sqlite3ExprDelete(pParse->db, (yypminor->yy314));
141506         -}
141507         -      break;
141508         -    case 178: /* eidlist_opt */
141509         -    case 187: /* sortlist */
141510         -    case 188: /* eidlist */
141511         -    case 200: /* selcollist */
141512         -    case 203: /* groupby_opt */
141513         -    case 205: /* orderby_opt */
141514         -    case 208: /* nexprlist */
141515         -    case 209: /* exprlist */
141516         -    case 210: /* sclp */
141517         -    case 220: /* setlist */
141518         -    case 226: /* paren_exprlist */
141519         -    case 228: /* case_exprlist */
141520         -{
141521         -sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
141522         -}
141523         -      break;
141524         -    case 194: /* fullname */
141525         -    case 201: /* from */
141526         -    case 212: /* seltablist */
141527         -    case 213: /* stl_prefix */
141528         -{
141529         -sqlite3SrcListDelete(pParse->db, (yypminor->yy259));
141530         -}
141531         -      break;
141532         -    case 197: /* wqlist */
141533         -{
141534         -sqlite3WithDelete(pParse->db, (yypminor->yy451));
141535         -}
141536         -      break;
141537         -    case 217: /* using_opt */
141538         -    case 218: /* idlist */
141539         -    case 222: /* idlist_opt */
141540         -{
141541         -sqlite3IdListDelete(pParse->db, (yypminor->yy384));
141542         -}
141543         -      break;
141544         -    case 234: /* trigger_cmd_list */
141545         -    case 239: /* trigger_cmd */
141546         -{
141547         -sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203));
141548         -}
141549         -      break;
141550         -    case 236: /* trigger_event */
141551         -{
141552         -sqlite3IdListDelete(pParse->db, (yypminor->yy90).b);
       142398  +    case 164: /* select */
       142399  +    case 196: /* selectnowith */
       142400  +    case 197: /* oneselect */
       142401  +    case 208: /* values */
       142402  +{
       142403  +sqlite3SelectDelete(pParse->db, (yypminor->yy399));
       142404  +}
       142405  +      break;
       142406  +    case 174: /* term */
       142407  +    case 175: /* expr */
       142408  +    case 203: /* where_opt */
       142409  +    case 205: /* having_opt */
       142410  +    case 217: /* on_opt */
       142411  +    case 230: /* case_operand */
       142412  +    case 232: /* case_else */
       142413  +    case 241: /* when_clause */
       142414  +    case 246: /* key_opt */
       142415  +{
       142416  +sqlite3ExprDelete(pParse->db, (yypminor->yy182));
       142417  +}
       142418  +      break;
       142419  +    case 179: /* eidlist_opt */
       142420  +    case 188: /* sortlist */
       142421  +    case 189: /* eidlist */
       142422  +    case 201: /* selcollist */
       142423  +    case 204: /* groupby_opt */
       142424  +    case 206: /* orderby_opt */
       142425  +    case 209: /* nexprlist */
       142426  +    case 210: /* exprlist */
       142427  +    case 211: /* sclp */
       142428  +    case 222: /* setlist */
       142429  +    case 229: /* paren_exprlist */
       142430  +    case 231: /* case_exprlist */
       142431  +{
       142432  +sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
       142433  +}
       142434  +      break;
       142435  +    case 195: /* fullname */
       142436  +    case 202: /* from */
       142437  +    case 213: /* seltablist */
       142438  +    case 214: /* stl_prefix */
       142439  +    case 219: /* xfullname */
       142440  +{
       142441  +sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
       142442  +}
       142443  +      break;
       142444  +    case 198: /* wqlist */
       142445  +{
       142446  +sqlite3WithDelete(pParse->db, (yypminor->yy91));
       142447  +}
       142448  +      break;
       142449  +    case 218: /* using_opt */
       142450  +    case 220: /* idlist */
       142451  +    case 224: /* idlist_opt */
       142452  +{
       142453  +sqlite3IdListDelete(pParse->db, (yypminor->yy510));
       142454  +}
       142455  +      break;
       142456  +    case 237: /* trigger_cmd_list */
       142457  +    case 242: /* trigger_cmd */
       142458  +{
       142459  +sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
       142460  +}
       142461  +      break;
       142462  +    case 239: /* trigger_event */
       142463  +{
       142464  +sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
141553 142465   }
141554 142466         break;
141555 142467   /********* End destructor definitions *****************************************/
141556 142468       default:  break;   /* If no destructor action specified: do nothing */
141557 142469     }
141558 142470   }
141559 142471   
................................................................................
141657 142569   }
141658 142570   #endif
141659 142571   
141660 142572   /*
141661 142573   ** Find the appropriate action for a parser given the terminal
141662 142574   ** look-ahead token iLookAhead.
141663 142575   */
141664         -static unsigned int yy_find_shift_action(
141665         -  yyParser *pParser,        /* The parser */
141666         -  YYCODETYPE iLookAhead     /* The look-ahead token */
       142576  +static YYACTIONTYPE yy_find_shift_action(
       142577  +  YYCODETYPE iLookAhead,    /* The look-ahead token */
       142578  +  YYACTIONTYPE stateno      /* Current state number */
141667 142579   ){
141668 142580     int i;
141669         -  int stateno = pParser->yytos->stateno;
141670         - 
       142581  +
141671 142582     if( stateno>YY_MAX_SHIFT ) return stateno;
141672 142583     assert( stateno <= YY_SHIFT_COUNT );
141673 142584   #if defined(YYCOVERAGE)
141674 142585     yycoverage[stateno][iLookAhead] = 1;
141675 142586   #endif
141676 142587     do{
141677 142588       i = yy_shift_ofst[stateno];
................................................................................
141727 142638   }
141728 142639   
141729 142640   /*
141730 142641   ** Find the appropriate action for a parser given the non-terminal
141731 142642   ** look-ahead token iLookAhead.
141732 142643   */
141733 142644   static int yy_find_reduce_action(
141734         -  int stateno,              /* Current state number */
       142645  +  YYACTIONTYPE stateno,     /* Current state number */
141735 142646     YYCODETYPE iLookAhead     /* The look-ahead token */
141736 142647   ){
141737 142648     int i;
141738 142649   #ifdef YYERRORSYMBOL
141739 142650     if( stateno>YY_REDUCE_COUNT ){
141740 142651       return yy_default[stateno];
141741 142652     }
................................................................................
141756 142667     return yy_action[i];
141757 142668   }
141758 142669   
141759 142670   /*
141760 142671   ** The following routine is called if the stack overflows.
141761 142672   */
141762 142673   static void yyStackOverflow(yyParser *yypParser){
141763         -   sqlite3ParserARG_FETCH;
       142674  +   sqlite3ParserARG_FETCH
       142675  +   sqlite3ParserCTX_FETCH
141764 142676   #ifndef NDEBUG
141765 142677      if( yyTraceFILE ){
141766 142678        fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
141767 142679      }
141768 142680   #endif
141769 142681      while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
141770 142682      /* Here code is inserted which will execute if the parser
141771 142683      ** stack every overflows */
141772 142684   /******** Begin %stack_overflow code ******************************************/
141773 142685   
141774 142686     sqlite3ErrorMsg(pParse, "parser stack overflow");
141775 142687   /******** End %stack_overflow code ********************************************/
141776         -   sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */
       142688  +   sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */
       142689  +   sqlite3ParserCTX_STORE
141777 142690   }
141778 142691   
141779 142692   /*
141780 142693   ** Print tracing information for a SHIFT action
141781 142694   */
141782 142695   #ifndef NDEBUG
141783 142696   static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
................................................................................
141798 142711   #endif
141799 142712   
141800 142713   /*
141801 142714   ** Perform a shift action.
141802 142715   */
141803 142716   static void yy_shift(
141804 142717     yyParser *yypParser,          /* The parser to be shifted */
141805         -  int yyNewState,               /* The new state to shift in */
141806         -  int yyMajor,                  /* The major token to shift in */
       142718  +  YYACTIONTYPE yyNewState,      /* The new state to shift in */
       142719  +  YYCODETYPE yyMajor,           /* The major token to shift in */
141807 142720     sqlite3ParserTOKENTYPE yyMinor        /* The minor token to shift in */
141808 142721   ){
141809 142722     yyStackEntry *yytos;
141810 142723     yypParser->yytos++;
141811 142724   #ifdef YYTRACKMAXSTACKDEPTH
141812 142725     if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
141813 142726       yypParser->yyhwm++;
................................................................................
141829 142742       }
141830 142743     }
141831 142744   #endif
141832 142745     if( yyNewState > YY_MAX_SHIFT ){
141833 142746       yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
141834 142747     }
141835 142748     yytos = yypParser->yytos;
141836         -  yytos->stateno = (YYACTIONTYPE)yyNewState;
141837         -  yytos->major = (YYCODETYPE)yyMajor;
       142749  +  yytos->stateno = yyNewState;
       142750  +  yytos->major = yyMajor;
141838 142751     yytos->minor.yy0 = yyMinor;
141839 142752     yyTraceShift(yypParser, yyNewState, "Shift");
141840 142753   }
141841 142754   
141842 142755   /* The following table contains information about every rule that
141843 142756   ** is used during the reduce.
141844 142757   */
141845 142758   static const struct {
141846 142759     YYCODETYPE lhs;       /* Symbol on the left-hand side of the rule */
141847 142760     signed char nrhs;     /* Negative of the number of RHS symbols in the rule */
141848 142761   } yyRuleInfo[] = {
141849         -  {  147,   -1 }, /* (0) explain ::= EXPLAIN */
141850         -  {  147,   -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
       142762  +  {  149,   -1 }, /* (0) explain ::= EXPLAIN */
       142763  +  {  149,   -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
141851 142764     {  148,   -1 }, /* (2) cmdx ::= cmd */
141852         -  {  149,   -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
141853         -  {  150,    0 }, /* (4) transtype ::= */
141854         -  {  150,   -1 }, /* (5) transtype ::= DEFERRED */
141855         -  {  150,   -1 }, /* (6) transtype ::= IMMEDIATE */
141856         -  {  150,   -1 }, /* (7) transtype ::= EXCLUSIVE */
141857         -  {  149,   -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
141858         -  {  149,   -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
141859         -  {  149,   -2 }, /* (10) cmd ::= SAVEPOINT nm */
141860         -  {  149,   -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
141861         -  {  149,   -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
141862         -  {  154,   -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
141863         -  {  156,   -1 }, /* (14) createkw ::= CREATE */
141864         -  {  158,    0 }, /* (15) ifnotexists ::= */
141865         -  {  158,   -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
141866         -  {  157,   -1 }, /* (17) temp ::= TEMP */
141867         -  {  157,    0 }, /* (18) temp ::= */
141868         -  {  155,   -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
141869         -  {  155,   -2 }, /* (20) create_table_args ::= AS select */
141870         -  {  162,    0 }, /* (21) table_options ::= */
141871         -  {  162,   -2 }, /* (22) table_options ::= WITHOUT nm */
141872         -  {  164,   -2 }, /* (23) columnname ::= nm typetoken */
141873         -  {  166,    0 }, /* (24) typetoken ::= */
141874         -  {  166,   -4 }, /* (25) typetoken ::= typename LP signed RP */
141875         -  {  166,   -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
141876         -  {  167,   -2 }, /* (27) typename ::= typename ID|STRING */
141877         -  {  171,    0 }, /* (28) scanpt ::= */
141878         -  {  172,   -2 }, /* (29) ccons ::= CONSTRAINT nm */
141879         -  {  172,   -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
141880         -  {  172,   -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
141881         -  {  172,   -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
141882         -  {  172,   -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
141883         -  {  172,   -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
141884         -  {  172,   -3 }, /* (35) ccons ::= NOT NULL onconf */
141885         -  {  172,   -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
141886         -  {  172,   -2 }, /* (37) ccons ::= UNIQUE onconf */
141887         -  {  172,   -4 }, /* (38) ccons ::= CHECK LP expr RP */
141888         -  {  172,   -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
141889         -  {  172,   -1 }, /* (40) ccons ::= defer_subclause */
141890         -  {  172,   -2 }, /* (41) ccons ::= COLLATE ID|STRING */
141891         -  {  177,    0 }, /* (42) autoinc ::= */
141892         -  {  177,   -1 }, /* (43) autoinc ::= AUTOINCR */
141893         -  {  179,    0 }, /* (44) refargs ::= */
141894         -  {  179,   -2 }, /* (45) refargs ::= refargs refarg */
141895         -  {  181,   -2 }, /* (46) refarg ::= MATCH nm */
141896         -  {  181,   -3 }, /* (47) refarg ::= ON INSERT refact */
141897         -  {  181,   -3 }, /* (48) refarg ::= ON DELETE refact */
141898         -  {  181,   -3 }, /* (49) refarg ::= ON UPDATE refact */
141899         -  {  182,   -2 }, /* (50) refact ::= SET NULL */
141900         -  {  182,   -2 }, /* (51) refact ::= SET DEFAULT */
141901         -  {  182,   -1 }, /* (52) refact ::= CASCADE */
141902         -  {  182,   -1 }, /* (53) refact ::= RESTRICT */
141903         -  {  182,   -2 }, /* (54) refact ::= NO ACTION */
141904         -  {  180,   -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
141905         -  {  180,   -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
141906         -  {  183,    0 }, /* (57) init_deferred_pred_opt ::= */
141907         -  {  183,   -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
141908         -  {  183,   -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
141909         -  {  161,    0 }, /* (60) conslist_opt ::= */
141910         -  {  185,   -1 }, /* (61) tconscomma ::= COMMA */
141911         -  {  186,   -2 }, /* (62) tcons ::= CONSTRAINT nm */
141912         -  {  186,   -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
141913         -  {  186,   -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
141914         -  {  186,   -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
141915         -  {  186,  -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
141916         -  {  189,    0 }, /* (67) defer_subclause_opt ::= */
141917         -  {  175,    0 }, /* (68) onconf ::= */
141918         -  {  175,   -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
141919         -  {  190,    0 }, /* (70) orconf ::= */
141920         -  {  190,   -2 }, /* (71) orconf ::= OR resolvetype */
141921         -  {  191,   -1 }, /* (72) resolvetype ::= IGNORE */
141922         -  {  191,   -1 }, /* (73) resolvetype ::= REPLACE */
141923         -  {  149,   -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
141924         -  {  193,   -2 }, /* (75) ifexists ::= IF EXISTS */
141925         -  {  193,    0 }, /* (76) ifexists ::= */
141926         -  {  149,   -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
141927         -  {  149,   -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
141928         -  {  149,   -1 }, /* (79) cmd ::= select */
141929         -  {  163,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
141930         -  {  163,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
141931         -  {  163,   -1 }, /* (82) select ::= selectnowith */
141932         -  {  195,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
141933         -  {  198,   -1 }, /* (84) multiselect_op ::= UNION */
141934         -  {  198,   -2 }, /* (85) multiselect_op ::= UNION ALL */
141935         -  {  198,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
141936         -  {  196,   -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
141937         -  {  207,   -4 }, /* (88) values ::= VALUES LP nexprlist RP */
141938         -  {  207,   -5 }, /* (89) values ::= values COMMA LP exprlist RP */
141939         -  {  199,   -1 }, /* (90) distinct ::= DISTINCT */
141940         -  {  199,   -1 }, /* (91) distinct ::= ALL */
141941         -  {  199,    0 }, /* (92) distinct ::= */
141942         -  {  210,    0 }, /* (93) sclp ::= */
141943         -  {  200,   -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
141944         -  {  200,   -3 }, /* (95) selcollist ::= sclp scanpt STAR */
141945         -  {  200,   -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
141946         -  {  211,   -2 }, /* (97) as ::= AS nm */
141947         -  {  211,    0 }, /* (98) as ::= */
141948         -  {  201,    0 }, /* (99) from ::= */
141949         -  {  201,   -2 }, /* (100) from ::= FROM seltablist */
141950         -  {  213,   -2 }, /* (101) stl_prefix ::= seltablist joinop */
141951         -  {  213,    0 }, /* (102) stl_prefix ::= */
141952         -  {  212,   -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
141953         -  {  212,   -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
141954         -  {  212,   -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
141955         -  {  212,   -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
141956         -  {  159,    0 }, /* (107) dbnm ::= */
141957         -  {  159,   -2 }, /* (108) dbnm ::= DOT nm */
141958         -  {  194,   -1 }, /* (109) fullname ::= nm */
141959         -  {  194,   -3 }, /* (110) fullname ::= nm DOT nm */
141960         -  {  214,   -1 }, /* (111) joinop ::= COMMA|JOIN */
141961         -  {  214,   -2 }, /* (112) joinop ::= JOIN_KW JOIN */
141962         -  {  214,   -3 }, /* (113) joinop ::= JOIN_KW nm JOIN */
141963         -  {  214,   -4 }, /* (114) joinop ::= JOIN_KW nm nm JOIN */
141964         -  {  216,   -2 }, /* (115) on_opt ::= ON expr */
141965         -  {  216,    0 }, /* (116) on_opt ::= */
141966         -  {  215,    0 }, /* (117) indexed_opt ::= */
141967         -  {  215,   -3 }, /* (118) indexed_opt ::= INDEXED BY nm */
141968         -  {  215,   -2 }, /* (119) indexed_opt ::= NOT INDEXED */
141969         -  {  217,   -4 }, /* (120) using_opt ::= USING LP idlist RP */
141970         -  {  217,    0 }, /* (121) using_opt ::= */
141971         -  {  205,    0 }, /* (122) orderby_opt ::= */
141972         -  {  205,   -3 }, /* (123) orderby_opt ::= ORDER BY sortlist */
141973         -  {  187,   -4 }, /* (124) sortlist ::= sortlist COMMA expr sortorder */
141974         -  {  187,   -2 }, /* (125) sortlist ::= expr sortorder */
141975         -  {  176,   -1 }, /* (126) sortorder ::= ASC */
141976         -  {  176,   -1 }, /* (127) sortorder ::= DESC */
141977         -  {  176,    0 }, /* (128) sortorder ::= */
141978         -  {  203,    0 }, /* (129) groupby_opt ::= */
141979         -  {  203,   -3 }, /* (130) groupby_opt ::= GROUP BY nexprlist */
141980         -  {  204,    0 }, /* (131) having_opt ::= */
141981         -  {  204,   -2 }, /* (132) having_opt ::= HAVING expr */
141982         -  {  206,    0 }, /* (133) limit_opt ::= */
141983         -  {  206,   -2 }, /* (134) limit_opt ::= LIMIT expr */
141984         -  {  206,   -4 }, /* (135) limit_opt ::= LIMIT expr OFFSET expr */
141985         -  {  206,   -4 }, /* (136) limit_opt ::= LIMIT expr COMMA expr */
141986         -  {  149,   -6 }, /* (137) cmd ::= with DELETE FROM fullname indexed_opt where_opt */
141987         -  {  202,    0 }, /* (138) where_opt ::= */
141988         -  {  202,   -2 }, /* (139) where_opt ::= WHERE expr */
141989         -  {  149,   -8 }, /* (140) cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
141990         -  {  220,   -5 }, /* (141) setlist ::= setlist COMMA nm EQ expr */
141991         -  {  220,   -7 }, /* (142) setlist ::= setlist COMMA LP idlist RP EQ expr */
141992         -  {  220,   -3 }, /* (143) setlist ::= nm EQ expr */
141993         -  {  220,   -5 }, /* (144) setlist ::= LP idlist RP EQ expr */
141994         -  {  149,   -6 }, /* (145) cmd ::= with insert_cmd INTO fullname idlist_opt select */
141995         -  {  149,   -7 }, /* (146) cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
141996         -  {  221,   -2 }, /* (147) insert_cmd ::= INSERT orconf */
141997         -  {  221,   -1 }, /* (148) insert_cmd ::= REPLACE */
141998         -  {  222,    0 }, /* (149) idlist_opt ::= */
141999         -  {  222,   -3 }, /* (150) idlist_opt ::= LP idlist RP */
142000         -  {  218,   -3 }, /* (151) idlist ::= idlist COMMA nm */
142001         -  {  218,   -1 }, /* (152) idlist ::= nm */
142002         -  {  174,   -3 }, /* (153) expr ::= LP expr RP */
142003         -  {  174,   -1 }, /* (154) expr ::= ID|INDEXED */
142004         -  {  174,   -1 }, /* (155) expr ::= JOIN_KW */
142005         -  {  174,   -3 }, /* (156) expr ::= nm DOT nm */
142006         -  {  174,   -5 }, /* (157) expr ::= nm DOT nm DOT nm */
142007         -  {  173,   -1 }, /* (158) term ::= NULL|FLOAT|BLOB */
142008         -  {  173,   -1 }, /* (159) term ::= STRING */
142009         -  {  173,   -1 }, /* (160) term ::= INTEGER */
142010         -  {  174,   -1 }, /* (161) expr ::= VARIABLE */
142011         -  {  174,   -3 }, /* (162) expr ::= expr COLLATE ID|STRING */
142012         -  {  174,   -6 }, /* (163) expr ::= CAST LP expr AS typetoken RP */
142013         -  {  174,   -5 }, /* (164) expr ::= ID|INDEXED LP distinct exprlist RP */
142014         -  {  174,   -4 }, /* (165) expr ::= ID|INDEXED LP STAR RP */
142015         -  {  173,   -1 }, /* (166) term ::= CTIME_KW */
142016         -  {  174,   -5 }, /* (167) expr ::= LP nexprlist COMMA expr RP */
142017         -  {  174,   -3 }, /* (168) expr ::= expr AND expr */
142018         -  {  174,   -3 }, /* (169) expr ::= expr OR expr */
142019         -  {  174,   -3 }, /* (170) expr ::= expr LT|GT|GE|LE expr */
142020         -  {  174,   -3 }, /* (171) expr ::= expr EQ|NE expr */
142021         -  {  174,   -3 }, /* (172) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
142022         -  {  174,   -3 }, /* (173) expr ::= expr PLUS|MINUS expr */
142023         -  {  174,   -3 }, /* (174) expr ::= expr STAR|SLASH|REM expr */
142024         -  {  174,   -3 }, /* (175) expr ::= expr CONCAT expr */
142025         -  {  223,   -2 }, /* (176) likeop ::= NOT LIKE_KW|MATCH */
142026         -  {  174,   -3 }, /* (177) expr ::= expr likeop expr */
142027         -  {  174,   -5 }, /* (178) expr ::= expr likeop expr ESCAPE expr */
142028         -  {  174,   -2 }, /* (179) expr ::= expr ISNULL|NOTNULL */
142029         -  {  174,   -3 }, /* (180) expr ::= expr NOT NULL */
142030         -  {  174,   -3 }, /* (181) expr ::= expr IS expr */
142031         -  {  174,   -4 }, /* (182) expr ::= expr IS NOT expr */
142032         -  {  174,   -2 }, /* (183) expr ::= NOT expr */
142033         -  {  174,   -2 }, /* (184) expr ::= BITNOT expr */
142034         -  {  174,   -2 }, /* (185) expr ::= MINUS expr */
142035         -  {  174,   -2 }, /* (186) expr ::= PLUS expr */
142036         -  {  224,   -1 }, /* (187) between_op ::= BETWEEN */
142037         -  {  224,   -2 }, /* (188) between_op ::= NOT BETWEEN */
142038         -  {  174,   -5 }, /* (189) expr ::= expr between_op expr AND expr */
142039         -  {  225,   -1 }, /* (190) in_op ::= IN */
142040         -  {  225,   -2 }, /* (191) in_op ::= NOT IN */
142041         -  {  174,   -5 }, /* (192) expr ::= expr in_op LP exprlist RP */
142042         -  {  174,   -3 }, /* (193) expr ::= LP select RP */
142043         -  {  174,   -5 }, /* (194) expr ::= expr in_op LP select RP */
142044         -  {  174,   -5 }, /* (195) expr ::= expr in_op nm dbnm paren_exprlist */
142045         -  {  174,   -4 }, /* (196) expr ::= EXISTS LP select RP */
142046         -  {  174,   -5 }, /* (197) expr ::= CASE case_operand case_exprlist case_else END */
142047         -  {  228,   -5 }, /* (198) case_exprlist ::= case_exprlist WHEN expr THEN expr */
142048         -  {  228,   -4 }, /* (199) case_exprlist ::= WHEN expr THEN expr */
142049         -  {  229,   -2 }, /* (200) case_else ::= ELSE expr */
142050         -  {  229,    0 }, /* (201) case_else ::= */
142051         -  {  227,   -1 }, /* (202) case_operand ::= expr */
142052         -  {  227,    0 }, /* (203) case_operand ::= */
142053         -  {  209,    0 }, /* (204) exprlist ::= */
142054         -  {  208,   -3 }, /* (205) nexprlist ::= nexprlist COMMA expr */
142055         -  {  208,   -1 }, /* (206) nexprlist ::= expr */
142056         -  {  226,    0 }, /* (207) paren_exprlist ::= */
142057         -  {  226,   -3 }, /* (208) paren_exprlist ::= LP exprlist RP */
142058         -  {  149,  -12 }, /* (209) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
142059         -  {  230,   -1 }, /* (210) uniqueflag ::= UNIQUE */
142060         -  {  230,    0 }, /* (211) uniqueflag ::= */
142061         -  {  178,    0 }, /* (212) eidlist_opt ::= */
142062         -  {  178,   -3 }, /* (213) eidlist_opt ::= LP eidlist RP */
142063         -  {  188,   -5 }, /* (214) eidlist ::= eidlist COMMA nm collate sortorder */
142064         -  {  188,   -3 }, /* (215) eidlist ::= nm collate sortorder */
142065         -  {  231,    0 }, /* (216) collate ::= */
142066         -  {  231,   -2 }, /* (217) collate ::= COLLATE ID|STRING */
142067         -  {  149,   -4 }, /* (218) cmd ::= DROP INDEX ifexists fullname */
142068         -  {  149,   -1 }, /* (219) cmd ::= VACUUM */
142069         -  {  149,   -2 }, /* (220) cmd ::= VACUUM nm */
142070         -  {  149,   -3 }, /* (221) cmd ::= PRAGMA nm dbnm */
142071         -  {  149,   -5 }, /* (222) cmd ::= PRAGMA nm dbnm EQ nmnum */
142072         -  {  149,   -6 }, /* (223) cmd ::= PRAGMA nm dbnm LP nmnum RP */
142073         -  {  149,   -5 }, /* (224) cmd ::= PRAGMA nm dbnm EQ minus_num */
142074         -  {  149,   -6 }, /* (225) cmd ::= PRAGMA nm dbnm LP minus_num RP */
142075         -  {  169,   -2 }, /* (226) plus_num ::= PLUS INTEGER|FLOAT */
142076         -  {  170,   -2 }, /* (227) minus_num ::= MINUS INTEGER|FLOAT */
142077         -  {  149,   -5 }, /* (228) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
142078         -  {  233,  -11 }, /* (229) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
142079         -  {  235,   -1 }, /* (230) trigger_time ::= BEFORE|AFTER */
142080         -  {  235,   -2 }, /* (231) trigger_time ::= INSTEAD OF */
142081         -  {  235,    0 }, /* (232) trigger_time ::= */
142082         -  {  236,   -1 }, /* (233) trigger_event ::= DELETE|INSERT */
142083         -  {  236,   -1 }, /* (234) trigger_event ::= UPDATE */
142084         -  {  236,   -3 }, /* (235) trigger_event ::= UPDATE OF idlist */
142085         -  {  238,    0 }, /* (236) when_clause ::= */
142086         -  {  238,   -2 }, /* (237) when_clause ::= WHEN expr */
142087         -  {  234,   -3 }, /* (238) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
142088         -  {  234,   -2 }, /* (239) trigger_cmd_list ::= trigger_cmd SEMI */
142089         -  {  240,   -3 }, /* (240) trnm ::= nm DOT nm */
142090         -  {  241,   -3 }, /* (241) tridxby ::= INDEXED BY nm */
142091         -  {  241,   -2 }, /* (242) tridxby ::= NOT INDEXED */
142092         -  {  239,   -8 }, /* (243) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
142093         -  {  239,   -7 }, /* (244) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
142094         -  {  239,   -6 }, /* (245) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
142095         -  {  239,   -3 }, /* (246) trigger_cmd ::= scanpt select scanpt */
142096         -  {  174,   -4 }, /* (247) expr ::= RAISE LP IGNORE RP */
142097         -  {  174,   -6 }, /* (248) expr ::= RAISE LP raisetype COMMA nm RP */
142098         -  {  192,   -1 }, /* (249) raisetype ::= ROLLBACK */
142099         -  {  192,   -1 }, /* (250) raisetype ::= ABORT */
142100         -  {  192,   -1 }, /* (251) raisetype ::= FAIL */
142101         -  {  149,   -4 }, /* (252) cmd ::= DROP TRIGGER ifexists fullname */
142102         -  {  149,   -6 }, /* (253) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
142103         -  {  149,   -3 }, /* (254) cmd ::= DETACH database_kw_opt expr */
142104         -  {  243,    0 }, /* (255) key_opt ::= */
142105         -  {  243,   -2 }, /* (256) key_opt ::= KEY expr */
142106         -  {  149,   -1 }, /* (257) cmd ::= REINDEX */
142107         -  {  149,   -3 }, /* (258) cmd ::= REINDEX nm dbnm */
142108         -  {  149,   -1 }, /* (259) cmd ::= ANALYZE */
142109         -  {  149,   -3 }, /* (260) cmd ::= ANALYZE nm dbnm */
142110         -  {  149,   -6 }, /* (261) cmd ::= ALTER TABLE fullname RENAME TO nm */
142111         -  {  149,   -7 }, /* (262) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
142112         -  {  244,   -1 }, /* (263) add_column_fullname ::= fullname */
142113         -  {  149,   -1 }, /* (264) cmd ::= create_vtab */
142114         -  {  149,   -4 }, /* (265) cmd ::= create_vtab LP vtabarglist RP */
142115         -  {  246,   -8 }, /* (266) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
142116         -  {  248,    0 }, /* (267) vtabarg ::= */
142117         -  {  249,   -1 }, /* (268) vtabargtoken ::= ANY */
142118         -  {  249,   -3 }, /* (269) vtabargtoken ::= lp anylist RP */
142119         -  {  250,   -1 }, /* (270) lp ::= LP */
142120         -  {  219,   -2 }, /* (271) with ::= WITH wqlist */
142121         -  {  219,   -3 }, /* (272) with ::= WITH RECURSIVE wqlist */
142122         -  {  197,   -6 }, /* (273) wqlist ::= nm eidlist_opt AS LP select RP */
142123         -  {  197,   -8 }, /* (274) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
142124         -  {  144,   -1 }, /* (275) input ::= cmdlist */
142125         -  {  145,   -2 }, /* (276) cmdlist ::= cmdlist ecmd */
142126         -  {  145,   -1 }, /* (277) cmdlist ::= ecmd */
142127         -  {  146,   -1 }, /* (278) ecmd ::= SEMI */
142128         -  {  146,   -3 }, /* (279) ecmd ::= explain cmdx SEMI */
142129         -  {  147,    0 }, /* (280) explain ::= */
142130         -  {  151,    0 }, /* (281) trans_opt ::= */
142131         -  {  151,   -1 }, /* (282) trans_opt ::= TRANSACTION */
142132         -  {  151,   -2 }, /* (283) trans_opt ::= TRANSACTION nm */
142133         -  {  153,   -1 }, /* (284) savepoint_opt ::= SAVEPOINT */
142134         -  {  153,    0 }, /* (285) savepoint_opt ::= */
142135         -  {  149,   -2 }, /* (286) cmd ::= create_table create_table_args */
142136         -  {  160,   -4 }, /* (287) columnlist ::= columnlist COMMA columnname carglist */
142137         -  {  160,   -2 }, /* (288) columnlist ::= columnname carglist */
142138         -  {  152,   -1 }, /* (289) nm ::= ID|INDEXED */
142139         -  {  152,   -1 }, /* (290) nm ::= STRING */
142140         -  {  152,   -1 }, /* (291) nm ::= JOIN_KW */
142141         -  {  166,   -1 }, /* (292) typetoken ::= typename */
142142         -  {  167,   -1 }, /* (293) typename ::= ID|STRING */
142143         -  {  168,   -1 }, /* (294) signed ::= plus_num */
142144         -  {  168,   -1 }, /* (295) signed ::= minus_num */
142145         -  {  165,   -2 }, /* (296) carglist ::= carglist ccons */
142146         -  {  165,    0 }, /* (297) carglist ::= */
142147         -  {  172,   -2 }, /* (298) ccons ::= NULL onconf */
142148         -  {  161,   -2 }, /* (299) conslist_opt ::= COMMA conslist */
142149         -  {  184,   -3 }, /* (300) conslist ::= conslist tconscomma tcons */
142150         -  {  184,   -1 }, /* (301) conslist ::= tcons */
142151         -  {  185,    0 }, /* (302) tconscomma ::= */
142152         -  {  189,   -1 }, /* (303) defer_subclause_opt ::= defer_subclause */
142153         -  {  191,   -1 }, /* (304) resolvetype ::= raisetype */
142154         -  {  195,   -1 }, /* (305) selectnowith ::= oneselect */
142155         -  {  196,   -1 }, /* (306) oneselect ::= values */
142156         -  {  210,   -2 }, /* (307) sclp ::= selcollist COMMA */
142157         -  {  211,   -1 }, /* (308) as ::= ID|STRING */
142158         -  {  174,   -1 }, /* (309) expr ::= term */
142159         -  {  223,   -1 }, /* (310) likeop ::= LIKE_KW|MATCH */
142160         -  {  209,   -1 }, /* (311) exprlist ::= nexprlist */
142161         -  {  232,   -1 }, /* (312) nmnum ::= plus_num */
142162         -  {  232,   -1 }, /* (313) nmnum ::= nm */
142163         -  {  232,   -1 }, /* (314) nmnum ::= ON */
142164         -  {  232,   -1 }, /* (315) nmnum ::= DELETE */
142165         -  {  232,   -1 }, /* (316) nmnum ::= DEFAULT */
142166         -  {  169,   -1 }, /* (317) plus_num ::= INTEGER|FLOAT */
142167         -  {  237,    0 }, /* (318) foreach_clause ::= */
142168         -  {  237,   -3 }, /* (319) foreach_clause ::= FOR EACH ROW */
142169         -  {  240,   -1 }, /* (320) trnm ::= nm */
142170         -  {  241,    0 }, /* (321) tridxby ::= */
142171         -  {  242,   -1 }, /* (322) database_kw_opt ::= DATABASE */
142172         -  {  242,    0 }, /* (323) database_kw_opt ::= */
142173         -  {  245,    0 }, /* (324) kwcolumn_opt ::= */
142174         -  {  245,   -1 }, /* (325) kwcolumn_opt ::= COLUMNKW */
142175         -  {  247,   -1 }, /* (326) vtabarglist ::= vtabarg */
142176         -  {  247,   -3 }, /* (327) vtabarglist ::= vtabarglist COMMA vtabarg */
142177         -  {  248,   -2 }, /* (328) vtabarg ::= vtabarg vtabargtoken */
142178         -  {  251,    0 }, /* (329) anylist ::= */
142179         -  {  251,   -4 }, /* (330) anylist ::= anylist LP anylist RP */
142180         -  {  251,   -2 }, /* (331) anylist ::= anylist ANY */
142181         -  {  219,    0 }, /* (332) with ::= */
       142765  +  {  150,   -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
       142766  +  {  151,    0 }, /* (4) transtype ::= */
       142767  +  {  151,   -1 }, /* (5) transtype ::= DEFERRED */
       142768  +  {  151,   -1 }, /* (6) transtype ::= IMMEDIATE */
       142769  +  {  151,   -1 }, /* (7) transtype ::= EXCLUSIVE */
       142770  +  {  150,   -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
       142771  +  {  150,   -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
       142772  +  {  150,   -2 }, /* (10) cmd ::= SAVEPOINT nm */
       142773  +  {  150,   -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
       142774  +  {  150,   -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
       142775  +  {  155,   -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
       142776  +  {  157,   -1 }, /* (14) createkw ::= CREATE */
       142777  +  {  159,    0 }, /* (15) ifnotexists ::= */
       142778  +  {  159,   -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
       142779  +  {  158,   -1 }, /* (17) temp ::= TEMP */
       142780  +  {  158,    0 }, /* (18) temp ::= */
       142781  +  {  156,   -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
       142782  +  {  156,   -2 }, /* (20) create_table_args ::= AS select */
       142783  +  {  163,    0 }, /* (21) table_options ::= */
       142784  +  {  163,   -2 }, /* (22) table_options ::= WITHOUT nm */
       142785  +  {  165,   -2 }, /* (23) columnname ::= nm typetoken */
       142786  +  {  167,    0 }, /* (24) typetoken ::= */
       142787  +  {  167,   -4 }, /* (25) typetoken ::= typename LP signed RP */
       142788  +  {  167,   -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
       142789  +  {  168,   -2 }, /* (27) typename ::= typename ID|STRING */
       142790  +  {  172,    0 }, /* (28) scanpt ::= */
       142791  +  {  173,   -2 }, /* (29) ccons ::= CONSTRAINT nm */
       142792  +  {  173,   -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
       142793  +  {  173,   -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
       142794  +  {  173,   -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
       142795  +  {  173,   -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
       142796  +  {  173,   -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
       142797  +  {  173,   -3 }, /* (35) ccons ::= NOT NULL onconf */
       142798  +  {  173,   -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
       142799  +  {  173,   -2 }, /* (37) ccons ::= UNIQUE onconf */
       142800  +  {  173,   -4 }, /* (38) ccons ::= CHECK LP expr RP */
       142801  +  {  173,   -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
       142802  +  {  173,   -1 }, /* (40) ccons ::= defer_subclause */
       142803  +  {  173,   -2 }, /* (41) ccons ::= COLLATE ID|STRING */
       142804  +  {  178,    0 }, /* (42) autoinc ::= */
       142805  +  {  178,   -1 }, /* (43) autoinc ::= AUTOINCR */
       142806  +  {  180,    0 }, /* (44) refargs ::= */
       142807  +  {  180,   -2 }, /* (45) refargs ::= refargs refarg */
       142808  +  {  182,   -2 }, /* (46) refarg ::= MATCH nm */
       142809  +  {  182,   -3 }, /* (47) refarg ::= ON INSERT refact */
       142810  +  {  182,   -3 }, /* (48) refarg ::= ON DELETE refact */
       142811  +  {  182,   -3 }, /* (49) refarg ::= ON UPDATE refact */
       142812  +  {  183,   -2 }, /* (50) refact ::= SET NULL */
       142813  +  {  183,   -2 }, /* (51) refact ::= SET DEFAULT */
       142814  +  {  183,   -1 }, /* (52) refact ::= CASCADE */
       142815  +  {  183,   -1 }, /* (53) refact ::= RESTRICT */
       142816  +  {  183,   -2 }, /* (54) refact ::= NO ACTION */
       142817  +  {  181,   -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
       142818  +  {  181,   -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
       142819  +  {  184,    0 }, /* (57) init_deferred_pred_opt ::= */
       142820  +  {  184,   -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
       142821  +  {  184,   -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
       142822  +  {  162,    0 }, /* (60) conslist_opt ::= */
       142823  +  {  186,   -1 }, /* (61) tconscomma ::= COMMA */
       142824  +  {  187,   -2 }, /* (62) tcons ::= CONSTRAINT nm */
       142825  +  {  187,   -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
       142826  +  {  187,   -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
       142827  +  {  187,   -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
       142828  +  {  187,  -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
       142829  +  {  190,    0 }, /* (67) defer_subclause_opt ::= */
       142830  +  {  176,    0 }, /* (68) onconf ::= */
       142831  +  {  176,   -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
       142832  +  {  191,    0 }, /* (70) orconf ::= */
       142833  +  {  191,   -2 }, /* (71) orconf ::= OR resolvetype */
       142834  +  {  192,   -1 }, /* (72) resolvetype ::= IGNORE */
       142835  +  {  192,   -1 }, /* (73) resolvetype ::= REPLACE */
       142836  +  {  150,   -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
       142837  +  {  194,   -2 }, /* (75) ifexists ::= IF EXISTS */
       142838  +  {  194,    0 }, /* (76) ifexists ::= */
       142839  +  {  150,   -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
       142840  +  {  150,   -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
       142841  +  {  150,   -1 }, /* (79) cmd ::= select */
       142842  +  {  164,   -3 }, /* (80) select ::= WITH wqlist selectnowith */
       142843  +  {  164,   -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
       142844  +  {  164,   -1 }, /* (82) select ::= selectnowith */
       142845  +  {  196,   -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
       142846  +  {  199,   -1 }, /* (84) multiselect_op ::= UNION */
       142847  +  {  199,   -2 }, /* (85) multiselect_op ::= UNION ALL */
       142848  +  {  199,   -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
       142849  +  {  197,   -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
       142850  +  {  208,   -4 }, /* (88) values ::= VALUES LP nexprlist RP */
       142851  +  {  208,   -5 }, /* (89) values ::= values COMMA LP exprlist RP */
       142852  +  {  200,   -1 }, /* (90) distinct ::= DISTINCT */
       142853  +  {  200,   -1 }, /* (91) distinct ::= ALL */
       142854  +  {  200,    0 }, /* (92) distinct ::= */
       142855  +  {  211,    0 }, /* (93) sclp ::= */
       142856  +  {  201,   -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
       142857  +  {  201,   -3 }, /* (95) selcollist ::= sclp scanpt STAR */
       142858  +  {  201,   -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
       142859  +  {  212,   -2 }, /* (97) as ::= AS nm */
       142860  +  {  212,    0 }, /* (98) as ::= */
       142861  +  {  202,    0 }, /* (99) from ::= */
       142862  +  {  202,   -2 }, /* (100) from ::= FROM seltablist */
       142863  +  {  214,   -2 }, /* (101) stl_prefix ::= seltablist joinop */
       142864  +  {  214,    0 }, /* (102) stl_prefix ::= */
       142865  +  {  213,   -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
       142866  +  {  213,   -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
       142867  +  {  213,   -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
       142868  +  {  213,   -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
       142869  +  {  160,    0 }, /* (107) dbnm ::= */
       142870  +  {  160,   -2 }, /* (108) dbnm ::= DOT nm */
       142871  +  {  195,   -1 }, /* (109) fullname ::= nm */
       142872  +  {  195,   -3 }, /* (110) fullname ::= nm DOT nm */
       142873  +  {  219,   -1 }, /* (111) xfullname ::= nm */
       142874  +  {  219,   -3 }, /* (112) xfullname ::= nm DOT nm */
       142875  +  {  219,   -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
       142876  +  {  219,   -3 }, /* (114) xfullname ::= nm AS nm */
       142877  +  {  215,   -1 }, /* (115) joinop ::= COMMA|JOIN */
       142878  +  {  215,   -2 }, /* (116) joinop ::= JOIN_KW JOIN */
       142879  +  {  215,   -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
       142880  +  {  215,   -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
       142881  +  {  217,   -2 }, /* (119) on_opt ::= ON expr */
       142882  +  {  217,    0 }, /* (120) on_opt ::= */
       142883  +  {  216,    0 }, /* (121) indexed_opt ::= */
       142884  +  {  216,   -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
       142885  +  {  216,   -2 }, /* (123) indexed_opt ::= NOT INDEXED */
       142886  +  {  218,   -4 }, /* (124) using_opt ::= USING LP idlist RP */
       142887  +  {  218,    0 }, /* (125) using_opt ::= */
       142888  +  {  206,    0 }, /* (126) orderby_opt ::= */
       142889  +  {  206,   -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
       142890  +  {  188,   -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
       142891  +  {  188,   -2 }, /* (129) sortlist ::= expr sortorder */
       142892  +  {  177,   -1 }, /* (130) sortorder ::= ASC */
       142893  +  {  177,   -1 }, /* (131) sortorder ::= DESC */
       142894  +  {  177,    0 }, /* (132) sortorder ::= */
       142895  +  {  204,    0 }, /* (133) groupby_opt ::= */
       142896  +  {  204,   -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
       142897  +  {  205,    0 }, /* (135) having_opt ::= */
       142898  +  {  205,   -2 }, /* (136) having_opt ::= HAVING expr */
       142899  +  {  207,    0 }, /* (137) limit_opt ::= */
       142900  +  {  207,   -2 }, /* (138) limit_opt ::= LIMIT expr */
       142901  +  {  207,   -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
       142902  +  {  207,   -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
       142903  +  {  150,   -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
       142904  +  {  203,    0 }, /* (142) where_opt ::= */
       142905  +  {  203,   -2 }, /* (143) where_opt ::= WHERE expr */
       142906  +  {  150,   -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
       142907  +  {  222,   -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
       142908  +  {  222,   -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
       142909  +  {  222,   -3 }, /* (147) setlist ::= nm EQ expr */
       142910  +  {  222,   -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
       142911  +  {  150,   -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
       142912  +  {  150,   -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
       142913  +  {  225,    0 }, /* (151) upsert ::= */
       142914  +  {  225,  -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
       142915  +  {  225,   -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
       142916  +  {  225,   -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
       142917  +  {  223,   -2 }, /* (155) insert_cmd ::= INSERT orconf */
       142918  +  {  223,   -1 }, /* (156) insert_cmd ::= REPLACE */
       142919  +  {  224,    0 }, /* (157) idlist_opt ::= */
       142920  +  {  224,   -3 }, /* (158) idlist_opt ::= LP idlist RP */
       142921  +  {  220,   -3 }, /* (159) idlist ::= idlist COMMA nm */
       142922  +  {  220,   -1 }, /* (160) idlist ::= nm */
       142923  +  {  175,   -3 }, /* (161) expr ::= LP expr RP */
       142924  +  {  175,   -1 }, /* (162) expr ::= ID|INDEXED */
       142925  +  {  175,   -1 }, /* (163) expr ::= JOIN_KW */
       142926  +  {  175,   -3 }, /* (164) expr ::= nm DOT nm */
       142927  +  {  175,   -5 }, /* (165) expr ::= nm DOT nm DOT nm */
       142928  +  {  174,   -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
       142929  +  {  174,   -1 }, /* (167) term ::= STRING */
       142930  +  {  174,   -1 }, /* (168) term ::= INTEGER */
       142931  +  {  175,   -1 }, /* (169) expr ::= VARIABLE */
       142932  +  {  175,   -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
       142933  +  {  175,   -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
       142934  +  {  175,   -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
       142935  +  {  175,   -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
       142936  +  {  174,   -1 }, /* (174) term ::= CTIME_KW */
       142937  +  {  175,   -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
       142938  +  {  175,   -3 }, /* (176) expr ::= expr AND expr */
       142939  +  {  175,   -3 }, /* (177) expr ::= expr OR expr */
       142940  +  {  175,   -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
       142941  +  {  175,   -3 }, /* (179) expr ::= expr EQ|NE expr */
       142942  +  {  175,   -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
       142943  +  {  175,   -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
       142944  +  {  175,   -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
       142945  +  {  175,   -3 }, /* (183) expr ::= expr CONCAT expr */
       142946  +  {  226,   -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
       142947  +  {  175,   -3 }, /* (185) expr ::= expr likeop expr */
       142948  +  {  175,   -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
       142949  +  {  175,   -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
       142950  +  {  175,   -3 }, /* (188) expr ::= expr NOT NULL */
       142951  +  {  175,   -3 }, /* (189) expr ::= expr IS expr */
       142952  +  {  175,   -4 }, /* (190) expr ::= expr IS NOT expr */
       142953  +  {  175,   -2 }, /* (191) expr ::= NOT expr */
       142954  +  {  175,   -2 }, /* (192) expr ::= BITNOT expr */
       142955  +  {  175,   -2 }, /* (193) expr ::= MINUS expr */
       142956  +  {  175,   -2 }, /* (194) expr ::= PLUS expr */
       142957  +  {  227,   -1 }, /* (195) between_op ::= BETWEEN */
       142958  +  {  227,   -2 }, /* (196) between_op ::= NOT BETWEEN */
       142959  +  {  175,   -5 }, /* (197) expr ::= expr between_op expr AND expr */
       142960  +  {  228,   -1 }, /* (198) in_op ::= IN */
       142961  +  {  228,   -2 }, /* (199) in_op ::= NOT IN */
       142962  +  {  175,   -5 }, /* (200) expr ::= expr in_op LP exprlist RP */
       142963  +  {  175,   -3 }, /* (201) expr ::= LP select RP */
       142964  +  {  175,   -5 }, /* (202) expr ::= expr in_op LP select RP */
       142965  +  {  175,   -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */
       142966  +  {  175,   -4 }, /* (204) expr ::= EXISTS LP select RP */
       142967  +  {  175,   -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */
       142968  +  {  231,   -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */
       142969  +  {  231,   -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */
       142970  +  {  232,   -2 }, /* (208) case_else ::= ELSE expr */
       142971  +  {  232,    0 }, /* (209) case_else ::= */
       142972  +  {  230,   -1 }, /* (210) case_operand ::= expr */
       142973  +  {  230,    0 }, /* (211) case_operand ::= */
       142974  +  {  210,    0 }, /* (212) exprlist ::= */
       142975  +  {  209,   -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */
       142976  +  {  209,   -1 }, /* (214) nexprlist ::= expr */
       142977  +  {  229,    0 }, /* (215) paren_exprlist ::= */
       142978  +  {  229,   -3 }, /* (216) paren_exprlist ::= LP exprlist RP */
       142979  +  {  150,  -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
       142980  +  {  233,   -1 }, /* (218) uniqueflag ::= UNIQUE */
       142981  +  {  233,    0 }, /* (219) uniqueflag ::= */
       142982  +  {  179,    0 }, /* (220) eidlist_opt ::= */
       142983  +  {  179,   -3 }, /* (221) eidlist_opt ::= LP eidlist RP */
       142984  +  {  189,   -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */
       142985  +  {  189,   -3 }, /* (223) eidlist ::= nm collate sortorder */
       142986  +  {  234,    0 }, /* (224) collate ::= */
       142987  +  {  234,   -2 }, /* (225) collate ::= COLLATE ID|STRING */
       142988  +  {  150,   -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */
       142989  +  {  150,   -1 }, /* (227) cmd ::= VACUUM */
       142990  +  {  150,   -2 }, /* (228) cmd ::= VACUUM nm */
       142991  +  {  150,   -3 }, /* (229) cmd ::= PRAGMA nm dbnm */
       142992  +  {  150,   -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */
       142993  +  {  150,   -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */
       142994  +  {  150,   -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */
       142995  +  {  150,   -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */
       142996  +  {  170,   -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */
       142997  +  {  171,   -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */
       142998  +  {  150,   -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
       142999  +  {  236,  -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
       143000  +  {  238,   -1 }, /* (238) trigger_time ::= BEFORE|AFTER */
       143001  +  {  238,   -2 }, /* (239) trigger_time ::= INSTEAD OF */
       143002  +  {  238,    0 }, /* (240) trigger_time ::= */
       143003  +  {  239,   -1 }, /* (241) trigger_event ::= DELETE|INSERT */
       143004  +  {  239,   -1 }, /* (242) trigger_event ::= UPDATE */
       143005  +  {  239,   -3 }, /* (243) trigger_event ::= UPDATE OF idlist */
       143006  +  {  241,    0 }, /* (244) when_clause ::= */
       143007  +  {  241,   -2 }, /* (245) when_clause ::= WHEN expr */
       143008  +  {  237,   -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
       143009  +  {  237,   -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */
       143010  +  {  243,   -3 }, /* (248) trnm ::= nm DOT nm */
       143011  +  {  244,   -3 }, /* (249) tridxby ::= INDEXED BY nm */
       143012  +  {  244,   -2 }, /* (250) tridxby ::= NOT INDEXED */
       143013  +  {  242,   -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
       143014  +  {  242,   -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
       143015  +  {  242,   -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
       143016  +  {  242,   -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */
       143017  +  {  175,   -4 }, /* (255) expr ::= RAISE LP IGNORE RP */
       143018  +  {  175,   -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */
       143019  +  {  193,   -1 }, /* (257) raisetype ::= ROLLBACK */
       143020  +  {  193,   -1 }, /* (258) raisetype ::= ABORT */
       143021  +  {  193,   -1 }, /* (259) raisetype ::= FAIL */
       143022  +  {  150,   -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */
       143023  +  {  150,   -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
       143024  +  {  150,   -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */
       143025  +  {  246,    0 }, /* (263) key_opt ::= */
       143026  +  {  246,   -2 }, /* (264) key_opt ::= KEY expr */
       143027  +  {  150,   -1 }, /* (265) cmd ::= REINDEX */
       143028  +  {  150,   -3 }, /* (266) cmd ::= REINDEX nm dbnm */
       143029  +  {  150,   -1 }, /* (267) cmd ::= ANALYZE */
       143030  +  {  150,   -3 }, /* (268) cmd ::= ANALYZE nm dbnm */
       143031  +  {  150,   -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */
       143032  +  {  150,   -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
       143033  +  {  247,   -1 }, /* (271) add_column_fullname ::= fullname */
       143034  +  {  150,   -1 }, /* (272) cmd ::= create_vtab */
       143035  +  {  150,   -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
       143036  +  {  249,   -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
       143037  +  {  251,    0 }, /* (275) vtabarg ::= */
       143038  +  {  252,   -1 }, /* (276) vtabargtoken ::= ANY */
       143039  +  {  252,   -3 }, /* (277) vtabargtoken ::= lp anylist RP */
       143040  +  {  253,   -1 }, /* (278) lp ::= LP */
       143041  +  {  221,   -2 }, /* (279) with ::= WITH wqlist */
       143042  +  {  221,   -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
       143043  +  {  198,   -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
       143044  +  {  198,   -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
       143045  +  {  145,   -1 }, /* (283) input ::= cmdlist */
       143046  +  {  146,   -2 }, /* (284) cmdlist ::= cmdlist ecmd */
       143047  +  {  146,   -1 }, /* (285) cmdlist ::= ecmd */
       143048  +  {  147,   -1 }, /* (286) ecmd ::= SEMI */
       143049  +  {  147,   -2 }, /* (287) ecmd ::= cmdx SEMI */
       143050  +  {  147,   -2 }, /* (288) ecmd ::= explain cmdx */
       143051  +  {  152,    0 }, /* (289) trans_opt ::= */
       143052  +  {  152,   -1 }, /* (290) trans_opt ::= TRANSACTION */
       143053  +  {  152,   -2 }, /* (291) trans_opt ::= TRANSACTION nm */
       143054  +  {  154,   -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
       143055  +  {  154,    0 }, /* (293) savepoint_opt ::= */
       143056  +  {  150,   -2 }, /* (294) cmd ::= create_table create_table_args */
       143057  +  {  161,   -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
       143058  +  {  161,   -2 }, /* (296) columnlist ::= columnname carglist */
       143059  +  {  153,   -1 }, /* (297) nm ::= ID|INDEXED */
       143060  +  {  153,   -1 }, /* (298) nm ::= STRING */
       143061  +  {  153,   -1 }, /* (299) nm ::= JOIN_KW */
       143062  +  {  167,   -1 }, /* (300) typetoken ::= typename */
       143063  +  {  168,   -1 }, /* (301) typename ::= ID|STRING */
       143064  +  {  169,   -1 }, /* (302) signed ::= plus_num */
       143065  +  {  169,   -1 }, /* (303) signed ::= minus_num */
       143066  +  {  166,   -2 }, /* (304) carglist ::= carglist ccons */
       143067  +  {  166,    0 }, /* (305) carglist ::= */
       143068  +  {  173,   -2 }, /* (306) ccons ::= NULL onconf */
       143069  +  {  162,   -2 }, /* (307) conslist_opt ::= COMMA conslist */
       143070  +  {  185,   -3 }, /* (308) conslist ::= conslist tconscomma tcons */
       143071  +  {  185,   -1 }, /* (309) conslist ::= tcons */
       143072  +  {  186,    0 }, /* (310) tconscomma ::= */
       143073  +  {  190,   -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
       143074  +  {  192,   -1 }, /* (312) resolvetype ::= raisetype */
       143075  +  {  196,   -1 }, /* (313) selectnowith ::= oneselect */
       143076  +  {  197,   -1 }, /* (314) oneselect ::= values */
       143077  +  {  211,   -2 }, /* (315) sclp ::= selcollist COMMA */
       143078  +  {  212,   -1 }, /* (316) as ::= ID|STRING */
       143079  +  {  175,   -1 }, /* (317) expr ::= term */
       143080  +  {  226,   -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
       143081  +  {  210,   -1 }, /* (319) exprlist ::= nexprlist */
       143082  +  {  235,   -1 }, /* (320) nmnum ::= plus_num */
       143083  +  {  235,   -1 }, /* (321) nmnum ::= nm */
       143084  +  {  235,   -1 }, /* (322) nmnum ::= ON */
       143085  +  {  235,   -1 }, /* (323) nmnum ::= DELETE */
       143086  +  {  235,   -1 }, /* (324) nmnum ::= DEFAULT */
       143087  +  {  170,   -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
       143088  +  {  240,    0 }, /* (326) foreach_clause ::= */
       143089  +  {  240,   -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
       143090  +  {  243,   -1 }, /* (328) trnm ::= nm */
       143091  +  {  244,    0 }, /* (329) tridxby ::= */
       143092  +  {  245,   -1 }, /* (330) database_kw_opt ::= DATABASE */
       143093  +  {  245,    0 }, /* (331) database_kw_opt ::= */
       143094  +  {  248,    0 }, /* (332) kwcolumn_opt ::= */
       143095  +  {  248,   -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
       143096  +  {  250,   -1 }, /* (334) vtabarglist ::= vtabarg */
       143097  +  {  250,   -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
       143098  +  {  251,   -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
       143099  +  {  254,    0 }, /* (337) anylist ::= */
       143100  +  {  254,   -4 }, /* (338) anylist ::= anylist LP anylist RP */
       143101  +  {  254,   -2 }, /* (339) anylist ::= anylist ANY */
       143102  +  {  221,    0 }, /* (340) with ::= */
142182 143103   };
142183 143104   
142184 143105   static void yy_accept(yyParser*);  /* Forward Declaration */
142185 143106   
142186 143107   /*
142187 143108   ** Perform a reduce action and the shift that must immediately
142188 143109   ** follow the reduce.
................................................................................
142189 143110   **
142190 143111   ** The yyLookahead and yyLookaheadToken parameters provide reduce actions
142191 143112   ** access to the lookahead token (if any).  The yyLookahead will be YYNOCODE
142192 143113   ** if the lookahead token has already been consumed.  As this procedure is
142193 143114   ** only called from one place, optimizing compilers will in-line it, which
142194 143115   ** means that the extra parameters have no performance impact.
142195 143116   */
142196         -static void yy_reduce(
       143117  +static YYACTIONTYPE yy_reduce(
142197 143118     yyParser *yypParser,         /* The parser */
142198 143119     unsigned int yyruleno,       /* Number of the rule by which to reduce */
142199 143120     int yyLookahead,             /* Lookahead token, or YYNOCODE if none */
142200 143121     sqlite3ParserTOKENTYPE yyLookaheadToken  /* Value of the lookahead token */
       143122  +  sqlite3ParserCTX_PDECL                   /* %extra_context */
142201 143123   ){
142202 143124     int yygoto;                     /* The next state */
142203 143125     int yyact;                      /* The next action */
142204 143126     yyStackEntry *yymsp;            /* The top of the parser's stack */
142205 143127     int yysize;                     /* Amount to pop the stack */
142206         -  sqlite3ParserARG_FETCH;
       143128  +  sqlite3ParserARG_FETCH
142207 143129     (void)yyLookahead;
142208 143130     (void)yyLookaheadToken;
142209 143131     yymsp = yypParser->yytos;
142210 143132   #ifndef NDEBUG
142211 143133     if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
142212 143134       yysize = yyRuleInfo[yyruleno].nrhs;
142213 143135       if( yysize ){
................................................................................
142230 143152         yypParser->yyhwm++;
142231 143153         assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack));
142232 143154       }
142233 143155   #endif
142234 143156   #if YYSTACKDEPTH>0 
142235 143157       if( yypParser->yytos>=yypParser->yystackEnd ){
142236 143158         yyStackOverflow(yypParser);
142237         -      return;
       143159  +      /* The call to yyStackOverflow() above pops the stack until it is
       143160  +      ** empty, causing the main parser loop to exit.  So the return value
       143161  +      ** is never used and does not matter. */
       143162  +      return 0;
142238 143163       }
142239 143164   #else
142240 143165       if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){
142241 143166         if( yyGrowStack(yypParser) ){
142242 143167           yyStackOverflow(yypParser);
142243         -        return;
       143168  +        /* The call to yyStackOverflow() above pops the stack until it is
       143169  +        ** empty, causing the main parser loop to exit.  So the return value
       143170  +        ** is never used and does not matter. */
       143171  +        return 0;
142244 143172         }
142245 143173         yymsp = yypParser->yytos;
142246 143174       }
142247 143175   #endif
142248 143176     }
142249 143177   
142250 143178     switch( yyruleno ){
................................................................................
142264 143192         case 1: /* explain ::= EXPLAIN QUERY PLAN */
142265 143193   { pParse->explain = 2; }
142266 143194           break;
142267 143195         case 2: /* cmdx ::= cmd */
142268 143196   { sqlite3FinishCoding(pParse); }
142269 143197           break;
142270 143198         case 3: /* cmd ::= BEGIN transtype trans_opt */
142271         -{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);}
       143199  +{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
142272 143200           break;
142273 143201         case 4: /* transtype ::= */
142274         -{yymsp[1].minor.yy4 = TK_DEFERRED;}
       143202  +{yymsp[1].minor.yy502 = TK_DEFERRED;}
142275 143203           break;
142276 143204         case 5: /* transtype ::= DEFERRED */
142277 143205         case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
142278 143206         case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
142279         -{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/}
       143207  +{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
142280 143208           break;
142281 143209         case 8: /* cmd ::= COMMIT|END trans_opt */
142282 143210         case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
142283 143211   {sqlite3EndTransaction(pParse,yymsp[-1].major);}
142284 143212           break;
142285 143213         case 10: /* cmd ::= SAVEPOINT nm */
142286 143214   {
................................................................................
142295 143223         case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
142296 143224   {
142297 143225     sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
142298 143226   }
142299 143227           break;
142300 143228         case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
142301 143229   {
142302         -   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4);
       143230  +   sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
142303 143231   }
142304 143232           break;
142305 143233         case 14: /* createkw ::= CREATE */
142306 143234   {disableLookaside(pParse);}
142307 143235           break;
142308 143236         case 15: /* ifnotexists ::= */
142309 143237         case 18: /* temp ::= */ yytestcase(yyruleno==18);
142310 143238         case 21: /* table_options ::= */ yytestcase(yyruleno==21);
142311 143239         case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
142312 143240         case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
142313 143241         case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
142314 143242         case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
142315 143243         case 92: /* distinct ::= */ yytestcase(yyruleno==92);
142316         -      case 216: /* collate ::= */ yytestcase(yyruleno==216);
142317         -{yymsp[1].minor.yy4 = 0;}
       143244  +      case 224: /* collate ::= */ yytestcase(yyruleno==224);
       143245  +{yymsp[1].minor.yy502 = 0;}
142318 143246           break;
142319 143247         case 16: /* ifnotexists ::= IF NOT EXISTS */
142320         -{yymsp[-2].minor.yy4 = 1;}
       143248  +{yymsp[-2].minor.yy502 = 1;}
142321 143249           break;
142322 143250         case 17: /* temp ::= TEMP */
142323 143251         case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
142324         -{yymsp[0].minor.yy4 = 1;}
       143252  +{yymsp[0].minor.yy502 = 1;}
142325 143253           break;
142326 143254         case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
142327 143255   {
142328         -  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy4,0);
       143256  +  sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
142329 143257   }
142330 143258           break;
142331 143259         case 20: /* create_table_args ::= AS select */
142332 143260   {
142333         -  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy387);
142334         -  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
       143261  +  sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
       143262  +  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
142335 143263   }
142336 143264           break;
142337 143265         case 22: /* table_options ::= WITHOUT nm */
142338 143266   {
142339 143267     if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
142340         -    yymsp[-1].minor.yy4 = TF_WithoutRowid | TF_NoVisibleRowid;
       143268  +    yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
142341 143269     }else{
142342         -    yymsp[-1].minor.yy4 = 0;
       143270  +    yymsp[-1].minor.yy502 = 0;
142343 143271       sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
142344 143272     }
142345 143273   }
142346 143274           break;
142347 143275         case 23: /* columnname ::= nm typetoken */
142348 143276   {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
142349 143277           break;
................................................................................
142364 143292           break;
142365 143293         case 27: /* typename ::= typename ID|STRING */
142366 143294   {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
142367 143295           break;
142368 143296         case 28: /* scanpt ::= */
142369 143297   {
142370 143298     assert( yyLookahead!=YYNOCODE );
142371         -  yymsp[1].minor.yy336 = yyLookaheadToken.z;
       143299  +  yymsp[1].minor.yy36 = yyLookaheadToken.z;
142372 143300   }
142373 143301           break;
142374 143302         case 29: /* ccons ::= CONSTRAINT nm */
142375 143303         case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
142376 143304   {pParse->constraintName = yymsp[0].minor.yy0;}
142377 143305           break;
142378 143306         case 30: /* ccons ::= DEFAULT scanpt term scanpt */
142379         -{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy336,yymsp[0].minor.yy336);}
       143307  +{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
142380 143308           break;
142381 143309         case 31: /* ccons ::= DEFAULT LP expr RP */
142382         -{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
       143310  +{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
142383 143311           break;
142384 143312         case 32: /* ccons ::= DEFAULT PLUS term scanpt */
142385         -{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy314,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);}
       143313  +{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
142386 143314           break;
142387 143315         case 33: /* ccons ::= DEFAULT MINUS term scanpt */
142388 143316   {
142389         -  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy314, 0);
142390         -  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy336);
       143317  +  Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
       143318  +  sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
142391 143319   }
142392 143320           break;
142393 143321         case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
142394 143322   {
142395 143323     Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
142396 143324     if( p ){
142397 143325       sqlite3ExprIdToTrueFalse(p);
142398 143326       testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) );
142399 143327     }
142400 143328     sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
142401 143329   }
142402 143330           break;
142403 143331         case 35: /* ccons ::= NOT NULL onconf */
142404         -{sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);}
       143332  +{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
142405 143333           break;
142406 143334         case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
142407         -{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);}
       143335  +{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
142408 143336           break;
142409 143337         case 37: /* ccons ::= UNIQUE onconf */
142410         -{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0,
       143338  +{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
142411 143339                                      SQLITE_IDXTYPE_UNIQUE);}
142412 143340           break;
142413 143341         case 38: /* ccons ::= CHECK LP expr RP */
142414         -{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy314);}
       143342  +{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
142415 143343           break;
142416 143344         case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
142417         -{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);}
       143345  +{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
142418 143346           break;
142419 143347         case 40: /* ccons ::= defer_subclause */
142420         -{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);}
       143348  +{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
142421 143349           break;
142422 143350         case 41: /* ccons ::= COLLATE ID|STRING */
142423 143351   {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
142424 143352           break;
142425 143353         case 44: /* refargs ::= */
142426         -{ yymsp[1].minor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */}
       143354  +{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
142427 143355           break;
142428 143356         case 45: /* refargs ::= refargs refarg */
142429         -{ yymsp[-1].minor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; }
       143357  +{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
142430 143358           break;
142431 143359         case 46: /* refarg ::= MATCH nm */
142432         -{ yymsp[-1].minor.yy215.value = 0;     yymsp[-1].minor.yy215.mask = 0x000000; }
       143360  +{ yymsp[-1].minor.yy107.value = 0;     yymsp[-1].minor.yy107.mask = 0x000000; }
142433 143361           break;
142434 143362         case 47: /* refarg ::= ON INSERT refact */
142435         -{ yymsp[-2].minor.yy215.value = 0;     yymsp[-2].minor.yy215.mask = 0x000000; }
       143363  +{ yymsp[-2].minor.yy107.value = 0;     yymsp[-2].minor.yy107.mask = 0x000000; }
142436 143364           break;
142437 143365         case 48: /* refarg ::= ON DELETE refact */
142438         -{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4;     yymsp[-2].minor.yy215.mask = 0x0000ff; }
       143366  +{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502;     yymsp[-2].minor.yy107.mask = 0x0000ff; }
142439 143367           break;
142440 143368         case 49: /* refarg ::= ON UPDATE refact */
142441         -{ yymsp[-2].minor.yy215.value = yymsp[0].minor.yy4<<8;  yymsp[-2].minor.yy215.mask = 0x00ff00; }
       143369  +{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8;  yymsp[-2].minor.yy107.mask = 0x00ff00; }
142442 143370           break;
142443 143371         case 50: /* refact ::= SET NULL */
142444         -{ yymsp[-1].minor.yy4 = OE_SetNull;  /* EV: R-33326-45252 */}
       143372  +{ yymsp[-1].minor.yy502 = OE_SetNull;  /* EV: R-33326-45252 */}
142445 143373           break;
142446 143374         case 51: /* refact ::= SET DEFAULT */
142447         -{ yymsp[-1].minor.yy4 = OE_SetDflt;  /* EV: R-33326-45252 */}
       143375  +{ yymsp[-1].minor.yy502 = OE_SetDflt;  /* EV: R-33326-45252 */}
142448 143376           break;
142449 143377         case 52: /* refact ::= CASCADE */
142450         -{ yymsp[0].minor.yy4 = OE_Cascade;  /* EV: R-33326-45252 */}
       143378  +{ yymsp[0].minor.yy502 = OE_Cascade;  /* EV: R-33326-45252 */}
142451 143379           break;
142452 143380         case 53: /* refact ::= RESTRICT */
142453         -{ yymsp[0].minor.yy4 = OE_Restrict; /* EV: R-33326-45252 */}
       143381  +{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
142454 143382           break;
142455 143383         case 54: /* refact ::= NO ACTION */
142456         -{ yymsp[-1].minor.yy4 = OE_None;     /* EV: R-33326-45252 */}
       143384  +{ yymsp[-1].minor.yy502 = OE_None;     /* EV: R-33326-45252 */}
142457 143385           break;
142458 143386         case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
142459         -{yymsp[-2].minor.yy4 = 0;}
       143387  +{yymsp[-2].minor.yy502 = 0;}
142460 143388           break;
142461 143389         case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
142462 143390         case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
142463         -      case 147: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==147);
142464         -{yymsp[-1].minor.yy4 = yymsp[0].minor.yy4;}
       143391  +      case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
       143392  +{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
142465 143393           break;
142466 143394         case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
142467 143395         case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
142468         -      case 188: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==188);
142469         -      case 191: /* in_op ::= NOT IN */ yytestcase(yyruleno==191);
142470         -      case 217: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==217);
142471         -{yymsp[-1].minor.yy4 = 1;}
       143396  +      case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196);
       143397  +      case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199);
       143398  +      case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225);
       143399  +{yymsp[-1].minor.yy502 = 1;}
142472 143400           break;
142473 143401         case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
142474         -{yymsp[-1].minor.yy4 = 0;}
       143402  +{yymsp[-1].minor.yy502 = 0;}
142475 143403           break;
142476 143404         case 61: /* tconscomma ::= COMMA */
142477 143405   {pParse->constraintName.n = 0;}
142478 143406           break;
142479 143407         case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
142480         -{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);}
       143408  +{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
142481 143409           break;
142482 143410         case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
142483         -{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0,
       143411  +{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
142484 143412                                          SQLITE_IDXTYPE_UNIQUE);}
142485 143413           break;
142486 143414         case 65: /* tcons ::= CHECK LP expr RP onconf */
142487         -{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy314);}
       143415  +{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
142488 143416           break;
142489 143417         case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
142490 143418   {
142491         -    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4);
142492         -    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4);
       143419  +    sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
       143420  +    sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
142493 143421   }
142494 143422           break;
142495 143423         case 68: /* onconf ::= */
142496 143424         case 70: /* orconf ::= */ yytestcase(yyruleno==70);
142497         -{yymsp[1].minor.yy4 = OE_Default;}
       143425  +{yymsp[1].minor.yy502 = OE_Default;}
142498 143426           break;
142499 143427         case 69: /* onconf ::= ON CONFLICT resolvetype */
142500         -{yymsp[-2].minor.yy4 = yymsp[0].minor.yy4;}
       143428  +{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
142501 143429           break;
142502 143430         case 72: /* resolvetype ::= IGNORE */
142503         -{yymsp[0].minor.yy4 = OE_Ignore;}
       143431  +{yymsp[0].minor.yy502 = OE_Ignore;}
142504 143432           break;
142505 143433         case 73: /* resolvetype ::= REPLACE */
142506         -      case 148: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==148);
142507         -{yymsp[0].minor.yy4 = OE_Replace;}
       143434  +      case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
       143435  +{yymsp[0].minor.yy502 = OE_Replace;}
142508 143436           break;
142509 143437         case 74: /* cmd ::= DROP TABLE ifexists fullname */
142510 143438   {
142511         -  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4);
       143439  +  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
142512 143440   }
142513 143441           break;
142514 143442         case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
142515 143443   {
142516         -  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy387, yymsp[-7].minor.yy4, yymsp[-5].minor.yy4);
       143444  +  sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
142517 143445   }
142518 143446           break;
142519 143447         case 78: /* cmd ::= DROP VIEW ifexists fullname */
142520 143448   {
142521         -  sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4);
       143449  +  sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
142522 143450   }
142523 143451           break;
142524 143452         case 79: /* cmd ::= select */
142525 143453   {
142526 143454     SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
142527         -  sqlite3Select(pParse, yymsp[0].minor.yy387, &dest);
142528         -  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387);
       143455  +  sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
       143456  +  sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
142529 143457   }
142530 143458           break;
142531 143459         case 80: /* select ::= WITH wqlist selectnowith */
142532 143460   {
142533         -  Select *p = yymsp[0].minor.yy387;
       143461  +  Select *p = yymsp[0].minor.yy399;
142534 143462     if( p ){
142535         -    p->pWith = yymsp[-1].minor.yy451;
       143463  +    p->pWith = yymsp[-1].minor.yy91;
142536 143464       parserDoubleLinkSelect(pParse, p);
142537 143465     }else{
142538         -    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
       143466  +    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
142539 143467     }
142540         -  yymsp[-2].minor.yy387 = p;
       143468  +  yymsp[-2].minor.yy399 = p;
142541 143469   }
142542 143470           break;
142543 143471         case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
142544 143472   {
142545         -  Select *p = yymsp[0].minor.yy387;
       143473  +  Select *p = yymsp[0].minor.yy399;
142546 143474     if( p ){
142547         -    p->pWith = yymsp[-1].minor.yy451;
       143475  +    p->pWith = yymsp[-1].minor.yy91;
142548 143476       parserDoubleLinkSelect(pParse, p);
142549 143477     }else{
142550         -    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy451);
       143478  +    sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
142551 143479     }
142552         -  yymsp[-3].minor.yy387 = p;
       143480  +  yymsp[-3].minor.yy399 = p;
142553 143481   }
142554 143482           break;
142555 143483         case 82: /* select ::= selectnowith */
142556 143484   {
142557         -  Select *p = yymsp[0].minor.yy387;
       143485  +  Select *p = yymsp[0].minor.yy399;
142558 143486     if( p ){
142559 143487       parserDoubleLinkSelect(pParse, p);
142560 143488     }
142561         -  yymsp[0].minor.yy387 = p; /*A-overwrites-X*/
       143489  +  yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
142562 143490   }
142563 143491           break;
142564 143492         case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
142565 143493   {
142566         -  Select *pRhs = yymsp[0].minor.yy387;
142567         -  Select *pLhs = yymsp[-2].minor.yy387;
       143494  +  Select *pRhs = yymsp[0].minor.yy399;
       143495  +  Select *pLhs = yymsp[-2].minor.yy399;
142568 143496     if( pRhs && pRhs->pPrior ){
142569 143497       SrcList *pFrom;
142570 143498       Token x;
142571 143499       x.n = 0;
142572 143500       parserDoubleLinkSelect(pParse, pRhs);
142573 143501       pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
142574 143502       pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
142575 143503     }
142576 143504     if( pRhs ){
142577         -    pRhs->op = (u8)yymsp[-1].minor.yy4;
       143505  +    pRhs->op = (u8)yymsp[-1].minor.yy502;
142578 143506       pRhs->pPrior = pLhs;
142579 143507       if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
142580 143508       pRhs->selFlags &= ~SF_MultiValue;
142581         -    if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1;
       143509  +    if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
142582 143510     }else{
142583 143511       sqlite3SelectDelete(pParse->db, pLhs);
142584 143512     }
142585         -  yymsp[-2].minor.yy387 = pRhs;
       143513  +  yymsp[-2].minor.yy399 = pRhs;
142586 143514   }
142587 143515           break;
142588 143516         case 84: /* multiselect_op ::= UNION */
142589 143517         case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
142590         -{yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-OP*/}
       143518  +{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
142591 143519           break;
142592 143520         case 85: /* multiselect_op ::= UNION ALL */
142593         -{yymsp[-1].minor.yy4 = TK_ALL;}
       143521  +{yymsp[-1].minor.yy502 = TK_ALL;}
142594 143522           break;
142595 143523         case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
142596 143524   {
142597 143525   #if SELECTTRACE_ENABLED
142598 143526     Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/
142599 143527   #endif
142600         -  yymsp[-8].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy314);
       143528  +  yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
142601 143529   #if SELECTTRACE_ENABLED
142602 143530     /* Populate the Select.zSelName[] string that is used to help with
142603 143531     ** query planner debugging, to differentiate between multiple Select
142604 143532     ** objects in a complex query.
142605 143533     **
142606 143534     ** If the SELECT keyword is immediately followed by a C-style comment
142607 143535     ** then extract the first few alphanumeric characters from within that
142608 143536     ** comment to be the zSelName value.  Otherwise, the label is #N where
142609 143537     ** is an integer that is incremented with each SELECT statement seen.
142610 143538     */
142611         -  if( yymsp[-8].minor.yy387!=0 ){
       143539  +  if( yymsp[-8].minor.yy399!=0 ){
142612 143540       const char *z = s.z+6;
142613 143541       int i;
142614         -    sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName,"#%d",++pParse->nSelect);
       143542  +    sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect);
142615 143543       while( z[0]==' ' ) z++;
142616 143544       if( z[0]=='/' && z[1]=='*' ){
142617 143545         z += 2;
142618 143546         while( z[0]==' ' ) z++;
142619 143547         for(i=0; sqlite3Isalnum(z[i]); i++){}
142620         -      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy387->zSelName), yymsp[-8].minor.yy387->zSelName, "%.*s", i, z);
       143548  +      sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName, "%.*s", i, z);
142621 143549       }
142622 143550     }
142623 143551   #endif /* SELECTRACE_ENABLED */
142624 143552   }
142625 143553           break;
142626 143554         case 88: /* values ::= VALUES LP nexprlist RP */
142627 143555   {
142628         -  yymsp[-3].minor.yy387 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
       143556  +  yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
142629 143557   }
142630 143558           break;
142631 143559         case 89: /* values ::= values COMMA LP exprlist RP */
142632 143560   {
142633         -  Select *pRight, *pLeft = yymsp[-4].minor.yy387;
142634         -  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values|SF_MultiValue,0);
       143561  +  Select *pRight, *pLeft = yymsp[-4].minor.yy399;
       143562  +  pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
142635 143563     if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
142636 143564     if( pRight ){
142637 143565       pRight->op = TK_ALL;
142638 143566       pRight->pPrior = pLeft;
142639         -    yymsp[-4].minor.yy387 = pRight;
       143567  +    yymsp[-4].minor.yy399 = pRight;
142640 143568     }else{
142641         -    yymsp[-4].minor.yy387 = pLeft;
       143569  +    yymsp[-4].minor.yy399 = pLeft;
142642 143570     }
142643 143571   }
142644 143572           break;
142645 143573         case 90: /* distinct ::= DISTINCT */
142646         -{yymsp[0].minor.yy4 = SF_Distinct;}
       143574  +{yymsp[0].minor.yy502 = SF_Distinct;}
142647 143575           break;
142648 143576         case 91: /* distinct ::= ALL */
142649         -{yymsp[0].minor.yy4 = SF_All;}
       143577  +{yymsp[0].minor.yy502 = SF_All;}
142650 143578           break;
142651 143579         case 93: /* sclp ::= */
142652         -      case 122: /* orderby_opt ::= */ yytestcase(yyruleno==122);
142653         -      case 129: /* groupby_opt ::= */ yytestcase(yyruleno==129);
142654         -      case 204: /* exprlist ::= */ yytestcase(yyruleno==204);
142655         -      case 207: /* paren_exprlist ::= */ yytestcase(yyruleno==207);
142656         -      case 212: /* eidlist_opt ::= */ yytestcase(yyruleno==212);
142657         -{yymsp[1].minor.yy322 = 0;}
       143580  +      case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
       143581  +      case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
       143582  +      case 212: /* exprlist ::= */ yytestcase(yyruleno==212);
       143583  +      case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215);
       143584  +      case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220);
       143585  +{yymsp[1].minor.yy232 = 0;}
142658 143586           break;
142659 143587         case 94: /* selcollist ::= sclp scanpt expr scanpt as */
142660 143588   {
142661         -   yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
142662         -   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
142663         -   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy336,yymsp[-1].minor.yy336);
       143589  +   yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
       143590  +   if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
       143591  +   sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
142664 143592   }
142665 143593           break;
142666 143594         case 95: /* selcollist ::= sclp scanpt STAR */
142667 143595   {
142668 143596     Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
142669         -  yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
       143597  +  yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
142670 143598   }
142671 143599           break;
142672 143600         case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
142673 143601   {
142674 143602     Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
142675 143603     Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
142676 143604     Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
142677         -  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
       143605  +  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
142678 143606   }
142679 143607           break;
142680 143608         case 97: /* as ::= AS nm */
142681 143609         case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
142682         -      case 226: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==226);
142683         -      case 227: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==227);
       143610  +      case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
       143611  +      case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235);
142684 143612   {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
142685 143613           break;
142686 143614         case 99: /* from ::= */
142687         -{yymsp[1].minor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy259));}
       143615  +{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
142688 143616           break;
142689 143617         case 100: /* from ::= FROM seltablist */
142690 143618   {
142691         -  yymsp[-1].minor.yy259 = yymsp[0].minor.yy259;
142692         -  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy259);
       143619  +  yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
       143620  +  sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
142693 143621   }
142694 143622           break;
142695 143623         case 101: /* stl_prefix ::= seltablist joinop */
142696 143624   {
142697         -   if( ALWAYS(yymsp[-1].minor.yy259 && yymsp[-1].minor.yy259->nSrc>0) ) yymsp[-1].minor.yy259->a[yymsp[-1].minor.yy259->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy4;
       143625  +   if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
142698 143626   }
142699 143627           break;
142700 143628         case 102: /* stl_prefix ::= */
142701         -{yymsp[1].minor.yy259 = 0;}
       143629  +{yymsp[1].minor.yy427 = 0;}
142702 143630           break;
142703 143631         case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
142704 143632   {
142705         -  yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
142706         -  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy259, &yymsp[-2].minor.yy0);
       143633  +  yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
       143634  +  sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0);
142707 143635   }
142708 143636           break;
142709 143637         case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
142710 143638   {
142711         -  yymsp[-8].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy259,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
142712         -  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy259, yymsp[-4].minor.yy322);
       143639  +  yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
       143640  +  sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
142713 143641   }
142714 143642           break;
142715 143643         case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
142716 143644   {
142717         -    yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
       143645  +    yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
142718 143646     }
142719 143647           break;
142720 143648         case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
142721 143649   {
142722         -    if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){
142723         -      yymsp[-6].minor.yy259 = yymsp[-4].minor.yy259;
142724         -    }else if( yymsp[-4].minor.yy259->nSrc==1 ){
142725         -      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
142726         -      if( yymsp[-6].minor.yy259 ){
142727         -        struct SrcList_item *pNew = &yymsp[-6].minor.yy259->a[yymsp[-6].minor.yy259->nSrc-1];
142728         -        struct SrcList_item *pOld = yymsp[-4].minor.yy259->a;
       143650  +    if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
       143651  +      yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
       143652  +    }else if( yymsp[-4].minor.yy427->nSrc==1 ){
       143653  +      yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
       143654  +      if( yymsp[-6].minor.yy427 ){
       143655  +        struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
       143656  +        struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
142729 143657           pNew->zName = pOld->zName;
142730 143658           pNew->zDatabase = pOld->zDatabase;
142731 143659           pNew->pSelect = pOld->pSelect;
142732 143660           pOld->zName = pOld->zDatabase = 0;
142733 143661           pOld->pSelect = 0;
142734 143662         }
142735         -      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy259);
       143663  +      sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
142736 143664       }else{
142737 143665         Select *pSubquery;
142738         -      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259);
142739         -      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,SF_NestedFrom,0);
142740         -      yymsp[-6].minor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384);
       143666  +      sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
       143667  +      pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
       143668  +      yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
142741 143669       }
142742 143670     }
142743 143671           break;
142744 143672         case 107: /* dbnm ::= */
142745         -      case 117: /* indexed_opt ::= */ yytestcase(yyruleno==117);
       143673  +      case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
142746 143674   {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
142747 143675           break;
142748 143676         case 109: /* fullname ::= nm */
142749         -{yymsp[0].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
       143677  +      case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111);
       143678  +{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
142750 143679           break;
142751 143680         case 110: /* fullname ::= nm DOT nm */
142752         -{yymsp[-2].minor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
142753         -        break;
142754         -      case 111: /* joinop ::= COMMA|JOIN */
142755         -{ yymsp[0].minor.yy4 = JT_INNER; }
142756         -        break;
142757         -      case 112: /* joinop ::= JOIN_KW JOIN */
142758         -{yymsp[-1].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
142759         -        break;
142760         -      case 113: /* joinop ::= JOIN_KW nm JOIN */
142761         -{yymsp[-2].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
142762         -        break;
142763         -      case 114: /* joinop ::= JOIN_KW nm nm JOIN */
142764         -{yymsp[-3].minor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
142765         -        break;
142766         -      case 115: /* on_opt ::= ON expr */
142767         -      case 132: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==132);
142768         -      case 139: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==139);
142769         -      case 200: /* case_else ::= ELSE expr */ yytestcase(yyruleno==200);
142770         -{yymsp[-1].minor.yy314 = yymsp[0].minor.yy314;}
142771         -        break;
142772         -      case 116: /* on_opt ::= */
142773         -      case 131: /* having_opt ::= */ yytestcase(yyruleno==131);
142774         -      case 133: /* limit_opt ::= */ yytestcase(yyruleno==133);
142775         -      case 138: /* where_opt ::= */ yytestcase(yyruleno==138);
142776         -      case 201: /* case_else ::= */ yytestcase(yyruleno==201);
142777         -      case 203: /* case_operand ::= */ yytestcase(yyruleno==203);
142778         -{yymsp[1].minor.yy314 = 0;}
142779         -        break;
142780         -      case 118: /* indexed_opt ::= INDEXED BY nm */
       143681  +      case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112);
       143682  +{yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
       143683  +        break;
       143684  +      case 113: /* xfullname ::= nm DOT nm AS nm */
       143685  +{
       143686  +   yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
       143687  +   if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
       143688  +}
       143689  +        break;
       143690  +      case 114: /* xfullname ::= nm AS nm */
       143691  +{  
       143692  +   yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
       143693  +   if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
       143694  +}
       143695  +        break;
       143696  +      case 115: /* joinop ::= COMMA|JOIN */
       143697  +{ yymsp[0].minor.yy502 = JT_INNER; }
       143698  +        break;
       143699  +      case 116: /* joinop ::= JOIN_KW JOIN */
       143700  +{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0);  /*X-overwrites-A*/}
       143701  +        break;
       143702  +      case 117: /* joinop ::= JOIN_KW nm JOIN */
       143703  +{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
       143704  +        break;
       143705  +      case 118: /* joinop ::= JOIN_KW nm nm JOIN */
       143706  +{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
       143707  +        break;
       143708  +      case 119: /* on_opt ::= ON expr */
       143709  +      case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
       143710  +      case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
       143711  +      case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208);
       143712  +{yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
       143713  +        break;
       143714  +      case 120: /* on_opt ::= */
       143715  +      case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
       143716  +      case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
       143717  +      case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
       143718  +      case 209: /* case_else ::= */ yytestcase(yyruleno==209);
       143719  +      case 211: /* case_operand ::= */ yytestcase(yyruleno==211);
       143720  +{yymsp[1].minor.yy182 = 0;}
       143721  +        break;
       143722  +      case 122: /* indexed_opt ::= INDEXED BY nm */
142781 143723   {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
142782 143724           break;
142783         -      case 119: /* indexed_opt ::= NOT INDEXED */
       143725  +      case 123: /* indexed_opt ::= NOT INDEXED */
142784 143726   {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
142785 143727           break;
142786         -      case 120: /* using_opt ::= USING LP idlist RP */
142787         -{yymsp[-3].minor.yy384 = yymsp[-1].minor.yy384;}
142788         -        break;
142789         -      case 121: /* using_opt ::= */
142790         -      case 149: /* idlist_opt ::= */ yytestcase(yyruleno==149);
142791         -{yymsp[1].minor.yy384 = 0;}
142792         -        break;
142793         -      case 123: /* orderby_opt ::= ORDER BY sortlist */
142794         -      case 130: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==130);
142795         -{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
142796         -        break;
142797         -      case 124: /* sortlist ::= sortlist COMMA expr sortorder */
142798         -{
142799         -  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314);
142800         -  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy322,yymsp[0].minor.yy4);
142801         -}
142802         -        break;
142803         -      case 125: /* sortlist ::= expr sortorder */
142804         -{
142805         -  yymsp[-1].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); /*A-overwrites-Y*/
142806         -  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy322,yymsp[0].minor.yy4);
142807         -}
142808         -        break;
142809         -      case 126: /* sortorder ::= ASC */
142810         -{yymsp[0].minor.yy4 = SQLITE_SO_ASC;}
142811         -        break;
142812         -      case 127: /* sortorder ::= DESC */
142813         -{yymsp[0].minor.yy4 = SQLITE_SO_DESC;}
142814         -        break;
142815         -      case 128: /* sortorder ::= */
142816         -{yymsp[1].minor.yy4 = SQLITE_SO_UNDEFINED;}
142817         -        break;
142818         -      case 134: /* limit_opt ::= LIMIT expr */
142819         -{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,0);}
142820         -        break;
142821         -      case 135: /* limit_opt ::= LIMIT expr OFFSET expr */
142822         -{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
142823         -        break;
142824         -      case 136: /* limit_opt ::= LIMIT expr COMMA expr */
142825         -{yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy314,yymsp[-2].minor.yy314);}
142826         -        break;
142827         -      case 137: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */
142828         -{
142829         -  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0);
142830         -  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314,0,0);
142831         -}
142832         -        break;
142833         -      case 140: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */
142834         -{
142835         -  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0);
142836         -  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); 
142837         -  sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy4,0,0);
142838         -}
142839         -        break;
142840         -      case 141: /* setlist ::= setlist COMMA nm EQ expr */
142841         -{
142842         -  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
142843         -  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
142844         -}
142845         -        break;
142846         -      case 142: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
142847         -{
142848         -  yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
142849         -}
142850         -        break;
142851         -      case 143: /* setlist ::= nm EQ expr */
142852         -{
142853         -  yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy314);
142854         -  sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
142855         -}
142856         -  yymsp[-2].minor.yy322 = yylhsminor.yy322;
142857         -        break;
142858         -      case 144: /* setlist ::= LP idlist RP EQ expr */
142859         -{
142860         -  yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy384, yymsp[0].minor.yy314);
142861         -}
142862         -        break;
142863         -      case 145: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */
142864         -{
142865         -  sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy4);
142866         -}
142867         -        break;
142868         -      case 146: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */
142869         -{
142870         -  sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy4);
142871         -}
142872         -        break;
142873         -      case 150: /* idlist_opt ::= LP idlist RP */
142874         -{yymsp[-2].minor.yy384 = yymsp[-1].minor.yy384;}
142875         -        break;
142876         -      case 151: /* idlist ::= idlist COMMA nm */
142877         -{yymsp[-2].minor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);}
142878         -        break;
142879         -      case 152: /* idlist ::= nm */
142880         -{yymsp[0].minor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
142881         -        break;
142882         -      case 153: /* expr ::= LP expr RP */
142883         -{yymsp[-2].minor.yy314 = yymsp[-1].minor.yy314;}
142884         -        break;
142885         -      case 154: /* expr ::= ID|INDEXED */
142886         -      case 155: /* expr ::= JOIN_KW */ yytestcase(yyruleno==155);
142887         -{yymsp[0].minor.yy314=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
142888         -        break;
142889         -      case 156: /* expr ::= nm DOT nm */
       143728  +      case 124: /* using_opt ::= USING LP idlist RP */
       143729  +{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
       143730  +        break;
       143731  +      case 125: /* using_opt ::= */
       143732  +      case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
       143733  +{yymsp[1].minor.yy510 = 0;}
       143734  +        break;
       143735  +      case 127: /* orderby_opt ::= ORDER BY sortlist */
       143736  +      case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
       143737  +{yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
       143738  +        break;
       143739  +      case 128: /* sortlist ::= sortlist COMMA expr sortorder */
       143740  +{
       143741  +  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
       143742  +  sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
       143743  +}
       143744  +        break;
       143745  +      case 129: /* sortlist ::= expr sortorder */
       143746  +{
       143747  +  yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
       143748  +  sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
       143749  +}
       143750  +        break;
       143751  +      case 130: /* sortorder ::= ASC */
       143752  +{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
       143753  +        break;
       143754  +      case 131: /* sortorder ::= DESC */
       143755  +{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
       143756  +        break;
       143757  +      case 132: /* sortorder ::= */
       143758  +{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
       143759  +        break;
       143760  +      case 138: /* limit_opt ::= LIMIT expr */
       143761  +{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
       143762  +        break;
       143763  +      case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
       143764  +{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
       143765  +        break;
       143766  +      case 140: /* limit_opt ::= LIMIT expr COMMA expr */
       143767  +{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
       143768  +        break;
       143769  +      case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
       143770  +{
       143771  +  sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
       143772  +  sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
       143773  +}
       143774  +        break;
       143775  +      case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
       143776  +{
       143777  +  sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
       143778  +  sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list"); 
       143779  +  sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
       143780  +}
       143781  +        break;
       143782  +      case 145: /* setlist ::= setlist COMMA nm EQ expr */
       143783  +{
       143784  +  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
       143785  +  sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
       143786  +}
       143787  +        break;
       143788  +      case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
       143789  +{
       143790  +  yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
       143791  +}
       143792  +        break;
       143793  +      case 147: /* setlist ::= nm EQ expr */
       143794  +{
       143795  +  yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
       143796  +  sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
       143797  +}
       143798  +  yymsp[-2].minor.yy232 = yylhsminor.yy232;
       143799  +        break;
       143800  +      case 148: /* setlist ::= LP idlist RP EQ expr */
       143801  +{
       143802  +  yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
       143803  +}
       143804  +        break;
       143805  +      case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
       143806  +{
       143807  +  sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
       143808  +}
       143809  +        break;
       143810  +      case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
       143811  +{
       143812  +  sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
       143813  +}
       143814  +        break;
       143815  +      case 151: /* upsert ::= */
       143816  +{ yymsp[1].minor.yy198 = 0; }
       143817  +        break;
       143818  +      case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
       143819  +{ yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
       143820  +        break;
       143821  +      case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
       143822  +{ yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
       143823  +        break;
       143824  +      case 154: /* upsert ::= ON CONFLICT DO NOTHING */
       143825  +{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
       143826  +        break;
       143827  +      case 158: /* idlist_opt ::= LP idlist RP */
       143828  +{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
       143829  +        break;
       143830  +      case 159: /* idlist ::= idlist COMMA nm */
       143831  +{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
       143832  +        break;
       143833  +      case 160: /* idlist ::= nm */
       143834  +{yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
       143835  +        break;
       143836  +      case 161: /* expr ::= LP expr RP */
       143837  +{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
       143838  +        break;
       143839  +      case 162: /* expr ::= ID|INDEXED */
       143840  +      case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
       143841  +{yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
       143842  +        break;
       143843  +      case 164: /* expr ::= nm DOT nm */
142890 143844   {
142891 143845     Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
142892 143846     Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
142893         -  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
       143847  +  yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
142894 143848   }
142895         -  yymsp[-2].minor.yy314 = yylhsminor.yy314;
       143849  +  yymsp[-2].minor.yy182 = yylhsminor.yy182;
142896 143850           break;
142897         -      case 157: /* expr ::= nm DOT nm DOT nm */
       143851  +      case 165: /* expr ::= nm DOT nm DOT nm */
142898 143852   {
142899 143853     Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
142900 143854     Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
142901 143855     Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
142902 143856     Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
142903         -  yylhsminor.yy314 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
       143857  +  yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
142904 143858   }
142905         -  yymsp[-4].minor.yy314 = yylhsminor.yy314;
       143859  +  yymsp[-4].minor.yy182 = yylhsminor.yy182;
142906 143860           break;
142907         -      case 158: /* term ::= NULL|FLOAT|BLOB */
142908         -      case 159: /* term ::= STRING */ yytestcase(yyruleno==159);
142909         -{yymsp[0].minor.yy314=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
       143861  +      case 166: /* term ::= NULL|FLOAT|BLOB */
       143862  +      case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
       143863  +{yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
142910 143864           break;
142911         -      case 160: /* term ::= INTEGER */
       143865  +      case 168: /* term ::= INTEGER */
142912 143866   {
142913         -  yylhsminor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
       143867  +  yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
142914 143868   }
142915         -  yymsp[0].minor.yy314 = yylhsminor.yy314;
       143869  +  yymsp[0].minor.yy182 = yylhsminor.yy182;
142916 143870           break;
142917         -      case 161: /* expr ::= VARIABLE */
       143871  +      case 169: /* expr ::= VARIABLE */
142918 143872   {
142919 143873     if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
142920 143874       u32 n = yymsp[0].minor.yy0.n;
142921         -    yymsp[0].minor.yy314 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
142922         -    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy314, n);
       143875  +    yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
       143876  +    sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
142923 143877     }else{
142924 143878       /* When doing a nested parse, one can include terms in an expression
142925 143879       ** that look like this:   #1 #2 ...  These terms refer to registers
142926 143880       ** in the virtual machine.  #N is the N-th register. */
142927 143881       Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
142928 143882       assert( t.n>=2 );
142929 143883       if( pParse->nested==0 ){
142930 143884         sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
142931         -      yymsp[0].minor.yy314 = 0;
142932         -    }else{
142933         -      yymsp[0].minor.yy314 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
142934         -      if( yymsp[0].minor.yy314 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy314->iTable);
142935         -    }
142936         -  }
142937         -}
142938         -        break;
142939         -      case 162: /* expr ::= expr COLLATE ID|STRING */
142940         -{
142941         -  yymsp[-2].minor.yy314 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy314, &yymsp[0].minor.yy0, 1);
142942         -}
142943         -        break;
142944         -      case 163: /* expr ::= CAST LP expr AS typetoken RP */
142945         -{
142946         -  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
142947         -  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy314, yymsp[-3].minor.yy314, 0);
142948         -}
142949         -        break;
142950         -      case 164: /* expr ::= ID|INDEXED LP distinct exprlist RP */
142951         -{
142952         -  if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
       143885  +      yymsp[0].minor.yy182 = 0;
       143886  +    }else{
       143887  +      yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
       143888  +      if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
       143889  +    }
       143890  +  }
       143891  +}
       143892  +        break;
       143893  +      case 170: /* expr ::= expr COLLATE ID|STRING */
       143894  +{
       143895  +  yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
       143896  +}
       143897  +        break;
       143898  +      case 171: /* expr ::= CAST LP expr AS typetoken RP */
       143899  +{
       143900  +  yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
       143901  +  sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
       143902  +}
       143903  +        break;
       143904  +      case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
       143905  +{
       143906  +  if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
142953 143907       sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
142954 143908     }
142955         -  yylhsminor.yy314 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
142956         -  if( yymsp[-2].minor.yy4==SF_Distinct && yylhsminor.yy314 ){
142957         -    yylhsminor.yy314->flags |= EP_Distinct;
142958         -  }
142959         -}
142960         -  yymsp[-4].minor.yy314 = yylhsminor.yy314;
142961         -        break;
142962         -      case 165: /* expr ::= ID|INDEXED LP STAR RP */
142963         -{
142964         -  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
142965         -}
142966         -  yymsp[-3].minor.yy314 = yylhsminor.yy314;
142967         -        break;
142968         -      case 166: /* term ::= CTIME_KW */
142969         -{
142970         -  yylhsminor.yy314 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
142971         -}
142972         -  yymsp[0].minor.yy314 = yylhsminor.yy314;
142973         -        break;
142974         -      case 167: /* expr ::= LP nexprlist COMMA expr RP */
142975         -{
142976         -  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy314);
142977         -  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
142978         -  if( yymsp[-4].minor.yy314 ){
142979         -    yymsp[-4].minor.yy314->x.pList = pList;
       143909  +  yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0);
       143910  +  if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){
       143911  +    yylhsminor.yy182->flags |= EP_Distinct;
       143912  +  }
       143913  +}
       143914  +  yymsp[-4].minor.yy182 = yylhsminor.yy182;
       143915  +        break;
       143916  +      case 173: /* expr ::= ID|INDEXED LP STAR RP */
       143917  +{
       143918  +  yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
       143919  +}
       143920  +  yymsp[-3].minor.yy182 = yylhsminor.yy182;
       143921  +        break;
       143922  +      case 174: /* term ::= CTIME_KW */
       143923  +{
       143924  +  yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0);
       143925  +}
       143926  +  yymsp[0].minor.yy182 = yylhsminor.yy182;
       143927  +        break;
       143928  +      case 175: /* expr ::= LP nexprlist COMMA expr RP */
       143929  +{
       143930  +  ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
       143931  +  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
       143932  +  if( yymsp[-4].minor.yy182 ){
       143933  +    yymsp[-4].minor.yy182->x.pList = pList;
142980 143934     }else{
142981 143935       sqlite3ExprListDelete(pParse->db, pList);
142982 143936     }
142983 143937   }
142984 143938           break;
142985         -      case 168: /* expr ::= expr AND expr */
142986         -      case 169: /* expr ::= expr OR expr */ yytestcase(yyruleno==169);
142987         -      case 170: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==170);
142988         -      case 171: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==171);
142989         -      case 172: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==172);
142990         -      case 173: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==173);
142991         -      case 174: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==174);
142992         -      case 175: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==175);
142993         -{yymsp[-2].minor.yy314=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);}
       143939  +      case 176: /* expr ::= expr AND expr */
       143940  +      case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177);
       143941  +      case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178);
       143942  +      case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
       143943  +      case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
       143944  +      case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
       143945  +      case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
       143946  +      case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
       143947  +{yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
142994 143948           break;
142995         -      case 176: /* likeop ::= NOT LIKE_KW|MATCH */
       143949  +      case 184: /* likeop ::= NOT LIKE_KW|MATCH */
142996 143950   {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
142997 143951           break;
142998         -      case 177: /* expr ::= expr likeop expr */
       143952  +      case 185: /* expr ::= expr likeop expr */
142999 143953   {
143000 143954     ExprList *pList;
143001 143955     int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
143002 143956     yymsp[-1].minor.yy0.n &= 0x7fffffff;
143003         -  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy314);
143004         -  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy314);
143005         -  yymsp[-2].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
143006         -  if( bNot ) yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy314, 0);
143007         -  if( yymsp[-2].minor.yy314 ) yymsp[-2].minor.yy314->flags |= EP_InfixFunc;
       143957  +  pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
       143958  +  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
       143959  +  yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0);
       143960  +  if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
       143961  +  if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
143008 143962   }
143009 143963           break;
143010         -      case 178: /* expr ::= expr likeop expr ESCAPE expr */
       143964  +      case 186: /* expr ::= expr likeop expr ESCAPE expr */
143011 143965   {
143012 143966     ExprList *pList;
143013 143967     int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
143014 143968     yymsp[-3].minor.yy0.n &= 0x7fffffff;
143015         -  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
143016         -  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy314);
143017         -  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
143018         -  yymsp[-4].minor.yy314 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
143019         -  if( bNot ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
143020         -  if( yymsp[-4].minor.yy314 ) yymsp[-4].minor.yy314->flags |= EP_InfixFunc;
143021         -}
143022         -        break;
143023         -      case 179: /* expr ::= expr ISNULL|NOTNULL */
143024         -{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy314,0);}
143025         -        break;
143026         -      case 180: /* expr ::= expr NOT NULL */
143027         -{yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy314,0);}
143028         -        break;
143029         -      case 181: /* expr ::= expr IS expr */
143030         -{
143031         -  yymsp[-2].minor.yy314 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy314,yymsp[0].minor.yy314);
143032         -  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-2].minor.yy314, TK_ISNULL);
143033         -}
143034         -        break;
143035         -      case 182: /* expr ::= expr IS NOT expr */
143036         -{
143037         -  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy314,yymsp[0].minor.yy314);
143038         -  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy314, yymsp[-3].minor.yy314, TK_NOTNULL);
143039         -}
143040         -        break;
143041         -      case 183: /* expr ::= NOT expr */
143042         -      case 184: /* expr ::= BITNOT expr */ yytestcase(yyruleno==184);
143043         -{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy314, 0);/*A-overwrites-B*/}
143044         -        break;
143045         -      case 185: /* expr ::= MINUS expr */
143046         -{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy314, 0);}
143047         -        break;
143048         -      case 186: /* expr ::= PLUS expr */
143049         -{yymsp[-1].minor.yy314 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy314, 0);}
143050         -        break;
143051         -      case 187: /* between_op ::= BETWEEN */
143052         -      case 190: /* in_op ::= IN */ yytestcase(yyruleno==190);
143053         -{yymsp[0].minor.yy4 = 0;}
143054         -        break;
143055         -      case 189: /* expr ::= expr between_op expr AND expr */
143056         -{
143057         -  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
143058         -  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy314);
143059         -  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy314, 0);
143060         -  if( yymsp[-4].minor.yy314 ){
143061         -    yymsp[-4].minor.yy314->x.pList = pList;
       143969  +  pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
       143970  +  pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
       143971  +  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
       143972  +  yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0);
       143973  +  if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
       143974  +  if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
       143975  +}
       143976  +        break;
       143977  +      case 187: /* expr ::= expr ISNULL|NOTNULL */
       143978  +{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
       143979  +        break;
       143980  +      case 188: /* expr ::= expr NOT NULL */
       143981  +{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
       143982  +        break;
       143983  +      case 189: /* expr ::= expr IS expr */
       143984  +{
       143985  +  yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
       143986  +  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
       143987  +}
       143988  +        break;
       143989  +      case 190: /* expr ::= expr IS NOT expr */
       143990  +{
       143991  +  yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
       143992  +  binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL);
       143993  +}
       143994  +        break;
       143995  +      case 191: /* expr ::= NOT expr */
       143996  +      case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
       143997  +{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
       143998  +        break;
       143999  +      case 193: /* expr ::= MINUS expr */
       144000  +{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);}
       144001  +        break;
       144002  +      case 194: /* expr ::= PLUS expr */
       144003  +{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);}
       144004  +        break;
       144005  +      case 195: /* between_op ::= BETWEEN */
       144006  +      case 198: /* in_op ::= IN */ yytestcase(yyruleno==198);
       144007  +{yymsp[0].minor.yy502 = 0;}
       144008  +        break;
       144009  +      case 197: /* expr ::= expr between_op expr AND expr */
       144010  +{
       144011  +  ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
       144012  +  pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
       144013  +  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
       144014  +  if( yymsp[-4].minor.yy182 ){
       144015  +    yymsp[-4].minor.yy182->x.pList = pList;
143062 144016     }else{
143063 144017       sqlite3ExprListDelete(pParse->db, pList);
143064 144018     } 
143065         -  if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
       144019  +  if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
143066 144020   }
143067 144021           break;
143068         -      case 192: /* expr ::= expr in_op LP exprlist RP */
       144022  +      case 200: /* expr ::= expr in_op LP exprlist RP */
143069 144023   {
143070         -    if( yymsp[-1].minor.yy322==0 ){
       144024  +    if( yymsp[-1].minor.yy232==0 ){
143071 144025         /* Expressions of the form
143072 144026         **
143073 144027         **      expr1 IN ()
143074 144028         **      expr1 NOT IN ()
143075 144029         **
143076 144030         ** simplify to constants 0 (false) and 1 (true), respectively,
143077 144031         ** regardless of the value of expr1.
143078 144032         */
143079         -      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy314);
143080         -      yymsp[-4].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy4],1);
143081         -    }else if( yymsp[-1].minor.yy322->nExpr==1 ){
       144033  +      sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
       144034  +      yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
       144035  +    }else if( yymsp[-1].minor.yy232->nExpr==1 ){
143082 144036         /* Expressions of the form:
143083 144037         **
143084 144038         **      expr1 IN (?1)
143085 144039         **      expr1 NOT IN (?2)
143086 144040         **
143087 144041         ** with exactly one value on the RHS can be simplified to something
143088 144042         ** like this:
................................................................................
143091 144045         **      expr1 <> ?2
143092 144046         **
143093 144047         ** But, the RHS of the == or <> is marked with the EP_Generic flag
143094 144048         ** so that it may not contribute to the computation of comparison
143095 144049         ** affinity or the collating sequence to use for comparison.  Otherwise,
143096 144050         ** the semantics would be subtly different from IN or NOT IN.
143097 144051         */
143098         -      Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
143099         -      yymsp[-1].minor.yy322->a[0].pExpr = 0;
143100         -      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
       144052  +      Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
       144053  +      yymsp[-1].minor.yy232->a[0].pExpr = 0;
       144054  +      sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
143101 144055         /* pRHS cannot be NULL because a malloc error would have been detected
143102 144056         ** before now and control would have never reached this point */
143103 144057         if( ALWAYS(pRHS) ){
143104 144058           pRHS->flags &= ~EP_Collate;
143105 144059           pRHS->flags |= EP_Generic;
143106 144060         }
143107         -      yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, yymsp[-3].minor.yy4 ? TK_NE : TK_EQ, yymsp[-4].minor.yy314, pRHS);
143108         -    }else{
143109         -      yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
143110         -      if( yymsp[-4].minor.yy314 ){
143111         -        yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy322;
143112         -        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
143113         -      }else{
143114         -        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
143115         -      }
143116         -      if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
143117         -    }
143118         -  }
143119         -        break;
143120         -      case 193: /* expr ::= LP select RP */
143121         -{
143122         -    yymsp[-2].minor.yy314 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
143123         -    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy314, yymsp[-1].minor.yy387);
143124         -  }
143125         -        break;
143126         -      case 194: /* expr ::= expr in_op LP select RP */
143127         -{
143128         -    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
143129         -    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, yymsp[-1].minor.yy387);
143130         -    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
143131         -  }
143132         -        break;
143133         -      case 195: /* expr ::= expr in_op nm dbnm paren_exprlist */
       144061  +      yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
       144062  +    }else{
       144063  +      yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
       144064  +      if( yymsp[-4].minor.yy182 ){
       144065  +        yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
       144066  +        sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
       144067  +      }else{
       144068  +        sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
       144069  +      }
       144070  +      if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
       144071  +    }
       144072  +  }
       144073  +        break;
       144074  +      case 201: /* expr ::= LP select RP */
       144075  +{
       144076  +    yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
       144077  +    sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
       144078  +  }
       144079  +        break;
       144080  +      case 202: /* expr ::= expr in_op LP select RP */
       144081  +{
       144082  +    yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
       144083  +    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
       144084  +    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
       144085  +  }
       144086  +        break;
       144087  +      case 203: /* expr ::= expr in_op nm dbnm paren_exprlist */
143134 144088   {
143135 144089       SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
143136 144090       Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
143137         -    if( yymsp[0].minor.yy322 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
143138         -    yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy314, 0);
143139         -    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy314, pSelect);
143140         -    if( yymsp[-3].minor.yy4 ) yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy314, 0);
       144091  +    if( yymsp[0].minor.yy232 )  sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
       144092  +    yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
       144093  +    sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
       144094  +    if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
143141 144095     }
143142 144096           break;
143143         -      case 196: /* expr ::= EXISTS LP select RP */
       144097  +      case 204: /* expr ::= EXISTS LP select RP */
143144 144098   {
143145 144099       Expr *p;
143146         -    p = yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
143147         -    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy387);
143148         -  }
143149         -        break;
143150         -      case 197: /* expr ::= CASE case_operand case_exprlist case_else END */
143151         -{
143152         -  yymsp[-4].minor.yy314 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, 0);
143153         -  if( yymsp[-4].minor.yy314 ){
143154         -    yymsp[-4].minor.yy314->x.pList = yymsp[-1].minor.yy314 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy314) : yymsp[-2].minor.yy322;
143155         -    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy314);
143156         -  }else{
143157         -    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
143158         -    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314);
143159         -  }
143160         -}
143161         -        break;
143162         -      case 198: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
143163         -{
143164         -  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy314);
143165         -  yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy314);
143166         -}
143167         -        break;
143168         -      case 199: /* case_exprlist ::= WHEN expr THEN expr */
143169         -{
143170         -  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy314);
143171         -  yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy314);
143172         -}
143173         -        break;
143174         -      case 202: /* case_operand ::= expr */
143175         -{yymsp[0].minor.yy314 = yymsp[0].minor.yy314; /*A-overwrites-X*/}
143176         -        break;
143177         -      case 205: /* nexprlist ::= nexprlist COMMA expr */
143178         -{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy314);}
143179         -        break;
143180         -      case 206: /* nexprlist ::= expr */
143181         -{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy314); /*A-overwrites-Y*/}
143182         -        break;
143183         -      case 208: /* paren_exprlist ::= LP exprlist RP */
143184         -      case 213: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==213);
143185         -{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
143186         -        break;
143187         -      case 209: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
       144100  +    p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
       144101  +    sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
       144102  +  }
       144103  +        break;
       144104  +      case 205: /* expr ::= CASE case_operand case_exprlist case_else END */
       144105  +{
       144106  +  yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
       144107  +  if( yymsp[-4].minor.yy182 ){
       144108  +    yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
       144109  +    sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
       144110  +  }else{
       144111  +    sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
       144112  +    sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
       144113  +  }
       144114  +}
       144115  +        break;
       144116  +      case 206: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
       144117  +{
       144118  +  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
       144119  +  yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
       144120  +}
       144121  +        break;
       144122  +      case 207: /* case_exprlist ::= WHEN expr THEN expr */
       144123  +{
       144124  +  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
       144125  +  yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
       144126  +}
       144127  +        break;
       144128  +      case 210: /* case_operand ::= expr */
       144129  +{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
       144130  +        break;
       144131  +      case 213: /* nexprlist ::= nexprlist COMMA expr */
       144132  +{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
       144133  +        break;
       144134  +      case 214: /* nexprlist ::= expr */
       144135  +{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
       144136  +        break;
       144137  +      case 216: /* paren_exprlist ::= LP exprlist RP */
       144138  +      case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221);
       144139  +{yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
       144140  +        break;
       144141  +      case 217: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
143188 144142   {
143189 144143     sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, 
143190         -                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy4,
143191         -                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy314, SQLITE_SO_ASC, yymsp[-8].minor.yy4, SQLITE_IDXTYPE_APPDEF);
143192         -}
143193         -        break;
143194         -      case 210: /* uniqueflag ::= UNIQUE */
143195         -      case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
143196         -{yymsp[0].minor.yy4 = OE_Abort;}
143197         -        break;
143198         -      case 211: /* uniqueflag ::= */
143199         -{yymsp[1].minor.yy4 = OE_None;}
143200         -        break;
143201         -      case 214: /* eidlist ::= eidlist COMMA nm collate sortorder */
143202         -{
143203         -  yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4);
143204         -}
143205         -        break;
143206         -      case 215: /* eidlist ::= nm collate sortorder */
143207         -{
143208         -  yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy4, yymsp[0].minor.yy4); /*A-overwrites-Y*/
143209         -}
143210         -        break;
143211         -      case 218: /* cmd ::= DROP INDEX ifexists fullname */
143212         -{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);}
143213         -        break;
143214         -      case 219: /* cmd ::= VACUUM */
       144144  +                     sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
       144145  +                      &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
       144146  +}
       144147  +        break;
       144148  +      case 218: /* uniqueflag ::= UNIQUE */
       144149  +      case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258);
       144150  +{yymsp[0].minor.yy502 = OE_Abort;}
       144151  +        break;
       144152  +      case 219: /* uniqueflag ::= */
       144153  +{yymsp[1].minor.yy502 = OE_None;}
       144154  +        break;
       144155  +      case 222: /* eidlist ::= eidlist COMMA nm collate sortorder */
       144156  +{
       144157  +  yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
       144158  +}
       144159  +        break;
       144160  +      case 223: /* eidlist ::= nm collate sortorder */
       144161  +{
       144162  +  yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
       144163  +}
       144164  +        break;
       144165  +      case 226: /* cmd ::= DROP INDEX ifexists fullname */
       144166  +{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
       144167  +        break;
       144168  +      case 227: /* cmd ::= VACUUM */
143215 144169   {sqlite3Vacuum(pParse,0);}
143216 144170           break;
143217         -      case 220: /* cmd ::= VACUUM nm */
       144171  +      case 228: /* cmd ::= VACUUM nm */
143218 144172   {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
143219 144173           break;
143220         -      case 221: /* cmd ::= PRAGMA nm dbnm */
       144174  +      case 229: /* cmd ::= PRAGMA nm dbnm */
143221 144175   {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
143222 144176           break;
143223         -      case 222: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
       144177  +      case 230: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
143224 144178   {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
143225 144179           break;
143226         -      case 223: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
       144180  +      case 231: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
143227 144181   {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
143228 144182           break;
143229         -      case 224: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
       144183  +      case 232: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
143230 144184   {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
143231 144185           break;
143232         -      case 225: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
       144186  +      case 233: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
143233 144187   {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
143234 144188           break;
143235         -      case 228: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
       144189  +      case 236: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
143236 144190   {
143237 144191     Token all;
143238 144192     all.z = yymsp[-3].minor.yy0.z;
143239 144193     all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
143240         -  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all);
       144194  +  sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
143241 144195   }
143242 144196           break;
143243         -      case 229: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
       144197  +      case 237: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
143244 144198   {
143245         -  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4);
       144199  +  sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
143246 144200     yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
143247 144201   }
143248 144202           break;
143249         -      case 230: /* trigger_time ::= BEFORE|AFTER */
143250         -{ yymsp[0].minor.yy4 = yymsp[0].major; /*A-overwrites-X*/ }
143251         -        break;
143252         -      case 231: /* trigger_time ::= INSTEAD OF */
143253         -{ yymsp[-1].minor.yy4 = TK_INSTEAD;}
143254         -        break;
143255         -      case 232: /* trigger_time ::= */
143256         -{ yymsp[1].minor.yy4 = TK_BEFORE; }
143257         -        break;
143258         -      case 233: /* trigger_event ::= DELETE|INSERT */
143259         -      case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234);
143260         -{yymsp[0].minor.yy90.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy90.b = 0;}
143261         -        break;
143262         -      case 235: /* trigger_event ::= UPDATE OF idlist */
143263         -{yymsp[-2].minor.yy90.a = TK_UPDATE; yymsp[-2].minor.yy90.b = yymsp[0].minor.yy384;}
143264         -        break;
143265         -      case 236: /* when_clause ::= */
143266         -      case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
143267         -{ yymsp[1].minor.yy314 = 0; }
143268         -        break;
143269         -      case 237: /* when_clause ::= WHEN expr */
143270         -      case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256);
143271         -{ yymsp[-1].minor.yy314 = yymsp[0].minor.yy314; }
143272         -        break;
143273         -      case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
143274         -{
143275         -  assert( yymsp[-2].minor.yy203!=0 );
143276         -  yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203;
143277         -  yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203;
143278         -}
143279         -        break;
143280         -      case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
       144203  +      case 238: /* trigger_time ::= BEFORE|AFTER */
       144204  +{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
       144205  +        break;
       144206  +      case 239: /* trigger_time ::= INSTEAD OF */
       144207  +{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
       144208  +        break;
       144209  +      case 240: /* trigger_time ::= */
       144210  +{ yymsp[1].minor.yy502 = TK_BEFORE; }
       144211  +        break;
       144212  +      case 241: /* trigger_event ::= DELETE|INSERT */
       144213  +      case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242);
       144214  +{yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;}
       144215  +        break;
       144216  +      case 243: /* trigger_event ::= UPDATE OF idlist */
       144217  +{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
       144218  +        break;
       144219  +      case 244: /* when_clause ::= */
       144220  +      case 263: /* key_opt ::= */ yytestcase(yyruleno==263);
       144221  +{ yymsp[1].minor.yy182 = 0; }
       144222  +        break;
       144223  +      case 245: /* when_clause ::= WHEN expr */
       144224  +      case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264);
       144225  +{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
       144226  +        break;
       144227  +      case 246: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
       144228  +{
       144229  +  assert( yymsp[-2].minor.yy47!=0 );
       144230  +  yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
       144231  +  yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
       144232  +}
       144233  +        break;
       144234  +      case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */
143281 144235   { 
143282         -  assert( yymsp[-1].minor.yy203!=0 );
143283         -  yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203;
       144236  +  assert( yymsp[-1].minor.yy47!=0 );
       144237  +  yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
143284 144238   }
143285 144239           break;
143286         -      case 240: /* trnm ::= nm DOT nm */
       144240  +      case 248: /* trnm ::= nm DOT nm */
143287 144241   {
143288 144242     yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
143289 144243     sqlite3ErrorMsg(pParse, 
143290 144244           "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
143291 144245           "statements within triggers");
143292 144246   }
143293 144247           break;
143294         -      case 241: /* tridxby ::= INDEXED BY nm */
       144248  +      case 249: /* tridxby ::= INDEXED BY nm */
143295 144249   {
143296 144250     sqlite3ErrorMsg(pParse,
143297 144251           "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
143298 144252           "within triggers");
143299 144253   }
143300 144254           break;
143301         -      case 242: /* tridxby ::= NOT INDEXED */
       144255  +      case 250: /* tridxby ::= NOT INDEXED */
143302 144256   {
143303 144257     sqlite3ErrorMsg(pParse,
143304 144258           "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
143305 144259           "within triggers");
143306 144260   }
143307 144261           break;
143308         -      case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
143309         -{yylhsminor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy314, yymsp[-6].minor.yy4, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy336);}
143310         -  yymsp[-7].minor.yy203 = yylhsminor.yy203;
143311         -        break;
143312         -      case 244: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select scanpt */
143313         -{yylhsminor.yy203 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-3].minor.yy0,yymsp[-2].minor.yy384,yymsp[-1].minor.yy387,yymsp[-5].minor.yy4,yymsp[-6].minor.yy336,yymsp[0].minor.yy336);/*yylhsminor.yy203-overwrites-yymsp[-5].minor.yy4*/}
143314         -  yymsp[-6].minor.yy203 = yylhsminor.yy203;
143315         -        break;
143316         -      case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
143317         -{yylhsminor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy314, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy336);}
143318         -  yymsp[-5].minor.yy203 = yylhsminor.yy203;
143319         -        break;
143320         -      case 246: /* trigger_cmd ::= scanpt select scanpt */
143321         -{yylhsminor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy387, yymsp[-2].minor.yy336, yymsp[0].minor.yy336); /*yylhsminor.yy203-overwrites-yymsp[-1].minor.yy387*/}
143322         -  yymsp[-2].minor.yy203 = yylhsminor.yy203;
143323         -        break;
143324         -      case 247: /* expr ::= RAISE LP IGNORE RP */
143325         -{
143326         -  yymsp[-3].minor.yy314 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); 
143327         -  if( yymsp[-3].minor.yy314 ){
143328         -    yymsp[-3].minor.yy314->affinity = OE_Ignore;
143329         -  }
143330         -}
143331         -        break;
143332         -      case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
143333         -{
143334         -  yymsp[-5].minor.yy314 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); 
143335         -  if( yymsp[-5].minor.yy314 ) {
143336         -    yymsp[-5].minor.yy314->affinity = (char)yymsp[-3].minor.yy4;
143337         -  }
143338         -}
143339         -        break;
143340         -      case 249: /* raisetype ::= ROLLBACK */
143341         -{yymsp[0].minor.yy4 = OE_Rollback;}
143342         -        break;
143343         -      case 251: /* raisetype ::= FAIL */
143344         -{yymsp[0].minor.yy4 = OE_Fail;}
143345         -        break;
143346         -      case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
143347         -{
143348         -  sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4);
143349         -}
143350         -        break;
143351         -      case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
143352         -{
143353         -  sqlite3Attach(pParse, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, yymsp[0].minor.yy314);
143354         -}
143355         -        break;
143356         -      case 254: /* cmd ::= DETACH database_kw_opt expr */
143357         -{
143358         -  sqlite3Detach(pParse, yymsp[0].minor.yy314);
143359         -}
143360         -        break;
143361         -      case 257: /* cmd ::= REINDEX */
       144262  +      case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
       144263  +{yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
       144264  +  yymsp[-7].minor.yy47 = yylhsminor.yy47;
       144265  +        break;
       144266  +      case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
       144267  +{
       144268  +   yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
       144269  +}
       144270  +  yymsp[-7].minor.yy47 = yylhsminor.yy47;
       144271  +        break;
       144272  +      case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
       144273  +{yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
       144274  +  yymsp[-5].minor.yy47 = yylhsminor.yy47;
       144275  +        break;
       144276  +      case 254: /* trigger_cmd ::= scanpt select scanpt */
       144277  +{yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yy