Fossil SCM

Update the built-in SQLite to the latest 3.28.0 alpha version.

drh 2019-04-03 18:33 trunk
Commit 41974e0881d69af99fc9b5dd9892039bfdc092bf0128135169b6d608f69550b0
3 files changed +90 -43 +4152 -3451 +26 -3
+90 -43
--- src/shell.c
+++ src/shell.c
@@ -2181,11 +2181,11 @@
21812181
if( pBuf==0 ){
21822182
sqlite3_result_error_nomem(ctx);
21832183
fclose(in);
21842184
return;
21852185
}
2186
- if( nIn==fread(pBuf, 1, nIn, in) ){
2186
+ if( nIn==(sqlite3_int64)fread(pBuf, 1, (size_t)nIn, in) ){
21872187
sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
21882188
}else{
21892189
sqlite3_result_error_code(ctx, SQLITE_IOERR);
21902190
sqlite3_free(pBuf);
21912191
}
@@ -2316,19 +2316,19 @@
23162316
23172317
/*
23182318
** Argument zFile is the name of a file that will be created and/or written
23192319
** by SQL function writefile(). This function ensures that the directory
23202320
** zFile will be written to exists, creating it if required. The permissions
2321
-** for any path components created by this function are set to (mode&0777).
2321
+** for any path components created by this function are set in accordance
2322
+** with the current umask.
23222323
**
23232324
** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise,
23242325
** SQLITE_OK is returned if the directory is successfully created, or
23252326
** SQLITE_ERROR otherwise.
23262327
*/
23272328
static int makeDirectory(
2328
- const char *zFile,
2329
- mode_t mode
2329
+ const char *zFile
23302330
){
23312331
char *zCopy = sqlite3_mprintf("%s", zFile);
23322332
int rc = SQLITE_OK;
23332333
23342334
if( zCopy==0 ){
@@ -2345,11 +2345,11 @@
23452345
if( i==nCopy ) break;
23462346
zCopy[i] = '\0';
23472347
23482348
rc2 = fileStat(zCopy, &sStat);
23492349
if( rc2!=0 ){
2350
- if( mkdir(zCopy, mode & 0777) ) rc = SQLITE_ERROR;
2350
+ if( mkdir(zCopy, 0777) ) rc = SQLITE_ERROR;
23512351
}else{
23522352
if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR;
23532353
}
23542354
zCopy[i] = '/';
23552355
i++;
@@ -2503,11 +2503,11 @@
25032503
mtime = sqlite3_value_int64(argv[3]);
25042504
}
25052505
25062506
res = writeFile(context, zFile, argv[1], mode, mtime);
25072507
if( res==1 && errno==ENOENT ){
2508
- if( makeDirectory(zFile, mode)==SQLITE_OK ){
2508
+ if( makeDirectory(zFile)==SQLITE_OK ){
25092509
res = writeFile(context, zFile, argv[1], mode, mtime);
25102510
}
25112511
}
25122512
25132513
if( argc>2 && res!=0 ){
@@ -10428,29 +10428,30 @@
1042810428
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
1042910429
sqlite3WhereTrace = savedWhereTrace;
1043010430
#endif
1043110431
}
1043210432
10433
-/* Name of the TEMP table that holds bind parameter values */
10434
-#define BIND_PARAM_TABLE "$Parameters"
10435
-
1043610433
/* Create the TEMP table used to store parameter bindings */
1043710434
static void bind_table_init(ShellState *p){
10435
+ int wrSchema = 0;
10436
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema);
10437
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
1043810438
sqlite3_exec(p->db,
10439
- "CREATE TABLE IF NOT EXISTS temp.[" BIND_PARAM_TABLE "](\n"
10439
+ "CREATE TABLE IF NOT EXISTS temp.sqlite_parameters(\n"
1044010440
" key TEXT PRIMARY KEY,\n"
1044110441
" value ANY\n"
1044210442
") WITHOUT ROWID;",
1044310443
0, 0, 0);
10444
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0);
1044410445
}
1044510446
1044610447
/*
1044710448
** Bind parameters on a prepared statement.
1044810449
**
1044910450
** Parameter bindings are taken from a TEMP table of the form:
1045010451
**
10451
-** CREATE TEMP TABLE "$Parameters"(key TEXT PRIMARY KEY, value)
10452
+** CREATE TEMP TABLE sqlite_parameters(key TEXT PRIMARY KEY, value)
1045210453
** WITHOUT ROWID;
1045310454
**
1045410455
** No bindings occur if this table does not exist. The special character '$'
1045510456
** is included in the table name to help prevent collisions with actual tables.
1045610457
** The table must be in the TEMP schema.
@@ -10461,16 +10462,16 @@
1046110462
int rc;
1046210463
sqlite3_stmt *pQ = 0;
1046310464
1046410465
nVar = sqlite3_bind_parameter_count(pStmt);
1046510466
if( nVar==0 ) return; /* Nothing to do */
10466
- if( sqlite3_table_column_metadata(pArg->db, "TEMP", BIND_PARAM_TABLE,
10467
+ if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters",
1046710468
"key", 0, 0, 0, 0, 0)!=SQLITE_OK ){
1046810469
return; /* Parameter table does not exist */
1046910470
}
1047010471
rc = sqlite3_prepare_v2(pArg->db,
10471
- "SELECT value FROM temp.\"" BIND_PARAM_TABLE "\""
10472
+ "SELECT value FROM temp.sqlite_parameters"
1047210473
" WHERE key=?1", -1, &pQ, 0);
1047310474
if( rc || pQ==0 ) return;
1047410475
for(i=1; i<=nVar; i++){
1047510476
char zNum[30];
1047610477
const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
@@ -11133,11 +11134,12 @@
1113311134
static const char *(azHelp[]) = {
1113411135
#if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
1113511136
".archive ... Manage SQL archives",
1113611137
" Each command must have exactly one of the following options:",
1113711138
" -c, --create Create a new archive",
11138
- " -u, --update Update or add files to an existing archive",
11139
+ " -u, --update Add files or update files with changed mtime",
11140
+ " -i, --insert Like -u but always add even if mtime unchanged",
1113911141
" -t, --list List contents of archive",
1114011142
" -x, --extract Extract files from archive",
1114111143
" Optional arguments:",
1114211144
" -v, --verbose Print each filename as it is processed",
1114311145
" -f FILE, --file FILE Operate on archive FILE (default is current db)",
@@ -12454,20 +12456,31 @@
1245412456
{ "number of views:",
1245512457
"SELECT count(*) FROM %s WHERE type='view'" },
1245612458
{ "schema size:",
1245712459
"SELECT total(length(sql)) FROM %s" },
1245812460
};
12459
- int i;
12461
+ int i, rc;
1246012462
unsigned iDataVersion;
1246112463
char *zSchemaTab;
1246212464
char *zDb = nArg>=2 ? azArg[1] : "main";
1246312465
sqlite3_stmt *pStmt = 0;
1246412466
unsigned char aHdr[100];
1246512467
open_db(p, 0);
1246612468
if( p->db==0 ) return 1;
12467
- sqlite3_prepare_v2(p->db,"SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1",
12468
- -1, &pStmt, 0);
12469
+ rc = sqlite3_prepare_v2(p->db,
12470
+ "SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1",
12471
+ -1, &pStmt, 0);
12472
+ if( rc ){
12473
+ if( !sqlite3_compileoption_used("ENABLE_DBPAGE_VTAB") ){
12474
+ utf8_printf(stderr, "the \".dbinfo\" command requires the "
12475
+ "-DSQLITE_ENABLE_DBPAGE_VTAB compile-time options\n");
12476
+ }else{
12477
+ utf8_printf(stderr, "error: %s\n", sqlite3_errmsg(p->db));
12478
+ }
12479
+ sqlite3_finalize(pStmt);
12480
+ return 1;
12481
+ }
1246912482
sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC);
1247012483
if( sqlite3_step(pStmt)==SQLITE_ROW
1247112484
&& sqlite3_column_bytes(pStmt,0)>100
1247212485
){
1247312486
memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100);
@@ -13057,30 +13070,32 @@
1305713070
1305813071
/*
1305913072
** Values for ArCommand.eCmd.
1306013073
*/
1306113074
#define AR_CMD_CREATE 1
13062
-#define AR_CMD_EXTRACT 2
13063
-#define AR_CMD_LIST 3
13064
-#define AR_CMD_UPDATE 4
13065
-#define AR_CMD_HELP 5
13075
+#define AR_CMD_UPDATE 2
13076
+#define AR_CMD_INSERT 3
13077
+#define AR_CMD_EXTRACT 4
13078
+#define AR_CMD_LIST 5
13079
+#define AR_CMD_HELP 6
1306613080
1306713081
/*
1306813082
** Other (non-command) switches.
1306913083
*/
13070
-#define AR_SWITCH_VERBOSE 6
13071
-#define AR_SWITCH_FILE 7
13072
-#define AR_SWITCH_DIRECTORY 8
13073
-#define AR_SWITCH_APPEND 9
13074
-#define AR_SWITCH_DRYRUN 10
13084
+#define AR_SWITCH_VERBOSE 7
13085
+#define AR_SWITCH_FILE 8
13086
+#define AR_SWITCH_DIRECTORY 9
13087
+#define AR_SWITCH_APPEND 10
13088
+#define AR_SWITCH_DRYRUN 11
1307513089
1307613090
static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){
1307713091
switch( eSwitch ){
1307813092
case AR_CMD_CREATE:
1307913093
case AR_CMD_EXTRACT:
1308013094
case AR_CMD_LIST:
1308113095
case AR_CMD_UPDATE:
13096
+ case AR_CMD_INSERT:
1308213097
case AR_CMD_HELP:
1308313098
if( pAr->eCmd ){
1308413099
return arErrorMsg(pAr, "multiple command options");
1308513100
}
1308613101
pAr->eCmd = eSwitch;
@@ -13123,10 +13138,11 @@
1312313138
u8 eSwitch;
1312413139
u8 bArg;
1312513140
} aSwitch[] = {
1312613141
{ "create", 'c', AR_CMD_CREATE, 0 },
1312713142
{ "extract", 'x', AR_CMD_EXTRACT, 0 },
13143
+ { "insert", 'i', AR_CMD_INSERT, 0 },
1312813144
{ "list", 't', AR_CMD_LIST, 0 },
1312913145
{ "update", 'u', AR_CMD_UPDATE, 0 },
1313013146
{ "help", 'h', AR_CMD_HELP, 0 },
1313113147
{ "verbose", 'v', AR_SWITCH_VERBOSE, 0 },
1313213148
{ "file", 'f', AR_SWITCH_FILE, 1 },
@@ -13458,23 +13474,31 @@
1345813474
return rc;
1345913475
}
1346013476
1346113477
1346213478
/*
13463
-** Implementation of .ar "create" and "update" commands.
13479
+** Implementation of .ar "create", "insert", and "update" commands.
13480
+**
13481
+** create -> Create a new SQL archive
13482
+** insert -> Insert or reinsert all files listed
13483
+** update -> Insert files that have changed or that were not
13484
+** previously in the archive
1346413485
**
1346513486
** Create the "sqlar" table in the database if it does not already exist.
1346613487
** Then add each file in the azFile[] array to the archive. Directories
1346713488
** are added recursively. If argument bVerbose is non-zero, a message is
1346813489
** printed on stdout for each file archived.
1346913490
**
1347013491
** The create command is the same as update, except that it drops
13471
-** any existing "sqlar" table before beginning.
13492
+** any existing "sqlar" table before beginning. The "insert" command
13493
+** always overwrites every file named on the command-line, where as
13494
+** "update" only overwrites if the size or mtime or mode has changed.
1347213495
*/
1347313496
static int arCreateOrUpdateCommand(
1347413497
ArCommand *pAr, /* Command arguments and options */
13475
- int bUpdate /* true for a --create. false for --update */
13498
+ int bUpdate, /* true for a --create. */
13499
+ int bOnlyIfChanged /* Only update if file has changed */
1347613500
){
1347713501
const char *zCreate =
1347813502
"CREATE TABLE IF NOT EXISTS sqlar(\n"
1347913503
" name TEXT PRIMARY KEY, -- name of the file\n"
1348013504
" mode INT, -- access permissions\n"
@@ -13492,26 +13516,28 @@
1349213516
" CASE substr(lsmode(mode),1,1)\n"
1349313517
" WHEN '-' THEN length(data)\n"
1349413518
" WHEN 'd' THEN 0\n"
1349513519
" ELSE -1 END,\n"
1349613520
" sqlar_compress(data)\n"
13497
- " FROM fsdir(%Q,%Q)\n"
13498
- " WHERE lsmode(mode) NOT LIKE '?%%';",
13521
+ " FROM fsdir(%Q,%Q) AS disk\n"
13522
+ " WHERE lsmode(mode) NOT LIKE '?%%'%s;"
13523
+ ,
1349913524
"REPLACE INTO %s(name,mode,mtime,data)\n"
1350013525
" SELECT\n"
1350113526
" %s,\n"
1350213527
" mode,\n"
1350313528
" mtime,\n"
1350413529
" data\n"
13505
- " FROM fsdir(%Q,%Q)\n"
13506
- " WHERE lsmode(mode) NOT LIKE '?%%';"
13530
+ " FROM fsdir(%Q,%Q) AS disk\n"
13531
+ " WHERE lsmode(mode) NOT LIKE '?%%'%s;"
1350713532
};
1350813533
int i; /* For iterating through azFile[] */
1350913534
int rc; /* Return code */
1351013535
const char *zTab = 0; /* SQL table into which to insert */
1351113536
char *zSql;
1351213537
char zTemp[50];
13538
+ char *zExists = 0;
1351313539
1351413540
arExecSql(pAr, "PRAGMA page_size=512");
1351513541
rc = arExecSql(pAr, "SAVEPOINT ar;");
1351613542
if( rc!=SQLITE_OK ) return rc;
1351713543
zTemp[0] = 0;
@@ -13538,14 +13564,25 @@
1353813564
rc = arExecSql(pAr, zDrop);
1353913565
if( rc!=SQLITE_OK ) goto end_ar_transaction;
1354013566
}
1354113567
rc = arExecSql(pAr, zCreate);
1354213568
}
13569
+ if( bOnlyIfChanged ){
13570
+ zExists = sqlite3_mprintf(
13571
+ " AND NOT EXISTS("
13572
+ "SELECT 1 FROM %s AS mem"
13573
+ " WHERE mem.name=disk.name"
13574
+ " AND mem.mtime=disk.mtime"
13575
+ " AND mem.mode=disk.mode)", zTab);
13576
+ }else{
13577
+ zExists = sqlite3_mprintf("");
13578
+ }
13579
+ if( zExists==0 ) rc = SQLITE_NOMEM;
1354313580
for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
1354413581
char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
1354513582
pAr->bVerbose ? "shell_putsnl(name)" : "name",
13546
- pAr->azArg[i], pAr->zDir);
13583
+ pAr->azArg[i], pAr->zDir, zExists);
1354713584
rc = arExecSql(pAr, zSql2);
1354813585
sqlite3_free(zSql2);
1354913586
}
1355013587
end_ar_transaction:
1355113588
if( rc!=SQLITE_OK ){
@@ -13556,10 +13593,11 @@
1355613593
zSql = sqlite3_mprintf("DROP TABLE %s", zTemp);
1355713594
arExecSql(pAr, zSql);
1355813595
sqlite3_free(zSql);
1355913596
}
1356013597
}
13598
+ sqlite3_free(zExists);
1356113599
return rc;
1356213600
}
1356313601
1356413602
/*
1356513603
** Implementation of ".ar" dot command.
@@ -13594,11 +13632,12 @@
1359413632
}
1359513633
cmd.bZip = 1;
1359613634
}else if( cmd.zFile ){
1359713635
int flags;
1359813636
if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS;
13599
- if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){
13637
+ if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_INSERT
13638
+ || cmd.eCmd==AR_CMD_UPDATE ){
1360013639
flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
1360113640
}else{
1360213641
flags = SQLITE_OPEN_READONLY;
1360313642
}
1360413643
cmd.db = 0;
@@ -13631,11 +13670,11 @@
1363113670
cmd.zSrcTable = sqlite3_mprintf("sqlar");
1363213671
}
1363313672
1363413673
switch( cmd.eCmd ){
1363513674
case AR_CMD_CREATE:
13636
- rc = arCreateOrUpdateCommand(&cmd, 0);
13675
+ rc = arCreateOrUpdateCommand(&cmd, 0, 0);
1363713676
break;
1363813677
1363913678
case AR_CMD_EXTRACT:
1364013679
rc = arExtractCommand(&cmd);
1364113680
break;
@@ -13646,13 +13685,17 @@
1364613685
1364713686
case AR_CMD_HELP:
1364813687
arUsage(pState->out);
1364913688
break;
1365013689
13690
+ case AR_CMD_INSERT:
13691
+ rc = arCreateOrUpdateCommand(&cmd, 1, 0);
13692
+ break;
13693
+
1365113694
default:
1365213695
assert( cmd.eCmd==AR_CMD_UPDATE );
13653
- rc = arCreateOrUpdateCommand(&cmd, 1);
13696
+ rc = arCreateOrUpdateCommand(&cmd, 1, 1);
1365413697
break;
1365513698
}
1365613699
}
1365713700
end_ar_command:
1365813701
if( cmd.db!=pState->db ){
@@ -14781,12 +14824,16 @@
1478114824
1478214825
/* .parameter clear
1478314826
** Clear all bind parameters by dropping the TEMP table that holds them.
1478414827
*/
1478514828
if( nArg==2 && strcmp(azArg[1],"clear")==0 ){
14786
- sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.[" BIND_PARAM_TABLE "];",
14829
+ int wrSchema = 0;
14830
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema);
14831
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
14832
+ sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;",
1478714833
0, 0, 0);
14834
+ sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0);
1478814835
}else
1478914836
1479014837
/* .parameter list
1479114838
** List all bind parameters.
1479214839
*/
@@ -14794,21 +14841,21 @@
1479414841
sqlite3_stmt *pStmt = 0;
1479514842
int rx;
1479614843
int len = 0;
1479714844
rx = sqlite3_prepare_v2(p->db,
1479814845
"SELECT max(length(key)) "
14799
- "FROM temp.[" BIND_PARAM_TABLE "];", -1, &pStmt, 0);
14846
+ "FROM temp.sqlite_parameters;", -1, &pStmt, 0);
1480014847
if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
1480114848
len = sqlite3_column_int(pStmt, 0);
1480214849
if( len>40 ) len = 40;
1480314850
}
1480414851
sqlite3_finalize(pStmt);
1480514852
pStmt = 0;
1480614853
if( len ){
1480714854
rx = sqlite3_prepare_v2(p->db,
1480814855
"SELECT key, quote(value) "
14809
- "FROM temp.[" BIND_PARAM_TABLE "];", -1, &pStmt, 0);
14856
+ "FROM temp.sqlite_parameters;", -1, &pStmt, 0);
1481014857
while( sqlite3_step(pStmt)==SQLITE_ROW ){
1481114858
utf8_printf(p->out, "%-*s %s\n", len, sqlite3_column_text(pStmt,0),
1481214859
sqlite3_column_text(pStmt,1));
1481314860
}
1481414861
sqlite3_finalize(pStmt);
@@ -14835,21 +14882,21 @@
1483514882
sqlite3_stmt *pStmt;
1483614883
const char *zKey = azArg[2];
1483714884
const char *zValue = azArg[3];
1483814885
bind_table_init(p);
1483914886
zSql = sqlite3_mprintf(
14840
- "REPLACE INTO temp.[" BIND_PARAM_TABLE "](key,value)"
14887
+ "REPLACE INTO temp.sqlite_parameters(key,value)"
1484114888
"VALUES(%Q,%s);", zKey, zValue);
1484214889
if( zSql==0 ) shell_out_of_memory();
1484314890
pStmt = 0;
1484414891
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
1484514892
sqlite3_free(zSql);
1484614893
if( rx!=SQLITE_OK ){
1484714894
sqlite3_finalize(pStmt);
1484814895
pStmt = 0;
1484914896
zSql = sqlite3_mprintf(
14850
- "REPLACE INTO temp.[" BIND_PARAM_TABLE "](key,value)"
14897
+ "REPLACE INTO temp.sqlite_parameters(key,value)"
1485114898
"VALUES(%Q,%Q);", zKey, zValue);
1485214899
if( zSql==0 ) shell_out_of_memory();
1485314900
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
1485414901
sqlite3_free(zSql);
1485514902
if( rx!=SQLITE_OK ){
@@ -14867,11 +14914,11 @@
1486714914
** Remove the NAME binding from the parameter binding table, if it
1486814915
** exists.
1486914916
*/
1487014917
if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
1487114918
char *zSql = sqlite3_mprintf(
14872
- "DELETE FROM temp.[" BIND_PARAM_TABLE "] WHERE key=%Q", azArg[2]);
14919
+ "DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]);
1487314920
if( zSql==0 ) shell_out_of_memory();
1487414921
sqlite3_exec(p->db, zSql, 0, 0, 0);
1487514922
sqlite3_free(zSql);
1487614923
}else
1487714924
/* If no command name matches, show a syntax error */
1487814925
--- src/shell.c
+++ src/shell.c
@@ -2181,11 +2181,11 @@
2181 if( pBuf==0 ){
2182 sqlite3_result_error_nomem(ctx);
2183 fclose(in);
2184 return;
2185 }
2186 if( nIn==fread(pBuf, 1, nIn, in) ){
2187 sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
2188 }else{
2189 sqlite3_result_error_code(ctx, SQLITE_IOERR);
2190 sqlite3_free(pBuf);
2191 }
@@ -2316,19 +2316,19 @@
2316
2317 /*
2318 ** Argument zFile is the name of a file that will be created and/or written
2319 ** by SQL function writefile(). This function ensures that the directory
2320 ** zFile will be written to exists, creating it if required. The permissions
2321 ** for any path components created by this function are set to (mode&0777).
 
2322 **
2323 ** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise,
2324 ** SQLITE_OK is returned if the directory is successfully created, or
2325 ** SQLITE_ERROR otherwise.
2326 */
2327 static int makeDirectory(
2328 const char *zFile,
2329 mode_t mode
2330 ){
2331 char *zCopy = sqlite3_mprintf("%s", zFile);
2332 int rc = SQLITE_OK;
2333
2334 if( zCopy==0 ){
@@ -2345,11 +2345,11 @@
2345 if( i==nCopy ) break;
2346 zCopy[i] = '\0';
2347
2348 rc2 = fileStat(zCopy, &sStat);
2349 if( rc2!=0 ){
2350 if( mkdir(zCopy, mode & 0777) ) rc = SQLITE_ERROR;
2351 }else{
2352 if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR;
2353 }
2354 zCopy[i] = '/';
2355 i++;
@@ -2503,11 +2503,11 @@
2503 mtime = sqlite3_value_int64(argv[3]);
2504 }
2505
2506 res = writeFile(context, zFile, argv[1], mode, mtime);
2507 if( res==1 && errno==ENOENT ){
2508 if( makeDirectory(zFile, mode)==SQLITE_OK ){
2509 res = writeFile(context, zFile, argv[1], mode, mtime);
2510 }
2511 }
2512
2513 if( argc>2 && res!=0 ){
@@ -10428,29 +10428,30 @@
10428 #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
10429 sqlite3WhereTrace = savedWhereTrace;
10430 #endif
10431 }
10432
10433 /* Name of the TEMP table that holds bind parameter values */
10434 #define BIND_PARAM_TABLE "$Parameters"
10435
10436 /* Create the TEMP table used to store parameter bindings */
10437 static void bind_table_init(ShellState *p){
 
 
 
10438 sqlite3_exec(p->db,
10439 "CREATE TABLE IF NOT EXISTS temp.[" BIND_PARAM_TABLE "](\n"
10440 " key TEXT PRIMARY KEY,\n"
10441 " value ANY\n"
10442 ") WITHOUT ROWID;",
10443 0, 0, 0);
 
10444 }
10445
10446 /*
10447 ** Bind parameters on a prepared statement.
10448 **
10449 ** Parameter bindings are taken from a TEMP table of the form:
10450 **
10451 ** CREATE TEMP TABLE "$Parameters"(key TEXT PRIMARY KEY, value)
10452 ** WITHOUT ROWID;
10453 **
10454 ** No bindings occur if this table does not exist. The special character '$'
10455 ** is included in the table name to help prevent collisions with actual tables.
10456 ** The table must be in the TEMP schema.
@@ -10461,16 +10462,16 @@
10461 int rc;
10462 sqlite3_stmt *pQ = 0;
10463
10464 nVar = sqlite3_bind_parameter_count(pStmt);
10465 if( nVar==0 ) return; /* Nothing to do */
10466 if( sqlite3_table_column_metadata(pArg->db, "TEMP", BIND_PARAM_TABLE,
10467 "key", 0, 0, 0, 0, 0)!=SQLITE_OK ){
10468 return; /* Parameter table does not exist */
10469 }
10470 rc = sqlite3_prepare_v2(pArg->db,
10471 "SELECT value FROM temp.\"" BIND_PARAM_TABLE "\""
10472 " WHERE key=?1", -1, &pQ, 0);
10473 if( rc || pQ==0 ) return;
10474 for(i=1; i<=nVar; i++){
10475 char zNum[30];
10476 const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
@@ -11133,11 +11134,12 @@
11133 static const char *(azHelp[]) = {
11134 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
11135 ".archive ... Manage SQL archives",
11136 " Each command must have exactly one of the following options:",
11137 " -c, --create Create a new archive",
11138 " -u, --update Update or add files to an existing archive",
 
11139 " -t, --list List contents of archive",
11140 " -x, --extract Extract files from archive",
11141 " Optional arguments:",
11142 " -v, --verbose Print each filename as it is processed",
11143 " -f FILE, --file FILE Operate on archive FILE (default is current db)",
@@ -12454,20 +12456,31 @@
12454 { "number of views:",
12455 "SELECT count(*) FROM %s WHERE type='view'" },
12456 { "schema size:",
12457 "SELECT total(length(sql)) FROM %s" },
12458 };
12459 int i;
12460 unsigned iDataVersion;
12461 char *zSchemaTab;
12462 char *zDb = nArg>=2 ? azArg[1] : "main";
12463 sqlite3_stmt *pStmt = 0;
12464 unsigned char aHdr[100];
12465 open_db(p, 0);
12466 if( p->db==0 ) return 1;
12467 sqlite3_prepare_v2(p->db,"SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1",
12468 -1, &pStmt, 0);
 
 
 
 
 
 
 
 
 
 
 
12469 sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC);
12470 if( sqlite3_step(pStmt)==SQLITE_ROW
12471 && sqlite3_column_bytes(pStmt,0)>100
12472 ){
12473 memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100);
@@ -13057,30 +13070,32 @@
13057
13058 /*
13059 ** Values for ArCommand.eCmd.
13060 */
13061 #define AR_CMD_CREATE 1
13062 #define AR_CMD_EXTRACT 2
13063 #define AR_CMD_LIST 3
13064 #define AR_CMD_UPDATE 4
13065 #define AR_CMD_HELP 5
 
13066
13067 /*
13068 ** Other (non-command) switches.
13069 */
13070 #define AR_SWITCH_VERBOSE 6
13071 #define AR_SWITCH_FILE 7
13072 #define AR_SWITCH_DIRECTORY 8
13073 #define AR_SWITCH_APPEND 9
13074 #define AR_SWITCH_DRYRUN 10
13075
13076 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){
13077 switch( eSwitch ){
13078 case AR_CMD_CREATE:
13079 case AR_CMD_EXTRACT:
13080 case AR_CMD_LIST:
13081 case AR_CMD_UPDATE:
 
13082 case AR_CMD_HELP:
13083 if( pAr->eCmd ){
13084 return arErrorMsg(pAr, "multiple command options");
13085 }
13086 pAr->eCmd = eSwitch;
@@ -13123,10 +13138,11 @@
13123 u8 eSwitch;
13124 u8 bArg;
13125 } aSwitch[] = {
13126 { "create", 'c', AR_CMD_CREATE, 0 },
13127 { "extract", 'x', AR_CMD_EXTRACT, 0 },
 
13128 { "list", 't', AR_CMD_LIST, 0 },
13129 { "update", 'u', AR_CMD_UPDATE, 0 },
13130 { "help", 'h', AR_CMD_HELP, 0 },
13131 { "verbose", 'v', AR_SWITCH_VERBOSE, 0 },
13132 { "file", 'f', AR_SWITCH_FILE, 1 },
@@ -13458,23 +13474,31 @@
13458 return rc;
13459 }
13460
13461
13462 /*
13463 ** Implementation of .ar "create" and "update" commands.
 
 
 
 
 
13464 **
13465 ** Create the "sqlar" table in the database if it does not already exist.
13466 ** Then add each file in the azFile[] array to the archive. Directories
13467 ** are added recursively. If argument bVerbose is non-zero, a message is
13468 ** printed on stdout for each file archived.
13469 **
13470 ** The create command is the same as update, except that it drops
13471 ** any existing "sqlar" table before beginning.
 
 
13472 */
13473 static int arCreateOrUpdateCommand(
13474 ArCommand *pAr, /* Command arguments and options */
13475 int bUpdate /* true for a --create. false for --update */
 
13476 ){
13477 const char *zCreate =
13478 "CREATE TABLE IF NOT EXISTS sqlar(\n"
13479 " name TEXT PRIMARY KEY, -- name of the file\n"
13480 " mode INT, -- access permissions\n"
@@ -13492,26 +13516,28 @@
13492 " CASE substr(lsmode(mode),1,1)\n"
13493 " WHEN '-' THEN length(data)\n"
13494 " WHEN 'd' THEN 0\n"
13495 " ELSE -1 END,\n"
13496 " sqlar_compress(data)\n"
13497 " FROM fsdir(%Q,%Q)\n"
13498 " WHERE lsmode(mode) NOT LIKE '?%%';",
 
13499 "REPLACE INTO %s(name,mode,mtime,data)\n"
13500 " SELECT\n"
13501 " %s,\n"
13502 " mode,\n"
13503 " mtime,\n"
13504 " data\n"
13505 " FROM fsdir(%Q,%Q)\n"
13506 " WHERE lsmode(mode) NOT LIKE '?%%';"
13507 };
13508 int i; /* For iterating through azFile[] */
13509 int rc; /* Return code */
13510 const char *zTab = 0; /* SQL table into which to insert */
13511 char *zSql;
13512 char zTemp[50];
 
13513
13514 arExecSql(pAr, "PRAGMA page_size=512");
13515 rc = arExecSql(pAr, "SAVEPOINT ar;");
13516 if( rc!=SQLITE_OK ) return rc;
13517 zTemp[0] = 0;
@@ -13538,14 +13564,25 @@
13538 rc = arExecSql(pAr, zDrop);
13539 if( rc!=SQLITE_OK ) goto end_ar_transaction;
13540 }
13541 rc = arExecSql(pAr, zCreate);
13542 }
 
 
 
 
 
 
 
 
 
 
 
13543 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
13544 char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
13545 pAr->bVerbose ? "shell_putsnl(name)" : "name",
13546 pAr->azArg[i], pAr->zDir);
13547 rc = arExecSql(pAr, zSql2);
13548 sqlite3_free(zSql2);
13549 }
13550 end_ar_transaction:
13551 if( rc!=SQLITE_OK ){
@@ -13556,10 +13593,11 @@
13556 zSql = sqlite3_mprintf("DROP TABLE %s", zTemp);
13557 arExecSql(pAr, zSql);
13558 sqlite3_free(zSql);
13559 }
13560 }
 
13561 return rc;
13562 }
13563
13564 /*
13565 ** Implementation of ".ar" dot command.
@@ -13594,11 +13632,12 @@
13594 }
13595 cmd.bZip = 1;
13596 }else if( cmd.zFile ){
13597 int flags;
13598 if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS;
13599 if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_UPDATE ){
 
13600 flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
13601 }else{
13602 flags = SQLITE_OPEN_READONLY;
13603 }
13604 cmd.db = 0;
@@ -13631,11 +13670,11 @@
13631 cmd.zSrcTable = sqlite3_mprintf("sqlar");
13632 }
13633
13634 switch( cmd.eCmd ){
13635 case AR_CMD_CREATE:
13636 rc = arCreateOrUpdateCommand(&cmd, 0);
13637 break;
13638
13639 case AR_CMD_EXTRACT:
13640 rc = arExtractCommand(&cmd);
13641 break;
@@ -13646,13 +13685,17 @@
13646
13647 case AR_CMD_HELP:
13648 arUsage(pState->out);
13649 break;
13650
 
 
 
 
13651 default:
13652 assert( cmd.eCmd==AR_CMD_UPDATE );
13653 rc = arCreateOrUpdateCommand(&cmd, 1);
13654 break;
13655 }
13656 }
13657 end_ar_command:
13658 if( cmd.db!=pState->db ){
@@ -14781,12 +14824,16 @@
14781
14782 /* .parameter clear
14783 ** Clear all bind parameters by dropping the TEMP table that holds them.
14784 */
14785 if( nArg==2 && strcmp(azArg[1],"clear")==0 ){
14786 sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.[" BIND_PARAM_TABLE "];",
 
 
 
14787 0, 0, 0);
 
14788 }else
14789
14790 /* .parameter list
14791 ** List all bind parameters.
14792 */
@@ -14794,21 +14841,21 @@
14794 sqlite3_stmt *pStmt = 0;
14795 int rx;
14796 int len = 0;
14797 rx = sqlite3_prepare_v2(p->db,
14798 "SELECT max(length(key)) "
14799 "FROM temp.[" BIND_PARAM_TABLE "];", -1, &pStmt, 0);
14800 if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
14801 len = sqlite3_column_int(pStmt, 0);
14802 if( len>40 ) len = 40;
14803 }
14804 sqlite3_finalize(pStmt);
14805 pStmt = 0;
14806 if( len ){
14807 rx = sqlite3_prepare_v2(p->db,
14808 "SELECT key, quote(value) "
14809 "FROM temp.[" BIND_PARAM_TABLE "];", -1, &pStmt, 0);
14810 while( sqlite3_step(pStmt)==SQLITE_ROW ){
14811 utf8_printf(p->out, "%-*s %s\n", len, sqlite3_column_text(pStmt,0),
14812 sqlite3_column_text(pStmt,1));
14813 }
14814 sqlite3_finalize(pStmt);
@@ -14835,21 +14882,21 @@
14835 sqlite3_stmt *pStmt;
14836 const char *zKey = azArg[2];
14837 const char *zValue = azArg[3];
14838 bind_table_init(p);
14839 zSql = sqlite3_mprintf(
14840 "REPLACE INTO temp.[" BIND_PARAM_TABLE "](key,value)"
14841 "VALUES(%Q,%s);", zKey, zValue);
14842 if( zSql==0 ) shell_out_of_memory();
14843 pStmt = 0;
14844 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
14845 sqlite3_free(zSql);
14846 if( rx!=SQLITE_OK ){
14847 sqlite3_finalize(pStmt);
14848 pStmt = 0;
14849 zSql = sqlite3_mprintf(
14850 "REPLACE INTO temp.[" BIND_PARAM_TABLE "](key,value)"
14851 "VALUES(%Q,%Q);", zKey, zValue);
14852 if( zSql==0 ) shell_out_of_memory();
14853 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
14854 sqlite3_free(zSql);
14855 if( rx!=SQLITE_OK ){
@@ -14867,11 +14914,11 @@
14867 ** Remove the NAME binding from the parameter binding table, if it
14868 ** exists.
14869 */
14870 if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
14871 char *zSql = sqlite3_mprintf(
14872 "DELETE FROM temp.[" BIND_PARAM_TABLE "] WHERE key=%Q", azArg[2]);
14873 if( zSql==0 ) shell_out_of_memory();
14874 sqlite3_exec(p->db, zSql, 0, 0, 0);
14875 sqlite3_free(zSql);
14876 }else
14877 /* If no command name matches, show a syntax error */
14878
--- src/shell.c
+++ src/shell.c
@@ -2181,11 +2181,11 @@
2181 if( pBuf==0 ){
2182 sqlite3_result_error_nomem(ctx);
2183 fclose(in);
2184 return;
2185 }
2186 if( nIn==(sqlite3_int64)fread(pBuf, 1, (size_t)nIn, in) ){
2187 sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
2188 }else{
2189 sqlite3_result_error_code(ctx, SQLITE_IOERR);
2190 sqlite3_free(pBuf);
2191 }
@@ -2316,19 +2316,19 @@
2316
2317 /*
2318 ** Argument zFile is the name of a file that will be created and/or written
2319 ** by SQL function writefile(). This function ensures that the directory
2320 ** zFile will be written to exists, creating it if required. The permissions
2321 ** for any path components created by this function are set in accordance
2322 ** with the current umask.
2323 **
2324 ** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise,
2325 ** SQLITE_OK is returned if the directory is successfully created, or
2326 ** SQLITE_ERROR otherwise.
2327 */
2328 static int makeDirectory(
2329 const char *zFile
 
2330 ){
2331 char *zCopy = sqlite3_mprintf("%s", zFile);
2332 int rc = SQLITE_OK;
2333
2334 if( zCopy==0 ){
@@ -2345,11 +2345,11 @@
2345 if( i==nCopy ) break;
2346 zCopy[i] = '\0';
2347
2348 rc2 = fileStat(zCopy, &sStat);
2349 if( rc2!=0 ){
2350 if( mkdir(zCopy, 0777) ) rc = SQLITE_ERROR;
2351 }else{
2352 if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR;
2353 }
2354 zCopy[i] = '/';
2355 i++;
@@ -2503,11 +2503,11 @@
2503 mtime = sqlite3_value_int64(argv[3]);
2504 }
2505
2506 res = writeFile(context, zFile, argv[1], mode, mtime);
2507 if( res==1 && errno==ENOENT ){
2508 if( makeDirectory(zFile)==SQLITE_OK ){
2509 res = writeFile(context, zFile, argv[1], mode, mtime);
2510 }
2511 }
2512
2513 if( argc>2 && res!=0 ){
@@ -10428,29 +10428,30 @@
10428 #if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_WHERETRACE)
10429 sqlite3WhereTrace = savedWhereTrace;
10430 #endif
10431 }
10432
 
 
 
10433 /* Create the TEMP table used to store parameter bindings */
10434 static void bind_table_init(ShellState *p){
10435 int wrSchema = 0;
10436 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema);
10437 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
10438 sqlite3_exec(p->db,
10439 "CREATE TABLE IF NOT EXISTS temp.sqlite_parameters(\n"
10440 " key TEXT PRIMARY KEY,\n"
10441 " value ANY\n"
10442 ") WITHOUT ROWID;",
10443 0, 0, 0);
10444 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0);
10445 }
10446
10447 /*
10448 ** Bind parameters on a prepared statement.
10449 **
10450 ** Parameter bindings are taken from a TEMP table of the form:
10451 **
10452 ** CREATE TEMP TABLE sqlite_parameters(key TEXT PRIMARY KEY, value)
10453 ** WITHOUT ROWID;
10454 **
10455 ** No bindings occur if this table does not exist. The special character '$'
10456 ** is included in the table name to help prevent collisions with actual tables.
10457 ** The table must be in the TEMP schema.
@@ -10461,16 +10462,16 @@
10462 int rc;
10463 sqlite3_stmt *pQ = 0;
10464
10465 nVar = sqlite3_bind_parameter_count(pStmt);
10466 if( nVar==0 ) return; /* Nothing to do */
10467 if( sqlite3_table_column_metadata(pArg->db, "TEMP", "sqlite_parameters",
10468 "key", 0, 0, 0, 0, 0)!=SQLITE_OK ){
10469 return; /* Parameter table does not exist */
10470 }
10471 rc = sqlite3_prepare_v2(pArg->db,
10472 "SELECT value FROM temp.sqlite_parameters"
10473 " WHERE key=?1", -1, &pQ, 0);
10474 if( rc || pQ==0 ) return;
10475 for(i=1; i<=nVar; i++){
10476 char zNum[30];
10477 const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
@@ -11133,11 +11134,12 @@
11134 static const char *(azHelp[]) = {
11135 #if defined(SQLITE_HAVE_ZLIB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
11136 ".archive ... Manage SQL archives",
11137 " Each command must have exactly one of the following options:",
11138 " -c, --create Create a new archive",
11139 " -u, --update Add files or update files with changed mtime",
11140 " -i, --insert Like -u but always add even if mtime unchanged",
11141 " -t, --list List contents of archive",
11142 " -x, --extract Extract files from archive",
11143 " Optional arguments:",
11144 " -v, --verbose Print each filename as it is processed",
11145 " -f FILE, --file FILE Operate on archive FILE (default is current db)",
@@ -12454,20 +12456,31 @@
12456 { "number of views:",
12457 "SELECT count(*) FROM %s WHERE type='view'" },
12458 { "schema size:",
12459 "SELECT total(length(sql)) FROM %s" },
12460 };
12461 int i, rc;
12462 unsigned iDataVersion;
12463 char *zSchemaTab;
12464 char *zDb = nArg>=2 ? azArg[1] : "main";
12465 sqlite3_stmt *pStmt = 0;
12466 unsigned char aHdr[100];
12467 open_db(p, 0);
12468 if( p->db==0 ) return 1;
12469 rc = sqlite3_prepare_v2(p->db,
12470 "SELECT data FROM sqlite_dbpage(?1) WHERE pgno=1",
12471 -1, &pStmt, 0);
12472 if( rc ){
12473 if( !sqlite3_compileoption_used("ENABLE_DBPAGE_VTAB") ){
12474 utf8_printf(stderr, "the \".dbinfo\" command requires the "
12475 "-DSQLITE_ENABLE_DBPAGE_VTAB compile-time options\n");
12476 }else{
12477 utf8_printf(stderr, "error: %s\n", sqlite3_errmsg(p->db));
12478 }
12479 sqlite3_finalize(pStmt);
12480 return 1;
12481 }
12482 sqlite3_bind_text(pStmt, 1, zDb, -1, SQLITE_STATIC);
12483 if( sqlite3_step(pStmt)==SQLITE_ROW
12484 && sqlite3_column_bytes(pStmt,0)>100
12485 ){
12486 memcpy(aHdr, sqlite3_column_blob(pStmt,0), 100);
@@ -13057,30 +13070,32 @@
13070
13071 /*
13072 ** Values for ArCommand.eCmd.
13073 */
13074 #define AR_CMD_CREATE 1
13075 #define AR_CMD_UPDATE 2
13076 #define AR_CMD_INSERT 3
13077 #define AR_CMD_EXTRACT 4
13078 #define AR_CMD_LIST 5
13079 #define AR_CMD_HELP 6
13080
13081 /*
13082 ** Other (non-command) switches.
13083 */
13084 #define AR_SWITCH_VERBOSE 7
13085 #define AR_SWITCH_FILE 8
13086 #define AR_SWITCH_DIRECTORY 9
13087 #define AR_SWITCH_APPEND 10
13088 #define AR_SWITCH_DRYRUN 11
13089
13090 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){
13091 switch( eSwitch ){
13092 case AR_CMD_CREATE:
13093 case AR_CMD_EXTRACT:
13094 case AR_CMD_LIST:
13095 case AR_CMD_UPDATE:
13096 case AR_CMD_INSERT:
13097 case AR_CMD_HELP:
13098 if( pAr->eCmd ){
13099 return arErrorMsg(pAr, "multiple command options");
13100 }
13101 pAr->eCmd = eSwitch;
@@ -13123,10 +13138,11 @@
13138 u8 eSwitch;
13139 u8 bArg;
13140 } aSwitch[] = {
13141 { "create", 'c', AR_CMD_CREATE, 0 },
13142 { "extract", 'x', AR_CMD_EXTRACT, 0 },
13143 { "insert", 'i', AR_CMD_INSERT, 0 },
13144 { "list", 't', AR_CMD_LIST, 0 },
13145 { "update", 'u', AR_CMD_UPDATE, 0 },
13146 { "help", 'h', AR_CMD_HELP, 0 },
13147 { "verbose", 'v', AR_SWITCH_VERBOSE, 0 },
13148 { "file", 'f', AR_SWITCH_FILE, 1 },
@@ -13458,23 +13474,31 @@
13474 return rc;
13475 }
13476
13477
13478 /*
13479 ** Implementation of .ar "create", "insert", and "update" commands.
13480 **
13481 ** create -> Create a new SQL archive
13482 ** insert -> Insert or reinsert all files listed
13483 ** update -> Insert files that have changed or that were not
13484 ** previously in the archive
13485 **
13486 ** Create the "sqlar" table in the database if it does not already exist.
13487 ** Then add each file in the azFile[] array to the archive. Directories
13488 ** are added recursively. If argument bVerbose is non-zero, a message is
13489 ** printed on stdout for each file archived.
13490 **
13491 ** The create command is the same as update, except that it drops
13492 ** any existing "sqlar" table before beginning. The "insert" command
13493 ** always overwrites every file named on the command-line, where as
13494 ** "update" only overwrites if the size or mtime or mode has changed.
13495 */
13496 static int arCreateOrUpdateCommand(
13497 ArCommand *pAr, /* Command arguments and options */
13498 int bUpdate, /* true for a --create. */
13499 int bOnlyIfChanged /* Only update if file has changed */
13500 ){
13501 const char *zCreate =
13502 "CREATE TABLE IF NOT EXISTS sqlar(\n"
13503 " name TEXT PRIMARY KEY, -- name of the file\n"
13504 " mode INT, -- access permissions\n"
@@ -13492,26 +13516,28 @@
13516 " CASE substr(lsmode(mode),1,1)\n"
13517 " WHEN '-' THEN length(data)\n"
13518 " WHEN 'd' THEN 0\n"
13519 " ELSE -1 END,\n"
13520 " sqlar_compress(data)\n"
13521 " FROM fsdir(%Q,%Q) AS disk\n"
13522 " WHERE lsmode(mode) NOT LIKE '?%%'%s;"
13523 ,
13524 "REPLACE INTO %s(name,mode,mtime,data)\n"
13525 " SELECT\n"
13526 " %s,\n"
13527 " mode,\n"
13528 " mtime,\n"
13529 " data\n"
13530 " FROM fsdir(%Q,%Q) AS disk\n"
13531 " WHERE lsmode(mode) NOT LIKE '?%%'%s;"
13532 };
13533 int i; /* For iterating through azFile[] */
13534 int rc; /* Return code */
13535 const char *zTab = 0; /* SQL table into which to insert */
13536 char *zSql;
13537 char zTemp[50];
13538 char *zExists = 0;
13539
13540 arExecSql(pAr, "PRAGMA page_size=512");
13541 rc = arExecSql(pAr, "SAVEPOINT ar;");
13542 if( rc!=SQLITE_OK ) return rc;
13543 zTemp[0] = 0;
@@ -13538,14 +13564,25 @@
13564 rc = arExecSql(pAr, zDrop);
13565 if( rc!=SQLITE_OK ) goto end_ar_transaction;
13566 }
13567 rc = arExecSql(pAr, zCreate);
13568 }
13569 if( bOnlyIfChanged ){
13570 zExists = sqlite3_mprintf(
13571 " AND NOT EXISTS("
13572 "SELECT 1 FROM %s AS mem"
13573 " WHERE mem.name=disk.name"
13574 " AND mem.mtime=disk.mtime"
13575 " AND mem.mode=disk.mode)", zTab);
13576 }else{
13577 zExists = sqlite3_mprintf("");
13578 }
13579 if( zExists==0 ) rc = SQLITE_NOMEM;
13580 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
13581 char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
13582 pAr->bVerbose ? "shell_putsnl(name)" : "name",
13583 pAr->azArg[i], pAr->zDir, zExists);
13584 rc = arExecSql(pAr, zSql2);
13585 sqlite3_free(zSql2);
13586 }
13587 end_ar_transaction:
13588 if( rc!=SQLITE_OK ){
@@ -13556,10 +13593,11 @@
13593 zSql = sqlite3_mprintf("DROP TABLE %s", zTemp);
13594 arExecSql(pAr, zSql);
13595 sqlite3_free(zSql);
13596 }
13597 }
13598 sqlite3_free(zExists);
13599 return rc;
13600 }
13601
13602 /*
13603 ** Implementation of ".ar" dot command.
@@ -13594,11 +13632,12 @@
13632 }
13633 cmd.bZip = 1;
13634 }else if( cmd.zFile ){
13635 int flags;
13636 if( cmd.bAppend ) eDbType = SHELL_OPEN_APPENDVFS;
13637 if( cmd.eCmd==AR_CMD_CREATE || cmd.eCmd==AR_CMD_INSERT
13638 || cmd.eCmd==AR_CMD_UPDATE ){
13639 flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
13640 }else{
13641 flags = SQLITE_OPEN_READONLY;
13642 }
13643 cmd.db = 0;
@@ -13631,11 +13670,11 @@
13670 cmd.zSrcTable = sqlite3_mprintf("sqlar");
13671 }
13672
13673 switch( cmd.eCmd ){
13674 case AR_CMD_CREATE:
13675 rc = arCreateOrUpdateCommand(&cmd, 0, 0);
13676 break;
13677
13678 case AR_CMD_EXTRACT:
13679 rc = arExtractCommand(&cmd);
13680 break;
@@ -13646,13 +13685,17 @@
13685
13686 case AR_CMD_HELP:
13687 arUsage(pState->out);
13688 break;
13689
13690 case AR_CMD_INSERT:
13691 rc = arCreateOrUpdateCommand(&cmd, 1, 0);
13692 break;
13693
13694 default:
13695 assert( cmd.eCmd==AR_CMD_UPDATE );
13696 rc = arCreateOrUpdateCommand(&cmd, 1, 1);
13697 break;
13698 }
13699 }
13700 end_ar_command:
13701 if( cmd.db!=pState->db ){
@@ -14781,12 +14824,16 @@
14824
14825 /* .parameter clear
14826 ** Clear all bind parameters by dropping the TEMP table that holds them.
14827 */
14828 if( nArg==2 && strcmp(azArg[1],"clear")==0 ){
14829 int wrSchema = 0;
14830 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, -1, &wrSchema);
14831 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, 1, 0);
14832 sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp.sqlite_parameters;",
14833 0, 0, 0);
14834 sqlite3_db_config(p->db, SQLITE_DBCONFIG_WRITABLE_SCHEMA, wrSchema, 0);
14835 }else
14836
14837 /* .parameter list
14838 ** List all bind parameters.
14839 */
@@ -14794,21 +14841,21 @@
14841 sqlite3_stmt *pStmt = 0;
14842 int rx;
14843 int len = 0;
14844 rx = sqlite3_prepare_v2(p->db,
14845 "SELECT max(length(key)) "
14846 "FROM temp.sqlite_parameters;", -1, &pStmt, 0);
14847 if( rx==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
14848 len = sqlite3_column_int(pStmt, 0);
14849 if( len>40 ) len = 40;
14850 }
14851 sqlite3_finalize(pStmt);
14852 pStmt = 0;
14853 if( len ){
14854 rx = sqlite3_prepare_v2(p->db,
14855 "SELECT key, quote(value) "
14856 "FROM temp.sqlite_parameters;", -1, &pStmt, 0);
14857 while( sqlite3_step(pStmt)==SQLITE_ROW ){
14858 utf8_printf(p->out, "%-*s %s\n", len, sqlite3_column_text(pStmt,0),
14859 sqlite3_column_text(pStmt,1));
14860 }
14861 sqlite3_finalize(pStmt);
@@ -14835,21 +14882,21 @@
14882 sqlite3_stmt *pStmt;
14883 const char *zKey = azArg[2];
14884 const char *zValue = azArg[3];
14885 bind_table_init(p);
14886 zSql = sqlite3_mprintf(
14887 "REPLACE INTO temp.sqlite_parameters(key,value)"
14888 "VALUES(%Q,%s);", zKey, zValue);
14889 if( zSql==0 ) shell_out_of_memory();
14890 pStmt = 0;
14891 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
14892 sqlite3_free(zSql);
14893 if( rx!=SQLITE_OK ){
14894 sqlite3_finalize(pStmt);
14895 pStmt = 0;
14896 zSql = sqlite3_mprintf(
14897 "REPLACE INTO temp.sqlite_parameters(key,value)"
14898 "VALUES(%Q,%Q);", zKey, zValue);
14899 if( zSql==0 ) shell_out_of_memory();
14900 rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
14901 sqlite3_free(zSql);
14902 if( rx!=SQLITE_OK ){
@@ -14867,11 +14914,11 @@
14914 ** Remove the NAME binding from the parameter binding table, if it
14915 ** exists.
14916 */
14917 if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
14918 char *zSql = sqlite3_mprintf(
14919 "DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]);
14920 if( zSql==0 ) shell_out_of_memory();
14921 sqlite3_exec(p->db, zSql, 0, 0, 0);
14922 sqlite3_free(zSql);
14923 }else
14924 /* If no command name matches, show a syntax error */
14925
+4152 -3451
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
11621162
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11631163
** [sqlite_version()] and [sqlite_source_id()].
11641164
*/
11651165
#define SQLITE_VERSION "3.28.0"
11661166
#define SQLITE_VERSION_NUMBER 3028000
1167
-#define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07e2f93"
1167
+#define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f"
11681168
11691169
/*
11701170
** CAPI3REF: Run-Time Library Version Numbers
11711171
** KEYWORDS: sqlite3_version sqlite3_sourceid
11721172
**
@@ -1226,10 +1226,13 @@
12261226
** [sqlite_compileoption_get()] and the [compile_options pragma].
12271227
*/
12281228
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
12291229
SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
12301230
SQLITE_API const char *sqlite3_compileoption_get(int N);
1231
+#else
1232
+# define sqlite3_compileoption_used(X) 0
1233
+# define sqlite3_compileoption_get(X) ((void*)0)
12311234
#endif
12321235
12331236
/*
12341237
** CAPI3REF: Test To See If The Library Is Threadsafe
12351238
**
@@ -3236,10 +3239,21 @@
32363239
** <li> The [PRAGMA writable_schema=ON] statement.
32373240
** <li> Writes to the [sqlite_dbpage] virtual table.
32383241
** <li> Direct writes to [shadow tables].
32393242
** </ul>
32403243
** </dd>
3244
+**
3245
+** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
3246
+** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
3247
+** "writable_schema" flag. This has the same effect and is logically equivalent
3248
+** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF].
3249
+** The first argument to this setting is an integer which is 0 to disable
3250
+** the writable_schema, positive to enable writable_schema, or negative to
3251
+** leave the setting unchanged. The second parameter is a pointer to an
3252
+** integer into which is written 0 or 1 to indicate whether the writable_schema
3253
+** is enabled or disabled following this call.
3254
+** </dd>
32413255
** </dl>
32423256
*/
32433257
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
32443258
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
32453259
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3249,11 +3263,12 @@
32493263
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
32503264
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
32513265
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
32523266
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
32533267
#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3254
-#define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
3268
+#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
3269
+#define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */
32553270
32563271
/*
32573272
** CAPI3REF: Enable Or Disable Extended Result Codes
32583273
** METHOD: sqlite3
32593274
**
@@ -6001,10 +6016,12 @@
60016016
** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
60026017
** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
60036018
** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
60046019
** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
60056020
** against a virtual table.
6021
+** <tr><td><b>sqlite3_value_frombind&nbsp;&nbsp;</b>
6022
+** <td>&rarr;&nbsp;&nbsp;<td>True if value originated a bound parameter
60066023
** </table></blockquote>
60076024
**
60086025
** <b>Details:</b>
60096026
**
60106027
** These routines extract type, size, and content information from
@@ -6061,10 +6078,15 @@
60616078
** was unchanging). ^Within an [xUpdate] method, any value for which
60626079
** sqlite3_value_nochange(X) is true will in all other respects appear
60636080
** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
60646081
** than within an [xUpdate] method call for an UPDATE statement, then
60656082
** the return value is arbitrary and meaningless.
6083
+**
6084
+** ^The sqlite3_value_frombind(X) interface returns non-zero if the
6085
+** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
6086
+** interfaces. ^If X comes from an SQL literal value, or a table column,
6087
+** and expression, then sqlite3_value_frombind(X) returns zero.
60666088
**
60676089
** Please pay particular attention to the fact that the pointer returned
60686090
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
60696091
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
60706092
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6107,10 +6129,11 @@
61076129
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
61086130
SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
61096131
SQLITE_API int sqlite3_value_type(sqlite3_value*);
61106132
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
61116133
SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
6134
+SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
61126135
61136136
/*
61146137
** CAPI3REF: Finding The Subtype Of SQL Values
61156138
** METHOD: sqlite3_value
61166139
**
@@ -11943,11 +11966,11 @@
1194311966
**
1194411967
** Argument pIn must point to a buffer containing a changeset nIn bytes
1194511968
** in size. This function allocates and populates a buffer with a copy
1194611969
** of the changeset rebased rebased according to the configuration of the
1194711970
** rebaser object passed as the first argument. If successful, (*ppOut)
11948
-** is set to point to the new buffer containing the rebased changset and
11971
+** is set to point to the new buffer containing the rebased changeset and
1194911972
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
1195011973
** responsibility of the caller to eventually free the new buffer using
1195111974
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
1195211975
** are set to zero and an SQLite error code returned.
1195311976
*/
@@ -13534,96 +13557,100 @@
1353413557
#define TK_FOLLOWING 83
1353513558
#define TK_PARTITION 84
1353613559
#define TK_PRECEDING 85
1353713560
#define TK_RANGE 86
1353813561
#define TK_UNBOUNDED 87
13539
-#define TK_REINDEX 88
13540
-#define TK_RENAME 89
13541
-#define TK_CTIME_KW 90
13542
-#define TK_ANY 91
13543
-#define TK_BITAND 92
13544
-#define TK_BITOR 93
13545
-#define TK_LSHIFT 94
13546
-#define TK_RSHIFT 95
13547
-#define TK_PLUS 96
13548
-#define TK_MINUS 97
13549
-#define TK_STAR 98
13550
-#define TK_SLASH 99
13551
-#define TK_REM 100
13552
-#define TK_CONCAT 101
13553
-#define TK_COLLATE 102
13554
-#define TK_BITNOT 103
13555
-#define TK_ON 104
13556
-#define TK_INDEXED 105
13557
-#define TK_STRING 106
13558
-#define TK_JOIN_KW 107
13559
-#define TK_CONSTRAINT 108
13560
-#define TK_DEFAULT 109
13561
-#define TK_NULL 110
13562
-#define TK_PRIMARY 111
13563
-#define TK_UNIQUE 112
13564
-#define TK_CHECK 113
13565
-#define TK_REFERENCES 114
13566
-#define TK_AUTOINCR 115
13567
-#define TK_INSERT 116
13568
-#define TK_DELETE 117
13569
-#define TK_UPDATE 118
13570
-#define TK_SET 119
13571
-#define TK_DEFERRABLE 120
13572
-#define TK_FOREIGN 121
13573
-#define TK_DROP 122
13574
-#define TK_UNION 123
13575
-#define TK_ALL 124
13576
-#define TK_EXCEPT 125
13577
-#define TK_INTERSECT 126
13578
-#define TK_SELECT 127
13579
-#define TK_VALUES 128
13580
-#define TK_DISTINCT 129
13581
-#define TK_DOT 130
13582
-#define TK_FROM 131
13583
-#define TK_JOIN 132
13584
-#define TK_USING 133
13585
-#define TK_ORDER 134
13586
-#define TK_GROUP 135
13587
-#define TK_HAVING 136
13588
-#define TK_LIMIT 137
13589
-#define TK_WHERE 138
13590
-#define TK_INTO 139
13591
-#define TK_NOTHING 140
13592
-#define TK_FLOAT 141
13593
-#define TK_BLOB 142
13594
-#define TK_INTEGER 143
13595
-#define TK_VARIABLE 144
13596
-#define TK_CASE 145
13597
-#define TK_WHEN 146
13598
-#define TK_THEN 147
13599
-#define TK_ELSE 148
13600
-#define TK_INDEX 149
13601
-#define TK_ALTER 150
13602
-#define TK_ADD 151
13603
-#define TK_WINDOW 152
13604
-#define TK_OVER 153
13605
-#define TK_FILTER 154
13606
-#define TK_TRUEFALSE 155
13607
-#define TK_ISNOT 156
13608
-#define TK_FUNCTION 157
13609
-#define TK_COLUMN 158
13610
-#define TK_AGG_FUNCTION 159
13611
-#define TK_AGG_COLUMN 160
13612
-#define TK_UMINUS 161
13613
-#define TK_UPLUS 162
13614
-#define TK_TRUTH 163
13615
-#define TK_REGISTER 164
13616
-#define TK_VECTOR 165
13617
-#define TK_SELECT_COLUMN 166
13618
-#define TK_IF_NULL_ROW 167
13619
-#define TK_ASTERISK 168
13620
-#define TK_SPAN 169
13621
-#define TK_END_OF_FILE 170
13622
-#define TK_UNCLOSED_STRING 171
13623
-#define TK_SPACE 172
13624
-#define TK_ILLEGAL 173
13562
+#define TK_EXCLUDE 88
13563
+#define TK_GROUPS 89
13564
+#define TK_OTHERS 90
13565
+#define TK_TIES 91
13566
+#define TK_REINDEX 92
13567
+#define TK_RENAME 93
13568
+#define TK_CTIME_KW 94
13569
+#define TK_ANY 95
13570
+#define TK_BITAND 96
13571
+#define TK_BITOR 97
13572
+#define TK_LSHIFT 98
13573
+#define TK_RSHIFT 99
13574
+#define TK_PLUS 100
13575
+#define TK_MINUS 101
13576
+#define TK_STAR 102
13577
+#define TK_SLASH 103
13578
+#define TK_REM 104
13579
+#define TK_CONCAT 105
13580
+#define TK_COLLATE 106
13581
+#define TK_BITNOT 107
13582
+#define TK_ON 108
13583
+#define TK_INDEXED 109
13584
+#define TK_STRING 110
13585
+#define TK_JOIN_KW 111
13586
+#define TK_CONSTRAINT 112
13587
+#define TK_DEFAULT 113
13588
+#define TK_NULL 114
13589
+#define TK_PRIMARY 115
13590
+#define TK_UNIQUE 116
13591
+#define TK_CHECK 117
13592
+#define TK_REFERENCES 118
13593
+#define TK_AUTOINCR 119
13594
+#define TK_INSERT 120
13595
+#define TK_DELETE 121
13596
+#define TK_UPDATE 122
13597
+#define TK_SET 123
13598
+#define TK_DEFERRABLE 124
13599
+#define TK_FOREIGN 125
13600
+#define TK_DROP 126
13601
+#define TK_UNION 127
13602
+#define TK_ALL 128
13603
+#define TK_EXCEPT 129
13604
+#define TK_INTERSECT 130
13605
+#define TK_SELECT 131
13606
+#define TK_VALUES 132
13607
+#define TK_DISTINCT 133
13608
+#define TK_DOT 134
13609
+#define TK_FROM 135
13610
+#define TK_JOIN 136
13611
+#define TK_USING 137
13612
+#define TK_ORDER 138
13613
+#define TK_GROUP 139
13614
+#define TK_HAVING 140
13615
+#define TK_LIMIT 141
13616
+#define TK_WHERE 142
13617
+#define TK_INTO 143
13618
+#define TK_NOTHING 144
13619
+#define TK_FLOAT 145
13620
+#define TK_BLOB 146
13621
+#define TK_INTEGER 147
13622
+#define TK_VARIABLE 148
13623
+#define TK_CASE 149
13624
+#define TK_WHEN 150
13625
+#define TK_THEN 151
13626
+#define TK_ELSE 152
13627
+#define TK_INDEX 153
13628
+#define TK_ALTER 154
13629
+#define TK_ADD 155
13630
+#define TK_WINDOW 156
13631
+#define TK_OVER 157
13632
+#define TK_FILTER 158
13633
+#define TK_TRUEFALSE 159
13634
+#define TK_ISNOT 160
13635
+#define TK_FUNCTION 161
13636
+#define TK_COLUMN 162
13637
+#define TK_AGG_FUNCTION 163
13638
+#define TK_AGG_COLUMN 164
13639
+#define TK_UMINUS 165
13640
+#define TK_UPLUS 166
13641
+#define TK_TRUTH 167
13642
+#define TK_REGISTER 168
13643
+#define TK_VECTOR 169
13644
+#define TK_SELECT_COLUMN 170
13645
+#define TK_IF_NULL_ROW 171
13646
+#define TK_ASTERISK 172
13647
+#define TK_SPAN 173
13648
+#define TK_END_OF_FILE 174
13649
+#define TK_UNCLOSED_STRING 175
13650
+#define TK_SPACE 176
13651
+#define TK_ILLEGAL 177
1362513652
1362613653
/* The token codes above must all fit in 8 bits */
1362713654
#define TKFLG_MASK 0xff
1362813655
1362913656
/* Flags that can be added to a token code when it is not
@@ -14558,13 +14585,10 @@
1455814585
};
1455914586
1456014587
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
1456114588
int flags, int seekResult);
1456214589
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
14563
-#ifndef SQLITE_OMIT_WINDOWFUNC
14564
-SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor*);
14565
-#endif
1456614590
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
1456714591
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
1456814592
SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
1456914593
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
1457014594
SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14918,29 +14942,29 @@
1491814942
#define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
1491914943
#define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
1492014944
#define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */
1492114945
#define OP_Column 90 /* synopsis: r[P3]=PX */
1492214946
#define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
14923
-#define OP_BitAnd 92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14924
-#define OP_BitOr 93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14925
-#define OP_ShiftLeft 94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14926
-#define OP_ShiftRight 95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14927
-#define OP_Add 96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14928
-#define OP_Subtract 97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14929
-#define OP_Multiply 98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14930
-#define OP_Divide 99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14931
-#define OP_Remainder 100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14932
-#define OP_Concat 101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14933
-#define OP_MakeRecord 102 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14934
-#define OP_BitNot 103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14935
-#define OP_Count 104 /* synopsis: r[P2]=count() */
14936
-#define OP_ReadCookie 105
14937
-#define OP_String8 106 /* same as TK_STRING, synopsis: r[P2]='P4' */
14938
-#define OP_SetCookie 107
14939
-#define OP_ReopenIdx 108 /* synopsis: root=P2 iDb=P3 */
14940
-#define OP_OpenRead 109 /* synopsis: root=P2 iDb=P3 */
14941
-#define OP_OpenWrite 110 /* synopsis: root=P2 iDb=P3 */
14947
+#define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14948
+#define OP_Count 93 /* synopsis: r[P2]=count() */
14949
+#define OP_ReadCookie 94
14950
+#define OP_SetCookie 95
14951
+#define OP_BitAnd 96 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14952
+#define OP_BitOr 97 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14953
+#define OP_ShiftLeft 98 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14954
+#define OP_ShiftRight 99 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14955
+#define OP_Add 100 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14956
+#define OP_Subtract 101 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14957
+#define OP_Multiply 102 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14958
+#define OP_Divide 103 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14959
+#define OP_Remainder 104 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14960
+#define OP_Concat 105 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14961
+#define OP_ReopenIdx 106 /* synopsis: root=P2 iDb=P3 */
14962
+#define OP_BitNot 107 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14963
+#define OP_OpenRead 108 /* synopsis: root=P2 iDb=P3 */
14964
+#define OP_OpenWrite 109 /* synopsis: root=P2 iDb=P3 */
14965
+#define OP_String8 110 /* same as TK_STRING, synopsis: r[P2]='P4' */
1494214966
#define OP_OpenDup 111
1494314967
#define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */
1494414968
#define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */
1494514969
#define OP_SorterOpen 114
1494614970
#define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
@@ -14967,15 +14991,15 @@
1496714991
#define OP_Destroy 136
1496814992
#define OP_Clear 137
1496914993
#define OP_ResetSorter 138
1497014994
#define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
1497114995
#define OP_SqlExec 140
14972
-#define OP_Real 141 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
14973
-#define OP_ParseSchema 142
14974
-#define OP_LoadAnalysis 143
14975
-#define OP_DropTable 144
14976
-#define OP_DropIndex 145
14996
+#define OP_ParseSchema 141
14997
+#define OP_LoadAnalysis 142
14998
+#define OP_DropTable 143
14999
+#define OP_DropIndex 144
15000
+#define OP_Real 145 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
1497715001
#define OP_DropTrigger 146
1497815002
#define OP_IntegrityCk 147
1497915003
#define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
1498015004
#define OP_Param 149
1498115005
#define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
@@ -15022,18 +15046,18 @@
1502215046
/* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1502315047
/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
1502415048
/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
1502515049
/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
1502615050
/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15027
-/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26,\
15028
-/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
15029
-/* 104 */ 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15051
+/* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15052
+/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15053
+/* 104 */ 0x26, 0x26, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00,\
1503015054
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1503115055
/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1503215056
/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15033
-/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00,\
15034
-/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15057
+/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15058
+/* 144 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
1503515059
/* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1503615060
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
1503715061
/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
1503815062
1503915063
/* The sqlite3P2Values() routine is able to run faster if it knows
@@ -16479,11 +16503,11 @@
1647916503
** Bits of the sqlite3.dbOptFlags field that are used by the
1648016504
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
1648116505
** selectively disable various optimizations.
1648216506
*/
1648316507
#define SQLITE_QueryFlattener 0x0001 /* Query flattening */
16484
- /* 0x0002 available for reuse */
16508
+#define SQLITE_WindowFunc 0x0002 /* Use xInverse for window functions */
1648516509
#define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */
1648616510
#define SQLITE_FactorOutConst 0x0008 /* Constant factoring */
1648716511
#define SQLITE_DistinctOpt 0x0010 /* DISTINCT using indexes */
1648816512
#define SQLITE_CoverIdxScan 0x0020 /* Covering index scans */
1648916513
#define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
@@ -16597,11 +16621,10 @@
1659716621
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
1659816622
** single query - might change over time */
1659916623
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
1660016624
#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
1660116625
#define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
16602
-#define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
1660316626
#define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
1660416627
1660516628
/*
1660616629
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
1660716630
** used to create the initializers for the FuncDef structures.
@@ -17403,16 +17426,20 @@
1740317426
} y;
1740417427
};
1740517428
1740617429
/*
1740717430
** The following are the meanings of bits in the Expr.flags field.
17431
+** Value restrictions:
17432
+**
17433
+** EP_Agg == NC_HasAgg == SF_HasAgg
17434
+** EP_Win == NC_HasWin
1740817435
*/
1740917436
#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17410
-#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
17437
+#define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
1741117438
#define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
1741217439
#define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17413
-#define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
17440
+#define EP_Agg 0x000010 /* Contains one or more aggregate functions */
1741417441
#define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
1741517442
#define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
1741617443
#define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
1741717444
#define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
1741817445
#define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
@@ -17419,11 +17446,11 @@
1741917446
#define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
1742017447
#define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
1742117448
#define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */
1742217449
#define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
1742317450
#define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17424
-#define EP_Static 0x008000 /* Held in memory not obtained from malloc() */
17451
+#define EP_Win 0x008000 /* Contains window functions */
1742517452
#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
1742617453
#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
1742717454
#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
1742817455
#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
1742917456
#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
@@ -17431,10 +17458,11 @@
1743117458
#define EP_Alias 0x400000 /* Is an alias for a result set column */
1743217459
#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
1743317460
#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
1743417461
#define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
1743517462
#define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17463
+#define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
1743617464
1743717465
/*
1743817466
** The EP_Propagate mask is a set of properties that automatically propagate
1743917467
** upwards into parent nodes.
1744017468
*/
@@ -17670,12 +17698,13 @@
1767017698
1767117699
/*
1767217700
** Allowed values for the NameContext, ncFlags field.
1767317701
**
1767417702
** Value constraints (all checked via assert()):
17675
-** NC_HasAgg == SF_HasAgg
17703
+** NC_HasAgg == SF_HasAgg == EP_Agg
1767617704
** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17705
+** NC_HasWin == EP_Win
1767717706
**
1767817707
*/
1767917708
#define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
1768017709
#define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */
1768117710
#define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
@@ -17687,10 +17716,11 @@
1768717716
#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
1768817717
#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
1768917718
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
1769017719
#define NC_Complex 0x2000 /* True if a function or subquery seen */
1769117720
#define NC_AllowWin 0x4000 /* Window functions are allowed here */
17721
+#define NC_HasWin 0x8000 /* One or more window functions seen */
1769217722
1769317723
/*
1769417724
** An instance of the following object describes a single ON CONFLICT
1769517725
** clause in an upsert.
1769617726
**
@@ -18442,11 +18472,11 @@
1844218472
u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
1844318473
};
1844418474
#endif /* SQLITE_DEBUG */
1844518475
1844618476
/*
18447
-** This object is used in varioius ways, all related to window functions
18477
+** This object is used in various ways, all related to window functions
1844818478
**
1844918479
** (1) A single instance of this structure is attached to the
1845018480
** the Expr.pWin field for each window function in an expression tree.
1845118481
** This object holds the information contained in the OVER clause,
1845218482
** plus additional fields used during code generation.
@@ -18457,19 +18487,22 @@
1845718487
**
1845818488
** (3) The terms of the WINDOW clause of a SELECT are instances of this
1845918489
** object on a linked list attached to Select.pWinDefn.
1846018490
**
1846118491
** The uses (1) and (2) are really the same Window object that just happens
18462
-** to be accessible in two different ways. Use (3) is are separate objects.
18492
+** to be accessible in two different ways. Use case (3) are separate objects.
1846318493
*/
1846418494
struct Window {
1846518495
char *zName; /* Name of window (may be NULL) */
18496
+ char *zBase; /* Name of base window for chaining (may be NULL) */
1846618497
ExprList *pPartition; /* PARTITION BY clause */
1846718498
ExprList *pOrderBy; /* ORDER BY clause */
18468
- u8 eType; /* TK_RANGE or TK_ROWS */
18499
+ u8 eFrmType; /* TK_RANGE, TK_GROUPS, TK_ROWS, or 0 */
1846918500
u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
1847018501
u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18502
+ u8 bImplicitFrame; /* True if frame was implicitly specified */
18503
+ u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */
1847118504
Expr *pStart; /* Expression for "<expr> PRECEDING" */
1847218505
Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
1847318506
Window *pNextWin; /* Next window function belonging to this SELECT */
1847418507
Expr *pFilter; /* The FILTER expression */
1847518508
FuncDef *pFunc; /* The function */
@@ -18476,21 +18509,23 @@
1847618509
int iEphCsr; /* Partition buffer or Peer buffer */
1847718510
int regAccum;
1847818511
int regResult;
1847918512
int csrApp; /* Function cursor (used by min/max) */
1848018513
int regApp; /* Function register (also used by min/max) */
18481
- int regPart; /* First in a set of registers holding PARTITION BY
18482
- ** and ORDER BY values for the window */
18514
+ int regPart; /* Array of registers for PARTITION BY values */
1848318515
Expr *pOwner; /* Expression object this window is attached to */
1848418516
int nBufferCol; /* Number of columns in buffer table */
1848518517
int iArgCol; /* Offset of first argument for this function */
18518
+ int regOne; /* Register containing constant value 1 */
18519
+ int regStartRowid;
18520
+ int regEndRowid;
1848618521
};
1848718522
1848818523
#ifndef SQLITE_OMIT_WINDOWFUNC
1848918524
SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
1849018525
SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18491
-SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
18526
+SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
1849218527
SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
1849318528
SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
1849418529
SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
1849518530
SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
1849618531
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
@@ -18497,10 +18532,12 @@
1849718532
SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
1849818533
SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
1849918534
SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
1850018535
SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
1850118536
SQLITE_PRIVATE void sqlite3WindowFunctions(void);
18537
+SQLITE_PRIVATE void sqlite3WindowChain(Parse*, Window*, Window*);
18538
+SQLITE_PRIVATE Window *sqlite3WindowAssemble(Parse*, Window*, ExprList*, ExprList*, Token*);
1850218539
#else
1850318540
# define sqlite3WindowDelete(a,b)
1850418541
# define sqlite3WindowFunctions()
1850518542
# define sqlite3WindowAttach(a,b,c)
1850618543
#endif
@@ -20149,15 +20186,15 @@
2014920186
#define MEM_Str 0x0002 /* Value is a string */
2015020187
#define MEM_Int 0x0004 /* Value is an integer */
2015120188
#define MEM_Real 0x0008 /* Value is a real number */
2015220189
#define MEM_Blob 0x0010 /* Value is a BLOB */
2015320190
#define MEM_AffMask 0x001f /* Mask of affinity bits */
20154
-/* Available 0x0020 */
20191
+#define MEM_FromBind 0x0020 /* Value originates from sqlite3_bind() */
2015520192
/* Available 0x0040 */
2015620193
#define MEM_Undefined 0x0080 /* Value is undefined */
2015720194
#define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
20158
-#define MEM_TypeMask 0xc1ff /* Mask of type bits */
20195
+#define MEM_TypeMask 0xc1df /* Mask of type bits */
2015920196
2016020197
2016120198
/* Whenever Mem contains a valid string or blob representation, one of
2016220199
** the following flags must be set to determine the memory management
2016320200
** policy for Mem.z. The MEM_Term flag tells us whether or not the
@@ -28786,28 +28823,66 @@
2878628823
#ifndef SQLITE_OMIT_WINDOWFUNC
2878728824
/*
2878828825
** Generate a human-readable explanation for a Window object
2878928826
*/
2879028827
SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){
28828
+ int nElement = 0;
28829
+ if( pWin->pFilter ){
28830
+ sqlite3TreeViewItem(pView, "FILTER", 1);
28831
+ sqlite3TreeViewExpr(pView, pWin->pFilter, 0);
28832
+ sqlite3TreeViewPop(pView);
28833
+ }
2879128834
pView = sqlite3TreeViewPush(pView, more);
2879228835
if( pWin->zName ){
28793
- sqlite3TreeViewLine(pView, "OVER %s", pWin->zName);
28836
+ sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin);
2879428837
}else{
28795
- sqlite3TreeViewLine(pView, "OVER");
28838
+ sqlite3TreeViewLine(pView, "OVER (%p)", pWin);
28839
+ }
28840
+ if( pWin->zBase ) nElement++;
28841
+ if( pWin->pOrderBy ) nElement++;
28842
+ if( pWin->eFrmType ) nElement++;
28843
+ if( pWin->eExclude ) nElement++;
28844
+ if( pWin->zBase ){
28845
+ sqlite3TreeViewPush(pView, (--nElement)>0);
28846
+ sqlite3TreeViewLine(pView, "window: %s", pWin->zBase);
28847
+ sqlite3TreeViewPop(pView);
2879628848
}
2879728849
if( pWin->pPartition ){
28798
- sqlite3TreeViewExprList(pView, pWin->pPartition, 1, "PARTITION-BY");
28850
+ sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY");
2879928851
}
2880028852
if( pWin->pOrderBy ){
28801
- sqlite3TreeViewExprList(pView, pWin->pOrderBy, 1, "ORDER-BY");
28853
+ sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY");
2880228854
}
28803
- if( pWin->eType ){
28804
- sqlite3TreeViewItem(pView, pWin->eType==TK_RANGE ? "RANGE" : "ROWS", 0);
28855
+ if( pWin->eFrmType ){
28856
+ char zBuf[30];
28857
+ const char *zFrmType = "ROWS";
28858
+ if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE";
28859
+ if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS";
28860
+ sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType,
28861
+ pWin->bImplicitFrame ? " (implied)" : "");
28862
+ sqlite3TreeViewItem(pView, zBuf, (--nElement)>0);
2880528863
sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
2880628864
sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
2880728865
sqlite3TreeViewPop(pView);
2880828866
}
28867
+ if( pWin->eExclude ){
28868
+ char zBuf[30];
28869
+ const char *zExclude;
28870
+ switch( pWin->eExclude ){
28871
+ case TK_NO: zExclude = "NO OTHERS"; break;
28872
+ case TK_CURRENT: zExclude = "CURRENT ROW"; break;
28873
+ case TK_GROUP: zExclude = "GROUP"; break;
28874
+ case TK_TIES: zExclude = "TIES"; break;
28875
+ default:
28876
+ sqlite3_snprintf(sizeof(zBuf),zBuf,"invalid(%d)", pWin->eExclude);
28877
+ zExclude = zBuf;
28878
+ break;
28879
+ }
28880
+ sqlite3TreeViewPush(pView, 0);
28881
+ sqlite3TreeViewLine(pView, "EXCLUDE %s", zExclude);
28882
+ sqlite3TreeViewPop(pView);
28883
+ }
2880928884
sqlite3TreeViewPop(pView);
2881028885
}
2881128886
#endif /* SQLITE_OMIT_WINDOWFUNC */
2881228887
2881328888
#ifndef SQLITE_OMIT_WINDOWFUNC
@@ -32124,29 +32199,29 @@
3212432199
/* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
3212532200
/* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
3212632201
/* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
3212732202
/* 90 */ "Column" OpHelp("r[P3]=PX"),
3212832203
/* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32129
- /* 92 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32130
- /* 93 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32131
- /* 94 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32132
- /* 95 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32133
- /* 96 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32134
- /* 97 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32135
- /* 98 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32136
- /* 99 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32137
- /* 100 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32138
- /* 101 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32139
- /* 102 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32140
- /* 103 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32141
- /* 104 */ "Count" OpHelp("r[P2]=count()"),
32142
- /* 105 */ "ReadCookie" OpHelp(""),
32143
- /* 106 */ "String8" OpHelp("r[P2]='P4'"),
32144
- /* 107 */ "SetCookie" OpHelp(""),
32145
- /* 108 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32146
- /* 109 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32147
- /* 110 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32204
+ /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32205
+ /* 93 */ "Count" OpHelp("r[P2]=count()"),
32206
+ /* 94 */ "ReadCookie" OpHelp(""),
32207
+ /* 95 */ "SetCookie" OpHelp(""),
32208
+ /* 96 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32209
+ /* 97 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32210
+ /* 98 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32211
+ /* 99 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32212
+ /* 100 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32213
+ /* 101 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32214
+ /* 102 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32215
+ /* 103 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32216
+ /* 104 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32217
+ /* 105 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32218
+ /* 106 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32219
+ /* 107 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32220
+ /* 108 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32221
+ /* 109 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32222
+ /* 110 */ "String8" OpHelp("r[P2]='P4'"),
3214832223
/* 111 */ "OpenDup" OpHelp(""),
3214932224
/* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"),
3215032225
/* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"),
3215132226
/* 114 */ "SorterOpen" OpHelp(""),
3215232227
/* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
@@ -32173,15 +32248,15 @@
3217332248
/* 136 */ "Destroy" OpHelp(""),
3217432249
/* 137 */ "Clear" OpHelp(""),
3217532250
/* 138 */ "ResetSorter" OpHelp(""),
3217632251
/* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
3217732252
/* 140 */ "SqlExec" OpHelp(""),
32178
- /* 141 */ "Real" OpHelp("r[P2]=P4"),
32179
- /* 142 */ "ParseSchema" OpHelp(""),
32180
- /* 143 */ "LoadAnalysis" OpHelp(""),
32181
- /* 144 */ "DropTable" OpHelp(""),
32182
- /* 145 */ "DropIndex" OpHelp(""),
32253
+ /* 141 */ "ParseSchema" OpHelp(""),
32254
+ /* 142 */ "LoadAnalysis" OpHelp(""),
32255
+ /* 143 */ "DropTable" OpHelp(""),
32256
+ /* 144 */ "DropIndex" OpHelp(""),
32257
+ /* 145 */ "Real" OpHelp("r[P2]=P4"),
3218332258
/* 146 */ "DropTrigger" OpHelp(""),
3218432259
/* 147 */ "IntegrityCk" OpHelp(""),
3218532260
/* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
3218632261
/* 149 */ "Param" OpHelp(""),
3218732262
/* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
@@ -59204,10 +59279,11 @@
5920459279
static void walCleanupHash(Wal *pWal){
5920559280
WalHashLoc sLoc; /* Hash table location */
5920659281
int iLimit = 0; /* Zero values greater than this */
5920759282
int nByte; /* Number of bytes to zero in aPgno[] */
5920859283
int i; /* Used to iterate through aHash[] */
59284
+ int rc; /* Return code form walHashGet() */
5920959285
5921059286
assert( pWal->writeLock );
5921159287
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
5921259288
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
5921359289
testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -59214,15 +59290,16 @@
5921459290
5921559291
if( pWal->hdr.mxFrame==0 ) return;
5921659292
5921759293
/* Obtain pointers to the hash-table and page-number array containing
5921859294
** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
59219
- ** that the page said hash-table and array reside on is already mapped.
59295
+ ** that the page said hash-table and array reside on is already mapped.(1)
5922059296
*/
5922159297
assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
5922259298
assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
59223
- walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
59299
+ rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
59300
+ if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
5922459301
5922559302
/* Zero all hash-table entries that correspond to frame numbers greater
5922659303
** than pWal->hdr.mxFrame.
5922759304
*/
5922859305
iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -63922,18 +63999,22 @@
6392263999
** at most one effective restoreCursorPosition() call after each
6392364000
** saveCursorPosition().
6392464001
*/
6392564002
static int btreeRestoreCursorPosition(BtCursor *pCur){
6392664003
int rc;
63927
- int skipNext;
64004
+ int skipNext = 0;
6392864005
assert( cursorOwnsBtShared(pCur) );
6392964006
assert( pCur->eState>=CURSOR_REQUIRESEEK );
6393064007
if( pCur->eState==CURSOR_FAULT ){
6393164008
return pCur->skipNext;
6393264009
}
6393364010
pCur->eState = CURSOR_INVALID;
63934
- rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
64011
+ if( sqlite3FaultSim(410) ){
64012
+ rc = SQLITE_IOERR;
64013
+ }else{
64014
+ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
64015
+ }
6393564016
if( rc==SQLITE_OK ){
6393664017
sqlite3_free(pCur->pKey);
6393764018
pCur->pKey = 0;
6393864019
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
6393964020
if( skipNext ) pCur->skipNext = skipNext;
@@ -64521,15 +64602,11 @@
6452164602
** two (or one) blocks of cells using memmove() and add the required
6452264603
** offsets to each pointer in the cell-pointer array than it is to
6452364604
** reconstruct the entire page. */
6452464605
if( (int)data[hdr+7]<=nMaxFrag ){
6452564606
int iFree = get2byte(&data[hdr+1]);
64526
-
64527
- /* If the initial freeblock offset were out of bounds, that would have
64528
- ** been detected by btreeComputeFreeSpace() when it was computing the
64529
- ** number of free bytes on the page. */
64530
- assert( iFree<=usableSize-4 );
64607
+ if( iFree>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
6453164608
if( iFree ){
6453264609
int iFree2 = get2byte(&data[iFree]);
6453364610
if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
6453464611
if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
6453564612
u8 *pEnd = &data[cellOffset + nCell*2];
@@ -64544,11 +64621,14 @@
6454464621
if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
6454564622
sz2 = get2byte(&data[iFree2+2]);
6454664623
if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
6454764624
memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
6454864625
sz += sz2;
64626
+ }else if( iFree+sz>usableSize ){
64627
+ return SQLITE_CORRUPT_PAGE(pPage);
6454964628
}
64629
+
6455064630
cbrk = top+sz;
6455164631
assert( cbrk+(iFree-top) <= usableSize );
6455264632
memmove(&data[cbrk], &data[top], iFree-top);
6455364633
for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){
6455464634
pc = get2byte(pAddr);
@@ -65102,11 +65182,11 @@
6510265182
/* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
6510365183
** possible for a root page of a table that contains no rows) then the
6510465184
** offset to the cell content area will equal the page size minus the
6510565185
** bytes of reserved space. */
6510665186
assert( pPage->nCell>0
65107
- || get2byteNotZero(&data[5])==pBt->usableSize
65187
+ || get2byteNotZero(&data[5])==(int)pBt->usableSize
6510865188
|| CORRUPT_DB );
6510965189
pPage->nFree = -1; /* Indicate that this value is yet uncomputed */
6511065190
pPage->isInit = 1;
6511165191
if( pBt->db->flags & SQLITE_CellSizeCk ){
6511265192
return btreeCellSizeCheck(pPage);
@@ -68359,27 +68439,10 @@
6835968439
rc = SQLITE_OK;
6836068440
}
6836168441
return rc;
6836268442
}
6836368443
68364
-/*
68365
-** This function is a no-op if cursor pCur does not point to a valid row.
68366
-** Otherwise, if pCur is valid, configure it so that the next call to
68367
-** sqlite3BtreeNext() is a no-op.
68368
-*/
68369
-#ifndef SQLITE_OMIT_WINDOWFUNC
68370
-SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor *pCur){
68371
- /* We believe that the cursor must always be in the valid state when
68372
- ** this routine is called, but the proof is difficult, so we add an
68373
- ** ALWaYS() test just in case we are wrong. */
68374
- if( ALWAYS(pCur->eState==CURSOR_VALID) ){
68375
- pCur->eState = CURSOR_SKIPNEXT;
68376
- pCur->skipNext = 1;
68377
- }
68378
-}
68379
-#endif /* SQLITE_OMIT_WINDOWFUNC */
68380
-
6838168444
/* Move the cursor to the last entry in the table. Return SQLITE_OK
6838268445
** on success. Set *pRes to 0 if the cursor actually points to something
6838368446
** or set *pRes to 1 if the table is empty.
6838468447
*/
6838568448
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -69279,11 +69342,13 @@
6927969342
6928069343
assert( sqlite3_mutex_held(pBt->mutex) );
6928169344
assert( CORRUPT_DB || iPage>1 );
6928269345
assert( !pMemPage || pMemPage->pgno==iPage );
6928369346
69284
- if( iPage<2 ) return SQLITE_CORRUPT_BKPT;
69347
+ if( iPage<2 || iPage>pBt->nPage ){
69348
+ return SQLITE_CORRUPT_BKPT;
69349
+ }
6928569350
if( pMemPage ){
6928669351
pPage = pMemPage;
6928769352
sqlite3PagerRef(pPage->pDbPage);
6928869353
}else{
6928969354
pPage = btreePageLookup(pBt, iPage);
@@ -70648,11 +70713,10 @@
7064870713
if( rc ){
7064970714
memset(apOld, 0, (i)*sizeof(MemPage*));
7065070715
goto balance_cleanup;
7065170716
}
7065270717
}
70653
- nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
7065470718
if( (i--)==0 ) break;
7065570719
7065670720
if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
7065770721
apDiv[i] = pParent->apOvfl[0];
7065870722
pgno = get4byte(apDiv[i]);
@@ -70692,10 +70756,11 @@
7069270756
}
7069370757
}
7069470758
7069570759
/* Make nMaxCells a multiple of 4 in order to preserve 8-byte
7069670760
** alignment */
70761
+ nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
7069770762
nMaxCells = (nMaxCells + 3)&~3;
7069870763
7069970764
/*
7070070765
** Allocate space for memory structures
7070170766
*/
@@ -70702,11 +70767,11 @@
7070270767
szScratch =
7070370768
nMaxCells*sizeof(u8*) /* b.apCell */
7070470769
+ nMaxCells*sizeof(u16) /* b.szCell */
7070570770
+ pBt->pageSize; /* aSpace1 */
7070670771
70707
- assert( szScratch<=6*(int)pBt->pageSize );
70772
+ assert( szScratch<=7*(int)pBt->pageSize );
7070870773
b.apCell = sqlite3StackAllocRaw(0, szScratch );
7070970774
if( b.apCell==0 ){
7071070775
rc = SQLITE_NOMEM_BKPT;
7071170776
goto balance_cleanup;
7071270777
}
@@ -71252,11 +71317,12 @@
7125271317
*/
7125371318
assert( nNew==1 || CORRUPT_DB );
7125471319
rc = defragmentPage(apNew[0], -1);
7125571320
testcase( rc!=SQLITE_OK );
7125671321
assert( apNew[0]->nFree ==
71257
- (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
71322
+ (get2byteNotZero(&apNew[0]->aData[5]) - apNew[0]->cellOffset
71323
+ - apNew[0]->nCell*2)
7125871324
|| rc!=SQLITE_OK
7125971325
);
7126071326
copyNodeContent(apNew[0], pParent, &rc);
7126171327
freePage(apNew[0], &rc);
7126271328
}else if( ISAUTOVACUUM && !leafCorrection ){
@@ -71917,13 +71983,16 @@
7191771983
assert( pBt->inTransaction==TRANS_WRITE );
7191871984
assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );
7191971985
assert( pCur->curFlags & BTCF_WriteFlag );
7192071986
assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
7192171987
assert( !hasReadConflicts(p, pCur->pgnoRoot) );
71922
- assert( pCur->ix<pCur->pPage->nCell );
71923
- assert( pCur->eState==CURSOR_VALID );
7192471988
assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
71989
+ if( pCur->eState==CURSOR_REQUIRESEEK ){
71990
+ rc = btreeRestoreCursorPosition(pCur);
71991
+ if( rc ) return rc;
71992
+ }
71993
+ assert( pCur->eState==CURSOR_VALID );
7192571994
7192671995
iCellDepth = pCur->iPage;
7192771996
iCellIdx = pCur->ix;
7192871997
pPage = pCur->pPage;
7192971998
pCell = findCell(pPage, iCellIdx);
@@ -74387,11 +74456,11 @@
7438774456
assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +
7438874457
((p->flags&MEM_Ephem)!=0 ? 1 : 0) +
7438974458
((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );
7439074459
7439174460
/* No other bits set */
74392
- assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype
74461
+ assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype|MEM_FromBind
7439374462
|MEM_Dyn|MEM_Ephem|MEM_Static))==0 );
7439474463
}else{
7439574464
/* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,
7439674465
** MEM_Ephem, MEM_Cleared, or MEM_Subtype */
7439774466
}
@@ -81474,10 +81543,15 @@
8147481543
8147581544
/* Return true if a parameter to xUpdate represents an unchanged column */
8147681545
SQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){
8147781546
return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero);
8147881547
}
81548
+
81549
+/* Return true if a parameter value originated from an sqlite3_bind() */
81550
+SQLITE_API int sqlite3_value_frombind(sqlite3_value *pVal){
81551
+ return (pVal->flags&MEM_FromBind)!=0;
81552
+}
8147981553
8148081554
/* Make a copy of an sqlite3_value object
8148181555
*/
8148281556
SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){
8148381557
sqlite3_value *pNew;
@@ -83505,16 +83579,24 @@
8350583579
/*
8350683580
** Invoke the VDBE coverage callback, if that callback is defined. This
8350783581
** feature is used for test suite validation only and does not appear an
8350883582
** production builds.
8350983583
**
83510
-** M is an integer between 2 and 4. 2 indicates a ordinary two-way
83511
-** branch (I=0 means fall through and I=1 means taken). 3 indicates
83512
-** a 3-way branch where the third way is when one of the operands is
83513
-** NULL. 4 indicates the OP_Jump instruction which has three destinations
83514
-** depending on whether the first operand is less than, equal to, or greater
83515
-** than the second.
83584
+** M is the type of branch. I is the direction taken for this instance of
83585
+** the branch.
83586
+**
83587
+** M: 2 - two-way branch (I=0: fall-thru 1: jump )
83588
+** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL )
83589
+** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3)
83590
+**
83591
+** In other words, if M is 2, then I is either 0 (for fall-through) or
83592
+** 1 (for when the branch is taken). If M is 3, the I is 0 for an
83593
+** ordinary fall-through, I is 1 if the branch was taken, and I is 2
83594
+** if the result of comparison is NULL. For M=3, I=2 the jump may or
83595
+** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5.
83596
+** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2
83597
+** depending on if the operands are less than, equal, or greater than.
8351683598
**
8351783599
** iSrcLine is the source code line (from the __LINE__ macro) that
8351883600
** generated the VDBE instruction combined with flag bits. The source
8351983601
** code line number is in the lower 24 bits of iSrcLine and the upper
8352083602
** 8 bytes are flags. The lower three bits of the flags indicate
@@ -83521,13 +83603,13 @@
8352183603
** values for I that should never occur. For example, if the branch is
8352283604
** always taken, the flags should be 0x05 since the fall-through and
8352383605
** alternate branch are never taken. If a branch is never taken then
8352483606
** flags should be 0x06 since only the fall-through approach is allowed.
8352583607
**
83526
-** Bit 0x04 of the flags indicates an OP_Jump opcode that is only
83608
+** Bit 0x08 of the flags indicates an OP_Jump opcode that is only
8352783609
** interested in equal or not-equal. In other words, I==0 and I==2
83528
-** should be treated the same.
83610
+** should be treated as equivalent
8352983611
**
8353083612
** Since only a line number is retained, not the filename, this macro
8353183613
** only works for amalgamation builds. But that is ok, since these macros
8353283614
** should be no-ops except for special builds used to measure test coverage.
8353383615
*/
@@ -83547,10 +83629,22 @@
8354783629
** a branch really does go in one of those directions, assert right
8354883630
** away. */
8354983631
mNever = iSrcLine >> 24;
8355083632
assert( (I & mNever)==0 );
8355183633
if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
83634
+ /* Invoke the branch coverage callback with three arguments:
83635
+ ** iSrcLine - the line number of the VdbeCoverage() macro, with
83636
+ ** flags removed.
83637
+ ** I - Mask of bits 0x07 indicating which cases are are
83638
+ ** fulfilled by this instance of the jump. 0x01 means
83639
+ ** fall-thru, 0x02 means taken, 0x04 means NULL. Any
83640
+ ** impossible cases (ex: if the comparison is never NULL)
83641
+ ** are filled in automatically so that the coverage
83642
+ ** measurement logic does not flag those impossible cases
83643
+ ** as missed coverage.
83644
+ ** M - Type of jump. Same as M argument above
83645
+ */
8355283646
I |= mNever;
8355383647
if( M==2 ) I |= 0x04;
8355483648
if( M==4 ){
8355583649
I |= 0x08;
8355683650
if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/
@@ -84708,11 +84802,14 @@
8470884802
pVar = &p->aVar[pOp->p1 - 1];
8470984803
if( sqlite3VdbeMemTooBig(pVar) ){
8471084804
goto too_big;
8471184805
}
8471284806
pOut = &aMem[pOp->p2];
84713
- sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
84807
+ if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
84808
+ memcpy(pOut, pVar, MEMCELLSIZE);
84809
+ pOut->flags &= ~(MEM_Dyn|MEM_Ephem);
84810
+ pOut->flags |= MEM_Static|MEM_FromBind;
8471484811
UPDATE_MAX_BLOBSIZE(pOut);
8471584812
break;
8471684813
}
8471784814
8471884815
/* Opcode: Move P1 P2 P3 * *
@@ -85206,20 +85303,21 @@
8520685303
*/
8520785304
case OP_MustBeInt: { /* jump, in1 */
8520885305
pIn1 = &aMem[pOp->p1];
8520985306
if( (pIn1->flags & MEM_Int)==0 ){
8521085307
applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
85211
- VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2);
8521285308
if( (pIn1->flags & MEM_Int)==0 ){
85309
+ VdbeBranchTaken(1, 2);
8521385310
if( pOp->p2==0 ){
8521485311
rc = SQLITE_MISMATCH;
8521585312
goto abort_due_to_error;
8521685313
}else{
8521785314
goto jump_to_p2;
8521885315
}
8521985316
}
8522085317
}
85318
+ VdbeBranchTaken(0, 2);
8522185319
MemSetTypeFlag(pIn1, MEM_Int);
8522285320
break;
8522385321
}
8522485322
8522585323
#ifndef SQLITE_OMIT_FLOATING_POINT
@@ -85390,20 +85488,19 @@
8539085488
if( pOp->p5 & SQLITE_NULLEQ ){
8539185489
/* If SQLITE_NULLEQ is set (which will only happen if the operator is
8539285490
** OP_Eq or OP_Ne) then take the jump or not depending on whether
8539385491
** or not both operands are null.
8539485492
*/
85395
- assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
8539685493
assert( (flags1 & MEM_Cleared)==0 );
8539785494
assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );
8539885495
testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );
8539985496
if( (flags1&flags3&MEM_Null)!=0
8540085497
&& (flags3&MEM_Cleared)==0
8540185498
){
8540285499
res = 0; /* Operands are equal */
8540385500
}else{
85404
- res = 1; /* Operands are not equal */
85501
+ res = ((flags3 & MEM_Null) ? -1 : +1); /* Operands are not equal */
8540585502
}
8540685503
}else{
8540785504
/* SQLITE_NULLEQ is clear and at least one operand is NULL,
8540885505
** then the result is always NULL.
8540985506
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
@@ -85517,11 +85614,11 @@
8551785614
memAboutToChange(p, pOut);
8551885615
MemSetTypeFlag(pOut, MEM_Int);
8551985616
pOut->u.i = res2;
8552085617
REGISTER_TRACE(pOp->p2, pOut);
8552185618
}else{
85522
- VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
85619
+ VdbeBranchTaken(res2!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
8552385620
if( res2 ){
8552485621
goto jump_to_p2;
8552585622
}
8552685623
}
8552785624
break;
@@ -87078,10 +87175,11 @@
8707887175
pCx->nullRow = 1;
8707987176
pCx->isEphemeral = 1;
8708087177
pCx->pKeyInfo = pOrig->pKeyInfo;
8708187178
pCx->isTable = pOrig->isTable;
8708287179
pCx->pgnoRoot = pOrig->pgnoRoot;
87180
+ pCx->isOrdered = pOrig->isOrdered;
8708387181
rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
8708487182
pCx->pKeyInfo, pCx->uc.pCursor);
8708587183
/* The sqlite3BtreeCursor() routine can only fail for the first cursor
8708687184
** opened for a database. Since there is already an open cursor when this
8708787185
** opcode is run, the sqlite3BtreeCursor() cannot fail */
@@ -88586,22 +88684,18 @@
8858688684
sqlite3_search_count--;
8858788685
#endif
8858888686
p->aCounter[SQLITE_STMTSTATUS_SORT]++;
8858988687
/* Fall through into OP_Rewind */
8859088688
}
88591
-/* Opcode: Rewind P1 P2 * * P5
88689
+/* Opcode: Rewind P1 P2 * * *
8859288690
**
8859388691
** The next use of the Rowid or Column or Next instruction for P1
8859488692
** will refer to the first entry in the database table or index.
8859588693
** If the table or index is empty, jump immediately to P2.
8859688694
** If the table or index is not empty, fall through to the following
8859788695
** instruction.
8859888696
**
88599
-** If P5 is non-zero and the table is not empty, then the "skip-next"
88600
-** flag is set on the cursor so that the next OP_Next instruction
88601
-** executed on it is a no-op.
88602
-**
8860388697
** This opcode leaves the cursor configured to move in forward order,
8860488698
** from the beginning toward the end. In other words, the cursor is
8860588699
** configured to use Next, not Prev.
8860688700
*/
8860788701
case OP_Rewind: { /* jump */
@@ -88608,10 +88702,11 @@
8860888702
VdbeCursor *pC;
8860988703
BtCursor *pCrsr;
8861088704
int res;
8861188705
8861288706
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
88707
+ assert( pOp->p5==0 );
8861388708
pC = p->apCsr[pOp->p1];
8861488709
assert( pC!=0 );
8861588710
assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );
8861688711
res = 1;
8861788712
#ifdef SQLITE_DEBUG
@@ -88622,13 +88717,10 @@
8862288717
}else{
8862388718
assert( pC->eCurType==CURTYPE_BTREE );
8862488719
pCrsr = pC->uc.pCursor;
8862588720
assert( pCrsr );
8862688721
rc = sqlite3BtreeFirst(pCrsr, &res);
88627
-#ifndef SQLITE_OMIT_WINDOWFUNC
88628
- if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);
88629
-#endif
8863088722
pC->deferredMoveto = 0;
8863188723
pC->cacheStatus = CACHE_STALE;
8863288724
}
8863388725
if( rc ) goto abort_due_to_error;
8863488726
pC->nullRow = (u8)res;
@@ -90006,10 +90098,11 @@
9000690098
assert( pOp->p3==0 || pOp->opcode==OP_AggValue );
9000790099
pMem = &aMem[pOp->p1];
9000890100
assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
9000990101
#ifndef SQLITE_OMIT_WINDOWFUNC
9001090102
if( pOp->p3 ){
90103
+ memAboutToChange(p, &aMem[pOp->p3]);
9001190104
rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
9001290105
pMem = &aMem[pOp->p3];
9001390106
}else
9001490107
#endif
9001590108
{
@@ -95424,10 +95517,14 @@
9542495517
assert( pExpr->x.pSelect==0 );
9542595518
pOrig = pEList->a[j].pExpr;
9542695519
if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){
9542795520
sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs);
9542895521
return WRC_Abort;
95522
+ }
95523
+ if( (pNC->ncFlags&NC_AllowWin)==0 && ExprHasProperty(pOrig, EP_Win) ){
95524
+ sqlite3ErrorMsg(pParse, "misuse of aliased window function %s",zAs);
95525
+ return WRC_Abort;
9542995526
}
9543095527
if( sqlite3ExprVectorSize(pOrig)!=1 ){
9543195528
sqlite3ErrorMsg(pParse, "row value misused");
9543295529
return WRC_Abort;
9543395530
}
@@ -95715,10 +95812,11 @@
9571595812
int is_agg = 0; /* True if is an aggregate function */
9571695813
int nId; /* Number of characters in function name */
9571795814
const char *zId; /* The function name. */
9571895815
FuncDef *pDef; /* Information about the function */
9571995816
u8 enc = ENC(pParse->db); /* The database encoding */
95817
+ int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin));
9572095818
9572195819
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
9572295820
zId = pExpr->u.zToken;
9572395821
nId = sqlite3Strlen30(zId);
9572495822
pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
@@ -95836,12 +95934,15 @@
9583695934
sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
9583795935
nId, zId);
9583895936
pNC->nErr++;
9583995937
}
9584095938
if( is_agg ){
95939
+ /* Window functions may not be arguments of aggregate functions.
95940
+ ** Or arguments of other window functions. But aggregate functions
95941
+ ** may be arguments for window functions. */
9584195942
#ifndef SQLITE_OMIT_WINDOWFUNC
95842
- pNC->ncFlags &= ~(pExpr->y.pWin ? NC_AllowWin : NC_AllowAgg);
95943
+ pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0));
9584395944
#else
9584495945
pNC->ncFlags &= ~NC_AllowAgg;
9584595946
#endif
9584695947
}
9584795948
}
@@ -95858,11 +95959,11 @@
9585895959
|| 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
9585995960
){
9586095961
pExpr->y.pWin->pNextWin = pSel->pWin;
9586195962
pSel->pWin = pExpr->y.pWin;
9586295963
}
95863
- pNC->ncFlags |= NC_AllowWin;
95964
+ pNC->ncFlags |= NC_HasWin;
9586495965
}else
9586595966
#endif /* SQLITE_OMIT_WINDOWFUNC */
9586695967
{
9586795968
NameContext *pNC2 = pNC;
9586895969
pExpr->op = TK_AGG_FUNCTION;
@@ -95876,12 +95977,12 @@
9587695977
assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
9587795978
testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
9587895979
pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
9587995980
9588095981
}
95881
- pNC->ncFlags |= NC_AllowAgg;
9588295982
}
95983
+ pNC->ncFlags |= savedAllowFlags;
9588395984
}
9588495985
/* FIX ME: Compute pExpr->affinity based on the expected return
9588595986
** type of the function
9588695987
*/
9588795988
return WRC_Prune;
@@ -96414,11 +96515,11 @@
9641496515
9641596516
/* Recursively resolve names in all subqueries
9641696517
*/
9641796518
for(i=0; i<p->pSrc->nSrc; i++){
9641896519
struct SrcList_item *pItem = &p->pSrc->a[i];
96419
- if( pItem->pSelect ){
96520
+ if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
9642096521
NameContext *pNC; /* Used to iterate name contexts */
9642196522
int nRef = 0; /* Refcount for pOuterNC and outer contexts */
9642296523
const char *zSavedContext = pParse->zAuthContext;
9642396524
9642496525
/* Count the total number of references to pOuterNC and all of its
@@ -96638,12 +96739,12 @@
9663896739
){
9663996740
u16 savedHasAgg;
9664096741
Walker w;
9664196742
9664296743
if( pExpr==0 ) return SQLITE_OK;
96643
- savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);
96644
- pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);
96744
+ savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
96745
+ pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
9664596746
w.pParse = pNC->pParse;
9664696747
w.xExprCallback = resolveExprStep;
9664796748
w.xSelectCallback = resolveSelectStep;
9664896749
w.xSelectCallback2 = 0;
9664996750
w.u.pNC = pNC;
@@ -96655,13 +96756,15 @@
9665596756
#endif
9665696757
sqlite3WalkExpr(&w, pExpr);
9665796758
#if SQLITE_MAX_EXPR_DEPTH>0
9665896759
w.pParse->nHeight -= pExpr->nHeight;
9665996760
#endif
96660
- if( pNC->ncFlags & NC_HasAgg ){
96661
- ExprSetProperty(pExpr, EP_Agg);
96662
- }
96761
+ assert( EP_Agg==NC_HasAgg );
96762
+ assert( EP_Win==NC_HasWin );
96763
+ testcase( pNC->ncFlags & NC_HasAgg );
96764
+ testcase( pNC->ncFlags & NC_HasWin );
96765
+ ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
9666396766
pNC->ncFlags |= savedHasAgg;
9666496767
return pNC->nErr>0 || w.pParse->nErr>0;
9666596768
}
9666696769
9666796770
/*
@@ -101788,10 +101891,21 @@
101788101891
** be non-NULL, then the LEFT JOIN can be safely converted into an
101789101892
** ordinary join.
101790101893
*/
101791101894
SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
101792101895
Walker w;
101896
+ p = sqlite3ExprSkipCollate(p);
101897
+ while( p ){
101898
+ if( p->op==TK_NOTNULL ){
101899
+ p = p->pLeft;
101900
+ }else if( p->op==TK_AND ){
101901
+ if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
101902
+ p = p->pRight;
101903
+ }else{
101904
+ break;
101905
+ }
101906
+ }
101793101907
w.xExprCallback = impliesNotNullRow;
101794101908
w.xSelectCallback = 0;
101795101909
w.xSelectCallback2 = 0;
101796101910
w.eCode = 0;
101797101911
w.u.iCur = iTab;
@@ -106961,10 +107075,11 @@
106961107075
if( zSql==0 ){
106962107076
/* This can result either from an OOM or because the formatted string
106963107077
** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set
106964107078
** an error */
106965107079
if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG;
107080
+ pParse->nErr++;
106966107081
return;
106967107082
}
106968107083
pParse->nested++;
106969107084
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
106970107085
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
@@ -108101,11 +108216,12 @@
108101108216
&& pCol
108102108217
&& sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
108103108218
&& sortOrder!=SQLITE_SO_DESC
108104108219
){
108105108220
if( IN_RENAME_OBJECT && pList ){
108106
- sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);
108221
+ Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[0].pExpr);
108222
+ sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pCExpr);
108107108223
}
108108108224
pTab->iPKey = iCol;
108109108225
pTab->keyConf = (u8)onError;
108110108226
assert( autoInc==0 || autoInc==1 );
108111108227
pTab->tabFlags |= autoInc*TF_Autoincrement;
@@ -109850,17 +109966,17 @@
109850109966
109851109967
assert( pTab!=0 );
109852109968
assert( pParse->nErr==0 );
109853109969
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
109854109970
&& db->init.busy==0
109971
+ && pTblName!=0
109855109972
#if SQLITE_USER_AUTHENTICATION
109856109973
&& sqlite3UserAuthTable(pTab->zName)==0
109857109974
#endif
109858109975
#ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX
109859109976
&& sqlite3StrICmp(&pTab->zName[7],"master")!=0
109860109977
#endif
109861
- && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0
109862109978
){
109863109979
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
109864109980
goto exit_create_index;
109865109981
}
109866109982
#ifndef SQLITE_OMIT_VIEW
@@ -109960,10 +110076,11 @@
109960110076
if( pList==0 ) goto exit_create_index;
109961110077
assert( pList->nExpr==1 );
109962110078
sqlite3ExprListSetSortOrder(pList, sortOrder);
109963110079
}else{
109964110080
sqlite3ExprListCheckLength(pParse, pList, "index");
110081
+ if( pParse->nErr ) goto exit_create_index;
109965110082
}
109966110083
109967110084
/* Figure out how many bytes of space are required to store explicitly
109968110085
** specified collation sequence names.
109969110086
*/
@@ -109978,10 +110095,11 @@
109978110095
/*
109979110096
** Allocate the index structure.
109980110097
*/
109981110098
nName = sqlite3Strlen30(zName);
109982110099
nExtraCol = pPk ? pPk->nKeyCol : 1;
110100
+ assert( pList->nExpr + nExtraCol <= 32767 /* Fits in i16 */ );
109983110101
pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,
109984110102
nName + nExtra + 1, &zExtra);
109985110103
if( db->mallocFailed ){
109986110104
goto exit_create_index;
109987110105
}
@@ -119232,10 +119350,13 @@
119232119350
void (*xValue)(sqlite3_context*),
119233119351
void (*xInv)(sqlite3_context*,int,sqlite3_value**),
119234119352
void(*xDestroy)(void*));
119235119353
/* Version 3.26.0 and later */
119236119354
const char *(*normalized_sql)(sqlite3_stmt*);
119355
+ /* Version 3.28.0 and later */
119356
+ int (*stmt_isexplain)(sqlite3_stmt*);
119357
+ int (*value_frombind)(sqlite3_value*);
119237119358
};
119238119359
119239119360
/*
119240119361
** This is the function signature used for all extension entry points. It
119241119362
** is also defined in the file "loadext.c".
@@ -119521,10 +119642,13 @@
119521119642
#define sqlite3_str_value sqlite3_api->str_value
119522119643
/* Version 3.25.0 and later */
119523119644
#define sqlite3_create_window_function sqlite3_api->create_window_function
119524119645
/* Version 3.26.0 and later */
119525119646
#define sqlite3_normalized_sql sqlite3_api->normalized_sql
119647
+/* Version 3.28.0 and later */
119648
+#define sqlite3_stmt_isexplain sqlite3_api->isexplain
119649
+#define sqlite3_value_frombind sqlite3_api->frombind
119526119650
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
119527119651
119528119652
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
119529119653
/* This case when the file really is being compiled as a loadable
119530119654
** extension */
@@ -133859,19 +133983,20 @@
133859133983
*/
133860133984
SQLITE_PRIVATE int sqlite3RunVacuum(
133861133985
char **pzErrMsg, /* Write error message here */
133862133986
sqlite3 *db, /* Database connection */
133863133987
int iDb, /* Which attached DB to vacuum */
133864
- sqlite3_value *pOut /* Write results here, if not NULL */
133988
+ sqlite3_value *pOut /* Write results here, if not NULL. VACUUM INTO */
133865133989
){
133866133990
int rc = SQLITE_OK; /* Return code from service routines */
133867133991
Btree *pMain; /* The database being vacuumed */
133868133992
Btree *pTemp; /* The temporary database we vacuum into */
133869133993
u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
133870133994
u64 saved_flags; /* Saved value of db->flags */
133871133995
int saved_nChange; /* Saved value of db->nChange */
133872133996
int saved_nTotalChange; /* Saved value of db->nTotalChange */
133997
+ u32 saved_openFlags; /* Saved value of db->openFlags */
133873133998
u8 saved_mTrace; /* Saved trace settings */
133874133999
Db *pDb = 0; /* Database to detach at end of vacuum */
133875134000
int isMemDb; /* True if vacuuming a :memory: database */
133876134001
int nRes; /* Bytes of reserved space at the end of each page */
133877134002
int nDb; /* Number of attached databases */
@@ -133884,16 +134009,19 @@
133884134009
}
133885134010
if( db->nVdbeActive>1 ){
133886134011
sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
133887134012
return SQLITE_ERROR;
133888134013
}
134014
+ saved_openFlags = db->openFlags;
133889134015
if( pOut ){
133890134016
if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
133891134017
sqlite3SetString(pzErrMsg, db, "non-text filename");
133892134018
return SQLITE_ERROR;
133893134019
}
133894134020
zOut = (const char*)sqlite3_value_text(pOut);
134021
+ db->openFlags &= ~SQLITE_OPEN_READONLY;
134022
+ db->openFlags |= SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
133895134023
}else{
133896134024
zOut = "";
133897134025
}
133898134026
133899134027
/* Save the current value of the database flags so that it can be
@@ -133928,10 +134056,11 @@
133928134056
** time to parse and run the PRAGMA to turn journalling off than it does
133929134057
** to write the journal header file.
133930134058
*/
133931134059
nDb = db->nDb;
133932134060
rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
134061
+ db->openFlags = saved_openFlags;
133933134062
if( rc!=SQLITE_OK ) goto end_of_vacuum;
133934134063
assert( (db->nDb-1)==nDb );
133935134064
pDb = &db->aDb[nDb];
133936134065
assert( strcmp(pDb->zDbSName,"vacuum_db")==0 );
133937134066
pTemp = pDb->pBt;
@@ -138164,12 +138293,13 @@
138164138293
continue;
138165138294
#else
138166138295
u32 x = pLevel->iLikeRepCntr;
138167138296
if( x>0 ){
138168138297
skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1));
138298
+ VdbeCoverageIf(v, (x&1)==1);
138299
+ VdbeCoverageIf(v, (x&1)==0);
138169138300
}
138170
- VdbeCoverage(v);
138171138301
#endif
138172138302
}
138173138303
#ifdef WHERETRACE_ENABLED /* 0xffff */
138174138304
if( sqlite3WhereTrace ){
138175138305
VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
@@ -143189,15 +143319,15 @@
143189143319
WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
143190143320
WHERETRACE(0x40, (" VirtualOne: all usable\n"));
143191143321
rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
143192143322
143193143323
/* If the call to xBestIndex() with all terms enabled produced a plan
143194
- ** that does not require any source tables (IOW: a plan with mBest==0),
143195
- ** then there is no point in making any further calls to xBestIndex()
143196
- ** since they will all return the same result (if the xBestIndex()
143197
- ** implementation is sane). */
143198
- if( rc==SQLITE_OK && (mBest = (pNew->prereq & ~mPrereq))!=0 ){
143324
+ ** that does not require any source tables (IOW: a plan with mBest==0)
143325
+ ** and does not use an IN(...) operator, then there is no point in making
143326
+ ** any further calls to xBestIndex() since they will all return the same
143327
+ ** result (if the xBestIndex() implementation is sane). */
143328
+ if( rc==SQLITE_OK && ((mBest = (pNew->prereq & ~mPrereq))!=0 || bIn) ){
143199143329
int seenZero = 0; /* True if a plan with no prereqs seen */
143200143330
int seenZeroNoIN = 0; /* Plan with no prereqs and no IN(...) seen */
143201143331
Bitmask mPrev = 0;
143202143332
Bitmask mBestNoIn = 0;
143203143333
@@ -145426,10 +145556,100 @@
145426145556
}
145427145557
sqlite3_result_int64(pCtx, p->nValue);
145428145558
}
145429145559
}
145430145560
145561
+/*
145562
+** Implementation of built-in window function nth_value(). This
145563
+** implementation is used in "slow mode" only - when the EXCLUDE clause
145564
+** is not set to the default value "NO OTHERS".
145565
+*/
145566
+struct NthValueCtx {
145567
+ i64 nStep;
145568
+ sqlite3_value *pValue;
145569
+};
145570
+static void nth_valueStepFunc(
145571
+ sqlite3_context *pCtx,
145572
+ int nArg,
145573
+ sqlite3_value **apArg
145574
+){
145575
+ struct NthValueCtx *p;
145576
+ p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145577
+ if( p ){
145578
+ i64 iVal;
145579
+ switch( sqlite3_value_numeric_type(apArg[1]) ){
145580
+ case SQLITE_INTEGER:
145581
+ iVal = sqlite3_value_int64(apArg[1]);
145582
+ break;
145583
+ case SQLITE_FLOAT: {
145584
+ double fVal = sqlite3_value_double(apArg[1]);
145585
+ if( ((i64)fVal)!=fVal ) goto error_out;
145586
+ iVal = (i64)fVal;
145587
+ break;
145588
+ }
145589
+ default:
145590
+ goto error_out;
145591
+ }
145592
+ if( iVal<=0 ) goto error_out;
145593
+
145594
+ p->nStep++;
145595
+ if( iVal==p->nStep ){
145596
+ p->pValue = sqlite3_value_dup(apArg[0]);
145597
+ if( !p->pValue ){
145598
+ sqlite3_result_error_nomem(pCtx);
145599
+ }
145600
+ }
145601
+ }
145602
+ UNUSED_PARAMETER(nArg);
145603
+ UNUSED_PARAMETER(apArg);
145604
+ return;
145605
+
145606
+ error_out:
145607
+ sqlite3_result_error(
145608
+ pCtx, "second argument to nth_value must be a positive integer", -1
145609
+ );
145610
+}
145611
+static void nth_valueFinalizeFunc(sqlite3_context *pCtx){
145612
+ struct NthValueCtx *p;
145613
+ p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, 0);
145614
+ if( p && p->pValue ){
145615
+ sqlite3_result_value(pCtx, p->pValue);
145616
+ sqlite3_value_free(p->pValue);
145617
+ p->pValue = 0;
145618
+ }
145619
+}
145620
+#define nth_valueInvFunc noopStepFunc
145621
+#define nth_valueValueFunc noopValueFunc
145622
+
145623
+static void first_valueStepFunc(
145624
+ sqlite3_context *pCtx,
145625
+ int nArg,
145626
+ sqlite3_value **apArg
145627
+){
145628
+ struct NthValueCtx *p;
145629
+ p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145630
+ if( p && p->pValue==0 ){
145631
+ p->pValue = sqlite3_value_dup(apArg[0]);
145632
+ if( !p->pValue ){
145633
+ sqlite3_result_error_nomem(pCtx);
145634
+ }
145635
+ }
145636
+ UNUSED_PARAMETER(nArg);
145637
+ UNUSED_PARAMETER(apArg);
145638
+}
145639
+static void first_valueFinalizeFunc(sqlite3_context *pCtx){
145640
+ struct NthValueCtx *p;
145641
+ p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145642
+ if( p && p->pValue ){
145643
+ sqlite3_result_value(pCtx, p->pValue);
145644
+ sqlite3_value_free(p->pValue);
145645
+ p->pValue = 0;
145646
+ }
145647
+}
145648
+#define first_valueInvFunc noopStepFunc
145649
+#define first_valueValueFunc noopValueFunc
145650
+
145431145651
/*
145432145652
** Implementation of built-in window function rank(). Assumes that
145433145653
** the window frame has been set to:
145434145654
**
145435145655
** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
@@ -145461,75 +145681,90 @@
145461145681
145462145682
/*
145463145683
** Implementation of built-in window function percent_rank(). Assumes that
145464145684
** the window frame has been set to:
145465145685
**
145466
-** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
145686
+** GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
145467145687
*/
145468145688
static void percent_rankStepFunc(
145469145689
sqlite3_context *pCtx,
145470145690
int nArg,
145471145691
sqlite3_value **apArg
145472145692
){
145473145693
struct CallCount *p;
145474
- UNUSED_PARAMETER(nArg); assert( nArg==1 );
145475
-
145694
+ UNUSED_PARAMETER(nArg); assert( nArg==0 );
145695
+ UNUSED_PARAMETER(apArg);
145696
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145697
+ if( p ){
145698
+ p->nTotal++;
145699
+ }
145700
+}
145701
+static void percent_rankInvFunc(
145702
+ sqlite3_context *pCtx,
145703
+ int nArg,
145704
+ sqlite3_value **apArg
145705
+){
145706
+ struct CallCount *p;
145707
+ UNUSED_PARAMETER(nArg); assert( nArg==0 );
145708
+ UNUSED_PARAMETER(apArg);
145476145709
p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145477
- if( p ){
145478
- if( p->nTotal==0 ){
145479
- p->nTotal = sqlite3_value_int64(apArg[0]);
145480
- }
145481
- p->nStep++;
145482
- if( p->nValue==0 ){
145483
- p->nValue = p->nStep;
145484
- }
145485
- }
145710
+ p->nStep++;
145486145711
}
145487145712
static void percent_rankValueFunc(sqlite3_context *pCtx){
145488145713
struct CallCount *p;
145489145714
p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145490145715
if( p ){
145716
+ p->nValue = p->nStep;
145491145717
if( p->nTotal>1 ){
145492
- double r = (double)(p->nValue-1) / (double)(p->nTotal-1);
145718
+ double r = (double)p->nValue / (double)(p->nTotal-1);
145493145719
sqlite3_result_double(pCtx, r);
145494145720
}else{
145495145721
sqlite3_result_double(pCtx, 0.0);
145496145722
}
145497
- p->nValue = 0;
145498145723
}
145499145724
}
145725
+#define percent_rankFinalizeFunc percent_rankValueFunc
145500145726
145501145727
/*
145502145728
** Implementation of built-in window function cume_dist(). Assumes that
145503145729
** the window frame has been set to:
145504145730
**
145505
-** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
145731
+** GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
145506145732
*/
145507145733
static void cume_distStepFunc(
145508145734
sqlite3_context *pCtx,
145509145735
int nArg,
145510145736
sqlite3_value **apArg
145511145737
){
145512145738
struct CallCount *p;
145513
- assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145514
-
145739
+ UNUSED_PARAMETER(nArg); assert( nArg==0 );
145740
+ UNUSED_PARAMETER(apArg);
145741
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145742
+ if( p ){
145743
+ p->nTotal++;
145744
+ }
145745
+}
145746
+static void cume_distInvFunc(
145747
+ sqlite3_context *pCtx,
145748
+ int nArg,
145749
+ sqlite3_value **apArg
145750
+){
145751
+ struct CallCount *p;
145752
+ UNUSED_PARAMETER(nArg); assert( nArg==0 );
145753
+ UNUSED_PARAMETER(apArg);
145515145754
p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145516
- if( p ){
145517
- if( p->nTotal==0 ){
145518
- p->nTotal = sqlite3_value_int64(apArg[0]);
145519
- }
145520
- p->nStep++;
145521
- }
145755
+ p->nStep++;
145522145756
}
145523145757
static void cume_distValueFunc(sqlite3_context *pCtx){
145524145758
struct CallCount *p;
145525
- p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145526
- if( p && p->nTotal ){
145759
+ p = (struct CallCount*)sqlite3_aggregate_context(pCtx, 0);
145760
+ if( p ){
145527145761
double r = (double)(p->nStep) / (double)(p->nTotal);
145528145762
sqlite3_result_double(pCtx, r);
145529145763
}
145530145764
}
145765
+#define cume_distFinalizeFunc cume_distValueFunc
145531145766
145532145767
/*
145533145768
** Context object for ntile() window function.
145534145769
*/
145535145770
struct NtileCtx {
@@ -145540,44 +145775,54 @@
145540145775
145541145776
/*
145542145777
** Implementation of ntile(). This assumes that the window frame has
145543145778
** been coerced to:
145544145779
**
145545
-** ROWS UNBOUNDED PRECEDING AND CURRENT ROW
145780
+** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING
145546145781
*/
145547145782
static void ntileStepFunc(
145548145783
sqlite3_context *pCtx,
145549145784
int nArg,
145550145785
sqlite3_value **apArg
145551145786
){
145552145787
struct NtileCtx *p;
145553
- assert( nArg==2 ); UNUSED_PARAMETER(nArg);
145788
+ assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145554145789
p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145555145790
if( p ){
145556145791
if( p->nTotal==0 ){
145557145792
p->nParam = sqlite3_value_int64(apArg[0]);
145558
- p->nTotal = sqlite3_value_int64(apArg[1]);
145559145793
if( p->nParam<=0 ){
145560145794
sqlite3_result_error(
145561145795
pCtx, "argument of ntile must be a positive integer", -1
145562145796
);
145563145797
}
145564145798
}
145565
- p->iRow++;
145799
+ p->nTotal++;
145566145800
}
145801
+}
145802
+static void ntileInvFunc(
145803
+ sqlite3_context *pCtx,
145804
+ int nArg,
145805
+ sqlite3_value **apArg
145806
+){
145807
+ struct NtileCtx *p;
145808
+ assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145809
+ UNUSED_PARAMETER(apArg);
145810
+ p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145811
+ p->iRow++;
145567145812
}
145568145813
static void ntileValueFunc(sqlite3_context *pCtx){
145569145814
struct NtileCtx *p;
145570145815
p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145571145816
if( p && p->nParam>0 ){
145572145817
int nSize = (p->nTotal / p->nParam);
145573145818
if( nSize==0 ){
145574
- sqlite3_result_int64(pCtx, p->iRow);
145819
+ sqlite3_result_int64(pCtx, p->iRow+1);
145575145820
}else{
145576145821
i64 nLarge = p->nTotal - p->nParam*nSize;
145577145822
i64 iSmall = nLarge*(nSize+1);
145578
- i64 iRow = p->iRow-1;
145823
+ i64 iRow = p->iRow;
145579145824
145580145825
assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );
145581145826
145582145827
if( iRow<iSmall ){
145583145828
sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
@@ -145585,10 +145830,11 @@
145585145830
sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
145586145831
}
145587145832
}
145588145833
}
145589145834
}
145835
+#define ntileFinalizeFunc ntileValueFunc
145590145836
145591145837
/*
145592145838
** Context object for last_value() window function.
145593145839
*/
145594145840
struct LastValueCtx {
@@ -145634,11 +145880,11 @@
145634145880
}
145635145881
}
145636145882
}
145637145883
static void last_valueValueFunc(sqlite3_context *pCtx){
145638145884
struct LastValueCtx *p;
145639
- p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145885
+ p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, 0);
145640145886
if( p && p->pVal ){
145641145887
sqlite3_result_value(pCtx, p->pVal);
145642145888
}
145643145889
}
145644145890
static void last_valueFinalizeFunc(sqlite3_context *pCtx){
@@ -145724,25 +145970,36 @@
145724145970
SQLITE_PRIVATE void sqlite3WindowFunctions(void){
145725145971
static FuncDef aWindowFuncs[] = {
145726145972
WINDOWFUNCX(row_number, 0, 0),
145727145973
WINDOWFUNCX(dense_rank, 0, 0),
145728145974
WINDOWFUNCX(rank, 0, 0),
145729
- WINDOWFUNCX(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),
145730
- WINDOWFUNCX(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),
145731
- WINDOWFUNCX(ntile, 1, SQLITE_FUNC_WINDOW_SIZE),
145975
+ WINDOWFUNCALL(percent_rank, 0, 0),
145976
+ WINDOWFUNCALL(cume_dist, 0, 0),
145977
+ WINDOWFUNCALL(ntile, 1, 0),
145732145978
WINDOWFUNCALL(last_value, 1, 0),
145733
- WINDOWFUNCNOOP(nth_value, 2, 0),
145734
- WINDOWFUNCNOOP(first_value, 1, 0),
145979
+ WINDOWFUNCALL(nth_value, 2, 0),
145980
+ WINDOWFUNCALL(first_value, 1, 0),
145735145981
WINDOWFUNCNOOP(lead, 1, 0),
145736145982
WINDOWFUNCNOOP(lead, 2, 0),
145737145983
WINDOWFUNCNOOP(lead, 3, 0),
145738145984
WINDOWFUNCNOOP(lag, 1, 0),
145739145985
WINDOWFUNCNOOP(lag, 2, 0),
145740145986
WINDOWFUNCNOOP(lag, 3, 0),
145741145987
};
145742145988
sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
145743145989
}
145990
+
145991
+static Window *windowFind(Parse *pParse, Window *pList, const char *zName){
145992
+ Window *p;
145993
+ for(p=pList; p; p=p->pNextWin){
145994
+ if( sqlite3StrICmp(p->zName, zName)==0 ) break;
145995
+ }
145996
+ if( p==0 ){
145997
+ sqlite3ErrorMsg(pParse, "no such window: %s", zName);
145998
+ }
145999
+ return p;
146000
+}
145744146001
145745146002
/*
145746146003
** This function is called immediately after resolving the function name
145747146004
** for a window function within a SELECT statement. Argument pList is a
145748146005
** linked list of WINDOW definitions for the current SELECT statement.
@@ -145763,52 +146020,70 @@
145763146020
Parse *pParse,
145764146021
Window *pList, /* List of named windows for this SELECT */
145765146022
Window *pWin, /* Window frame to update */
145766146023
FuncDef *pFunc /* Window function definition */
145767146024
){
145768
- if( pWin->zName && pWin->eType==0 ){
145769
- Window *p;
145770
- for(p=pList; p; p=p->pNextWin){
145771
- if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;
145772
- }
145773
- if( p==0 ){
145774
- sqlite3ErrorMsg(pParse, "no such window: %s", pWin->zName);
145775
- return;
145776
- }
146025
+ if( pWin->zName && pWin->eFrmType==0 ){
146026
+ Window *p = windowFind(pParse, pList, pWin->zName);
146027
+ if( p==0 ) return;
145777146028
pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
145778146029
pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
145779146030
pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
145780146031
pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
145781146032
pWin->eStart = p->eStart;
145782146033
pWin->eEnd = p->eEnd;
145783
- pWin->eType = p->eType;
146034
+ pWin->eFrmType = p->eFrmType;
146035
+ pWin->eExclude = p->eExclude;
146036
+ }else{
146037
+ sqlite3WindowChain(pParse, pWin, pList);
145784146038
}
146039
+ if( (pWin->eFrmType==TK_RANGE)
146040
+ && (pWin->pStart || pWin->pEnd)
146041
+ && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1)
146042
+ ){
146043
+ sqlite3ErrorMsg(pParse,
146044
+ "RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression"
146045
+ );
146046
+ }else
145785146047
if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
145786146048
sqlite3 *db = pParse->db;
145787146049
if( pWin->pFilter ){
145788146050
sqlite3ErrorMsg(pParse,
145789146051
"FILTER clause may only be used with aggregate window functions"
145790146052
);
145791
- }else
145792
- if( pFunc->zName==row_numberName || pFunc->zName==ntileName ){
145793
- sqlite3ExprDelete(db, pWin->pStart);
145794
- sqlite3ExprDelete(db, pWin->pEnd);
145795
- pWin->pStart = pWin->pEnd = 0;
145796
- pWin->eType = TK_ROWS;
145797
- pWin->eStart = TK_UNBOUNDED;
145798
- pWin->eEnd = TK_CURRENT;
145799
- }else
145800
-
145801
- if( pFunc->zName==dense_rankName || pFunc->zName==rankName
145802
- || pFunc->zName==percent_rankName || pFunc->zName==cume_distName
145803
- ){
145804
- sqlite3ExprDelete(db, pWin->pStart);
145805
- sqlite3ExprDelete(db, pWin->pEnd);
145806
- pWin->pStart = pWin->pEnd = 0;
145807
- pWin->eType = TK_RANGE;
145808
- pWin->eStart = TK_UNBOUNDED;
145809
- pWin->eEnd = TK_CURRENT;
146053
+ }else{
146054
+ struct WindowUpdate {
146055
+ const char *zFunc;
146056
+ int eFrmType;
146057
+ int eStart;
146058
+ int eEnd;
146059
+ } aUp[] = {
146060
+ { row_numberName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT },
146061
+ { dense_rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT },
146062
+ { rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT },
146063
+ { percent_rankName, TK_GROUPS, TK_CURRENT, TK_UNBOUNDED },
146064
+ { cume_distName, TK_GROUPS, TK_FOLLOWING, TK_UNBOUNDED },
146065
+ { ntileName, TK_ROWS, TK_CURRENT, TK_UNBOUNDED },
146066
+ { leadName, TK_ROWS, TK_UNBOUNDED, TK_UNBOUNDED },
146067
+ { lagName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT },
146068
+ };
146069
+ int i;
146070
+ for(i=0; i<ArraySize(aUp); i++){
146071
+ if( pFunc->zName==aUp[i].zFunc ){
146072
+ sqlite3ExprDelete(db, pWin->pStart);
146073
+ sqlite3ExprDelete(db, pWin->pEnd);
146074
+ pWin->pEnd = pWin->pStart = 0;
146075
+ pWin->eFrmType = aUp[i].eFrmType;
146076
+ pWin->eStart = aUp[i].eStart;
146077
+ pWin->eEnd = aUp[i].eEnd;
146078
+ pWin->eExclude = 0;
146079
+ if( pWin->eStart==TK_FOLLOWING ){
146080
+ pWin->pStart = sqlite3Expr(db, TK_INTEGER, "1");
146081
+ }
146082
+ break;
146083
+ }
146084
+ }
145810146085
}
145811146086
}
145812146087
pWin->pFunc = pFunc;
145813146088
}
145814146089
@@ -146009,10 +146284,11 @@
146009146284
146010146285
/* Assign a cursor number for the ephemeral table used to buffer rows.
146011146286
** The OpenEphemeral instruction is coded later, after it is known how
146012146287
** many columns the table will have. */
146013146288
pMWin->iEphCsr = pParse->nTab++;
146289
+ pParse->nTab += 3;
146014146290
146015146291
selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);
146016146292
selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);
146017146293
pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);
146018146294
@@ -146064,10 +146340,13 @@
146064146340
p->selFlags &= ~SF_Aggregate;
146065146341
sqlite3SelectPrep(pParse, pSub, 0);
146066146342
}
146067146343
146068146344
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
146345
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr);
146346
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+2, pMWin->iEphCsr);
146347
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+3, pMWin->iEphCsr);
146069146348
}else{
146070146349
sqlite3SelectDelete(db, pSub);
146071146350
}
146072146351
if( db->mallocFailed ) rc = SQLITE_NOMEM;
146073146352
}
@@ -146084,10 +146363,11 @@
146084146363
sqlite3ExprListDelete(db, p->pPartition);
146085146364
sqlite3ExprListDelete(db, p->pOrderBy);
146086146365
sqlite3ExprDelete(db, p->pEnd);
146087146366
sqlite3ExprDelete(db, p->pStart);
146088146367
sqlite3DbFree(db, p->zName);
146368
+ sqlite3DbFree(db, p->zBase);
146089146369
sqlite3DbFree(db, p);
146090146370
}
146091146371
}
146092146372
146093146373
/*
@@ -146120,34 +146400,32 @@
146120146400
/*
146121146401
** Allocate and return a new Window object describing a Window Definition.
146122146402
*/
146123146403
SQLITE_PRIVATE Window *sqlite3WindowAlloc(
146124146404
Parse *pParse, /* Parsing context */
146125
- int eType, /* Frame type. TK_RANGE or TK_ROWS */
146405
+ int eType, /* Frame type. TK_RANGE, TK_ROWS, TK_GROUPS, or 0 */
146126146406
int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
146127146407
Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
146128146408
int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
146129
- Expr *pEnd /* End window size if TK_FOLLOWING or PRECEDING */
146409
+ Expr *pEnd, /* End window size if TK_FOLLOWING or PRECEDING */
146410
+ u8 eExclude /* EXCLUDE clause */
146130146411
){
146131146412
Window *pWin = 0;
146413
+ int bImplicitFrame = 0;
146132146414
146133146415
/* Parser assures the following: */
146134
- assert( eType==TK_RANGE || eType==TK_ROWS );
146416
+ assert( eType==0 || eType==TK_RANGE || eType==TK_ROWS || eType==TK_GROUPS );
146135146417
assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
146136146418
|| eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
146137146419
assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
146138146420
|| eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
146139146421
assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
146140146422
assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );
146141146423
146142
-
146143
- /* If a frame is declared "RANGE" (not "ROWS"), then it may not use
146144
- ** either "<expr> PRECEDING" or "<expr> FOLLOWING".
146145
- */
146146
- if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){
146147
- sqlite3ErrorMsg(pParse, "RANGE must use only UNBOUNDED or CURRENT ROW");
146148
- goto windowAllocErr;
146424
+ if( eType==0 ){
146425
+ bImplicitFrame = 1;
146426
+ eType = TK_RANGE;
146149146427
}
146150146428
146151146429
/* Additionally, the
146152146430
** starting boundary type may not occur earlier in the following list than
146153146431
** the ending boundary type:
@@ -146163,28 +146441,96 @@
146163146441
** frame boundary.
146164146442
*/
146165146443
if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
146166146444
|| (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
146167146445
){
146168
- sqlite3ErrorMsg(pParse, "unsupported frame delimiter for ROWS");
146446
+ sqlite3ErrorMsg(pParse, "unsupported frame specification");
146169146447
goto windowAllocErr;
146170146448
}
146171146449
146172146450
pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
146173146451
if( pWin==0 ) goto windowAllocErr;
146174
- pWin->eType = eType;
146452
+ pWin->eFrmType = eType;
146175146453
pWin->eStart = eStart;
146176146454
pWin->eEnd = eEnd;
146455
+ if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_WindowFunc) ){
146456
+ eExclude = TK_NO;
146457
+ }
146458
+ pWin->eExclude = eExclude;
146459
+ pWin->bImplicitFrame = bImplicitFrame;
146177146460
pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
146178146461
pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
146179146462
return pWin;
146180146463
146181146464
windowAllocErr:
146182146465
sqlite3ExprDelete(pParse->db, pEnd);
146183146466
sqlite3ExprDelete(pParse->db, pStart);
146184146467
return 0;
146185146468
}
146469
+
146470
+/*
146471
+** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
146472
+** pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the
146473
+** equivalent nul-terminated string.
146474
+*/
146475
+SQLITE_PRIVATE Window *sqlite3WindowAssemble(
146476
+ Parse *pParse,
146477
+ Window *pWin,
146478
+ ExprList *pPartition,
146479
+ ExprList *pOrderBy,
146480
+ Token *pBase
146481
+){
146482
+ if( pWin ){
146483
+ pWin->pPartition = pPartition;
146484
+ pWin->pOrderBy = pOrderBy;
146485
+ if( pBase ){
146486
+ pWin->zBase = sqlite3DbStrNDup(pParse->db, pBase->z, pBase->n);
146487
+ }
146488
+ }else{
146489
+ sqlite3ExprListDelete(pParse->db, pPartition);
146490
+ sqlite3ExprListDelete(pParse->db, pOrderBy);
146491
+ }
146492
+ return pWin;
146493
+}
146494
+
146495
+/*
146496
+** Window *pWin has just been created from a WINDOW clause. Tokne pBase
146497
+** is the base window. Earlier windows from the same WINDOW clause are
146498
+** stored in the linked list starting at pWin->pNextWin. This function
146499
+** either updates *pWin according to the base specification, or else
146500
+** leaves an error in pParse.
146501
+*/
146502
+SQLITE_PRIVATE void sqlite3WindowChain(Parse *pParse, Window *pWin, Window *pList){
146503
+ if( pWin->zBase ){
146504
+ sqlite3 *db = pParse->db;
146505
+ Window *pExist = windowFind(pParse, pList, pWin->zBase);
146506
+ if( pExist ){
146507
+ const char *zErr = 0;
146508
+ /* Check for errors */
146509
+ if( pWin->pPartition ){
146510
+ zErr = "PARTITION clause";
146511
+ }else if( pExist->pOrderBy && pWin->pOrderBy ){
146512
+ zErr = "ORDER BY clause";
146513
+ }else if( pExist->bImplicitFrame==0 ){
146514
+ zErr = "frame specification";
146515
+ }
146516
+ if( zErr ){
146517
+ sqlite3ErrorMsg(pParse,
146518
+ "cannot override %s of window: %s", zErr, pWin->zBase
146519
+ );
146520
+ }else{
146521
+ pWin->pPartition = sqlite3ExprListDup(db, pExist->pPartition, 0);
146522
+ if( pExist->pOrderBy ){
146523
+ assert( pWin->pOrderBy==0 );
146524
+ pWin->pOrderBy = sqlite3ExprListDup(db, pExist->pOrderBy, 0);
146525
+ }
146526
+ sqlite3DbFree(db, pWin->zBase);
146527
+ pWin->zBase = 0;
146528
+ }
146529
+ }
146530
+ }
146531
+}
146186146532
146187146533
/*
146188146534
** Attach window object pWin to expression p.
146189146535
*/
146190146536
SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
@@ -146210,13 +146556,14 @@
146210146556
/*
146211146557
** Return 0 if the two window objects are identical, or non-zero otherwise.
146212146558
** Identical window objects can be processed in a single scan.
146213146559
*/
146214146560
SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
146215
- if( p1->eType!=p2->eType ) return 1;
146561
+ if( p1->eFrmType!=p2->eFrmType ) return 1;
146216146562
if( p1->eStart!=p2->eStart ) return 1;
146217146563
if( p1->eEnd!=p2->eEnd ) return 1;
146564
+ if( p1->eExclude!=p2->eExclude ) return 1;
146218146565
if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
146219146566
if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
146220146567
if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
146221146568
if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
146222146569
return 0;
@@ -146229,16 +146576,31 @@
146229146576
** and initialize registers and cursors used by sqlite3WindowCodeStep().
146230146577
*/
146231146578
SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
146232146579
Window *pWin;
146233146580
Vdbe *v = sqlite3GetVdbe(pParse);
146234
- int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);
146235
- nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
146236
- if( nPart ){
146581
+
146582
+ /* Allocate registers to use for PARTITION BY values, if any. Initialize
146583
+ ** said registers to NULL. */
146584
+ if( pMWin->pPartition ){
146585
+ int nExpr = pMWin->pPartition->nExpr;
146237146586
pMWin->regPart = pParse->nMem+1;
146238
- pParse->nMem += nPart;
146239
- sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);
146587
+ pParse->nMem += nExpr;
146588
+ sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nExpr-1);
146589
+ }
146590
+
146591
+ pMWin->regOne = ++pParse->nMem;
146592
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regOne);
146593
+
146594
+ if( pMWin->eExclude ){
146595
+ pMWin->regStartRowid = ++pParse->nMem;
146596
+ pMWin->regEndRowid = ++pParse->nMem;
146597
+ pMWin->csrApp = pParse->nTab++;
146598
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid);
146599
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid);
146600
+ sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr);
146601
+ return;
146240146602
}
146241146603
146242146604
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146243146605
FuncDef *p = pWin->pFunc;
146244146606
if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
@@ -146263,50 +146625,71 @@
146263146625
sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146264146626
}
146265146627
else if( p->zName==nth_valueName || p->zName==first_valueName ){
146266146628
/* Allocate two registers at pWin->regApp. These will be used to
146267146629
** store the start and end index of the current frame. */
146268
- assert( pMWin->iEphCsr );
146269146630
pWin->regApp = pParse->nMem+1;
146270146631
pWin->csrApp = pParse->nTab++;
146271146632
pParse->nMem += 2;
146272146633
sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146273146634
}
146274146635
else if( p->zName==leadName || p->zName==lagName ){
146275
- assert( pMWin->iEphCsr );
146276146636
pWin->csrApp = pParse->nTab++;
146277146637
sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146278146638
}
146279146639
}
146280146640
}
146641
+
146642
+#define WINDOW_STARTING_INT 0
146643
+#define WINDOW_ENDING_INT 1
146644
+#define WINDOW_NTH_VALUE_INT 2
146645
+#define WINDOW_STARTING_NUM 3
146646
+#define WINDOW_ENDING_NUM 4
146281146647
146282146648
/*
146283146649
** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
146284146650
** value of the second argument to nth_value() (eCond==2) has just been
146285146651
** evaluated and the result left in register reg. This function generates VM
146286146652
** code to check that the value is a non-negative integer and throws an
146287146653
** exception if it is not.
146288146654
*/
146289
-static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
146655
+static void windowCheckValue(Parse *pParse, int reg, int eCond){
146290146656
static const char *azErr[] = {
146291146657
"frame starting offset must be a non-negative integer",
146292146658
"frame ending offset must be a non-negative integer",
146293
- "second argument to nth_value must be a positive integer"
146659
+ "second argument to nth_value must be a positive integer",
146660
+ "frame starting offset must be a non-negative number",
146661
+ "frame ending offset must be a non-negative number",
146294146662
};
146295
- static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };
146663
+ static int aOp[] = { OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge };
146296146664
Vdbe *v = sqlite3GetVdbe(pParse);
146297146665
int regZero = sqlite3GetTempReg(pParse);
146298
- assert( eCond==0 || eCond==1 || eCond==2 );
146666
+ assert( eCond>=0 && eCond<ArraySize(azErr) );
146299146667
sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
146300
- sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
146301
- VdbeCoverageIf(v, eCond==0);
146302
- VdbeCoverageIf(v, eCond==1);
146303
- VdbeCoverageIf(v, eCond==2);
146668
+ if( eCond>=WINDOW_STARTING_NUM ){
146669
+ int regString = sqlite3GetTempReg(pParse);
146670
+ sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
146671
+ sqlite3VdbeAddOp3(v, OP_Ge, regString, sqlite3VdbeCurrentAddr(v)+2, reg);
146672
+ sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC|SQLITE_JUMPIFNULL);
146673
+ VdbeCoverage(v);
146674
+ assert( eCond==3 || eCond==4 );
146675
+ VdbeCoverageIf(v, eCond==3);
146676
+ VdbeCoverageIf(v, eCond==4);
146677
+ }else{
146678
+ sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
146679
+ VdbeCoverage(v);
146680
+ assert( eCond==0 || eCond==1 || eCond==2 );
146681
+ VdbeCoverageIf(v, eCond==0);
146682
+ VdbeCoverageIf(v, eCond==1);
146683
+ VdbeCoverageIf(v, eCond==2);
146684
+ }
146304146685
sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
146305
- VdbeCoverageNeverNullIf(v, eCond==0);
146306
- VdbeCoverageNeverNullIf(v, eCond==1);
146686
+ VdbeCoverageNeverNullIf(v, eCond==0); /* NULL case captured by */
146687
+ VdbeCoverageNeverNullIf(v, eCond==1); /* the OP_MustBeInt */
146307146688
VdbeCoverageNeverNullIf(v, eCond==2);
146689
+ VdbeCoverageNeverNullIf(v, eCond==3); /* NULL case caught by */
146690
+ VdbeCoverageNeverNullIf(v, eCond==4); /* the OP_Ge */
146308146691
sqlite3MayAbort(pParse);
146309146692
sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
146310146693
sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
146311146694
sqlite3ReleaseTempReg(pParse, regZero);
146312146695
}
@@ -146342,41 +146725,32 @@
146342146725
static void windowAggStep(
146343146726
Parse *pParse,
146344146727
Window *pMWin, /* Linked list of window functions */
146345146728
int csr, /* Read arguments from this cursor */
146346146729
int bInverse, /* True to invoke xInverse instead of xStep */
146347
- int reg, /* Array of registers */
146348
- int regPartSize /* Register containing size of partition */
146730
+ int reg /* Array of registers */
146349146731
){
146350146732
Vdbe *v = sqlite3GetVdbe(pParse);
146351146733
Window *pWin;
146352146734
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146353
- int flags = pWin->pFunc->funcFlags;
146735
+ FuncDef *pFunc = pWin->pFunc;
146354146736
int regArg;
146355146737
int nArg = windowArgCount(pWin);
146738
+ int i;
146356146739
146357
- if( csr>=0 ){
146358
- int i;
146359
- for(i=0; i<nArg; i++){
146740
+ for(i=0; i<nArg; i++){
146741
+ if( i!=1 || pFunc->zName!=nth_valueName ){
146360146742
sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
146361
- }
146362
- regArg = reg;
146363
- if( flags & SQLITE_FUNC_WINDOW_SIZE ){
146364
- if( nArg==0 ){
146365
- regArg = regPartSize;
146366
- }else{
146367
- sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
146368
- }
146369
- nArg++;
146370
- }
146371
- }else{
146372
- assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
146373
- regArg = reg + pWin->iArgCol;
146374
- }
146375
-
146376
- if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146377
- && pWin->eStart!=TK_UNBOUNDED
146743
+ }else{
146744
+ sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
146745
+ }
146746
+ }
146747
+ regArg = reg;
146748
+
146749
+ if( pMWin->regStartRowid==0
146750
+ && (pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146751
+ && (pWin->eStart!=TK_UNBOUNDED)
146378146752
){
146379146753
int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
146380146754
VdbeCoverage(v);
146381146755
if( bInverse==0 ){
146382146756
sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
@@ -146389,151 +146763,223 @@
146389146763
sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
146390146764
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
146391146765
}
146392146766
sqlite3VdbeJumpHere(v, addrIsNull);
146393146767
}else if( pWin->regApp ){
146394
- assert( pWin->pFunc->zName==nth_valueName
146395
- || pWin->pFunc->zName==first_valueName
146768
+ assert( pFunc->zName==nth_valueName
146769
+ || pFunc->zName==first_valueName
146396146770
);
146397146771
assert( bInverse==0 || bInverse==1 );
146398146772
sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
146399
- }else if( pWin->pFunc->zName==leadName
146400
- || pWin->pFunc->zName==lagName
146401
- ){
146402
- /* no-op */
146403
- }else{
146773
+ }else if( pFunc->xSFunc!=noopStepFunc ){
146404146774
int addrIf = 0;
146405146775
if( pWin->pFilter ){
146406146776
int regTmp;
146407146777
assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
146408146778
assert( nArg || pWin->pOwner->x.pList==0 );
146409
- if( csr>0 ){
146410
- regTmp = sqlite3GetTempReg(pParse);
146411
- sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
146412
- }else{
146413
- regTmp = regArg + nArg;
146414
- }
146779
+ regTmp = sqlite3GetTempReg(pParse);
146780
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
146415146781
addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
146416146782
VdbeCoverage(v);
146417
- if( csr>0 ){
146418
- sqlite3ReleaseTempReg(pParse, regTmp);
146419
- }
146783
+ sqlite3ReleaseTempReg(pParse, regTmp);
146420146784
}
146421
- if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
146785
+ if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
146422146786
CollSeq *pColl;
146423146787
assert( nArg>0 );
146424146788
pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
146425146789
sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
146426146790
}
146427146791
sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
146428146792
bInverse, regArg, pWin->regAccum);
146429
- sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146793
+ sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
146430146794
sqlite3VdbeChangeP5(v, (u8)nArg);
146431146795
if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
146432146796
}
146433146797
}
146434146798
}
146435146799
146800
+typedef struct WindowCodeArg WindowCodeArg;
146801
+typedef struct WindowCsrAndReg WindowCsrAndReg;
146802
+struct WindowCsrAndReg {
146803
+ int csr;
146804
+ int reg;
146805
+};
146806
+
146807
+struct WindowCodeArg {
146808
+ Parse *pParse;
146809
+ Window *pMWin;
146810
+ Vdbe *pVdbe;
146811
+ int regGosub;
146812
+ int addrGosub;
146813
+ int regArg;
146814
+ int eDelete;
146815
+
146816
+ WindowCsrAndReg start;
146817
+ WindowCsrAndReg current;
146818
+ WindowCsrAndReg end;
146819
+};
146820
+
146436146821
/*
146437
-** Generate VM code to invoke either xValue() (bFinal==0) or xFinalize()
146438
-** (bFinal==1) for each window function in the linked list starting at
146822
+** Values that may be passed as the second argument to windowCodeOp().
146823
+*/
146824
+#define WINDOW_RETURN_ROW 1
146825
+#define WINDOW_AGGINVERSE 2
146826
+#define WINDOW_AGGSTEP 3
146827
+
146828
+/*
146829
+** Generate VM code to read the window frames peer values from cursor csr into
146830
+** an array of registers starting at reg.
146831
+*/
146832
+static void windowReadPeerValues(
146833
+ WindowCodeArg *p,
146834
+ int csr,
146835
+ int reg
146836
+){
146837
+ Window *pMWin = p->pMWin;
146838
+ ExprList *pOrderBy = pMWin->pOrderBy;
146839
+ if( pOrderBy ){
146840
+ Vdbe *v = sqlite3GetVdbe(p->pParse);
146841
+ ExprList *pPart = pMWin->pPartition;
146842
+ int iColOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
146843
+ int i;
146844
+ for(i=0; i<pOrderBy->nExpr; i++){
146845
+ sqlite3VdbeAddOp3(v, OP_Column, csr, iColOff+i, reg+i);
146846
+ }
146847
+ }
146848
+}
146849
+
146850
+/*
146851
+** Generate VM code to invoke either xValue() (bFin==0) or xFinalize()
146852
+** (bFin==1) for each window function in the linked list starting at
146439146853
** pMWin. Or, for built-in window-functions that do not use the standard
146440146854
** API, generate the equivalent VM code.
146441146855
*/
146442
-static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
146856
+static void windowAggFinal(WindowCodeArg *p, int bFin){
146857
+ Parse *pParse = p->pParse;
146858
+ Window *pMWin = p->pMWin;
146443146859
Vdbe *v = sqlite3GetVdbe(pParse);
146444146860
Window *pWin;
146445146861
146446146862
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146447
- if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146448
- && pWin->eStart!=TK_UNBOUNDED
146863
+ if( pMWin->regStartRowid==0
146864
+ && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146865
+ && (pWin->eStart!=TK_UNBOUNDED)
146449146866
){
146450146867
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146451146868
sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
146452146869
VdbeCoverage(v);
146453146870
sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
146454146871
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
146455
- if( bFinal ){
146456
- sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
146457
- }
146458146872
}else if( pWin->regApp ){
146873
+ assert( pMWin->regStartRowid==0 );
146459146874
}else{
146460
- if( bFinal ){
146461
- sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, windowArgCount(pWin));
146875
+ int nArg = windowArgCount(pWin);
146876
+ if( bFin ){
146877
+ sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
146462146878
sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146463146879
sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
146464146880
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146465146881
}else{
146466
- sqlite3VdbeAddOp3(v, OP_AggValue, pWin->regAccum, windowArgCount(pWin),
146467
- pWin->regResult);
146882
+ sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
146468146883
sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146469146884
}
146470146885
}
146471146886
}
146472146887
}
146473146888
146474146889
/*
146475
-** This function generates VM code to invoke the sub-routine at address
146476
-** lblFlushPart once for each partition with the entire partition cached in
146477
-** the Window.iEphCsr temp table.
146890
+** Generate code to calculate the current values of all window functions in the
146891
+** p->pMWin list by doing a full scan of the current window frame. Store the
146892
+** results in the Window.regResult registers, ready to return the upper
146893
+** layer.
146478146894
*/
146479
-static void windowPartitionCache(
146480
- Parse *pParse,
146481
- Select *p, /* The rewritten SELECT statement */
146482
- WhereInfo *pWInfo, /* WhereInfo to call WhereEnd() on */
146483
- int regFlushPart, /* Register to use with Gosub lblFlushPart */
146484
- int lblFlushPart, /* Subroutine to Gosub to */
146485
- int *pRegSize /* OUT: Register containing partition size */
146486
-){
146487
- Window *pMWin = p->pWin;
146488
- Vdbe *v = sqlite3GetVdbe(pParse);
146489
- int iSubCsr = p->pSrc->a[0].iCursor;
146490
- int nSub = p->pSrc->a[0].pTab->nCol;
146491
- int k;
146492
-
146493
- int reg = pParse->nMem+1;
146494
- int regRecord = reg+nSub;
146495
- int regRowid = regRecord+1;
146496
-
146497
- *pRegSize = regRowid;
146498
- pParse->nMem += nSub + 2;
146499
-
146500
- /* Load the column values for the row returned by the sub-select
146501
- ** into an array of registers starting at reg. */
146502
- for(k=0; k<nSub; k++){
146503
- sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
146504
- }
146505
- sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, nSub, regRecord);
146506
-
146507
- /* Check if this is the start of a new partition. If so, call the
146508
- ** flush_partition sub-routine. */
146509
- if( pMWin->pPartition ){
146895
+static void windowFullScan(WindowCodeArg *p){
146896
+ Window *pWin;
146897
+ Parse *pParse = p->pParse;
146898
+ Window *pMWin = p->pMWin;
146899
+ Vdbe *v = p->pVdbe;
146900
+
146901
+ int regCRowid = 0; /* Current rowid value */
146902
+ int regCPeer = 0; /* Current peer values */
146903
+ int regRowid = 0; /* AggStep rowid value */
146904
+ int regPeer = 0; /* AggStep peer values */
146905
+
146906
+ int nPeer;
146907
+ int lblNext;
146908
+ int lblBrk;
146909
+ int addrNext;
146910
+ int csr = pMWin->csrApp;
146911
+
146912
+ nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
146913
+
146914
+ lblNext = sqlite3VdbeMakeLabel(pParse);
146915
+ lblBrk = sqlite3VdbeMakeLabel(pParse);
146916
+
146917
+ regCRowid = sqlite3GetTempReg(pParse);
146918
+ regRowid = sqlite3GetTempReg(pParse);
146919
+ if( nPeer ){
146920
+ regCPeer = sqlite3GetTempRange(pParse, nPeer);
146921
+ regPeer = sqlite3GetTempRange(pParse, nPeer);
146922
+ }
146923
+
146924
+ sqlite3VdbeAddOp2(v, OP_Rowid, pMWin->iEphCsr, regCRowid);
146925
+ windowReadPeerValues(p, pMWin->iEphCsr, regCPeer);
146926
+
146927
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146928
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146929
+ }
146930
+
146931
+ sqlite3VdbeAddOp3(v, OP_SeekGE, csr, lblBrk, pMWin->regStartRowid);
146932
+ VdbeCoverage(v);
146933
+ addrNext = sqlite3VdbeCurrentAddr(v);
146934
+ sqlite3VdbeAddOp2(v, OP_Rowid, csr, regRowid);
146935
+ sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, lblBrk, regRowid);
146936
+ VdbeCoverageNeverNull(v);
146937
+
146938
+ if( pMWin->eExclude==TK_CURRENT ){
146939
+ sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid);
146940
+ VdbeCoverageNeverNull(v);
146941
+ }else if( pMWin->eExclude!=TK_NO ){
146510146942
int addr;
146511
- ExprList *pPart = pMWin->pPartition;
146512
- int nPart = pPart->nExpr;
146513
- int regNewPart = reg + pMWin->nBufferCol;
146514
- KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
146515
-
146516
- addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
146517
- sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
146518
- sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
146519
- VdbeCoverageEqNe(v);
146520
- sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
146521
- sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
146522
- VdbeComment((v, "call flush_partition"));
146523
- }
146524
-
146525
- /* Buffer the current row in the ephemeral table. */
146526
- sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
146527
- sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
146528
-
146529
- /* End of the input loop */
146530
- sqlite3WhereEnd(pWInfo);
146531
-
146532
- /* Invoke "flush_partition" to deal with the final (or only) partition */
146533
- sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
146534
- VdbeComment((v, "call flush_partition"));
146943
+ int addrEq = 0;
146944
+ KeyInfo *pKeyInfo = 0;
146945
+
146946
+ if( pMWin->pOrderBy ){
146947
+ pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy, 0, 0);
146948
+ }
146949
+ if( pMWin->eExclude==TK_TIES ){
146950
+ addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, 0, regRowid);
146951
+ VdbeCoverageNeverNull(v);
146952
+ }
146953
+ if( pKeyInfo ){
146954
+ windowReadPeerValues(p, csr, regPeer);
146955
+ sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer);
146956
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
146957
+ addr = sqlite3VdbeCurrentAddr(v)+1;
146958
+ sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr);
146959
+ VdbeCoverageEqNe(v);
146960
+ }else{
146961
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblNext);
146962
+ }
146963
+ if( addrEq ) sqlite3VdbeJumpHere(v, addrEq);
146964
+ }
146965
+
146966
+ windowAggStep(pParse, pMWin, csr, 0, p->regArg);
146967
+
146968
+ sqlite3VdbeResolveLabel(v, lblNext);
146969
+ sqlite3VdbeAddOp2(v, OP_Next, csr, addrNext);
146970
+ VdbeCoverage(v);
146971
+ sqlite3VdbeJumpHere(v, addrNext-1);
146972
+ sqlite3VdbeJumpHere(v, addrNext+1);
146973
+ sqlite3ReleaseTempReg(pParse, regRowid);
146974
+ sqlite3ReleaseTempReg(pParse, regCRowid);
146975
+ if( nPeer ){
146976
+ sqlite3ReleaseTempRange(pParse, regPeer, nPeer);
146977
+ sqlite3ReleaseTempRange(pParse, regCPeer, nPeer);
146978
+ }
146979
+
146980
+ windowAggFinal(p, 1);
146535146981
}
146536146982
146537146983
/*
146538146984
** Invoke the sub-routine at regGosub (generated by code in select.c) to
146539146985
** return the current row of Window.iEphCsr. If all window functions are
@@ -146545,114 +146991,78 @@
146545146991
** nth_value()
146546146992
** first_value()
146547146993
** lag()
146548146994
** lead()
146549146995
*/
146550
-static void windowReturnOneRow(
146551
- Parse *pParse,
146552
- Window *pMWin,
146553
- int regGosub,
146554
- int addrGosub
146555
-){
146556
- Vdbe *v = sqlite3GetVdbe(pParse);
146557
- Window *pWin;
146558
- for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146559
- FuncDef *pFunc = pWin->pFunc;
146560
- if( pFunc->zName==nth_valueName
146561
- || pFunc->zName==first_valueName
146562
- ){
146563
- int csr = pWin->csrApp;
146564
- int lbl = sqlite3VdbeMakeLabel(pParse);
146565
- int tmpReg = sqlite3GetTempReg(pParse);
146566
- sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146567
-
146568
- if( pFunc->zName==nth_valueName ){
146569
- sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+1,tmpReg);
146570
- windowCheckIntValue(pParse, tmpReg, 2);
146571
- }else{
146572
- sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
146573
- }
146574
- sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
146575
- sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
146576
- VdbeCoverageNeverNull(v);
146577
- sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
146578
- VdbeCoverageNeverTaken(v);
146579
- sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
146580
- sqlite3VdbeResolveLabel(v, lbl);
146581
- sqlite3ReleaseTempReg(pParse, tmpReg);
146582
- }
146583
- else if( pFunc->zName==leadName || pFunc->zName==lagName ){
146584
- int nArg = pWin->pOwner->x.pList->nExpr;
146585
- int iEph = pMWin->iEphCsr;
146586
- int csr = pWin->csrApp;
146587
- int lbl = sqlite3VdbeMakeLabel(pParse);
146588
- int tmpReg = sqlite3GetTempReg(pParse);
146589
-
146590
- if( nArg<3 ){
146591
- sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146592
- }else{
146593
- sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);
146594
- }
146595
- sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
146596
- if( nArg<2 ){
146597
- int val = (pFunc->zName==leadName ? 1 : -1);
146598
- sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
146599
- }else{
146600
- int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
146601
- int tmpReg2 = sqlite3GetTempReg(pParse);
146602
- sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
146603
- sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
146604
- sqlite3ReleaseTempReg(pParse, tmpReg2);
146605
- }
146606
-
146607
- sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
146608
- VdbeCoverage(v);
146609
- sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
146610
- sqlite3VdbeResolveLabel(v, lbl);
146611
- sqlite3ReleaseTempReg(pParse, tmpReg);
146612
- }
146613
- }
146614
- sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
146615
-}
146616
-
146617
-/*
146618
-** Invoke the code generated by windowReturnOneRow() and, optionally, the
146619
-** xInverse() function for each window function, for one or more rows
146620
-** from the Window.iEphCsr temp table. This routine generates VM code
146621
-** similar to:
146622
-**
146623
-** while( regCtr>0 ){
146624
-** regCtr--;
146625
-** windowReturnOneRow()
146626
-** if( bInverse ){
146627
-** AggInverse
146628
-** }
146629
-** Next (Window.iEphCsr)
146630
-** }
146631
-*/
146632
-static void windowReturnRows(
146633
- Parse *pParse,
146634
- Window *pMWin, /* List of window functions */
146635
- int regCtr, /* Register containing number of rows */
146636
- int regGosub, /* Register for Gosub addrGosub */
146637
- int addrGosub, /* Address of sub-routine for ReturnOneRow */
146638
- int regInvArg, /* Array of registers for xInverse args */
146639
- int regInvSize /* Register containing size of partition */
146640
-){
146641
- int addr;
146642
- Vdbe *v = sqlite3GetVdbe(pParse);
146643
- windowAggFinal(pParse, pMWin, 0);
146644
- addr = sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 ,1);
146645
- VdbeCoverage(v);
146646
- sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
146647
- windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
146648
- if( regInvArg ){
146649
- windowAggStep(pParse, pMWin, pMWin->iEphCsr, 1, regInvArg, regInvSize);
146650
- }
146651
- sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, addr);
146652
- VdbeCoverage(v);
146653
- sqlite3VdbeJumpHere(v, addr+1); /* The OP_Goto */
146996
+static void windowReturnOneRow(WindowCodeArg *p){
146997
+ Window *pMWin = p->pMWin;
146998
+ Vdbe *v = p->pVdbe;
146999
+
147000
+ if( pMWin->regStartRowid ){
147001
+ windowFullScan(p);
147002
+ }else{
147003
+ Parse *pParse = p->pParse;
147004
+ Window *pWin;
147005
+
147006
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147007
+ FuncDef *pFunc = pWin->pFunc;
147008
+ if( pFunc->zName==nth_valueName
147009
+ || pFunc->zName==first_valueName
147010
+ ){
147011
+ int csr = pWin->csrApp;
147012
+ int lbl = sqlite3VdbeMakeLabel(pParse);
147013
+ int tmpReg = sqlite3GetTempReg(pParse);
147014
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
147015
+
147016
+ if( pFunc->zName==nth_valueName ){
147017
+ sqlite3VdbeAddOp3(v, OP_Column,pMWin->iEphCsr,pWin->iArgCol+1,tmpReg);
147018
+ windowCheckValue(pParse, tmpReg, 2);
147019
+ }else{
147020
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
147021
+ }
147022
+ sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
147023
+ sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
147024
+ VdbeCoverageNeverNull(v);
147025
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
147026
+ VdbeCoverageNeverTaken(v);
147027
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
147028
+ sqlite3VdbeResolveLabel(v, lbl);
147029
+ sqlite3ReleaseTempReg(pParse, tmpReg);
147030
+ }
147031
+ else if( pFunc->zName==leadName || pFunc->zName==lagName ){
147032
+ int nArg = pWin->pOwner->x.pList->nExpr;
147033
+ int csr = pWin->csrApp;
147034
+ int lbl = sqlite3VdbeMakeLabel(pParse);
147035
+ int tmpReg = sqlite3GetTempReg(pParse);
147036
+ int iEph = pMWin->iEphCsr;
147037
+
147038
+ if( nArg<3 ){
147039
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
147040
+ }else{
147041
+ sqlite3VdbeAddOp3(v, OP_Column, iEph,pWin->iArgCol+2,pWin->regResult);
147042
+ }
147043
+ sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
147044
+ if( nArg<2 ){
147045
+ int val = (pFunc->zName==leadName ? 1 : -1);
147046
+ sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
147047
+ }else{
147048
+ int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
147049
+ int tmpReg2 = sqlite3GetTempReg(pParse);
147050
+ sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
147051
+ sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
147052
+ sqlite3ReleaseTempReg(pParse, tmpReg2);
147053
+ }
147054
+
147055
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
147056
+ VdbeCoverage(v);
147057
+ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
147058
+ sqlite3VdbeResolveLabel(v, lbl);
147059
+ sqlite3ReleaseTempReg(pParse, tmpReg);
147060
+ }
147061
+ }
147062
+ }
147063
+ sqlite3VdbeAddOp2(v, OP_Gosub, p->regGosub, p->addrGosub);
146654147064
}
146655147065
146656147066
/*
146657147067
** Generate code to set the accumulator register for each window function
146658147068
** in the linked list passed as the second argument to NULL. And perform
@@ -146666,693 +147076,269 @@
146666147076
Window *pWin;
146667147077
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146668147078
FuncDef *pFunc = pWin->pFunc;
146669147079
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146670147080
nArg = MAX(nArg, windowArgCount(pWin));
146671
- if( pFunc->zName==nth_valueName
146672
- || pFunc->zName==first_valueName
146673
- ){
146674
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
146675
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146676
- }
146677
-
146678
- if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
146679
- assert( pWin->eStart!=TK_UNBOUNDED );
146680
- sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
146681
- sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147081
+ if( pMWin->regStartRowid==0 ){
147082
+ if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){
147083
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
147084
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147085
+ }
147086
+
147087
+ if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
147088
+ assert( pWin->eStart!=TK_UNBOUNDED );
147089
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
147090
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147091
+ }
146682147092
}
146683147093
}
146684147094
regArg = pParse->nMem+1;
146685147095
pParse->nMem += nArg;
146686147096
return regArg;
146687147097
}
146688147098
146689
-
146690
-/*
146691
-** This function does the work of sqlite3WindowCodeStep() for all "ROWS"
146692
-** window frame types except for "BETWEEN UNBOUNDED PRECEDING AND CURRENT
146693
-** ROW". Pseudo-code for each follows.
146694
-**
146695
-** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
146696
-**
146697
-** ...
146698
-** if( new partition ){
146699
-** Gosub flush_partition
146700
-** }
146701
-** Insert (record in eph-table)
146702
-** sqlite3WhereEnd()
146703
-** Gosub flush_partition
146704
-**
146705
-** flush_partition:
146706
-** Once {
146707
-** OpenDup (iEphCsr -> csrStart)
146708
-** OpenDup (iEphCsr -> csrEnd)
146709
-** }
146710
-** regStart = <expr1> // PRECEDING expression
146711
-** regEnd = <expr2> // FOLLOWING expression
146712
-** if( regStart<0 || regEnd<0 ){ error! }
146713
-** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146714
-** Next(csrEnd) // if EOF skip Aggstep
146715
-** Aggstep (csrEnd)
146716
-** if( (regEnd--)<=0 ){
146717
-** AggFinal (xValue)
146718
-** Gosub addrGosub
146719
-** Next(csr) // if EOF goto flush_partition_done
146720
-** if( (regStart--)<=0 ){
146721
-** AggInverse (csrStart)
146722
-** Next(csrStart)
146723
-** }
146724
-** }
146725
-** flush_partition_done:
146726
-** ResetSorter (csr)
146727
-** Return
146728
-**
146729
-** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
146730
-** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
146731
-** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
146732
-**
146733
-** These are similar to the above. For "CURRENT ROW", intialize the
146734
-** register to 0. For "UNBOUNDED PRECEDING" to infinity.
146735
-**
146736
-** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
146737
-** ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
146738
-**
146739
-** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146740
-** while( 1 ){
146741
-** Next(csrEnd) // Exit while(1) at EOF
146742
-** Aggstep (csrEnd)
146743
-** }
146744
-** while( 1 ){
146745
-** AggFinal (xValue)
146746
-** Gosub addrGosub
146747
-** Next(csr) // if EOF goto flush_partition_done
146748
-** if( (regStart--)<=0 ){
146749
-** AggInverse (csrStart)
146750
-** Next(csrStart)
146751
-** }
146752
-** }
146753
-**
146754
-** For the "CURRENT ROW AND UNBOUNDED FOLLOWING" case, the final if()
146755
-** condition is always true (as if regStart were initialized to 0).
146756
-**
146757
-** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
146758
-**
146759
-** This is the only RANGE case handled by this routine. It modifies the
146760
-** second while( 1 ) loop in "ROWS BETWEEN CURRENT ... UNBOUNDED..." to
146761
-** be:
146762
-**
146763
-** while( 1 ){
146764
-** AggFinal (xValue)
146765
-** while( 1 ){
146766
-** regPeer++
146767
-** Gosub addrGosub
146768
-** Next(csr) // if EOF goto flush_partition_done
146769
-** if( new peer ) break;
146770
-** }
146771
-** while( (regPeer--)>0 ){
146772
-** AggInverse (csrStart)
146773
-** Next(csrStart)
146774
-** }
146775
-** }
146776
-**
146777
-** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
146778
-**
146779
-** regEnd = regEnd - regStart
146780
-** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146781
-** Aggstep (csrEnd)
146782
-** Next(csrEnd) // if EOF fall-through
146783
-** if( (regEnd--)<=0 ){
146784
-** if( (regStart--)<=0 ){
146785
-** AggFinal (xValue)
146786
-** Gosub addrGosub
146787
-** Next(csr) // if EOF goto flush_partition_done
146788
-** }
146789
-** AggInverse (csrStart)
146790
-** Next (csrStart)
146791
-** }
146792
-**
146793
-** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
146794
-**
146795
-** Replace the bit after "Rewind" in the above with:
146796
-**
146797
-** if( (regEnd--)<=0 ){
146798
-** AggStep (csrEnd)
146799
-** Next (csrEnd)
146800
-** }
146801
-** AggFinal (xValue)
146802
-** Gosub addrGosub
146803
-** Next(csr) // if EOF goto flush_partition_done
146804
-** if( (regStart--)<=0 ){
146805
-** AggInverse (csr2)
146806
-** Next (csr2)
146807
-** }
146808
-**
146809
-*/
146810
-static void windowCodeRowExprStep(
146811
- Parse *pParse,
146812
- Select *p,
146813
- WhereInfo *pWInfo,
146814
- int regGosub,
146815
- int addrGosub
146816
-){
146817
- Window *pMWin = p->pWin;
146818
- Vdbe *v = sqlite3GetVdbe(pParse);
146819
- int regFlushPart; /* Register for "Gosub flush_partition" */
146820
- int lblFlushPart; /* Label for "Gosub flush_partition" */
146821
- int lblFlushDone; /* Label for "Gosub flush_partition_done" */
146822
-
146823
- int regArg;
146824
- int addr;
146825
- int csrStart = pParse->nTab++;
146826
- int csrEnd = pParse->nTab++;
146827
- int regStart; /* Value of <expr> PRECEDING */
146828
- int regEnd; /* Value of <expr> FOLLOWING */
146829
- int addrGoto;
146830
- int addrTop;
146831
- int addrIfPos1 = 0;
146832
- int addrIfPos2 = 0;
146833
- int regSize = 0;
146834
-
146835
- assert( pMWin->eStart==TK_PRECEDING
146836
- || pMWin->eStart==TK_CURRENT
146837
- || pMWin->eStart==TK_FOLLOWING
146838
- || pMWin->eStart==TK_UNBOUNDED
146839
- );
146840
- assert( pMWin->eEnd==TK_FOLLOWING
146841
- || pMWin->eEnd==TK_CURRENT
146842
- || pMWin->eEnd==TK_UNBOUNDED
146843
- || pMWin->eEnd==TK_PRECEDING
146844
- );
146845
-
146846
- /* Allocate register and label for the "flush_partition" sub-routine. */
146847
- regFlushPart = ++pParse->nMem;
146848
- lblFlushPart = sqlite3VdbeMakeLabel(pParse);
146849
- lblFlushDone = sqlite3VdbeMakeLabel(pParse);
146850
-
146851
- regStart = ++pParse->nMem;
146852
- regEnd = ++pParse->nMem;
146853
-
146854
- windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
146855
-
146856
- addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
146857
-
146858
- /* Start of "flush_partition" */
146859
- sqlite3VdbeResolveLabel(v, lblFlushPart);
146860
- sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
146861
- VdbeCoverage(v);
146862
- VdbeComment((v, "Flush_partition subroutine"));
146863
- sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
146864
- sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);
146865
-
146866
- /* If either regStart or regEnd are not non-negative integers, throw
146867
- ** an exception. */
146868
- if( pMWin->pStart ){
146869
- sqlite3ExprCode(pParse, pMWin->pStart, regStart);
146870
- windowCheckIntValue(pParse, regStart, 0);
146871
- }
146872
- if( pMWin->pEnd ){
146873
- sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
146874
- windowCheckIntValue(pParse, regEnd, 1);
146875
- }
146876
-
146877
- /* If this is "ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING", do:
146878
- **
146879
- ** if( regEnd<regStart ){
146880
- ** // The frame always consists of 0 rows
146881
- ** regStart = regSize;
146882
- ** }
146883
- ** regEnd = regEnd - regStart;
146884
- */
146885
- if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){
146886
- assert( pMWin->pStart!=0 );
146887
- assert( pMWin->eEnd==TK_FOLLOWING );
146888
- sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);
146889
- VdbeCoverageNeverNull(v);
146890
- sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
146891
- sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
146892
- }
146893
-
146894
- if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){
146895
- assert( pMWin->pEnd!=0 );
146896
- assert( pMWin->eStart==TK_PRECEDING );
146897
- sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);
146898
- VdbeCoverageNeverNull(v);
146899
- sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
146900
- sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);
146901
- }
146902
-
146903
- /* Initialize the accumulator register for each window function to NULL */
146904
- regArg = windowInitAccum(pParse, pMWin);
146905
-
146906
- sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
146907
- VdbeCoverage(v);
146908
- sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
146909
- VdbeCoverageNeverTaken(v);
146910
- sqlite3VdbeChangeP5(v, 1);
146911
- sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);
146912
- VdbeCoverageNeverTaken(v);
146913
- sqlite3VdbeChangeP5(v, 1);
146914
-
146915
- /* Invoke AggStep function for each window function using the row that
146916
- ** csrEnd currently points to. Or, if csrEnd is already at EOF,
146917
- ** do nothing. */
146918
- addrTop = sqlite3VdbeCurrentAddr(v);
146919
- if( pMWin->eEnd==TK_PRECEDING ){
146920
- addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
146921
- VdbeCoverage(v);
146922
- }
146923
- sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
146924
- VdbeCoverage(v);
146925
- addr = sqlite3VdbeAddOp0(v, OP_Goto);
146926
- windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
146927
- if( pMWin->eEnd==TK_UNBOUNDED ){
146928
- sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
146929
- sqlite3VdbeJumpHere(v, addr);
146930
- addrTop = sqlite3VdbeCurrentAddr(v);
146931
- }else{
146932
- sqlite3VdbeJumpHere(v, addr);
146933
- if( pMWin->eEnd==TK_PRECEDING ){
146934
- sqlite3VdbeJumpHere(v, addrIfPos1);
146935
- }
146936
- }
146937
-
146938
- if( pMWin->eEnd==TK_FOLLOWING ){
146939
- addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
146940
- VdbeCoverage(v);
146941
- }
146942
- if( pMWin->eStart==TK_FOLLOWING ){
146943
- addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
146944
- VdbeCoverage(v);
146945
- }
146946
- windowAggFinal(pParse, pMWin, 0);
146947
- windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
146948
- sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
146949
- VdbeCoverage(v);
146950
- sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
146951
- if( pMWin->eStart==TK_FOLLOWING ){
146952
- sqlite3VdbeJumpHere(v, addrIfPos2);
146953
- }
146954
-
146955
- if( pMWin->eStart==TK_CURRENT
146956
- || pMWin->eStart==TK_PRECEDING
146957
- || pMWin->eStart==TK_FOLLOWING
146958
- ){
146959
- int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;
146960
- if( pMWin->eStart==TK_PRECEDING ){
146961
- sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
146962
- VdbeCoverage(v);
146963
- }
146964
- if( pMWin->eStart==TK_FOLLOWING ){
146965
- sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
146966
- VdbeCoverage(v);
146967
- sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
146968
- }else{
146969
- sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
146970
- VdbeCoverageAlwaysTaken(v);
146971
- }
146972
- windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
146973
- sqlite3VdbeResolveLabel(v, lblSkipInverse);
146974
- }
146975
- if( pMWin->eEnd==TK_FOLLOWING ){
146976
- sqlite3VdbeJumpHere(v, addrIfPos1);
146977
- }
146978
- sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
146979
-
146980
- /* flush_partition_done: */
146981
- sqlite3VdbeResolveLabel(v, lblFlushDone);
146982
- sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
146983
- sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
146984
- VdbeComment((v, "end flush_partition subroutine"));
146985
-
146986
- /* Jump to here to skip over flush_partition */
146987
- sqlite3VdbeJumpHere(v, addrGoto);
146988
-}
146989
-
146990
-/*
146991
-** This function does the work of sqlite3WindowCodeStep() for cases that
146992
-** would normally be handled by windowCodeDefaultStep() when there are
146993
-** one or more built-in window-functions that require the entire partition
146994
-** to be cached in a temp table before any rows can be returned. Additionally.
146995
-** "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" is always handled by
146996
-** this function.
146997
-**
146998
-** Pseudo-code corresponding to the VM code generated by this function
146999
-** for each type of window follows.
147000
-**
147001
-** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147002
-**
147003
-** flush_partition:
147004
-** Once {
147005
-** OpenDup (iEphCsr -> csrLead)
147006
-** }
147007
-** Integer ctr 0
147008
-** foreach row (csrLead){
147009
-** if( new peer ){
147010
-** AggFinal (xValue)
147011
-** for(i=0; i<ctr; i++){
147012
-** Gosub addrGosub
147013
-** Next iEphCsr
147014
-** }
147015
-** Integer ctr 0
147016
-** }
147017
-** AggStep (csrLead)
147018
-** Incr ctr
147019
-** }
147020
-**
147021
-** AggFinal (xFinalize)
147022
-** for(i=0; i<ctr; i++){
147023
-** Gosub addrGosub
147024
-** Next iEphCsr
147025
-** }
147026
-**
147027
-** ResetSorter (csr)
147028
-** Return
147029
-**
147030
-** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147031
-**
147032
-** As above, except that the "if( new peer )" branch is always taken.
147033
-**
147034
-** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147035
-**
147036
-** As above, except that each of the for() loops becomes:
147037
-**
147038
-** for(i=0; i<ctr; i++){
147039
-** Gosub addrGosub
147040
-** AggInverse (iEphCsr)
147041
-** Next iEphCsr
147042
-** }
147043
-**
147044
-** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147045
-**
147046
-** flush_partition:
147047
-** Once {
147048
-** OpenDup (iEphCsr -> csrLead)
147049
-** }
147050
-** foreach row (csrLead) {
147051
-** AggStep (csrLead)
147052
-** }
147053
-** foreach row (iEphCsr) {
147054
-** Gosub addrGosub
147055
-** }
147056
-**
147057
-** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
147058
-**
147059
-** flush_partition:
147060
-** Once {
147061
-** OpenDup (iEphCsr -> csrLead)
147062
-** }
147063
-** foreach row (csrLead){
147064
-** AggStep (csrLead)
147065
-** }
147066
-** Rewind (csrLead)
147067
-** Integer ctr 0
147068
-** foreach row (csrLead){
147069
-** if( new peer ){
147070
-** AggFinal (xValue)
147071
-** for(i=0; i<ctr; i++){
147072
-** Gosub addrGosub
147073
-** AggInverse (iEphCsr)
147074
-** Next iEphCsr
147075
-** }
147076
-** Integer ctr 0
147077
-** }
147078
-** Incr ctr
147079
-** }
147080
-**
147081
-** AggFinal (xFinalize)
147082
-** for(i=0; i<ctr; i++){
147083
-** Gosub addrGosub
147084
-** Next iEphCsr
147085
-** }
147086
-**
147087
-** ResetSorter (csr)
147088
-** Return
147089
-*/
147090
-static void windowCodeCacheStep(
147091
- Parse *pParse,
147092
- Select *p,
147093
- WhereInfo *pWInfo,
147094
- int regGosub,
147095
- int addrGosub
147096
-){
147097
- Window *pMWin = p->pWin;
147098
- Vdbe *v = sqlite3GetVdbe(pParse);
147099
- int k;
147100
- int addr;
147101
- ExprList *pPart = pMWin->pPartition;
147102
- ExprList *pOrderBy = pMWin->pOrderBy;
147103
- int nPeer = pOrderBy ? pOrderBy->nExpr : 0;
147104
- int regNewPeer;
147105
-
147106
- int addrGoto; /* Address of Goto used to jump flush_par.. */
147107
- int addrNext; /* Jump here for next iteration of loop */
147108
- int regFlushPart;
147109
- int lblFlushPart;
147110
- int csrLead;
147111
- int regCtr;
147112
- int regArg; /* Register array to martial function args */
147113
- int regSize;
147114
- int lblEmpty;
147115
- int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT
147116
- && pMWin->eEnd==TK_UNBOUNDED;
147117
-
147118
- assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147119
- || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
147120
- || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
147121
- || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
147122
- );
147123
-
147124
- lblEmpty = sqlite3VdbeMakeLabel(pParse);
147125
- regNewPeer = pParse->nMem+1;
147126
- pParse->nMem += nPeer;
147127
-
147128
- /* Allocate register and label for the "flush_partition" sub-routine. */
147129
- regFlushPart = ++pParse->nMem;
147130
- lblFlushPart = sqlite3VdbeMakeLabel(pParse);
147131
-
147132
- csrLead = pParse->nTab++;
147133
- regCtr = ++pParse->nMem;
147134
-
147135
- windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
147136
- addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147137
-
147138
- /* Start of "flush_partition" */
147139
- sqlite3VdbeResolveLabel(v, lblFlushPart);
147140
- sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
147141
- VdbeCoverage(v);
147142
- sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);
147143
-
147144
- /* Initialize the accumulator register for each window function to NULL */
147145
- regArg = windowInitAccum(pParse, pMWin);
147146
-
147147
- sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);
147148
- sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
147149
- VdbeCoverage(v);
147150
- sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);
147151
- VdbeCoverageNeverTaken(v);
147152
-
147153
- if( bReverse ){
147154
- int addr2 = sqlite3VdbeCurrentAddr(v);
147155
- windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
147156
- sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);
147157
- VdbeCoverage(v);
147158
- sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
147159
- VdbeCoverageNeverTaken(v);
147160
- }
147161
- addrNext = sqlite3VdbeCurrentAddr(v);
147162
-
147163
- if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){
147164
- int bCurrent = (pMWin->eStart==TK_CURRENT);
147165
- int addrJump = 0; /* Address of OP_Jump below */
147166
- if( pMWin->eType==TK_RANGE ){
147167
- int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
147168
- int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);
147169
- KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147170
- for(k=0; k<nPeer; k++){
147171
- sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);
147172
- }
147173
- addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
147174
- sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147175
- addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147176
- VdbeCoverage(v);
147177
- sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);
147178
- }
147179
-
147180
- windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub,
147181
- (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)
147182
- );
147183
- if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147184
- }
147185
-
147186
- if( bReverse==0 ){
147187
- windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
147188
- }
147189
- sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);
147190
- sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);
147191
- VdbeCoverage(v);
147192
-
147193
- windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);
147194
-
147195
- sqlite3VdbeResolveLabel(v, lblEmpty);
147196
- sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
147197
- sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
147198
-
147199
- /* Jump to here to skip over flush_partition */
147200
- sqlite3VdbeJumpHere(v, addrGoto);
147201
-}
147202
-
147203
-
147204
-/*
147205
-** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147206
-**
147207
-** ...
147208
-** if( new partition ){
147209
-** AggFinal (xFinalize)
147210
-** Gosub addrGosub
147211
-** ResetSorter eph-table
147212
-** }
147213
-** else if( new peer ){
147214
-** AggFinal (xValue)
147215
-** Gosub addrGosub
147216
-** ResetSorter eph-table
147217
-** }
147218
-** AggStep
147219
-** Insert (record into eph-table)
147220
-** sqlite3WhereEnd()
147221
-** AggFinal (xFinalize)
147222
-** Gosub addrGosub
147223
-**
147224
-** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147225
-**
147226
-** As above, except take no action for a "new peer". Invoke
147227
-** the sub-routine once only for each partition.
147228
-**
147229
-** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147230
-**
147231
-** As above, except that the "new peer" condition is handled in the
147232
-** same way as "new partition" (so there is no "else if" block).
147233
-**
147234
-** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147235
-**
147236
-** As above, except assume every row is a "new peer".
147237
-*/
147238
-static void windowCodeDefaultStep(
147239
- Parse *pParse,
147240
- Select *p,
147241
- WhereInfo *pWInfo,
147242
- int regGosub,
147243
- int addrGosub
147244
-){
147245
- Window *pMWin = p->pWin;
147246
- Vdbe *v = sqlite3GetVdbe(pParse);
147247
- int k;
147248
- int iSubCsr = p->pSrc->a[0].iCursor;
147249
- int nSub = p->pSrc->a[0].pTab->nCol;
147250
- int reg = pParse->nMem+1;
147251
- int regRecord = reg+nSub;
147252
- int regRowid = regRecord+1;
147253
- int addr;
147254
- ExprList *pPart = pMWin->pPartition;
147255
- ExprList *pOrderBy = pMWin->pOrderBy;
147256
-
147257
- assert( pMWin->eType==TK_RANGE
147258
- || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147259
- );
147260
-
147261
- assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147262
- || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
147263
- || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
147264
- || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)
147265
- );
147266
-
147267
- if( pMWin->eEnd==TK_UNBOUNDED ){
147268
- pOrderBy = 0;
147269
- }
147270
-
147271
- pParse->nMem += nSub + 2;
147272
-
147273
- /* Load the individual column values of the row returned by
147274
- ** the sub-select into an array of registers. */
147275
- for(k=0; k<nSub; k++){
147276
- sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
147277
- }
147278
-
147279
- /* Check if this is the start of a new partition or peer group. */
147280
- if( pPart || pOrderBy ){
147281
- int nPart = (pPart ? pPart->nExpr : 0);
147282
- int addrGoto = 0;
147283
- int addrJump = 0;
147284
- int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
147285
-
147286
- if( pPart ){
147287
- int regNewPart = reg + pMWin->nBufferCol;
147288
- KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
147289
- addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
147290
- sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147291
- addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147292
- VdbeCoverageEqNe(v);
147293
- windowAggFinal(pParse, pMWin, 1);
147294
- if( pOrderBy ){
147295
- addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147296
- }
147297
- }
147298
-
147299
- if( pOrderBy ){
147300
- int regNewPeer = reg + pMWin->nBufferCol + nPart;
147301
- int regPeer = pMWin->regPart + nPart;
147302
-
147303
- if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147304
- if( pMWin->eType==TK_RANGE ){
147305
- KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147306
- addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
147307
- sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147308
- addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147309
- VdbeCoverage(v);
147310
- }else{
147311
- addrJump = 0;
147312
- }
147313
- windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
147314
- if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
147315
- }
147316
-
147317
- sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
147318
- VdbeCoverage(v);
147319
- sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
147320
- sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
147321
- VdbeCoverage(v);
147322
-
147323
- sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
147324
- sqlite3VdbeAddOp3(
147325
- v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
147326
- );
147327
-
147328
- if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147329
- }
147330
-
147331
- /* Invoke step function for window functions */
147332
- windowAggStep(pParse, pMWin, -1, 0, reg, 0);
147333
-
147334
- /* Buffer the current row in the ephemeral table. */
147335
- if( pMWin->nBufferCol>0 ){
147336
- sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
147337
- }else{
147338
- sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
147339
- sqlite3VdbeAppendP4(v, (void*)"", 0);
147340
- }
147341
- sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
147342
- sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
147343
-
147344
- /* End the database scan loop. */
147345
- sqlite3WhereEnd(pWInfo);
147346
-
147347
- windowAggFinal(pParse, pMWin, 1);
147348
- sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
147349
- VdbeCoverage(v);
147350
- sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
147351
- sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
147352
- VdbeCoverage(v);
147353
-}
147099
+/*
147100
+** Return true if the current frame should be cached in the ephemeral table,
147101
+** even if there are no xInverse() calls required.
147102
+*/
147103
+static int windowCacheFrame(Window *pMWin){
147104
+ Window *pWin;
147105
+ if( pMWin->regStartRowid ) return 1;
147106
+ for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147107
+ FuncDef *pFunc = pWin->pFunc;
147108
+ if( (pFunc->zName==nth_valueName)
147109
+ || (pFunc->zName==first_valueName)
147110
+ || (pFunc->zName==leadName)
147111
+ || (pFunc->zName==lagName)
147112
+ ){
147113
+ return 1;
147114
+ }
147115
+ }
147116
+ return 0;
147117
+}
147118
+
147119
+/*
147120
+** regOld and regNew are each the first register in an array of size
147121
+** pOrderBy->nExpr. This function generates code to compare the two
147122
+** arrays of registers using the collation sequences and other comparison
147123
+** parameters specified by pOrderBy.
147124
+**
147125
+** If the two arrays are not equal, the contents of regNew is copied to
147126
+** regOld and control falls through. Otherwise, if the contents of the arrays
147127
+** are equal, an OP_Goto is executed. The address of the OP_Goto is returned.
147128
+*/
147129
+static void windowIfNewPeer(
147130
+ Parse *pParse,
147131
+ ExprList *pOrderBy,
147132
+ int regNew, /* First in array of new values */
147133
+ int regOld, /* First in array of old values */
147134
+ int addr /* Jump here */
147135
+){
147136
+ Vdbe *v = sqlite3GetVdbe(pParse);
147137
+ if( pOrderBy ){
147138
+ int nVal = pOrderBy->nExpr;
147139
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147140
+ sqlite3VdbeAddOp3(v, OP_Compare, regOld, regNew, nVal);
147141
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147142
+ sqlite3VdbeAddOp3(v, OP_Jump,
147143
+ sqlite3VdbeCurrentAddr(v)+1, addr, sqlite3VdbeCurrentAddr(v)+1
147144
+ );
147145
+ VdbeCoverageEqNe(v);
147146
+ sqlite3VdbeAddOp3(v, OP_Copy, regNew, regOld, nVal-1);
147147
+ }else{
147148
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
147149
+ }
147150
+}
147151
+
147152
+/*
147153
+** This function is called as part of generating VM programs for RANGE
147154
+** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for
147155
+** the ORDER BY term in the window, it generates code equivalent to:
147156
+**
147157
+** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
147158
+**
147159
+** A special type of arithmetic is used such that if csr.peerVal is not
147160
+** a numeric type (real or integer), then the result of the addition is
147161
+** a copy of csr1.peerVal.
147162
+*/
147163
+static void windowCodeRangeTest(
147164
+ WindowCodeArg *p,
147165
+ int op, /* OP_Ge or OP_Gt */
147166
+ int csr1,
147167
+ int regVal,
147168
+ int csr2,
147169
+ int lbl
147170
+){
147171
+ Parse *pParse = p->pParse;
147172
+ Vdbe *v = sqlite3GetVdbe(pParse);
147173
+ int reg1 = sqlite3GetTempReg(pParse);
147174
+ int reg2 = sqlite3GetTempReg(pParse);
147175
+ int arith = OP_Add;
147176
+ int addrGe;
147177
+
147178
+ int regString = ++pParse->nMem;
147179
+
147180
+ assert( op==OP_Ge || op==OP_Gt || op==OP_Le );
147181
+ assert( p->pMWin->pOrderBy && p->pMWin->pOrderBy->nExpr==1 );
147182
+ if( p->pMWin->pOrderBy->a[0].sortOrder ){
147183
+ switch( op ){
147184
+ case OP_Ge: op = OP_Le; break;
147185
+ case OP_Gt: op = OP_Lt; break;
147186
+ default: assert( op==OP_Le ); op = OP_Ge; break;
147187
+ }
147188
+ arith = OP_Subtract;
147189
+ }
147190
+
147191
+ windowReadPeerValues(p, csr1, reg1);
147192
+ windowReadPeerValues(p, csr2, reg2);
147193
+
147194
+ /* Check if the peer value for csr1 value is a text or blob by comparing
147195
+ ** it to the smallest possible string - ''. If it is, jump over the
147196
+ ** OP_Add or OP_Subtract operation and proceed directly to the comparison. */
147197
+ sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
147198
+ addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1);
147199
+ VdbeCoverage(v);
147200
+ sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1);
147201
+ sqlite3VdbeJumpHere(v, addrGe);
147202
+ sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v);
147203
+ sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
147204
+ assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le );
147205
+ testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge);
147206
+ testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt);
147207
+ testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le);
147208
+ testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt);
147209
+
147210
+ sqlite3ReleaseTempReg(pParse, reg1);
147211
+ sqlite3ReleaseTempReg(pParse, reg2);
147212
+}
147213
+
147214
+/*
147215
+** Helper function for sqlite3WindowCodeStep(). Each call to this function
147216
+** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE
147217
+** operation. Refer to the header comment for sqlite3WindowCodeStep() for
147218
+** details.
147219
+*/
147220
+static int windowCodeOp(
147221
+ WindowCodeArg *p, /* Context object */
147222
+ int op, /* WINDOW_RETURN_ROW, AGGSTEP or AGGINVERSE */
147223
+ int regCountdown, /* Register for OP_IfPos countdown */
147224
+ int jumpOnEof /* Jump here if stepped cursor reaches EOF */
147225
+){
147226
+ int csr, reg;
147227
+ Parse *pParse = p->pParse;
147228
+ Window *pMWin = p->pMWin;
147229
+ int ret = 0;
147230
+ Vdbe *v = p->pVdbe;
147231
+ int addrIf = 0;
147232
+ int addrContinue = 0;
147233
+ int addrGoto = 0;
147234
+ int bPeer = (pMWin->eFrmType!=TK_ROWS);
147235
+
147236
+ int lblDone = sqlite3VdbeMakeLabel(pParse);
147237
+ int addrNextRange = 0;
147238
+
147239
+ /* Special case - WINDOW_AGGINVERSE is always a no-op if the frame
147240
+ ** starts with UNBOUNDED PRECEDING. */
147241
+ if( op==WINDOW_AGGINVERSE && pMWin->eStart==TK_UNBOUNDED ){
147242
+ assert( regCountdown==0 && jumpOnEof==0 );
147243
+ return 0;
147244
+ }
147245
+
147246
+ if( regCountdown>0 ){
147247
+ if( pMWin->eFrmType==TK_RANGE ){
147248
+ addrNextRange = sqlite3VdbeCurrentAddr(v);
147249
+ assert( op==WINDOW_AGGINVERSE || op==WINDOW_AGGSTEP );
147250
+ if( op==WINDOW_AGGINVERSE ){
147251
+ if( pMWin->eStart==TK_FOLLOWING ){
147252
+ windowCodeRangeTest(
147253
+ p, OP_Le, p->current.csr, regCountdown, p->start.csr, lblDone
147254
+ );
147255
+ }else{
147256
+ windowCodeRangeTest(
147257
+ p, OP_Ge, p->start.csr, regCountdown, p->current.csr, lblDone
147258
+ );
147259
+ }
147260
+ }else{
147261
+ windowCodeRangeTest(
147262
+ p, OP_Gt, p->end.csr, regCountdown, p->current.csr, lblDone
147263
+ );
147264
+ }
147265
+ }else{
147266
+ addrIf = sqlite3VdbeAddOp3(v, OP_IfPos, regCountdown, 0, 1);
147267
+ VdbeCoverage(v);
147268
+ }
147269
+ }
147270
+
147271
+ if( op==WINDOW_RETURN_ROW && pMWin->regStartRowid==0 ){
147272
+ windowAggFinal(p, 0);
147273
+ }
147274
+ addrContinue = sqlite3VdbeCurrentAddr(v);
147275
+ switch( op ){
147276
+ case WINDOW_RETURN_ROW:
147277
+ csr = p->current.csr;
147278
+ reg = p->current.reg;
147279
+ windowReturnOneRow(p);
147280
+ break;
147281
+
147282
+ case WINDOW_AGGINVERSE:
147283
+ csr = p->start.csr;
147284
+ reg = p->start.reg;
147285
+ if( pMWin->regStartRowid ){
147286
+ assert( pMWin->regEndRowid );
147287
+ sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regStartRowid, 1);
147288
+ }else{
147289
+ windowAggStep(pParse, pMWin, csr, 1, p->regArg);
147290
+ }
147291
+ break;
147292
+
147293
+ default:
147294
+ assert( op==WINDOW_AGGSTEP );
147295
+ csr = p->end.csr;
147296
+ reg = p->end.reg;
147297
+ if( pMWin->regStartRowid ){
147298
+ assert( pMWin->regEndRowid );
147299
+ sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regEndRowid, 1);
147300
+ }else{
147301
+ windowAggStep(pParse, pMWin, csr, 0, p->regArg);
147302
+ }
147303
+ break;
147304
+ }
147305
+
147306
+ if( op==p->eDelete ){
147307
+ sqlite3VdbeAddOp1(v, OP_Delete, csr);
147308
+ sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);
147309
+ }
147310
+
147311
+ if( jumpOnEof ){
147312
+ sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+2);
147313
+ VdbeCoverage(v);
147314
+ ret = sqlite3VdbeAddOp0(v, OP_Goto);
147315
+ }else{
147316
+ sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+1+bPeer);
147317
+ VdbeCoverage(v);
147318
+ if( bPeer ){
147319
+ addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147320
+ }
147321
+ }
147322
+
147323
+ if( bPeer ){
147324
+ int nReg = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
147325
+ int regTmp = (nReg ? sqlite3GetTempRange(pParse, nReg) : 0);
147326
+ windowReadPeerValues(p, csr, regTmp);
147327
+ windowIfNewPeer(pParse, pMWin->pOrderBy, regTmp, reg, addrContinue);
147328
+ sqlite3ReleaseTempRange(pParse, regTmp, nReg);
147329
+ }
147330
+
147331
+ if( addrNextRange ){
147332
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNextRange);
147333
+ }
147334
+ sqlite3VdbeResolveLabel(v, lblDone);
147335
+ if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
147336
+ if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
147337
+ return ret;
147338
+}
147339
+
147354147340
147355147341
/*
147356147342
** Allocate and return a duplicate of the Window object indicated by the
147357147343
** third argument. Set the Window.pOwner field of the new object to
147358147344
** pOwner.
@@ -147365,13 +147351,14 @@
147365147351
pNew->zName = sqlite3DbStrDup(db, p->zName);
147366147352
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
147367147353
pNew->pFunc = p->pFunc;
147368147354
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
147369147355
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
147370
- pNew->eType = p->eType;
147356
+ pNew->eFrmType = p->eFrmType;
147371147357
pNew->eEnd = p->eEnd;
147372147358
pNew->eStart = p->eStart;
147359
+ pNew->eExclude = p->eExclude;
147373147360
pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
147374147361
pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
147375147362
pNew->pOwner = pOwner;
147376147363
}
147377147364
}
@@ -147393,95 +147380,689 @@
147393147380
pp = &((*pp)->pNextWin);
147394147381
}
147395147382
147396147383
return pRet;
147397147384
}
147385
+
147386
+/*
147387
+** Return true if it can be determined at compile time that expression
147388
+** pExpr evaluates to a value that, when cast to an integer, is greater
147389
+** than zero. False otherwise.
147390
+**
147391
+** If an OOM error occurs, this function sets the Parse.db.mallocFailed
147392
+** flag and returns zero.
147393
+*/
147394
+static int windowExprGtZero(Parse *pParse, Expr *pExpr){
147395
+ int ret = 0;
147396
+ sqlite3 *db = pParse->db;
147397
+ sqlite3_value *pVal = 0;
147398
+ sqlite3ValueFromExpr(db, pExpr, db->enc, SQLITE_AFF_NUMERIC, &pVal);
147399
+ if( pVal && sqlite3_value_int(pVal)>0 ){
147400
+ ret = 1;
147401
+ }
147402
+ sqlite3ValueFree(pVal);
147403
+ return ret;
147404
+}
147398147405
147399147406
/*
147400147407
** sqlite3WhereBegin() has already been called for the SELECT statement
147401147408
** passed as the second argument when this function is invoked. It generates
147402
-** code to populate the Window.regResult register for each window function and
147403
-** invoke the sub-routine at instruction addrGosub once for each row.
147404
-** This function calls sqlite3WhereEnd() before returning.
147409
+** code to populate the Window.regResult register for each window function
147410
+** and invoke the sub-routine at instruction addrGosub once for each row.
147411
+** sqlite3WhereEnd() is always called before returning.
147412
+**
147413
+** This function handles several different types of window frames, which
147414
+** require slightly different processing. The following pseudo code is
147415
+** used to implement window frames of the form:
147416
+**
147417
+** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
147418
+**
147419
+** Other window frame types use variants of the following:
147420
+**
147421
+** ... loop started by sqlite3WhereBegin() ...
147422
+** if( new partition ){
147423
+** Gosub flush
147424
+** }
147425
+** Insert new row into eph table.
147426
+**
147427
+** if( first row of partition ){
147428
+** // Rewind three cursors, all open on the eph table.
147429
+** Rewind(csrEnd);
147430
+** Rewind(csrStart);
147431
+** Rewind(csrCurrent);
147432
+**
147433
+** regEnd = <expr2> // FOLLOWING expression
147434
+** regStart = <expr1> // PRECEDING expression
147435
+** }else{
147436
+** // First time this branch is taken, the eph table contains two
147437
+** // rows. The first row in the partition, which all three cursors
147438
+** // currently point to, and the following row.
147439
+** AGGSTEP
147440
+** if( (regEnd--)<=0 ){
147441
+** RETURN_ROW
147442
+** if( (regStart--)<=0 ){
147443
+** AGGINVERSE
147444
+** }
147445
+** }
147446
+** }
147447
+** }
147448
+** flush:
147449
+** AGGSTEP
147450
+** while( 1 ){
147451
+** RETURN ROW
147452
+** if( csrCurrent is EOF ) break;
147453
+** if( (regStart--)<=0 ){
147454
+** AggInverse(csrStart)
147455
+** Next(csrStart)
147456
+** }
147457
+** }
147458
+**
147459
+** The pseudo-code above uses the following shorthand:
147460
+**
147461
+** AGGSTEP: invoke the aggregate xStep() function for each window function
147462
+** with arguments read from the current row of cursor csrEnd, then
147463
+** step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()).
147464
+**
147465
+** RETURN_ROW: return a row to the caller based on the contents of the
147466
+** current row of csrCurrent and the current state of all
147467
+** aggregates. Then step cursor csrCurrent forward one row.
147468
+**
147469
+** AGGINVERSE: invoke the aggregate xInverse() function for each window
147470
+** functions with arguments read from the current row of cursor
147471
+** csrStart. Then step csrStart forward one row.
147472
+**
147473
+** There are two other ROWS window frames that are handled significantly
147474
+** differently from the above - "BETWEEN <expr> PRECEDING AND <expr> PRECEDING"
147475
+** and "BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING". These are special
147476
+** cases because they change the order in which the three cursors (csrStart,
147477
+** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that
147478
+** use UNBOUNDED or CURRENT ROW are much simpler variations on one of these
147479
+** three.
147480
+**
147481
+** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147482
+**
147483
+** ... loop started by sqlite3WhereBegin() ...
147484
+** if( new partition ){
147485
+** Gosub flush
147486
+** }
147487
+** Insert new row into eph table.
147488
+** if( first row of partition ){
147489
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147490
+** regEnd = <expr2>
147491
+** regStart = <expr1>
147492
+** }else{
147493
+** if( (regEnd--)<=0 ){
147494
+** AGGSTEP
147495
+** }
147496
+** RETURN_ROW
147497
+** if( (regStart--)<=0 ){
147498
+** AGGINVERSE
147499
+** }
147500
+** }
147501
+** }
147502
+** flush:
147503
+** if( (regEnd--)<=0 ){
147504
+** AGGSTEP
147505
+** }
147506
+** RETURN_ROW
147507
+**
147508
+**
147509
+** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147510
+**
147511
+** ... loop started by sqlite3WhereBegin() ...
147512
+** if( new partition ){
147513
+** Gosub flush
147514
+** }
147515
+** Insert new row into eph table.
147516
+** if( first row of partition ){
147517
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147518
+** regEnd = <expr2>
147519
+** regStart = regEnd - <expr1>
147520
+** }else{
147521
+** AGGSTEP
147522
+** if( (regEnd--)<=0 ){
147523
+** RETURN_ROW
147524
+** }
147525
+** if( (regStart--)<=0 ){
147526
+** AGGINVERSE
147527
+** }
147528
+** }
147529
+** }
147530
+** flush:
147531
+** AGGSTEP
147532
+** while( 1 ){
147533
+** if( (regEnd--)<=0 ){
147534
+** RETURN_ROW
147535
+** if( eof ) break;
147536
+** }
147537
+** if( (regStart--)<=0 ){
147538
+** AGGINVERSE
147539
+** if( eof ) break
147540
+** }
147541
+** }
147542
+** while( !eof csrCurrent ){
147543
+** RETURN_ROW
147544
+** }
147545
+**
147546
+** For the most part, the patterns above are adapted to support UNBOUNDED by
147547
+** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and
147548
+** CURRENT ROW by assuming that it is equivilent to "0 PRECEDING/FOLLOWING".
147549
+** This is optimized of course - branches that will never be taken and
147550
+** conditions that are always true are omitted from the VM code. The only
147551
+** exceptional case is:
147552
+**
147553
+** ROWS BETWEEN <expr1> FOLLOWING AND UNBOUNDED FOLLOWING
147554
+**
147555
+** ... loop started by sqlite3WhereBegin() ...
147556
+** if( new partition ){
147557
+** Gosub flush
147558
+** }
147559
+** Insert new row into eph table.
147560
+** if( first row of partition ){
147561
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147562
+** regStart = <expr1>
147563
+** }else{
147564
+** AGGSTEP
147565
+** }
147566
+** }
147567
+** flush:
147568
+** AGGSTEP
147569
+** while( 1 ){
147570
+** if( (regStart--)<=0 ){
147571
+** AGGINVERSE
147572
+** if( eof ) break
147573
+** }
147574
+** RETURN_ROW
147575
+** }
147576
+** while( !eof csrCurrent ){
147577
+** RETURN_ROW
147578
+** }
147579
+**
147580
+** Also requiring special handling are the cases:
147581
+**
147582
+** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147583
+** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147584
+**
147585
+** when (expr1 < expr2). This is detected at runtime, not by this function.
147586
+** To handle this case, the pseudo-code programs depicted above are modified
147587
+** slightly to be:
147588
+**
147589
+** ... loop started by sqlite3WhereBegin() ...
147590
+** if( new partition ){
147591
+** Gosub flush
147592
+** }
147593
+** Insert new row into eph table.
147594
+** if( first row of partition ){
147595
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147596
+** regEnd = <expr2>
147597
+** regStart = <expr1>
147598
+** if( regEnd < regStart ){
147599
+** RETURN_ROW
147600
+** delete eph table contents
147601
+** continue
147602
+** }
147603
+** ...
147604
+**
147605
+** The new "continue" statement in the above jumps to the next iteration
147606
+** of the outer loop - the one started by sqlite3WhereBegin().
147607
+**
147608
+** The various GROUPS cases are implemented using the same patterns as
147609
+** ROWS. The VM code is modified slightly so that:
147610
+**
147611
+** 1. The else branch in the main loop is only taken if the row just
147612
+** added to the ephemeral table is the start of a new group. In
147613
+** other words, it becomes:
147614
+**
147615
+** ... loop started by sqlite3WhereBegin() ...
147616
+** if( new partition ){
147617
+** Gosub flush
147618
+** }
147619
+** Insert new row into eph table.
147620
+** if( first row of partition ){
147621
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147622
+** regEnd = <expr2>
147623
+** regStart = <expr1>
147624
+** }else if( new group ){
147625
+** ...
147626
+** }
147627
+** }
147628
+**
147629
+** 2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or
147630
+** AGGINVERSE step processes the current row of the relevant cursor and
147631
+** all subsequent rows belonging to the same group.
147632
+**
147633
+** RANGE window frames are a little different again. As for GROUPS, the
147634
+** main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE
147635
+** deal in groups instead of rows. As for ROWS and GROUPS, there are three
147636
+** basic cases:
147637
+**
147638
+** RANGE BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
147639
+**
147640
+** ... loop started by sqlite3WhereBegin() ...
147641
+** if( new partition ){
147642
+** Gosub flush
147643
+** }
147644
+** Insert new row into eph table.
147645
+** if( first row of partition ){
147646
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147647
+** regEnd = <expr2>
147648
+** regStart = <expr1>
147649
+** }else{
147650
+** AGGSTEP
147651
+** while( (csrCurrent.key + regEnd) < csrEnd.key ){
147652
+** RETURN_ROW
147653
+** while( csrStart.key + regStart) < csrCurrent.key ){
147654
+** AGGINVERSE
147655
+** }
147656
+** }
147657
+** }
147658
+** }
147659
+** flush:
147660
+** AGGSTEP
147661
+** while( 1 ){
147662
+** RETURN ROW
147663
+** if( csrCurrent is EOF ) break;
147664
+** while( csrStart.key + regStart) < csrCurrent.key ){
147665
+** AGGINVERSE
147666
+** }
147667
+** }
147668
+** }
147669
+**
147670
+** In the above notation, "csr.key" means the current value of the ORDER BY
147671
+** expression (there is only ever 1 for a RANGE that uses an <expr> FOLLOWING
147672
+** or <expr PRECEDING) read from cursor csr.
147673
+**
147674
+** RANGE BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147675
+**
147676
+** ... loop started by sqlite3WhereBegin() ...
147677
+** if( new partition ){
147678
+** Gosub flush
147679
+** }
147680
+** Insert new row into eph table.
147681
+** if( first row of partition ){
147682
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147683
+** regEnd = <expr2>
147684
+** regStart = <expr1>
147685
+** }else{
147686
+** if( (csrEnd.key + regEnd) <= csrCurrent.key ){
147687
+** AGGSTEP
147688
+** }
147689
+** while( (csrStart.key + regStart) < csrCurrent.key ){
147690
+** AGGINVERSE
147691
+** }
147692
+** RETURN_ROW
147693
+** }
147694
+** }
147695
+** flush:
147696
+** while( (csrEnd.key + regEnd) <= csrCurrent.key ){
147697
+** AGGSTEP
147698
+** }
147699
+** while( (csrStart.key + regStart) < csrCurrent.key ){
147700
+** AGGINVERSE
147701
+** }
147702
+** RETURN_ROW
147703
+**
147704
+** RANGE BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147705
+**
147706
+** ... loop started by sqlite3WhereBegin() ...
147707
+** if( new partition ){
147708
+** Gosub flush
147709
+** }
147710
+** Insert new row into eph table.
147711
+** if( first row of partition ){
147712
+** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147713
+** regEnd = <expr2>
147714
+** regStart = <expr1>
147715
+** }else{
147716
+** AGGSTEP
147717
+** while( (csrCurrent.key + regEnd) < csrEnd.key ){
147718
+** while( (csrCurrent.key + regStart) > csrStart.key ){
147719
+** AGGINVERSE
147720
+** }
147721
+** RETURN_ROW
147722
+** }
147723
+** }
147724
+** }
147725
+** flush:
147726
+** AGGSTEP
147727
+** while( 1 ){
147728
+** while( (csrCurrent.key + regStart) > csrStart.key ){
147729
+** AGGINVERSE
147730
+** if( eof ) break "while( 1 )" loop.
147731
+** }
147732
+** RETURN_ROW
147733
+** }
147734
+** while( !eof csrCurrent ){
147735
+** RETURN_ROW
147736
+** }
147737
+**
147738
+** The text above leaves out many details. Refer to the code and comments
147739
+** below for a more complete picture.
147405147740
*/
147406147741
SQLITE_PRIVATE void sqlite3WindowCodeStep(
147407147742
Parse *pParse, /* Parse context */
147408147743
Select *p, /* Rewritten SELECT statement */
147409147744
WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */
147410147745
int regGosub, /* Register for OP_Gosub */
147411147746
int addrGosub /* OP_Gosub here to return each row */
147412147747
){
147413147748
Window *pMWin = p->pWin;
147414
-
147415
- /* There are three different functions that may be used to do the work
147416
- ** of this one, depending on the window frame and the specific built-in
147417
- ** window functions used (if any).
147418
- **
147419
- ** windowCodeRowExprStep() handles all "ROWS" window frames, except for:
147420
- **
147421
- ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147422
- **
147423
- ** The exception is because windowCodeRowExprStep() implements all window
147424
- ** frame types by caching the entire partition in a temp table, and
147425
- ** "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" is easy enough to
147426
- ** implement without such a cache.
147427
- **
147428
- ** windowCodeCacheStep() is used for:
147429
- **
147430
- ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
147431
- **
147432
- ** It is also used for anything not handled by windowCodeRowExprStep()
147433
- ** that invokes a built-in window function that requires the entire
147434
- ** partition to be cached in a temp table before any rows are returned
147435
- ** (e.g. nth_value() or percent_rank()).
147436
- **
147437
- ** Finally, assuming there is no built-in window function that requires
147438
- ** the partition to be cached, windowCodeDefaultStep() is used for:
147439
- **
147440
- ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147441
- ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147442
- ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147443
- ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147444
- **
147445
- ** windowCodeDefaultStep() is the only one of the three functions that
147446
- ** does not cache each partition in a temp table before beginning to
147447
- ** return rows.
147448
- */
147449
- if( pMWin->eType==TK_ROWS
147450
- && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy)
147451
- ){
147452
- VdbeModuleComment((pParse->pVdbe, "Begin RowExprStep()"));
147453
- windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
147454
- }else{
147455
- Window *pWin;
147456
- int bCache = 0; /* True to use CacheStep() */
147457
-
147458
- if( pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED ){
147459
- bCache = 1;
147460
- }else{
147461
- for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147462
- FuncDef *pFunc = pWin->pFunc;
147463
- if( (pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE)
147464
- || (pFunc->zName==nth_valueName)
147465
- || (pFunc->zName==first_valueName)
147466
- || (pFunc->zName==leadName)
147467
- || (pFunc->zName==lagName)
147468
- ){
147469
- bCache = 1;
147470
- break;
147471
- }
147472
- }
147473
- }
147474
-
147475
- /* Otherwise, call windowCodeDefaultStep(). */
147476
- if( bCache ){
147477
- VdbeModuleComment((pParse->pVdbe, "Begin CacheStep()"));
147478
- windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
147479
- }else{
147480
- VdbeModuleComment((pParse->pVdbe, "Begin DefaultStep()"));
147481
- windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
147482
- }
147749
+ ExprList *pOrderBy = pMWin->pOrderBy;
147750
+ Vdbe *v = sqlite3GetVdbe(pParse);
147751
+ int csrWrite; /* Cursor used to write to eph. table */
147752
+ int csrInput = p->pSrc->a[0].iCursor; /* Cursor of sub-select */
147753
+ int nInput = p->pSrc->a[0].pTab->nCol; /* Number of cols returned by sub */
147754
+ int iInput; /* To iterate through sub cols */
147755
+ int addrNe; /* Address of OP_Ne */
147756
+ int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */
147757
+ int addrInteger = 0; /* Address of OP_Integer */
147758
+ int addrEmpty; /* Address of OP_Rewind in flush: */
147759
+ int regStart = 0; /* Value of <expr> PRECEDING */
147760
+ int regEnd = 0; /* Value of <expr> FOLLOWING */
147761
+ int regNew; /* Array of registers holding new input row */
147762
+ int regRecord; /* regNew array in record form */
147763
+ int regRowid; /* Rowid for regRecord in eph table */
147764
+ int regNewPeer = 0; /* Peer values for new row (part of regNew) */
147765
+ int regPeer = 0; /* Peer values for current row */
147766
+ int regFlushPart = 0; /* Register for "Gosub flush_partition" */
147767
+ WindowCodeArg s; /* Context object for sub-routines */
147768
+ int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */
147769
+
147770
+ assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_CURRENT
147771
+ || pMWin->eStart==TK_FOLLOWING || pMWin->eStart==TK_UNBOUNDED
147772
+ );
147773
+ assert( pMWin->eEnd==TK_FOLLOWING || pMWin->eEnd==TK_CURRENT
147774
+ || pMWin->eEnd==TK_UNBOUNDED || pMWin->eEnd==TK_PRECEDING
147775
+ );
147776
+ assert( pMWin->eExclude==0 || pMWin->eExclude==TK_CURRENT
147777
+ || pMWin->eExclude==TK_GROUP || pMWin->eExclude==TK_TIES
147778
+ || pMWin->eExclude==TK_NO
147779
+ );
147780
+
147781
+ lblWhereEnd = sqlite3VdbeMakeLabel(pParse);
147782
+
147783
+ /* Fill in the context object */
147784
+ memset(&s, 0, sizeof(WindowCodeArg));
147785
+ s.pParse = pParse;
147786
+ s.pMWin = pMWin;
147787
+ s.pVdbe = v;
147788
+ s.regGosub = regGosub;
147789
+ s.addrGosub = addrGosub;
147790
+ s.current.csr = pMWin->iEphCsr;
147791
+ csrWrite = s.current.csr+1;
147792
+ s.start.csr = s.current.csr+2;
147793
+ s.end.csr = s.current.csr+3;
147794
+
147795
+ /* Figure out when rows may be deleted from the ephemeral table. There
147796
+ ** are four options - they may never be deleted (eDelete==0), they may
147797
+ ** be deleted as soon as they are no longer part of the window frame
147798
+ ** (eDelete==WINDOW_AGGINVERSE), they may be deleted as after the row
147799
+ ** has been returned to the caller (WINDOW_RETURN_ROW), or they may
147800
+ ** be deleted after they enter the frame (WINDOW_AGGSTEP). */
147801
+ switch( pMWin->eStart ){
147802
+ case TK_FOLLOWING:
147803
+ if( pMWin->eFrmType!=TK_RANGE
147804
+ && windowExprGtZero(pParse, pMWin->pStart)
147805
+ ){
147806
+ s.eDelete = WINDOW_RETURN_ROW;
147807
+ }
147808
+ break;
147809
+ case TK_UNBOUNDED:
147810
+ if( windowCacheFrame(pMWin)==0 ){
147811
+ if( pMWin->eEnd==TK_PRECEDING ){
147812
+ if( pMWin->eFrmType!=TK_RANGE
147813
+ && windowExprGtZero(pParse, pMWin->pEnd)
147814
+ ){
147815
+ s.eDelete = WINDOW_AGGSTEP;
147816
+ }
147817
+ }else{
147818
+ s.eDelete = WINDOW_RETURN_ROW;
147819
+ }
147820
+ }
147821
+ break;
147822
+ default:
147823
+ s.eDelete = WINDOW_AGGINVERSE;
147824
+ break;
147825
+ }
147826
+
147827
+ /* Allocate registers for the array of values from the sub-query, the
147828
+ ** samve values in record form, and the rowid used to insert said record
147829
+ ** into the ephemeral table. */
147830
+ regNew = pParse->nMem+1;
147831
+ pParse->nMem += nInput;
147832
+ regRecord = ++pParse->nMem;
147833
+ regRowid = ++pParse->nMem;
147834
+
147835
+ /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
147836
+ ** clause, allocate registers to store the results of evaluating each
147837
+ ** <expr>. */
147838
+ if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){
147839
+ regStart = ++pParse->nMem;
147840
+ }
147841
+ if( pMWin->eEnd==TK_PRECEDING || pMWin->eEnd==TK_FOLLOWING ){
147842
+ regEnd = ++pParse->nMem;
147843
+ }
147844
+
147845
+ /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of
147846
+ ** registers to store copies of the ORDER BY expressions (peer values)
147847
+ ** for the main loop, and for each cursor (start, current and end). */
147848
+ if( pMWin->eFrmType!=TK_ROWS ){
147849
+ int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
147850
+ regNewPeer = regNew + pMWin->nBufferCol;
147851
+ if( pMWin->pPartition ) regNewPeer += pMWin->pPartition->nExpr;
147852
+ regPeer = pParse->nMem+1; pParse->nMem += nPeer;
147853
+ s.start.reg = pParse->nMem+1; pParse->nMem += nPeer;
147854
+ s.current.reg = pParse->nMem+1; pParse->nMem += nPeer;
147855
+ s.end.reg = pParse->nMem+1; pParse->nMem += nPeer;
147856
+ }
147857
+
147858
+ /* Load the column values for the row returned by the sub-select
147859
+ ** into an array of registers starting at regNew. Assemble them into
147860
+ ** a record in register regRecord. */
147861
+ for(iInput=0; iInput<nInput; iInput++){
147862
+ sqlite3VdbeAddOp3(v, OP_Column, csrInput, iInput, regNew+iInput);
147863
+ }
147864
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regNew, nInput, regRecord);
147865
+
147866
+ /* An input row has just been read into an array of registers starting
147867
+ ** at regNew. If the window has a PARTITION clause, this block generates
147868
+ ** VM code to check if the input row is the start of a new partition.
147869
+ ** If so, it does an OP_Gosub to an address to be filled in later. The
147870
+ ** address of the OP_Gosub is stored in local variable addrGosubFlush. */
147871
+ if( pMWin->pPartition ){
147872
+ int addr;
147873
+ ExprList *pPart = pMWin->pPartition;
147874
+ int nPart = pPart->nExpr;
147875
+ int regNewPart = regNew + pMWin->nBufferCol;
147876
+ KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
147877
+
147878
+ regFlushPart = ++pParse->nMem;
147879
+ addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart, nPart);
147880
+ sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147881
+ sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
147882
+ VdbeCoverageEqNe(v);
147883
+ addrGosubFlush = sqlite3VdbeAddOp1(v, OP_Gosub, regFlushPart);
147884
+ VdbeComment((v, "call flush_partition"));
147885
+ sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
147886
+ }
147887
+
147888
+ /* Insert the new row into the ephemeral table */
147889
+ sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid);
147890
+ sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid);
147891
+ addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid);
147892
+ VdbeCoverageNeverNull(v);
147893
+
147894
+ /* This block is run for the first row of each partition */
147895
+ s.regArg = windowInitAccum(pParse, pMWin);
147896
+
147897
+ if( regStart ){
147898
+ sqlite3ExprCode(pParse, pMWin->pStart, regStart);
147899
+ windowCheckValue(pParse, regStart, 0 + (pMWin->eFrmType==TK_RANGE ? 3 : 0));
147900
+ }
147901
+ if( regEnd ){
147902
+ sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
147903
+ windowCheckValue(pParse, regEnd, 1 + (pMWin->eFrmType==TK_RANGE ? 3 : 0));
147904
+ }
147905
+
147906
+ if( pMWin->eStart==pMWin->eEnd && regStart ){
147907
+ int op = ((pMWin->eStart==TK_FOLLOWING) ? OP_Ge : OP_Le);
147908
+ int addrGe = sqlite3VdbeAddOp3(v, op, regStart, 0, regEnd);
147909
+ VdbeCoverageNeverNullIf(v, op==OP_Ge); /* NeverNull because bound <expr> */
147910
+ VdbeCoverageNeverNullIf(v, op==OP_Le); /* values previously checked */
147911
+ windowAggFinal(&s, 0);
147912
+ sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
147913
+ VdbeCoverageNeverTaken(v);
147914
+ windowReturnOneRow(&s);
147915
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
147916
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
147917
+ sqlite3VdbeJumpHere(v, addrGe);
147918
+ }
147919
+ if( pMWin->eStart==TK_FOLLOWING && pMWin->eFrmType!=TK_RANGE && regEnd ){
147920
+ assert( pMWin->eEnd==TK_FOLLOWING );
147921
+ sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regStart);
147922
+ }
147923
+
147924
+ if( pMWin->eStart!=TK_UNBOUNDED ){
147925
+ sqlite3VdbeAddOp2(v, OP_Rewind, s.start.csr, 1);
147926
+ VdbeCoverageNeverTaken(v);
147927
+ }
147928
+ sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
147929
+ VdbeCoverageNeverTaken(v);
147930
+ sqlite3VdbeAddOp2(v, OP_Rewind, s.end.csr, 1);
147931
+ VdbeCoverageNeverTaken(v);
147932
+ if( regPeer && pOrderBy ){
147933
+ sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, pOrderBy->nExpr-1);
147934
+ sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.start.reg, pOrderBy->nExpr-1);
147935
+ sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.current.reg, pOrderBy->nExpr-1);
147936
+ sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.end.reg, pOrderBy->nExpr-1);
147937
+ }
147938
+
147939
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
147940
+
147941
+ sqlite3VdbeJumpHere(v, addrNe);
147942
+
147943
+ /* Beginning of the block executed for the second and subsequent rows. */
147944
+ if( regPeer ){
147945
+ windowIfNewPeer(pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd);
147946
+ }
147947
+ if( pMWin->eStart==TK_FOLLOWING ){
147948
+ windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
147949
+ if( pMWin->eEnd!=TK_UNBOUNDED ){
147950
+ if( pMWin->eFrmType==TK_RANGE ){
147951
+ int lbl = sqlite3VdbeMakeLabel(pParse);
147952
+ int addrNext = sqlite3VdbeCurrentAddr(v);
147953
+ windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl);
147954
+ windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147955
+ windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147956
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNext);
147957
+ sqlite3VdbeResolveLabel(v, lbl);
147958
+ }else{
147959
+ windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 0);
147960
+ windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147961
+ }
147962
+ }
147963
+ }else
147964
+ if( pMWin->eEnd==TK_PRECEDING ){
147965
+ int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
147966
+ windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
147967
+ if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147968
+ windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147969
+ if( !bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147970
+ }else{
147971
+ int addr = 0;
147972
+ windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
147973
+ if( pMWin->eEnd!=TK_UNBOUNDED ){
147974
+ if( pMWin->eFrmType==TK_RANGE ){
147975
+ int lbl = 0;
147976
+ addr = sqlite3VdbeCurrentAddr(v);
147977
+ if( regEnd ){
147978
+ lbl = sqlite3VdbeMakeLabel(pParse);
147979
+ windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl);
147980
+ }
147981
+ windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147982
+ windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147983
+ if( regEnd ){
147984
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
147985
+ sqlite3VdbeResolveLabel(v, lbl);
147986
+ }
147987
+ }else{
147988
+ if( regEnd ){
147989
+ addr = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0, 1);
147990
+ VdbeCoverage(v);
147991
+ }
147992
+ windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147993
+ windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147994
+ if( regEnd ) sqlite3VdbeJumpHere(v, addr);
147995
+ }
147996
+ }
147997
+ }
147998
+
147999
+ /* End of the main input loop */
148000
+ sqlite3VdbeResolveLabel(v, lblWhereEnd);
148001
+ sqlite3WhereEnd(pWInfo);
148002
+
148003
+ /* Fall through */
148004
+ if( pMWin->pPartition ){
148005
+ addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart);
148006
+ sqlite3VdbeJumpHere(v, addrGosubFlush);
148007
+ }
148008
+
148009
+ addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite);
148010
+ VdbeCoverage(v);
148011
+ if( pMWin->eEnd==TK_PRECEDING ){
148012
+ int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
148013
+ windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
148014
+ if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
148015
+ windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
148016
+ }else if( pMWin->eStart==TK_FOLLOWING ){
148017
+ int addrStart;
148018
+ int addrBreak1;
148019
+ int addrBreak2;
148020
+ int addrBreak3;
148021
+ windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
148022
+ if( pMWin->eFrmType==TK_RANGE ){
148023
+ addrStart = sqlite3VdbeCurrentAddr(v);
148024
+ addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1);
148025
+ addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148026
+ }else
148027
+ if( pMWin->eEnd==TK_UNBOUNDED ){
148028
+ addrStart = sqlite3VdbeCurrentAddr(v);
148029
+ addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regStart, 1);
148030
+ addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, 0, 1);
148031
+ }else{
148032
+ assert( pMWin->eEnd==TK_FOLLOWING );
148033
+ addrStart = sqlite3VdbeCurrentAddr(v);
148034
+ addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 1);
148035
+ addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1);
148036
+ }
148037
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148038
+ sqlite3VdbeJumpHere(v, addrBreak2);
148039
+ addrStart = sqlite3VdbeCurrentAddr(v);
148040
+ addrBreak3 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148041
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148042
+ sqlite3VdbeJumpHere(v, addrBreak1);
148043
+ sqlite3VdbeJumpHere(v, addrBreak3);
148044
+ }else{
148045
+ int addrBreak;
148046
+ int addrStart;
148047
+ windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
148048
+ addrStart = sqlite3VdbeCurrentAddr(v);
148049
+ addrBreak = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148050
+ windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
148051
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148052
+ sqlite3VdbeJumpHere(v, addrBreak);
148053
+ }
148054
+ sqlite3VdbeJumpHere(v, addrEmpty);
148055
+
148056
+ sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
148057
+ if( pMWin->pPartition ){
148058
+ if( pMWin->regStartRowid ){
148059
+ sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid);
148060
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid);
148061
+ }
148062
+ sqlite3VdbeChangeP1(v, addrInteger, sqlite3VdbeCurrentAddr(v));
148063
+ sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
147483148064
}
147484148065
}
147485148066
147486148067
#endif /* SQLITE_OMIT_WINDOWFUNC */
147487148068
@@ -147729,31 +148310,32 @@
147729148310
#ifndef INTERFACE
147730148311
# define INTERFACE 1
147731148312
#endif
147732148313
/************* Begin control #defines *****************************************/
147733148314
#define YYCODETYPE unsigned short int
147734
-#define YYNOCODE 278
148315
+#define YYNOCODE 284
147735148316
#define YYACTIONTYPE unsigned short int
147736
-#define YYWILDCARD 91
148317
+#define YYWILDCARD 95
147737148318
#define sqlite3ParserTOKENTYPE Token
147738148319
typedef union {
147739148320
int yyinit;
147740148321
sqlite3ParserTOKENTYPE yy0;
147741
- ExprList* yy42;
147742
- int yy96;
147743
- TriggerStep* yy119;
147744
- Window* yy147;
147745
- SrcList* yy167;
147746
- Upsert* yy266;
147747
- struct FrameBound yy317;
147748
- IdList* yy336;
147749
- struct TrigEvent yy350;
147750
- struct {int value; int mask;} yy367;
147751
- Select* yy423;
147752
- const char* yy464;
147753
- Expr* yy490;
147754
- With* yy499;
148322
+ u8 yy10;
148323
+ const char* yy104;
148324
+ Expr* yy130;
148325
+ SrcList* yy147;
148326
+ IdList* yy200;
148327
+ struct FrameBound yy273;
148328
+ Window* yy395;
148329
+ int yy420;
148330
+ Upsert* yy426;
148331
+ ExprList* yy442;
148332
+ Select* yy491;
148333
+ struct TrigEvent yy498;
148334
+ With* yy523;
148335
+ TriggerStep* yy524;
148336
+ struct {int value; int mask;} yy527;
147755148337
} YYMINORTYPE;
147756148338
#ifndef YYSTACKDEPTH
147757148339
#define YYSTACKDEPTH 100
147758148340
#endif
147759148341
#define sqlite3ParserARG_SDECL
@@ -147765,21 +148347,21 @@
147765148347
#define sqlite3ParserCTX_PDECL ,Parse *pParse
147766148348
#define sqlite3ParserCTX_PARAM ,pParse
147767148349
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
147768148350
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
147769148351
#define YYFALLBACK 1
147770
-#define YYNSTATE 524
147771
-#define YYNRULE 369
147772
-#define YYNTOKEN 155
147773
-#define YY_MAX_SHIFT 523
147774
-#define YY_MIN_SHIFTREDUCE 760
147775
-#define YY_MAX_SHIFTREDUCE 1128
147776
-#define YY_ERROR_ACTION 1129
147777
-#define YY_ACCEPT_ACTION 1130
147778
-#define YY_NO_ACTION 1131
147779
-#define YY_MIN_REDUCE 1132
147780
-#define YY_MAX_REDUCE 1500
148352
+#define YYNSTATE 541
148353
+#define YYNRULE 375
148354
+#define YYNTOKEN 159
148355
+#define YY_MAX_SHIFT 540
148356
+#define YY_MIN_SHIFTREDUCE 784
148357
+#define YY_MAX_SHIFTREDUCE 1158
148358
+#define YY_ERROR_ACTION 1159
148359
+#define YY_ACCEPT_ACTION 1160
148360
+#define YY_NO_ACTION 1161
148361
+#define YY_MIN_REDUCE 1162
148362
+#define YY_MAX_REDUCE 1536
147781148363
/************* End control #defines *******************************************/
147782148364
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
147783148365
147784148366
/* Define the yytestcase() macro to be a no-op if is not already defined
147785148367
** otherwise.
@@ -147842,573 +148424,606 @@
147842148424
** yy_reduce_ofst[] For each state, the offset into yy_action for
147843148425
** shifting non-terminals after a reduce.
147844148426
** yy_default[] Default action for each state.
147845148427
**
147846148428
*********** Begin parsing tables **********************************************/
147847
-#define YY_ACTTAB_COUNT (2009)
148429
+#define YY_ACTTAB_COUNT (2142)
147848148430
static const YYACTIONTYPE yy_action[] = {
147849
- /* 0 */ 377, 518, 371, 107, 104, 200, 1293, 518, 1130, 1,
147850
- /* 10 */ 1, 523, 2, 1134, 518, 1203, 1203, 1262, 277, 373,
147851
- /* 20 */ 129, 495, 37, 37, 1397, 1201, 1201, 1211, 65, 65,
147852
- /* 30 */ 480, 891, 107, 104, 200, 37, 37, 1043, 1494, 892,
147853
- /* 40 */ 346, 1494, 342, 114, 115, 105, 1106, 1106, 957, 960,
147854
- /* 50 */ 950, 950, 112, 112, 113, 113, 113, 113, 285, 254,
147855
- /* 60 */ 254, 518, 254, 254, 500, 518, 495, 518, 107, 104,
147856
- /* 70 */ 200, 1085, 515, 481, 386, 515, 1464, 442, 501, 230,
147857
- /* 80 */ 197, 439, 37, 37, 1172, 210, 65, 65, 65, 65,
147858
- /* 90 */ 254, 254, 111, 111, 111, 111, 110, 110, 109, 109,
147859
- /* 100 */ 109, 108, 404, 515, 404, 155, 1041, 431, 401, 400,
147860
- /* 110 */ 254, 254, 373, 1431, 1427, 408, 1110, 1085, 1086, 1087,
147861
- /* 120 */ 284, 1112, 500, 515, 500, 368, 1433, 1421, 1428, 1111,
147862
- /* 130 */ 1261, 499, 373, 502, 108, 404, 114, 115, 105, 1106,
147863
- /* 140 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147864
- /* 150 */ 113, 276, 509, 1113, 369, 1113, 114, 115, 105, 1106,
147865
- /* 160 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147866
- /* 170 */ 113, 496, 1420, 1431, 493, 1468, 1065, 260, 1063, 433,
147867
- /* 180 */ 74, 107, 104, 200, 498, 111, 111, 111, 111, 110,
147868
- /* 190 */ 110, 109, 109, 109, 108, 404, 373, 113, 113, 113,
147869
- /* 200 */ 113, 106, 131, 91, 1361, 111, 111, 111, 111, 110,
147870
- /* 210 */ 110, 109, 109, 109, 108, 404, 113, 113, 113, 113,
147871
- /* 220 */ 114, 115, 105, 1106, 1106, 957, 960, 950, 950, 112,
147872
- /* 230 */ 112, 113, 113, 113, 113, 111, 111, 111, 111, 110,
147873
- /* 240 */ 110, 109, 109, 109, 108, 404, 116, 110, 110, 109,
147874
- /* 250 */ 109, 109, 108, 404, 111, 111, 111, 111, 110, 110,
147875
- /* 260 */ 109, 109, 109, 108, 404, 917, 512, 512, 512, 111,
147876
- /* 270 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147877
- /* 280 */ 517, 1198, 1177, 181, 109, 109, 109, 108, 404, 373,
147878
- /* 290 */ 1198, 402, 402, 402, 75, 360, 111, 111, 111, 111,
147879
- /* 300 */ 110, 110, 109, 109, 109, 108, 404, 382, 299, 419,
147880
- /* 310 */ 287, 170, 518, 114, 115, 105, 1106, 1106, 957, 960,
147881
- /* 320 */ 950, 950, 112, 112, 113, 113, 113, 113, 1444, 523,
147882
- /* 330 */ 2, 1134, 518, 13, 13, 337, 277, 1085, 129, 226,
147883
- /* 340 */ 937, 1058, 1000, 471, 917, 1211, 453, 384, 1085, 395,
147884
- /* 350 */ 162, 1057, 155, 45, 45, 416, 928, 401, 400, 479,
147885
- /* 360 */ 927, 12, 111, 111, 111, 111, 110, 110, 109, 109,
147886
- /* 370 */ 109, 108, 404, 226, 286, 254, 254, 254, 254, 518,
147887
- /* 380 */ 16, 16, 373, 1085, 1086, 1087, 314, 299, 515, 472,
147888
- /* 390 */ 515, 927, 927, 929, 1085, 1086, 1087, 378, 276, 509,
147889
- /* 400 */ 65, 65, 1113, 210, 1113, 1085, 114, 115, 105, 1106,
147890
- /* 410 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147891
- /* 420 */ 113, 1448, 222, 1134, 1089, 461, 458, 457, 277, 180,
147892
- /* 430 */ 129, 378, 392, 408, 423, 456, 500, 1211, 240, 257,
147893
- /* 440 */ 324, 464, 319, 463, 227, 470, 12, 317, 424, 300,
147894
- /* 450 */ 317, 1085, 1086, 1087, 485, 111, 111, 111, 111, 110,
147895
- /* 460 */ 110, 109, 109, 109, 108, 404, 181, 118, 1085, 254,
147896
- /* 470 */ 254, 1089, 518, 90, 351, 373, 518, 1181, 365, 798,
147897
- /* 480 */ 1440, 339, 515, 248, 248, 77, 325, 133, 1085, 249,
147898
- /* 490 */ 424, 300, 794, 49, 49, 210, 515, 65, 65, 114,
147899
- /* 500 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147900
- /* 510 */ 113, 113, 113, 113, 1085, 1086, 1087, 222, 1085, 438,
147901
- /* 520 */ 461, 458, 457, 937, 787, 408, 171, 857, 362, 1021,
147902
- /* 530 */ 456, 136, 198, 486, 1085, 1086, 1087, 448, 794, 928,
147903
- /* 540 */ 5, 193, 192, 927, 1022, 107, 104, 200, 111, 111,
147904
- /* 550 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 1023,
147905
- /* 560 */ 254, 254, 803, 1085, 1085, 1086, 1087, 437, 373, 1085,
147906
- /* 570 */ 344, 787, 791, 515, 927, 927, 929, 1085, 1408, 1396,
147907
- /* 580 */ 832, 1085, 176, 3, 852, 1085, 518, 1439, 429, 851,
147908
- /* 590 */ 833, 518, 114, 115, 105, 1106, 1106, 957, 960, 950,
147909
- /* 600 */ 950, 112, 112, 113, 113, 113, 113, 13, 13, 1085,
147910
- /* 610 */ 1086, 1087, 13, 13, 518, 1085, 1086, 1087, 1496, 358,
147911
- /* 620 */ 1085, 389, 1234, 1085, 1086, 1087, 391, 1085, 1086, 1087,
147912
- /* 630 */ 448, 1085, 1086, 1087, 518, 65, 65, 947, 947, 958,
147913
- /* 640 */ 961, 111, 111, 111, 111, 110, 110, 109, 109, 109,
147914
- /* 650 */ 108, 404, 518, 382, 878, 13, 13, 518, 877, 518,
147915
- /* 660 */ 263, 373, 518, 431, 448, 1070, 1085, 1086, 1087, 267,
147916
- /* 670 */ 448, 488, 1360, 64, 64, 431, 812, 155, 50, 50,
147917
- /* 680 */ 65, 65, 518, 65, 65, 114, 115, 105, 1106, 1106,
147918
- /* 690 */ 957, 960, 950, 950, 112, 112, 113, 113, 113, 113,
147919
- /* 700 */ 518, 951, 382, 13, 13, 415, 411, 462, 414, 1085,
147920
- /* 710 */ 1366, 777, 1210, 292, 297, 813, 399, 497, 181, 403,
147921
- /* 720 */ 261, 15, 15, 276, 509, 414, 413, 1366, 1368, 410,
147922
- /* 730 */ 372, 345, 1209, 264, 111, 111, 111, 111, 110, 110,
147923
- /* 740 */ 109, 109, 109, 108, 404, 265, 254, 254, 229, 1405,
147924
- /* 750 */ 268, 1215, 268, 1103, 373, 1085, 1086, 1087, 938, 515,
147925
- /* 760 */ 393, 409, 876, 515, 254, 254, 1152, 482, 473, 262,
147926
- /* 770 */ 422, 476, 325, 503, 289, 518, 291, 515, 114, 115,
147927
- /* 780 */ 105, 1106, 1106, 957, 960, 950, 950, 112, 112, 113,
147928
- /* 790 */ 113, 113, 113, 414, 1021, 1366, 39, 39, 254, 254,
147929
- /* 800 */ 254, 254, 980, 254, 254, 254, 254, 255, 255, 1022,
147930
- /* 810 */ 279, 515, 516, 515, 846, 846, 515, 138, 515, 518,
147931
- /* 820 */ 515, 1043, 1495, 251, 1023, 1495, 876, 111, 111, 111,
147932
- /* 830 */ 111, 110, 110, 109, 109, 109, 108, 404, 518, 1353,
147933
- /* 840 */ 51, 51, 518, 199, 518, 506, 290, 373, 518, 276,
147934
- /* 850 */ 509, 922, 9, 483, 233, 1005, 1005, 445, 189, 52,
147935
- /* 860 */ 52, 325, 280, 53, 53, 54, 54, 373, 876, 55,
147936
- /* 870 */ 55, 114, 115, 105, 1106, 1106, 957, 960, 950, 950,
147937
- /* 880 */ 112, 112, 113, 113, 113, 113, 97, 518, 95, 1104,
147938
- /* 890 */ 1041, 114, 115, 105, 1106, 1106, 957, 960, 950, 950,
147939
- /* 900 */ 112, 112, 113, 113, 113, 113, 135, 199, 56, 56,
147940
- /* 910 */ 765, 766, 767, 225, 224, 223, 518, 283, 437, 233,
147941
- /* 920 */ 111, 111, 111, 111, 110, 110, 109, 109, 109, 108,
147942
- /* 930 */ 404, 1002, 876, 326, 518, 1002, 1104, 40, 40, 518,
147943
- /* 940 */ 111, 111, 111, 111, 110, 110, 109, 109, 109, 108,
147944
- /* 950 */ 404, 518, 448, 518, 1104, 41, 41, 518, 17, 518,
147945
- /* 960 */ 43, 43, 1155, 379, 518, 448, 518, 443, 518, 390,
147946
- /* 970 */ 518, 194, 44, 44, 57, 57, 1247, 518, 58, 58,
147947
- /* 980 */ 59, 59, 518, 466, 326, 14, 14, 60, 60, 120,
147948
- /* 990 */ 120, 61, 61, 449, 1206, 93, 518, 425, 46, 46,
147949
- /* 1000 */ 518, 1104, 518, 62, 62, 518, 437, 305, 518, 852,
147950
- /* 1010 */ 518, 298, 518, 1246, 851, 373, 518, 63, 63, 1293,
147951
- /* 1020 */ 397, 47, 47, 142, 142, 1467, 143, 143, 821, 70,
147952
- /* 1030 */ 70, 48, 48, 66, 66, 373, 518, 121, 121, 114,
147953
- /* 1040 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147954
- /* 1050 */ 113, 113, 113, 113, 518, 418, 518, 67, 67, 114,
147955
- /* 1060 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147956
- /* 1070 */ 113, 113, 113, 113, 312, 122, 122, 123, 123, 1293,
147957
- /* 1080 */ 518, 357, 1126, 88, 518, 435, 325, 387, 111, 111,
147958
- /* 1090 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 266,
147959
- /* 1100 */ 518, 119, 119, 518, 1293, 141, 141, 518, 111, 111,
147960
- /* 1110 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 518,
147961
- /* 1120 */ 801, 140, 140, 518, 127, 127, 511, 379, 126, 126,
147962
- /* 1130 */ 518, 137, 518, 1308, 518, 307, 518, 310, 518, 203,
147963
- /* 1140 */ 124, 124, 1307, 96, 125, 125, 207, 388, 1441, 468,
147964
- /* 1150 */ 1127, 69, 69, 71, 71, 68, 68, 38, 38, 42,
147965
- /* 1160 */ 42, 357, 1042, 373, 1293, 276, 509, 801, 185, 469,
147966
- /* 1170 */ 494, 436, 444, 6, 380, 156, 253, 197, 469, 134,
147967
- /* 1180 */ 426, 33, 1038, 373, 1121, 359, 1411, 114, 115, 105,
147968
- /* 1190 */ 1106, 1106, 957, 960, 950, 950, 112, 112, 113, 113,
147969
- /* 1200 */ 113, 113, 914, 296, 27, 293, 90, 114, 103, 105,
147970
- /* 1210 */ 1106, 1106, 957, 960, 950, 950, 112, 112, 113, 113,
147971
- /* 1220 */ 113, 113, 919, 275, 430, 232, 891, 232, 432, 256,
147972
- /* 1230 */ 1127, 232, 398, 370, 892, 28, 111, 111, 111, 111,
147973
- /* 1240 */ 110, 110, 109, 109, 109, 108, 404, 301, 454, 1385,
147974
- /* 1250 */ 90, 228, 209, 987, 811, 810, 111, 111, 111, 111,
147975
- /* 1260 */ 110, 110, 109, 109, 109, 108, 404, 315, 818, 819,
147976
- /* 1270 */ 90, 323, 983, 931, 885, 228, 373, 232, 999, 849,
147977
- /* 1280 */ 999, 322, 102, 998, 1384, 998, 785, 850, 440, 132,
147978
- /* 1290 */ 102, 302, 1243, 306, 309, 311, 373, 313, 1194, 1180,
147979
- /* 1300 */ 987, 115, 105, 1106, 1106, 957, 960, 950, 950, 112,
147980
- /* 1310 */ 112, 113, 113, 113, 113, 1178, 1179, 318, 327, 328,
147981
- /* 1320 */ 931, 1255, 105, 1106, 1106, 957, 960, 950, 950, 112,
147982
- /* 1330 */ 112, 113, 113, 113, 113, 1292, 1230, 1457, 273, 1241,
147983
- /* 1340 */ 504, 505, 1298, 100, 510, 246, 4, 1161, 1154, 111,
147984
- /* 1350 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147985
- /* 1360 */ 513, 1143, 187, 1142, 202, 1144, 1451, 356, 1227, 111,
147986
- /* 1370 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147987
- /* 1380 */ 11, 1277, 330, 405, 332, 334, 191, 1285, 364, 195,
147988
- /* 1390 */ 295, 417, 288, 100, 510, 507, 4, 434, 459, 321,
147989
- /* 1400 */ 1177, 349, 1357, 1356, 336, 155, 190, 1454, 1121, 158,
147990
- /* 1410 */ 513, 508, 235, 1404, 937, 1402, 1118, 381, 77, 428,
147991
- /* 1420 */ 98, 98, 8, 1282, 168, 30, 152, 99, 160, 405,
147992
- /* 1430 */ 520, 519, 88, 405, 927, 1362, 1274, 420, 163, 73,
147993
- /* 1440 */ 164, 76, 165, 166, 421, 507, 452, 212, 361, 363,
147994
- /* 1450 */ 427, 276, 509, 31, 1288, 172, 491, 441, 216, 1351,
147995
- /* 1460 */ 82, 490, 447, 1373, 937, 927, 927, 929, 930, 24,
147996
- /* 1470 */ 98, 98, 304, 247, 218, 177, 308, 99, 219, 405,
147997
- /* 1480 */ 520, 519, 450, 1145, 927, 220, 366, 1197, 100, 510,
147998
- /* 1490 */ 465, 4, 1188, 1196, 1195, 394, 803, 1169, 1187, 367,
147999
- /* 1500 */ 1168, 396, 484, 320, 1167, 513, 1466, 87, 475, 100,
148000
- /* 1510 */ 510, 271, 4, 272, 478, 927, 927, 929, 930, 24,
148001
- /* 1520 */ 1443, 1074, 407, 1238, 1239, 258, 513, 329, 405, 331,
148002
- /* 1530 */ 355, 355, 354, 243, 352, 234, 489, 774, 498, 184,
148003
- /* 1540 */ 507, 338, 1422, 339, 117, 1220, 10, 341, 333, 405,
148004
- /* 1550 */ 204, 491, 282, 1219, 1237, 1236, 492, 335, 343, 937,
148005
- /* 1560 */ 281, 507, 94, 1337, 186, 98, 98, 347, 89, 487,
148006
- /* 1570 */ 348, 241, 99, 29, 405, 520, 519, 274, 1151, 927,
148007
- /* 1580 */ 937, 521, 1080, 245, 242, 244, 98, 98, 856, 522,
148008
- /* 1590 */ 206, 1140, 1135, 99, 144, 405, 520, 519, 147, 375,
148009
- /* 1600 */ 927, 149, 376, 157, 1389, 1390, 1388, 1387, 205, 145,
148010
- /* 1610 */ 927, 927, 929, 930, 24, 146, 130, 761, 1165, 1164,
148011
- /* 1620 */ 72, 100, 510, 1162, 4, 269, 406, 188, 278, 201,
148012
- /* 1630 */ 259, 927, 927, 929, 930, 24, 128, 911, 513, 997,
148013
- /* 1640 */ 995, 159, 374, 208, 148, 161, 835, 276, 509, 211,
148014
- /* 1650 */ 294, 1011, 915, 167, 150, 383, 169, 78, 385, 79,
148015
- /* 1660 */ 80, 405, 81, 151, 1014, 213, 214, 1010, 139, 18,
148016
- /* 1670 */ 412, 215, 303, 507, 232, 1115, 1003, 446, 173, 217,
148017
- /* 1680 */ 174, 32, 776, 451, 491, 322, 221, 175, 814, 490,
148018
- /* 1690 */ 83, 455, 937, 19, 460, 316, 20, 84, 98, 98,
148019
- /* 1700 */ 270, 182, 85, 467, 153, 99, 154, 405, 520, 519,
148020
- /* 1710 */ 1074, 407, 927, 183, 258, 963, 1046, 86, 34, 355,
148021
- /* 1720 */ 355, 354, 243, 352, 474, 1047, 774, 35, 477, 196,
148022
- /* 1730 */ 250, 100, 510, 252, 4, 884, 178, 231, 1060, 204,
148023
- /* 1740 */ 21, 282, 102, 927, 927, 929, 930, 24, 513, 281,
148024
- /* 1750 */ 879, 22, 1064, 1062, 1051, 7, 340, 23, 978, 179,
148025
- /* 1760 */ 90, 92, 510, 964, 4, 236, 962, 966, 1020, 1019,
148026
- /* 1770 */ 237, 405, 967, 25, 36, 514, 932, 786, 513, 206,
148027
- /* 1780 */ 101, 26, 845, 507, 238, 239, 1459, 147, 350, 1458,
148028
- /* 1790 */ 149, 353, 1075, 1131, 1131, 1131, 1131, 205, 1131, 1131,
148029
- /* 1800 */ 1131, 405, 937, 1131, 1131, 1131, 1131, 1131, 98, 98,
148030
- /* 1810 */ 1131, 1131, 1131, 507, 1131, 99, 1131, 405, 520, 519,
148031
- /* 1820 */ 1131, 1131, 927, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148032
- /* 1830 */ 1131, 374, 937, 1131, 1131, 1131, 276, 509, 98, 98,
148033
- /* 1840 */ 1131, 1131, 1131, 1131, 1131, 99, 1131, 405, 520, 519,
148034
- /* 1850 */ 1131, 1131, 927, 927, 927, 929, 930, 24, 1131, 412,
148035
- /* 1860 */ 1131, 1131, 1131, 258, 1131, 1131, 1131, 1131, 355, 355,
148036
- /* 1870 */ 354, 243, 352, 1131, 1131, 774, 1131, 1131, 1131, 1131,
148037
- /* 1880 */ 1131, 1131, 1131, 927, 927, 929, 930, 24, 204, 1131,
148038
- /* 1890 */ 282, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 281, 1131,
148039
- /* 1900 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148040
- /* 1910 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148041
- /* 1920 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 206, 1131,
148042
- /* 1930 */ 1131, 1131, 1131, 1131, 1131, 1131, 147, 1131, 1131, 149,
148043
- /* 1940 */ 1131, 1131, 1131, 1131, 1131, 1131, 205, 1131, 1131, 1131,
148044
- /* 1950 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148045
- /* 1960 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148046
- /* 1970 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148047
- /* 1980 */ 374, 1131, 1131, 1131, 1131, 276, 509, 1131, 1131, 1131,
148048
- /* 1990 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148049
- /* 2000 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 412,
148431
+ /* 0 */ 388, 112, 109, 209, 535, 190, 442, 259, 1160, 1,
148432
+ /* 10 */ 1, 540, 2, 1164, 535, 1292, 1500, 371, 289, 384,
148433
+ /* 20 */ 134, 1484, 1427, 1164, 1202, 69, 69, 1241, 289, 492,
148434
+ /* 30 */ 134, 915, 382, 296, 175, 42, 42, 1241, 242, 916,
148435
+ /* 40 */ 112, 109, 209, 119, 120, 110, 1136, 1136, 981, 984,
148436
+ /* 50 */ 974, 974, 117, 117, 118, 118, 118, 118, 1291, 264,
148437
+ /* 60 */ 264, 264, 264, 112, 109, 209, 112, 109, 209, 264,
148438
+ /* 70 */ 264, 1115, 532, 1134, 532, 176, 270, 453, 239, 206,
148439
+ /* 80 */ 379, 450, 532, 356, 380, 219, 118, 118, 118, 118,
148440
+ /* 90 */ 111, 444, 535, 1233, 1233, 219, 116, 116, 116, 116,
148441
+ /* 100 */ 115, 115, 114, 114, 114, 113, 415, 258, 258, 112,
148442
+ /* 110 */ 109, 209, 1115, 42, 42, 419, 384, 1391, 1504, 1115,
148443
+ /* 120 */ 532, 1115, 1116, 1117, 1134, 419, 1463, 351, 116, 116,
148444
+ /* 130 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 961,
148445
+ /* 140 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
148446
+ /* 150 */ 117, 118, 118, 118, 118, 952, 1228, 1207, 1115, 951,
148447
+ /* 160 */ 412, 411, 1115, 1116, 1117, 1228, 535, 876, 1140, 1115,
148448
+ /* 170 */ 1116, 1117, 875, 1142, 941, 114, 114, 114, 113, 415,
148449
+ /* 180 */ 1089, 1141, 1089, 118, 118, 118, 118, 42, 42, 202,
148450
+ /* 190 */ 951, 951, 953, 116, 116, 116, 116, 115, 115, 114,
148451
+ /* 200 */ 114, 114, 113, 415, 1465, 1143, 350, 1143, 1115, 1116,
148452
+ /* 210 */ 1117, 231, 415, 384, 472, 469, 468, 412, 411, 442,
148453
+ /* 220 */ 96, 311, 430, 299, 467, 116, 116, 116, 116, 115,
148454
+ /* 230 */ 115, 114, 114, 114, 113, 415, 160, 119, 120, 110,
148455
+ /* 240 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148456
+ /* 250 */ 118, 118, 115, 115, 114, 114, 114, 113, 415, 529,
148457
+ /* 260 */ 529, 529, 1143, 121, 1143, 116, 116, 116, 116, 115,
148458
+ /* 270 */ 115, 114, 114, 114, 113, 415, 941, 337, 1463, 506,
148459
+ /* 280 */ 491, 1067, 1530, 384, 160, 1530, 288, 526, 1115, 274,
148460
+ /* 290 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148461
+ /* 300 */ 415, 16, 16, 406, 535, 93, 512, 119, 120, 110,
148462
+ /* 310 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148463
+ /* 320 */ 118, 118, 141, 311, 231, 54, 54, 472, 469, 468,
148464
+ /* 330 */ 427, 79, 368, 1156, 288, 526, 32, 467, 1115, 1116,
148465
+ /* 340 */ 1117, 1323, 1480, 540, 2, 1164, 971, 971, 982, 985,
148466
+ /* 350 */ 289, 384, 134, 459, 1065, 533, 80, 870, 870, 1241,
148467
+ /* 360 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148468
+ /* 370 */ 415, 818, 82, 1115, 1476, 119, 120, 110, 1136, 1136,
148469
+ /* 380 */ 981, 984, 974, 974, 117, 117, 118, 118, 118, 118,
148470
+ /* 390 */ 403, 264, 264, 238, 535, 1426, 250, 267, 336, 475,
148471
+ /* 400 */ 331, 474, 236, 459, 532, 1157, 961, 459, 329, 397,
148472
+ /* 410 */ 373, 513, 1450, 159, 975, 70, 70, 219, 413, 413,
148473
+ /* 420 */ 413, 818, 952, 1115, 1116, 1117, 951, 534, 116, 116,
148474
+ /* 430 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 1115,
148475
+ /* 440 */ 535, 442, 264, 264, 1115, 1390, 535, 419, 384, 422,
148476
+ /* 450 */ 1115, 517, 326, 1245, 304, 532, 1084, 951, 951, 953,
148477
+ /* 460 */ 493, 70, 70, 167, 509, 532, 1084, 70, 70, 1084,
148478
+ /* 470 */ 440, 535, 119, 120, 110, 1136, 1136, 981, 984, 974,
148479
+ /* 480 */ 974, 117, 117, 118, 118, 118, 118, 881, 535, 1115,
148480
+ /* 490 */ 1116, 1117, 55, 55, 1115, 1116, 1117, 517, 288, 526,
148481
+ /* 500 */ 1115, 1116, 1117, 517, 420, 494, 516, 113, 415, 13,
148482
+ /* 510 */ 13, 275, 482, 836, 349, 301, 535, 303, 500, 5,
148483
+ /* 520 */ 480, 1457, 138, 395, 6, 116, 116, 116, 116, 115,
148484
+ /* 530 */ 115, 114, 114, 114, 113, 415, 1458, 13, 13, 6,
148485
+ /* 540 */ 535, 1024, 1115, 535, 473, 384, 535, 435, 312, 822,
148486
+ /* 550 */ 1084, 400, 837, 159, 518, 181, 1115, 483, 502, 811,
148487
+ /* 560 */ 1084, 70, 70, 1084, 70, 70, 1115, 50, 50, 119,
148488
+ /* 570 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148489
+ /* 580 */ 118, 118, 118, 118, 95, 338, 264, 264, 1115, 264,
148490
+ /* 590 */ 264, 302, 1115, 1116, 1117, 495, 3, 498, 535, 532,
148491
+ /* 600 */ 517, 404, 532, 484, 801, 287, 1115, 1116, 1117, 519,
148492
+ /* 610 */ 811, 337, 501, 12, 535, 381, 1115, 1116, 1117, 70,
148493
+ /* 620 */ 70, 401, 116, 116, 116, 116, 115, 115, 114, 114,
148494
+ /* 630 */ 114, 113, 415, 1115, 1084, 13, 13, 535, 1115, 1116,
148495
+ /* 640 */ 1117, 1115, 384, 902, 1084, 1211, 815, 1084, 393, 402,
148496
+ /* 650 */ 160, 435, 312, 1532, 369, 284, 143, 297, 70, 70,
148497
+ /* 660 */ 510, 1457, 337, 433, 6, 901, 119, 120, 110, 1136,
148498
+ /* 670 */ 1136, 981, 984, 974, 974, 117, 117, 118, 118, 118,
148499
+ /* 680 */ 118, 1045, 426, 1115, 1116, 1117, 449, 535, 12, 264,
148500
+ /* 690 */ 264, 1115, 1116, 1117, 285, 535, 1046, 265, 265, 1004,
148501
+ /* 700 */ 288, 526, 532, 789, 790, 791, 190, 140, 70, 70,
148502
+ /* 710 */ 532, 1047, 1323, 535, 309, 298, 13, 13, 383, 116,
148503
+ /* 720 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 415,
148504
+ /* 730 */ 277, 535, 856, 190, 13, 13, 1383, 497, 278, 384,
148505
+ /* 740 */ 278, 362, 857, 1100, 410, 376, 264, 264, 184, 900,
148506
+ /* 750 */ 1210, 1239, 70, 70, 1182, 1455, 187, 535, 6, 532,
148507
+ /* 760 */ 535, 434, 207, 119, 120, 110, 1136, 1136, 981, 984,
148508
+ /* 770 */ 974, 974, 117, 117, 118, 118, 118, 118, 13, 13,
148509
+ /* 780 */ 398, 13, 13, 264, 264, 393, 264, 264, 414, 1185,
148510
+ /* 790 */ 390, 425, 185, 1396, 1084, 514, 532, 485, 9, 532,
148511
+ /* 800 */ 242, 464, 1067, 1531, 1084, 488, 1531, 1084, 425, 424,
148512
+ /* 810 */ 1396, 1398, 520, 1029, 1029, 456, 116, 116, 116, 116,
148513
+ /* 820 */ 115, 115, 114, 114, 114, 113, 415, 535, 235, 264,
148514
+ /* 830 */ 264, 508, 535, 393, 208, 1134, 384, 264, 264, 448,
148515
+ /* 840 */ 962, 448, 532, 261, 264, 264, 900, 507, 15, 15,
148516
+ /* 850 */ 532, 1026, 271, 44, 44, 1026, 1095, 532, 535, 900,
148517
+ /* 860 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
148518
+ /* 870 */ 117, 118, 118, 118, 118, 1065, 425, 1045, 1396, 56,
148519
+ /* 880 */ 56, 535, 368, 1066, 1231, 1231, 1134, 454, 535, 324,
148520
+ /* 890 */ 389, 355, 1046, 234, 233, 232, 512, 459, 459, 459,
148521
+ /* 900 */ 272, 448, 57, 57, 1095, 1438, 329, 1047, 535, 58,
148522
+ /* 910 */ 58, 421, 477, 116, 116, 116, 116, 115, 115, 114,
148523
+ /* 920 */ 114, 114, 113, 415, 1323, 535, 515, 535, 523, 59,
148524
+ /* 930 */ 59, 208, 273, 384, 310, 1435, 1323, 946, 876, 1240,
148525
+ /* 940 */ 1236, 317, 1456, 875, 136, 6, 60, 60, 61, 61,
148526
+ /* 950 */ 319, 535, 322, 384, 535, 1157, 900, 119, 120, 110,
148527
+ /* 960 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148528
+ /* 970 */ 118, 118, 45, 45, 535, 46, 46, 119, 120, 110,
148529
+ /* 980 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148530
+ /* 990 */ 118, 118, 399, 338, 276, 48, 48, 337, 1477, 479,
148531
+ /* 1000 */ 535, 107, 1451, 535, 455, 535, 1119, 95, 1338, 235,
148532
+ /* 1010 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148533
+ /* 1020 */ 415, 49, 49, 123, 62, 62, 63, 63, 535, 408,
148534
+ /* 1030 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148535
+ /* 1040 */ 415, 535, 142, 535, 481, 535, 1323, 535, 1503, 64,
148536
+ /* 1050 */ 64, 845, 1454, 1337, 535, 6, 535, 1119, 535, 357,
148537
+ /* 1060 */ 535, 353, 14, 14, 65, 65, 125, 125, 66, 66,
148538
+ /* 1070 */ 535, 389, 535, 291, 535, 51, 51, 67, 67, 68,
148539
+ /* 1080 */ 68, 52, 52, 292, 1453, 98, 535, 6, 535, 481,
148540
+ /* 1090 */ 535, 147, 147, 148, 148, 75, 75, 535, 915, 535,
148541
+ /* 1100 */ 827, 201, 200, 528, 390, 384, 916, 53, 53, 71,
148542
+ /* 1110 */ 71, 126, 126, 515, 409, 288, 526, 216, 72, 72,
148543
+ /* 1120 */ 127, 127, 391, 161, 535, 384, 535, 263, 206, 119,
148544
+ /* 1130 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148545
+ /* 1140 */ 118, 118, 118, 118, 535, 128, 128, 124, 124, 119,
148546
+ /* 1150 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148547
+ /* 1160 */ 118, 118, 118, 118, 446, 146, 146, 102, 1209, 100,
148548
+ /* 1170 */ 1133, 212, 139, 535, 38, 437, 1062, 308, 535, 370,
148549
+ /* 1180 */ 95, 295, 116, 116, 116, 116, 115, 115, 114, 114,
148550
+ /* 1190 */ 114, 113, 415, 535, 145, 145, 535, 938, 535, 132,
148551
+ /* 1200 */ 132, 535, 116, 116, 116, 116, 115, 115, 114, 114,
148552
+ /* 1210 */ 114, 113, 415, 535, 131, 131, 1151, 129, 129, 130,
148553
+ /* 1220 */ 130, 30, 74, 74, 535, 17, 535, 218, 535, 943,
148554
+ /* 1230 */ 441, 1277, 241, 241, 76, 76, 443, 101, 313, 241,
148555
+ /* 1240 */ 465, 95, 1023, 237, 1023, 73, 73, 43, 43, 47,
148556
+ /* 1250 */ 47, 335, 31, 327, 447, 266, 95, 384, 1276, 835,
148557
+ /* 1260 */ 834, 334, 193, 1007, 436, 429, 237, 825, 842, 843,
148558
+ /* 1270 */ 1011, 909, 873, 955, 241, 107, 1022, 384, 1022, 197,
148559
+ /* 1280 */ 1441, 119, 120, 110, 1136, 1136, 981, 984, 974, 974,
148560
+ /* 1290 */ 117, 117, 118, 118, 118, 118, 809, 305, 1264, 137,
148561
+ /* 1300 */ 1415, 119, 108, 110, 1136, 1136, 981, 984, 974, 974,
148562
+ /* 1310 */ 117, 117, 118, 118, 118, 118, 874, 522, 825, 107,
148563
+ /* 1320 */ 283, 1011, 1414, 1470, 955, 451, 314, 1273, 318, 321,
148564
+ /* 1330 */ 323, 325, 1224, 1208, 116, 116, 116, 116, 115, 115,
148565
+ /* 1340 */ 114, 114, 114, 113, 415, 330, 339, 340, 1285, 1322,
148566
+ /* 1350 */ 1260, 1271, 521, 1328, 116, 116, 116, 116, 115, 115,
148567
+ /* 1360 */ 114, 114, 114, 113, 415, 1191, 256, 1493, 1184, 1173,
148568
+ /* 1370 */ 460, 1172, 1174, 1257, 384, 342, 1487, 344, 346, 199,
148569
+ /* 1380 */ 195, 367, 11, 211, 307, 445, 1307, 428, 1315, 375,
148570
+ /* 1390 */ 203, 1207, 470, 188, 384, 189, 525, 1490, 1151, 120,
148571
+ /* 1400 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
148572
+ /* 1410 */ 118, 118, 118, 333, 1387, 1386, 245, 300, 348, 1434,
148573
+ /* 1420 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
148574
+ /* 1430 */ 118, 118, 118, 198, 360, 163, 1432, 1148, 78, 81,
148575
+ /* 1440 */ 392, 82, 1392, 439, 173, 105, 527, 157, 4, 165,
148576
+ /* 1450 */ 1312, 116, 116, 116, 116, 115, 115, 114, 114, 114,
148577
+ /* 1460 */ 113, 415, 530, 93, 35, 431, 432, 1304, 168, 463,
148578
+ /* 1470 */ 221, 116, 116, 116, 116, 115, 115, 114, 114, 114,
148579
+ /* 1480 */ 113, 415, 169, 170, 171, 416, 372, 438, 1318, 177,
148580
+ /* 1490 */ 452, 374, 36, 225, 1381, 87, 458, 524, 257, 1403,
148581
+ /* 1500 */ 316, 105, 527, 227, 4, 182, 461, 160, 320, 228,
148582
+ /* 1510 */ 377, 1175, 229, 476, 405, 1227, 1226, 1225, 530, 827,
148583
+ /* 1520 */ 961, 1218, 378, 1199, 1198, 407, 103, 103, 281, 1217,
148584
+ /* 1530 */ 8, 332, 1197, 104, 1502, 416, 537, 536, 282, 487,
148585
+ /* 1540 */ 951, 416, 490, 496, 1268, 92, 341, 243, 244, 1461,
148586
+ /* 1550 */ 1269, 1267, 122, 524, 1266, 515, 10, 288, 526, 343,
148587
+ /* 1560 */ 352, 1460, 354, 99, 504, 94, 499, 251, 1181, 503,
148588
+ /* 1570 */ 194, 951, 951, 953, 954, 27, 961, 1250, 345, 347,
148589
+ /* 1580 */ 1249, 358, 103, 103, 359, 34, 538, 1110, 1367, 104,
148590
+ /* 1590 */ 255, 416, 537, 536, 539, 1170, 951, 286, 252, 254,
148591
+ /* 1600 */ 149, 1165, 1419, 135, 1420, 785, 279, 1418, 417, 1417,
148592
+ /* 1610 */ 1195, 196, 150, 290, 210, 269, 151, 1021, 133, 1194,
148593
+ /* 1620 */ 1019, 935, 162, 386, 387, 77, 1192, 951, 951, 953,
148594
+ /* 1630 */ 954, 27, 1479, 1104, 418, 164, 153, 268, 217, 166,
148595
+ /* 1640 */ 859, 306, 366, 366, 365, 253, 363, 220, 1035, 798,
148596
+ /* 1650 */ 172, 939, 105, 527, 155, 4, 394, 174, 396, 83,
148597
+ /* 1660 */ 84, 85, 213, 86, 294, 1038, 156, 223, 222, 530,
148598
+ /* 1670 */ 1034, 144, 293, 18, 224, 241, 315, 1027, 1145, 178,
148599
+ /* 1680 */ 457, 226, 37, 179, 800, 334, 462, 230, 328, 466,
148600
+ /* 1690 */ 180, 471, 416, 88, 19, 20, 89, 280, 838, 158,
148601
+ /* 1700 */ 191, 478, 215, 1097, 524, 90, 204, 192, 987, 91,
148602
+ /* 1710 */ 152, 1070, 39, 154, 1071, 504, 486, 40, 489, 205,
148603
+ /* 1720 */ 505, 260, 105, 527, 214, 4, 908, 961, 262, 183,
148604
+ /* 1730 */ 240, 21, 903, 103, 103, 107, 22, 1086, 23, 530,
148605
+ /* 1740 */ 104, 1074, 416, 537, 536, 24, 1088, 951, 25, 1093,
148606
+ /* 1750 */ 1090, 1094, 7, 33, 511, 186, 26, 1002, 385, 95,
148607
+ /* 1760 */ 988, 986, 416, 288, 526, 990, 1044, 246, 1043, 247,
148608
+ /* 1770 */ 991, 28, 41, 106, 524, 956, 810, 29, 951, 951,
148609
+ /* 1780 */ 953, 954, 27, 531, 869, 504, 423, 248, 249, 1495,
148610
+ /* 1790 */ 503, 1494, 361, 364, 1105, 1161, 1161, 961, 1161, 1161,
148611
+ /* 1800 */ 1161, 1161, 1161, 103, 103, 1161, 1161, 1161, 1161, 1161,
148612
+ /* 1810 */ 104, 1161, 416, 537, 536, 1104, 418, 951, 1161, 268,
148613
+ /* 1820 */ 1161, 1161, 1161, 1161, 366, 366, 365, 253, 363, 1161,
148614
+ /* 1830 */ 1161, 798, 1161, 1161, 1161, 1161, 105, 527, 1161, 4,
148615
+ /* 1840 */ 1161, 1161, 1161, 1161, 213, 1161, 294, 1161, 951, 951,
148616
+ /* 1850 */ 953, 954, 27, 530, 293, 1161, 1161, 1161, 1161, 1161,
148617
+ /* 1860 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148618
+ /* 1870 */ 1161, 1161, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161,
148619
+ /* 1880 */ 1161, 1161, 1161, 1161, 215, 1161, 1161, 1161, 524, 1161,
148620
+ /* 1890 */ 1161, 1161, 152, 1161, 1161, 154, 105, 527, 1161, 4,
148621
+ /* 1900 */ 1161, 1161, 1161, 1161, 1161, 1161, 214, 1161, 1161, 1161,
148622
+ /* 1910 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 880,
148623
+ /* 1920 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148624
+ /* 1930 */ 1161, 951, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161,
148625
+ /* 1940 */ 385, 1161, 1161, 1161, 1161, 288, 526, 1161, 524, 1161,
148626
+ /* 1950 */ 1161, 1161, 1161, 1161, 1161, 1161, 97, 527, 1161, 4,
148627
+ /* 1960 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 423, 1161,
148628
+ /* 1970 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 1161,
148629
+ /* 1980 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148630
+ /* 1990 */ 1161, 951, 268, 1161, 1161, 1161, 416, 366, 366, 365,
148631
+ /* 2000 */ 253, 363, 1161, 1161, 798, 1161, 1161, 1161, 524, 1161,
148632
+ /* 2010 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 213, 1161, 294,
148633
+ /* 2020 */ 1161, 1161, 951, 951, 953, 954, 27, 293, 1161, 1161,
148634
+ /* 2030 */ 1161, 961, 1161, 1161, 1161, 1161, 1161, 103, 103, 1161,
148635
+ /* 2040 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148636
+ /* 2050 */ 1161, 951, 1161, 1161, 1161, 1161, 1161, 215, 1161, 1161,
148637
+ /* 2060 */ 1161, 1161, 1161, 1161, 1161, 152, 1161, 1161, 154, 1161,
148638
+ /* 2070 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 214,
148639
+ /* 2080 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 1161, 1161,
148640
+ /* 2090 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148641
+ /* 2100 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148642
+ /* 2110 */ 1161, 1161, 1161, 385, 1161, 1161, 1161, 1161, 288, 526,
148643
+ /* 2120 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148644
+ /* 2130 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148645
+ /* 2140 */ 1161, 423,
148050148646
};
148051148647
static const YYCODETYPE yy_lookahead[] = {
148052
- /* 0 */ 168, 163, 184, 238, 239, 240, 163, 163, 155, 156,
148053
- /* 10 */ 157, 158, 159, 160, 163, 202, 203, 187, 165, 19,
148054
- /* 20 */ 167, 163, 184, 185, 259, 202, 203, 174, 184, 185,
148055
- /* 30 */ 174, 31, 238, 239, 240, 184, 185, 22, 23, 39,
148056
- /* 40 */ 216, 26, 218, 43, 44, 45, 46, 47, 48, 49,
148057
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 206,
148058
- /* 60 */ 207, 163, 206, 207, 220, 163, 163, 163, 238, 239,
148059
- /* 70 */ 240, 59, 219, 229, 231, 219, 183, 245, 174, 223,
148060
- /* 80 */ 224, 249, 184, 185, 191, 232, 184, 185, 184, 185,
148061
- /* 90 */ 206, 207, 92, 93, 94, 95, 96, 97, 98, 99,
148062
- /* 100 */ 100, 101, 102, 219, 102, 81, 91, 163, 96, 97,
148063
- /* 110 */ 206, 207, 19, 275, 276, 262, 104, 105, 106, 107,
148064
- /* 120 */ 163, 109, 220, 219, 220, 184, 275, 269, 277, 117,
148065
- /* 130 */ 187, 229, 19, 229, 101, 102, 43, 44, 45, 46,
148066
- /* 140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148067
- /* 150 */ 57, 127, 128, 141, 184, 143, 43, 44, 45, 46,
148068
- /* 160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148069
- /* 170 */ 57, 268, 269, 275, 276, 197, 83, 233, 85, 163,
148070
- /* 180 */ 67, 238, 239, 240, 134, 92, 93, 94, 95, 96,
148071
- /* 190 */ 97, 98, 99, 100, 101, 102, 19, 54, 55, 56,
148072
- /* 200 */ 57, 58, 152, 26, 247, 92, 93, 94, 95, 96,
148073
- /* 210 */ 97, 98, 99, 100, 101, 102, 54, 55, 56, 57,
148074
- /* 220 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148075
- /* 230 */ 53, 54, 55, 56, 57, 92, 93, 94, 95, 96,
148076
- /* 240 */ 97, 98, 99, 100, 101, 102, 69, 96, 97, 98,
148077
- /* 250 */ 99, 100, 101, 102, 92, 93, 94, 95, 96, 97,
148078
- /* 260 */ 98, 99, 100, 101, 102, 73, 179, 180, 181, 92,
148079
- /* 270 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148080
- /* 280 */ 163, 191, 192, 163, 98, 99, 100, 101, 102, 19,
148081
- /* 290 */ 200, 179, 180, 181, 24, 175, 92, 93, 94, 95,
148082
- /* 300 */ 96, 97, 98, 99, 100, 101, 102, 163, 116, 117,
148083
- /* 310 */ 118, 22, 163, 43, 44, 45, 46, 47, 48, 49,
148084
- /* 320 */ 50, 51, 52, 53, 54, 55, 56, 57, 157, 158,
148085
- /* 330 */ 159, 160, 163, 184, 185, 163, 165, 59, 167, 46,
148086
- /* 340 */ 90, 76, 11, 174, 73, 174, 19, 198, 59, 19,
148087
- /* 350 */ 72, 86, 81, 184, 185, 234, 106, 96, 97, 163,
148088
- /* 360 */ 110, 182, 92, 93, 94, 95, 96, 97, 98, 99,
148089
- /* 370 */ 100, 101, 102, 46, 230, 206, 207, 206, 207, 163,
148090
- /* 380 */ 184, 185, 19, 105, 106, 107, 23, 116, 219, 220,
148091
- /* 390 */ 219, 141, 142, 143, 105, 106, 107, 104, 127, 128,
148092
- /* 400 */ 184, 185, 141, 232, 143, 59, 43, 44, 45, 46,
148093
- /* 410 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148094
- /* 420 */ 57, 158, 108, 160, 59, 111, 112, 113, 165, 250,
148095
- /* 430 */ 167, 104, 102, 262, 255, 121, 220, 174, 108, 109,
148096
- /* 440 */ 110, 111, 112, 113, 114, 229, 182, 120, 117, 118,
148097
- /* 450 */ 120, 105, 106, 107, 163, 92, 93, 94, 95, 96,
148098
- /* 460 */ 97, 98, 99, 100, 101, 102, 163, 22, 59, 206,
148099
- /* 470 */ 207, 106, 163, 26, 171, 19, 163, 193, 175, 23,
148100
- /* 480 */ 163, 22, 219, 206, 207, 139, 163, 22, 59, 182,
148101
- /* 490 */ 117, 118, 59, 184, 185, 232, 219, 184, 185, 43,
148102
- /* 500 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148103
- /* 510 */ 54, 55, 56, 57, 105, 106, 107, 108, 59, 255,
148104
- /* 520 */ 111, 112, 113, 90, 59, 262, 22, 98, 174, 12,
148105
- /* 530 */ 121, 208, 163, 220, 105, 106, 107, 163, 105, 106,
148106
- /* 540 */ 22, 96, 97, 110, 27, 238, 239, 240, 92, 93,
148107
- /* 550 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 42,
148108
- /* 560 */ 206, 207, 115, 59, 105, 106, 107, 163, 19, 59,
148109
- /* 570 */ 163, 106, 23, 219, 141, 142, 143, 59, 163, 205,
148110
- /* 580 */ 63, 59, 72, 22, 124, 59, 163, 270, 234, 129,
148111
- /* 590 */ 73, 163, 43, 44, 45, 46, 47, 48, 49, 50,
148112
- /* 600 */ 51, 52, 53, 54, 55, 56, 57, 184, 185, 105,
148113
- /* 610 */ 106, 107, 184, 185, 163, 105, 106, 107, 265, 266,
148114
- /* 620 */ 59, 198, 225, 105, 106, 107, 198, 105, 106, 107,
148115
- /* 630 */ 163, 105, 106, 107, 163, 184, 185, 46, 47, 48,
148116
- /* 640 */ 49, 92, 93, 94, 95, 96, 97, 98, 99, 100,
148117
- /* 650 */ 101, 102, 163, 163, 132, 184, 185, 163, 132, 163,
148118
- /* 660 */ 256, 19, 163, 163, 163, 23, 105, 106, 107, 198,
148119
- /* 670 */ 163, 220, 205, 184, 185, 163, 35, 81, 184, 185,
148120
- /* 680 */ 184, 185, 163, 184, 185, 43, 44, 45, 46, 47,
148121
- /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
148122
- /* 700 */ 163, 110, 163, 184, 185, 109, 205, 66, 163, 59,
148123
- /* 710 */ 163, 21, 205, 16, 174, 74, 220, 198, 163, 220,
148124
- /* 720 */ 230, 184, 185, 127, 128, 180, 181, 180, 181, 163,
148125
- /* 730 */ 175, 242, 174, 233, 92, 93, 94, 95, 96, 97,
148126
- /* 740 */ 98, 99, 100, 101, 102, 233, 206, 207, 26, 163,
148127
- /* 750 */ 195, 207, 197, 26, 19, 105, 106, 107, 23, 219,
148128
- /* 760 */ 119, 260, 26, 219, 206, 207, 174, 19, 174, 230,
148129
- /* 770 */ 80, 174, 163, 174, 77, 163, 79, 219, 43, 44,
148130
- /* 780 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148131
- /* 790 */ 55, 56, 57, 248, 12, 248, 184, 185, 206, 207,
148132
- /* 800 */ 206, 207, 112, 206, 207, 206, 207, 206, 207, 27,
148133
- /* 810 */ 163, 219, 123, 219, 125, 126, 219, 208, 219, 163,
148134
- /* 820 */ 219, 22, 23, 23, 42, 26, 26, 92, 93, 94,
148135
- /* 830 */ 95, 96, 97, 98, 99, 100, 101, 102, 163, 149,
148136
- /* 840 */ 184, 185, 163, 107, 163, 63, 149, 19, 163, 127,
148137
- /* 850 */ 128, 23, 22, 105, 24, 116, 117, 118, 131, 184,
148138
- /* 860 */ 185, 163, 163, 184, 185, 184, 185, 19, 132, 184,
148139
- /* 870 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148140
- /* 880 */ 52, 53, 54, 55, 56, 57, 146, 163, 148, 59,
148141
- /* 890 */ 91, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148142
- /* 900 */ 52, 53, 54, 55, 56, 57, 208, 107, 184, 185,
148143
- /* 910 */ 7, 8, 9, 116, 117, 118, 163, 163, 163, 24,
148144
- /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
148145
- /* 930 */ 102, 29, 132, 163, 163, 33, 106, 184, 185, 163,
148146
- /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
148147
- /* 950 */ 102, 163, 163, 163, 59, 184, 185, 163, 22, 163,
148148
- /* 960 */ 184, 185, 177, 178, 163, 163, 163, 65, 163, 199,
148149
- /* 970 */ 163, 26, 184, 185, 184, 185, 163, 163, 184, 185,
148150
- /* 980 */ 184, 185, 163, 98, 163, 184, 185, 184, 185, 184,
148151
- /* 990 */ 185, 184, 185, 252, 205, 147, 163, 61, 184, 185,
148152
- /* 1000 */ 163, 106, 163, 184, 185, 163, 163, 205, 163, 124,
148153
- /* 1010 */ 163, 256, 163, 163, 129, 19, 163, 184, 185, 163,
148154
- /* 1020 */ 199, 184, 185, 184, 185, 23, 184, 185, 26, 184,
148155
- /* 1030 */ 185, 184, 185, 184, 185, 19, 163, 184, 185, 43,
148156
- /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148157
- /* 1050 */ 54, 55, 56, 57, 163, 163, 163, 184, 185, 43,
148158
- /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148159
- /* 1070 */ 54, 55, 56, 57, 16, 184, 185, 184, 185, 163,
148160
- /* 1080 */ 163, 22, 23, 138, 163, 19, 163, 231, 92, 93,
148161
- /* 1090 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 256,
148162
- /* 1100 */ 163, 184, 185, 163, 163, 184, 185, 163, 92, 93,
148163
- /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
148164
- /* 1120 */ 59, 184, 185, 163, 184, 185, 177, 178, 184, 185,
148165
- /* 1130 */ 163, 208, 163, 237, 163, 77, 163, 79, 163, 15,
148166
- /* 1140 */ 184, 185, 237, 147, 184, 185, 24, 231, 153, 154,
148167
- /* 1150 */ 91, 184, 185, 184, 185, 184, 185, 184, 185, 184,
148168
- /* 1160 */ 185, 22, 23, 19, 163, 127, 128, 106, 24, 273,
148169
- /* 1170 */ 271, 105, 231, 274, 263, 264, 223, 224, 273, 22,
148170
- /* 1180 */ 118, 24, 23, 19, 60, 26, 163, 43, 44, 45,
148171
- /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148172
- /* 1200 */ 56, 57, 140, 23, 22, 163, 26, 43, 44, 45,
148173
- /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148174
- /* 1220 */ 56, 57, 23, 211, 23, 26, 31, 26, 23, 22,
148175
- /* 1230 */ 91, 26, 231, 221, 39, 53, 92, 93, 94, 95,
148176
- /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 23, 23, 163,
148177
- /* 1250 */ 26, 26, 130, 59, 109, 110, 92, 93, 94, 95,
148178
- /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 23, 7, 8,
148179
- /* 1270 */ 26, 110, 23, 59, 23, 26, 19, 26, 141, 23,
148180
- /* 1280 */ 143, 120, 26, 141, 163, 143, 23, 23, 163, 26,
148181
- /* 1290 */ 26, 163, 163, 163, 163, 163, 19, 163, 163, 193,
148182
- /* 1300 */ 106, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148183
- /* 1310 */ 53, 54, 55, 56, 57, 163, 193, 163, 163, 163,
148184
- /* 1320 */ 106, 163, 45, 46, 47, 48, 49, 50, 51, 52,
148185
- /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 130, 222, 163,
148186
- /* 1340 */ 163, 203, 163, 19, 20, 251, 22, 163, 163, 92,
148187
- /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148188
- /* 1360 */ 36, 163, 209, 163, 261, 163, 163, 161, 222, 92,
148189
- /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148190
- /* 1380 */ 210, 213, 222, 59, 222, 222, 182, 213, 213, 196,
148191
- /* 1390 */ 257, 226, 226, 19, 20, 71, 22, 257, 188, 187,
148192
- /* 1400 */ 192, 212, 187, 187, 226, 81, 210, 166, 60, 261,
148193
- /* 1410 */ 36, 244, 130, 170, 90, 170, 38, 170, 139, 104,
148194
- /* 1420 */ 96, 97, 48, 236, 22, 235, 43, 103, 201, 105,
148195
- /* 1430 */ 106, 107, 138, 59, 110, 247, 213, 18, 204, 258,
148196
- /* 1440 */ 204, 258, 204, 204, 170, 71, 18, 169, 213, 236,
148197
- /* 1450 */ 213, 127, 128, 235, 201, 201, 82, 170, 169, 213,
148198
- /* 1460 */ 146, 87, 62, 254, 90, 141, 142, 143, 144, 145,
148199
- /* 1470 */ 96, 97, 253, 170, 169, 22, 170, 103, 169, 105,
148200
- /* 1480 */ 106, 107, 189, 170, 110, 169, 189, 186, 19, 20,
148201
- /* 1490 */ 104, 22, 194, 186, 186, 64, 115, 186, 194, 189,
148202
- /* 1500 */ 188, 102, 133, 186, 186, 36, 186, 104, 189, 19,
148203
- /* 1510 */ 20, 246, 22, 246, 189, 141, 142, 143, 144, 145,
148204
- /* 1520 */ 0, 1, 2, 228, 228, 5, 36, 227, 59, 227,
148205
- /* 1530 */ 10, 11, 12, 13, 14, 170, 84, 17, 134, 216,
148206
- /* 1540 */ 71, 272, 270, 22, 137, 217, 22, 216, 227, 59,
148207
- /* 1550 */ 30, 82, 32, 217, 228, 228, 87, 227, 170, 90,
148208
- /* 1560 */ 40, 71, 146, 241, 215, 96, 97, 214, 136, 135,
148209
- /* 1570 */ 213, 25, 103, 26, 105, 106, 107, 243, 173, 110,
148210
- /* 1580 */ 90, 172, 13, 6, 164, 164, 96, 97, 98, 162,
148211
- /* 1590 */ 70, 162, 162, 103, 176, 105, 106, 107, 78, 267,
148212
- /* 1600 */ 110, 81, 267, 264, 182, 182, 182, 182, 88, 176,
148213
- /* 1610 */ 141, 142, 143, 144, 145, 176, 190, 4, 182, 182,
148214
- /* 1620 */ 182, 19, 20, 182, 22, 190, 3, 22, 151, 15,
148215
- /* 1630 */ 89, 141, 142, 143, 144, 145, 16, 128, 36, 23,
148216
- /* 1640 */ 23, 139, 122, 24, 119, 131, 20, 127, 128, 133,
148217
- /* 1650 */ 16, 1, 140, 131, 119, 61, 139, 53, 37, 53,
148218
- /* 1660 */ 53, 59, 53, 119, 105, 34, 130, 1, 5, 22,
148219
- /* 1670 */ 150, 104, 149, 71, 26, 75, 68, 41, 68, 130,
148220
- /* 1680 */ 104, 24, 20, 19, 82, 120, 114, 22, 28, 87,
148221
- /* 1690 */ 22, 67, 90, 22, 67, 23, 22, 22, 96, 97,
148222
- /* 1700 */ 67, 23, 138, 22, 37, 103, 153, 105, 106, 107,
148223
- /* 1710 */ 1, 2, 110, 23, 5, 23, 23, 26, 22, 10,
148224
- /* 1720 */ 11, 12, 13, 14, 24, 23, 17, 22, 24, 130,
148225
- /* 1730 */ 23, 19, 20, 23, 22, 105, 22, 34, 85, 30,
148226
- /* 1740 */ 34, 32, 26, 141, 142, 143, 144, 145, 36, 40,
148227
- /* 1750 */ 132, 34, 75, 83, 23, 44, 24, 34, 23, 26,
148228
- /* 1760 */ 26, 19, 20, 23, 22, 26, 23, 23, 23, 23,
148229
- /* 1770 */ 22, 59, 11, 22, 22, 26, 23, 23, 36, 70,
148230
- /* 1780 */ 22, 22, 124, 71, 130, 130, 130, 78, 23, 130,
148231
- /* 1790 */ 81, 15, 1, 278, 278, 278, 278, 88, 278, 278,
148232
- /* 1800 */ 278, 59, 90, 278, 278, 278, 278, 278, 96, 97,
148233
- /* 1810 */ 278, 278, 278, 71, 278, 103, 278, 105, 106, 107,
148234
- /* 1820 */ 278, 278, 110, 278, 278, 278, 278, 278, 278, 278,
148235
- /* 1830 */ 278, 122, 90, 278, 278, 278, 127, 128, 96, 97,
148236
- /* 1840 */ 278, 278, 278, 278, 278, 103, 278, 105, 106, 107,
148237
- /* 1850 */ 278, 278, 110, 141, 142, 143, 144, 145, 278, 150,
148238
- /* 1860 */ 278, 278, 278, 5, 278, 278, 278, 278, 10, 11,
148239
- /* 1870 */ 12, 13, 14, 278, 278, 17, 278, 278, 278, 278,
148240
- /* 1880 */ 278, 278, 278, 141, 142, 143, 144, 145, 30, 278,
148241
- /* 1890 */ 32, 278, 278, 278, 278, 278, 278, 278, 40, 278,
148242
- /* 1900 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148243
- /* 1910 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148244
- /* 1920 */ 278, 278, 278, 278, 278, 278, 278, 278, 70, 278,
148245
- /* 1930 */ 278, 278, 278, 278, 278, 278, 78, 278, 278, 81,
148246
- /* 1940 */ 278, 278, 278, 278, 278, 278, 88, 278, 278, 278,
148247
- /* 1950 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148248
- /* 1960 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148249
- /* 1970 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148250
- /* 1980 */ 122, 278, 278, 278, 278, 127, 128, 278, 278, 278,
148251
- /* 1990 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148252
- /* 2000 */ 278, 278, 278, 278, 278, 278, 278, 278, 150, 278,
148253
- /* 2010 */ 278, 278, 278, 278, 278, 278, 278, 278, 278,
148254
-};
148255
-#define YY_SHIFT_COUNT (523)
148648
+ /* 0 */ 172, 242, 243, 244, 167, 167, 167, 186, 159, 160,
148649
+ /* 10 */ 161, 162, 163, 164, 167, 191, 187, 179, 169, 19,
148650
+ /* 20 */ 171, 162, 263, 164, 195, 188, 189, 178, 169, 178,
148651
+ /* 30 */ 171, 31, 188, 167, 22, 188, 189, 178, 24, 39,
148652
+ /* 40 */ 242, 243, 244, 43, 44, 45, 46, 47, 48, 49,
148653
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 210,
148654
+ /* 60 */ 211, 210, 211, 242, 243, 244, 242, 243, 244, 210,
148655
+ /* 70 */ 211, 59, 223, 59, 223, 22, 237, 249, 227, 228,
148656
+ /* 80 */ 188, 253, 223, 246, 188, 236, 54, 55, 56, 57,
148657
+ /* 90 */ 58, 167, 167, 206, 207, 236, 96, 97, 98, 99,
148658
+ /* 100 */ 100, 101, 102, 103, 104, 105, 106, 210, 211, 242,
148659
+ /* 110 */ 243, 244, 59, 188, 189, 266, 19, 251, 201, 59,
148660
+ /* 120 */ 223, 109, 110, 111, 110, 266, 279, 280, 96, 97,
148661
+ /* 130 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 94,
148662
+ /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148663
+ /* 150 */ 53, 54, 55, 56, 57, 110, 195, 196, 59, 114,
148664
+ /* 160 */ 100, 101, 109, 110, 111, 204, 167, 128, 108, 109,
148665
+ /* 170 */ 110, 111, 133, 113, 73, 102, 103, 104, 105, 106,
148666
+ /* 180 */ 83, 121, 85, 54, 55, 56, 57, 188, 189, 26,
148667
+ /* 190 */ 145, 146, 147, 96, 97, 98, 99, 100, 101, 102,
148668
+ /* 200 */ 103, 104, 105, 106, 279, 145, 281, 147, 109, 110,
148669
+ /* 210 */ 111, 112, 106, 19, 115, 116, 117, 100, 101, 167,
148670
+ /* 220 */ 26, 120, 121, 122, 125, 96, 97, 98, 99, 100,
148671
+ /* 230 */ 101, 102, 103, 104, 105, 106, 81, 43, 44, 45,
148672
+ /* 240 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148673
+ /* 250 */ 56, 57, 100, 101, 102, 103, 104, 105, 106, 183,
148674
+ /* 260 */ 184, 185, 145, 69, 147, 96, 97, 98, 99, 100,
148675
+ /* 270 */ 101, 102, 103, 104, 105, 106, 73, 167, 279, 280,
148676
+ /* 280 */ 167, 22, 23, 19, 81, 26, 131, 132, 59, 237,
148677
+ /* 290 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148678
+ /* 300 */ 106, 188, 189, 19, 167, 142, 167, 43, 44, 45,
148679
+ /* 310 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148680
+ /* 320 */ 56, 57, 212, 120, 112, 188, 189, 115, 116, 117,
148681
+ /* 330 */ 238, 67, 22, 23, 131, 132, 22, 125, 109, 110,
148682
+ /* 340 */ 111, 167, 161, 162, 163, 164, 46, 47, 48, 49,
148683
+ /* 350 */ 169, 19, 171, 167, 95, 127, 24, 129, 130, 178,
148684
+ /* 360 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148685
+ /* 370 */ 106, 59, 143, 59, 167, 43, 44, 45, 46, 47,
148686
+ /* 380 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
148687
+ /* 390 */ 106, 210, 211, 26, 167, 209, 112, 113, 114, 115,
148688
+ /* 400 */ 116, 117, 118, 167, 223, 95, 94, 167, 124, 235,
148689
+ /* 410 */ 178, 272, 273, 167, 114, 188, 189, 236, 183, 184,
148690
+ /* 420 */ 185, 109, 110, 109, 110, 111, 114, 167, 96, 97,
148691
+ /* 430 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 59,
148692
+ /* 440 */ 167, 167, 210, 211, 59, 209, 167, 266, 19, 209,
148693
+ /* 450 */ 59, 224, 23, 211, 16, 223, 76, 145, 146, 147,
148694
+ /* 460 */ 233, 188, 189, 72, 84, 223, 86, 188, 189, 89,
148695
+ /* 470 */ 238, 167, 43, 44, 45, 46, 47, 48, 49, 50,
148696
+ /* 480 */ 51, 52, 53, 54, 55, 56, 57, 102, 167, 109,
148697
+ /* 490 */ 110, 111, 188, 189, 109, 110, 111, 224, 131, 132,
148698
+ /* 500 */ 109, 110, 111, 224, 264, 19, 233, 105, 106, 188,
148699
+ /* 510 */ 189, 237, 233, 35, 167, 77, 167, 79, 138, 22,
148700
+ /* 520 */ 274, 275, 22, 202, 278, 96, 97, 98, 99, 100,
148701
+ /* 530 */ 101, 102, 103, 104, 105, 106, 275, 188, 189, 278,
148702
+ /* 540 */ 167, 11, 59, 167, 66, 19, 167, 121, 122, 23,
148703
+ /* 550 */ 76, 202, 74, 167, 178, 72, 59, 178, 84, 59,
148704
+ /* 560 */ 86, 188, 189, 89, 188, 189, 59, 188, 189, 43,
148705
+ /* 570 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148706
+ /* 580 */ 54, 55, 56, 57, 26, 167, 210, 211, 59, 210,
148707
+ /* 590 */ 211, 153, 109, 110, 111, 109, 22, 224, 167, 223,
148708
+ /* 600 */ 224, 123, 223, 224, 21, 215, 109, 110, 111, 233,
148709
+ /* 610 */ 110, 167, 138, 186, 167, 225, 109, 110, 111, 188,
148710
+ /* 620 */ 189, 203, 96, 97, 98, 99, 100, 101, 102, 103,
148711
+ /* 630 */ 104, 105, 106, 59, 76, 188, 189, 167, 109, 110,
148712
+ /* 640 */ 111, 59, 19, 136, 86, 197, 23, 89, 167, 202,
148713
+ /* 650 */ 81, 121, 122, 269, 270, 224, 212, 178, 188, 189,
148714
+ /* 660 */ 274, 275, 167, 80, 278, 136, 43, 44, 45, 46,
148715
+ /* 670 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148716
+ /* 680 */ 57, 12, 113, 109, 110, 111, 259, 167, 186, 210,
148717
+ /* 690 */ 211, 109, 110, 111, 224, 167, 27, 210, 211, 116,
148718
+ /* 700 */ 131, 132, 223, 7, 8, 9, 167, 212, 188, 189,
148719
+ /* 710 */ 223, 42, 167, 167, 178, 234, 188, 189, 179, 96,
148720
+ /* 720 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
148721
+ /* 730 */ 202, 167, 63, 167, 188, 189, 153, 167, 199, 19,
148722
+ /* 740 */ 201, 175, 73, 23, 224, 179, 210, 211, 202, 26,
148723
+ /* 750 */ 197, 178, 188, 189, 178, 275, 254, 167, 278, 223,
148724
+ /* 760 */ 167, 259, 167, 43, 44, 45, 46, 47, 48, 49,
148725
+ /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 188, 189,
148726
+ /* 780 */ 235, 188, 189, 210, 211, 167, 210, 211, 224, 181,
148727
+ /* 790 */ 182, 167, 202, 167, 76, 202, 223, 178, 22, 223,
148728
+ /* 800 */ 24, 19, 22, 23, 86, 178, 26, 89, 184, 185,
148729
+ /* 810 */ 184, 185, 178, 120, 121, 122, 96, 97, 98, 99,
148730
+ /* 820 */ 100, 101, 102, 103, 104, 105, 106, 167, 46, 210,
148731
+ /* 830 */ 211, 66, 167, 167, 111, 59, 19, 210, 211, 167,
148732
+ /* 840 */ 23, 167, 223, 23, 210, 211, 26, 82, 188, 189,
148733
+ /* 850 */ 223, 29, 234, 188, 189, 33, 91, 223, 167, 136,
148734
+ /* 860 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148735
+ /* 870 */ 53, 54, 55, 56, 57, 95, 252, 12, 252, 188,
148736
+ /* 880 */ 189, 167, 22, 23, 206, 207, 110, 65, 167, 16,
148737
+ /* 890 */ 108, 167, 27, 120, 121, 122, 167, 167, 167, 167,
148738
+ /* 900 */ 234, 167, 188, 189, 139, 167, 124, 42, 167, 188,
148739
+ /* 910 */ 189, 167, 102, 96, 97, 98, 99, 100, 101, 102,
148740
+ /* 920 */ 103, 104, 105, 106, 167, 167, 138, 167, 63, 188,
148741
+ /* 930 */ 189, 111, 260, 19, 260, 167, 167, 23, 128, 209,
148742
+ /* 940 */ 209, 209, 275, 133, 156, 278, 188, 189, 188, 189,
148743
+ /* 950 */ 77, 167, 79, 19, 167, 95, 136, 43, 44, 45,
148744
+ /* 960 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148745
+ /* 970 */ 56, 57, 188, 189, 167, 188, 189, 43, 44, 45,
148746
+ /* 980 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148747
+ /* 990 */ 56, 57, 235, 167, 260, 188, 189, 167, 157, 158,
148748
+ /* 1000 */ 167, 26, 273, 167, 235, 167, 59, 26, 241, 46,
148749
+ /* 1010 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148750
+ /* 1020 */ 106, 188, 189, 22, 188, 189, 188, 189, 167, 203,
148751
+ /* 1030 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148752
+ /* 1040 */ 106, 167, 212, 167, 277, 167, 167, 167, 23, 188,
148753
+ /* 1050 */ 189, 26, 275, 241, 167, 278, 167, 110, 167, 220,
148754
+ /* 1060 */ 167, 222, 188, 189, 188, 189, 188, 189, 188, 189,
148755
+ /* 1070 */ 167, 108, 167, 167, 167, 188, 189, 188, 189, 188,
148756
+ /* 1080 */ 189, 188, 189, 167, 275, 151, 167, 278, 167, 277,
148757
+ /* 1090 */ 167, 188, 189, 188, 189, 188, 189, 167, 31, 167,
148758
+ /* 1100 */ 119, 100, 101, 181, 182, 19, 39, 188, 189, 188,
148759
+ /* 1110 */ 189, 188, 189, 138, 235, 131, 132, 24, 188, 189,
148760
+ /* 1120 */ 188, 189, 267, 268, 167, 19, 167, 227, 228, 43,
148761
+ /* 1130 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148762
+ /* 1140 */ 54, 55, 56, 57, 167, 188, 189, 188, 189, 43,
148763
+ /* 1150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148764
+ /* 1160 */ 54, 55, 56, 57, 19, 188, 189, 150, 197, 152,
148765
+ /* 1170 */ 26, 15, 22, 167, 24, 122, 23, 23, 167, 26,
148766
+ /* 1180 */ 26, 167, 96, 97, 98, 99, 100, 101, 102, 103,
148767
+ /* 1190 */ 104, 105, 106, 167, 188, 189, 167, 144, 167, 188,
148768
+ /* 1200 */ 189, 167, 96, 97, 98, 99, 100, 101, 102, 103,
148769
+ /* 1210 */ 104, 105, 106, 167, 188, 189, 60, 188, 189, 188,
148770
+ /* 1220 */ 189, 22, 188, 189, 167, 22, 167, 134, 167, 23,
148771
+ /* 1230 */ 23, 167, 26, 26, 188, 189, 23, 151, 23, 26,
148772
+ /* 1240 */ 23, 26, 145, 26, 147, 188, 189, 188, 189, 188,
148773
+ /* 1250 */ 189, 114, 53, 23, 109, 22, 26, 19, 167, 113,
148774
+ /* 1260 */ 114, 124, 24, 23, 61, 167, 26, 59, 7, 8,
148775
+ /* 1270 */ 59, 23, 23, 59, 26, 26, 145, 19, 147, 135,
148776
+ /* 1280 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148777
+ /* 1290 */ 52, 53, 54, 55, 56, 57, 23, 167, 229, 26,
148778
+ /* 1300 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148779
+ /* 1310 */ 52, 53, 54, 55, 56, 57, 23, 207, 110, 26,
148780
+ /* 1320 */ 226, 110, 167, 283, 110, 167, 167, 167, 167, 167,
148781
+ /* 1330 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101,
148782
+ /* 1340 */ 102, 103, 104, 105, 106, 167, 167, 167, 167, 167,
148783
+ /* 1350 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101,
148784
+ /* 1360 */ 102, 103, 104, 105, 106, 167, 255, 134, 167, 167,
148785
+ /* 1370 */ 256, 167, 167, 226, 19, 226, 167, 226, 226, 186,
148786
+ /* 1380 */ 213, 165, 214, 265, 261, 261, 217, 230, 217, 217,
148787
+ /* 1390 */ 200, 196, 192, 220, 19, 220, 248, 170, 60, 44,
148788
+ /* 1400 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148789
+ /* 1410 */ 55, 56, 57, 191, 191, 191, 134, 230, 230, 174,
148790
+ /* 1420 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148791
+ /* 1430 */ 55, 56, 57, 214, 216, 265, 174, 38, 262, 262,
148792
+ /* 1440 */ 174, 143, 251, 108, 22, 19, 20, 43, 22, 205,
148793
+ /* 1450 */ 240, 96, 97, 98, 99, 100, 101, 102, 103, 104,
148794
+ /* 1460 */ 105, 106, 36, 142, 239, 18, 174, 217, 208, 18,
148795
+ /* 1470 */ 173, 96, 97, 98, 99, 100, 101, 102, 103, 104,
148796
+ /* 1480 */ 105, 106, 208, 208, 208, 59, 217, 217, 205, 205,
148797
+ /* 1490 */ 174, 240, 239, 173, 217, 150, 62, 71, 174, 258,
148798
+ /* 1500 */ 257, 19, 20, 173, 22, 22, 193, 81, 174, 173,
148799
+ /* 1510 */ 193, 174, 173, 108, 64, 190, 190, 190, 36, 119,
148800
+ /* 1520 */ 94, 198, 193, 190, 192, 106, 100, 101, 250, 198,
148801
+ /* 1530 */ 48, 190, 190, 107, 190, 109, 110, 111, 250, 193,
148802
+ /* 1540 */ 114, 59, 193, 137, 232, 108, 231, 174, 88, 282,
148803
+ /* 1550 */ 232, 232, 141, 71, 232, 138, 22, 131, 132, 231,
148804
+ /* 1560 */ 220, 282, 174, 150, 82, 140, 139, 25, 177, 87,
148805
+ /* 1570 */ 219, 145, 146, 147, 148, 149, 94, 221, 231, 231,
148806
+ /* 1580 */ 221, 218, 100, 101, 217, 26, 176, 13, 245, 107,
148807
+ /* 1590 */ 6, 109, 110, 111, 166, 166, 114, 247, 168, 168,
148808
+ /* 1600 */ 180, 166, 186, 194, 186, 4, 194, 186, 3, 186,
148809
+ /* 1610 */ 186, 22, 180, 155, 15, 93, 180, 23, 16, 186,
148810
+ /* 1620 */ 23, 132, 268, 271, 271, 186, 186, 145, 146, 147,
148811
+ /* 1630 */ 148, 149, 0, 1, 2, 143, 123, 5, 24, 135,
148812
+ /* 1640 */ 20, 16, 10, 11, 12, 13, 14, 137, 1, 17,
148813
+ /* 1650 */ 135, 144, 19, 20, 123, 22, 61, 143, 37, 53,
148814
+ /* 1660 */ 53, 53, 30, 53, 32, 109, 123, 134, 34, 36,
148815
+ /* 1670 */ 1, 5, 40, 22, 108, 26, 153, 68, 75, 68,
148816
+ /* 1680 */ 41, 134, 24, 108, 20, 124, 19, 118, 23, 67,
148817
+ /* 1690 */ 22, 67, 59, 22, 22, 22, 22, 67, 28, 37,
148818
+ /* 1700 */ 23, 22, 70, 23, 71, 142, 157, 23, 23, 26,
148819
+ /* 1710 */ 78, 23, 22, 81, 23, 82, 24, 22, 24, 134,
148820
+ /* 1720 */ 87, 23, 19, 20, 92, 22, 109, 94, 23, 22,
148821
+ /* 1730 */ 34, 34, 136, 100, 101, 26, 34, 85, 34, 36,
148822
+ /* 1740 */ 107, 23, 109, 110, 111, 34, 83, 114, 34, 90,
148823
+ /* 1750 */ 75, 75, 44, 22, 24, 26, 34, 23, 126, 26,
148824
+ /* 1760 */ 23, 23, 59, 131, 132, 23, 23, 26, 23, 22,
148825
+ /* 1770 */ 11, 22, 22, 22, 71, 23, 23, 22, 145, 146,
148826
+ /* 1780 */ 147, 148, 149, 26, 128, 82, 154, 134, 134, 134,
148827
+ /* 1790 */ 87, 134, 23, 15, 1, 284, 284, 94, 284, 284,
148828
+ /* 1800 */ 284, 284, 284, 100, 101, 284, 284, 284, 284, 284,
148829
+ /* 1810 */ 107, 284, 109, 110, 111, 1, 2, 114, 284, 5,
148830
+ /* 1820 */ 284, 284, 284, 284, 10, 11, 12, 13, 14, 284,
148831
+ /* 1830 */ 284, 17, 284, 284, 284, 284, 19, 20, 284, 22,
148832
+ /* 1840 */ 284, 284, 284, 284, 30, 284, 32, 284, 145, 146,
148833
+ /* 1850 */ 147, 148, 149, 36, 40, 284, 284, 284, 284, 284,
148834
+ /* 1860 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148835
+ /* 1870 */ 284, 284, 284, 284, 284, 284, 59, 284, 284, 284,
148836
+ /* 1880 */ 284, 284, 284, 284, 70, 284, 284, 284, 71, 284,
148837
+ /* 1890 */ 284, 284, 78, 284, 284, 81, 19, 20, 284, 22,
148838
+ /* 1900 */ 284, 284, 284, 284, 284, 284, 92, 284, 284, 284,
148839
+ /* 1910 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 102,
148840
+ /* 1920 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148841
+ /* 1930 */ 284, 114, 284, 284, 284, 284, 59, 284, 284, 284,
148842
+ /* 1940 */ 126, 284, 284, 284, 284, 131, 132, 284, 71, 284,
148843
+ /* 1950 */ 284, 284, 284, 284, 284, 284, 19, 20, 284, 22,
148844
+ /* 1960 */ 284, 284, 145, 146, 147, 148, 149, 284, 154, 284,
148845
+ /* 1970 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 284,
148846
+ /* 1980 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148847
+ /* 1990 */ 284, 114, 5, 284, 284, 284, 59, 10, 11, 12,
148848
+ /* 2000 */ 13, 14, 284, 284, 17, 284, 284, 284, 71, 284,
148849
+ /* 2010 */ 284, 284, 284, 284, 284, 284, 284, 30, 284, 32,
148850
+ /* 2020 */ 284, 284, 145, 146, 147, 148, 149, 40, 284, 284,
148851
+ /* 2030 */ 284, 94, 284, 284, 284, 284, 284, 100, 101, 284,
148852
+ /* 2040 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148853
+ /* 2050 */ 284, 114, 284, 284, 284, 284, 284, 70, 284, 284,
148854
+ /* 2060 */ 284, 284, 284, 284, 284, 78, 284, 284, 81, 284,
148855
+ /* 2070 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 92,
148856
+ /* 2080 */ 284, 284, 145, 146, 147, 148, 149, 284, 284, 284,
148857
+ /* 2090 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148858
+ /* 2100 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148859
+ /* 2110 */ 284, 284, 284, 126, 284, 284, 284, 284, 131, 132,
148860
+ /* 2120 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148861
+ /* 2130 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148862
+ /* 2140 */ 284, 154, 284, 284, 284, 284, 284, 284, 284, 284,
148863
+ /* 2150 */ 284, 284,
148864
+};
148865
+#define YY_SHIFT_COUNT (540)
148256148866
#define YY_SHIFT_MIN (0)
148257
-#define YY_SHIFT_MAX (1858)
148867
+#define YY_SHIFT_MAX (1987)
148258148868
static const unsigned short int yy_shift_ofst[] = {
148259
- /* 0 */ 1709, 1520, 1858, 1324, 1324, 24, 1374, 1469, 1602, 1712,
148260
- /* 10 */ 1712, 1712, 271, 0, 0, 113, 1016, 1712, 1712, 1712,
148261
- /* 20 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 12, 12, 409,
148262
- /* 30 */ 596, 24, 24, 24, 24, 24, 24, 93, 177, 270,
148263
- /* 40 */ 363, 456, 549, 642, 735, 828, 848, 996, 1144, 1016,
148264
- /* 50 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
148265
- /* 60 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257,
148266
- /* 70 */ 1277, 1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148267
- /* 80 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148268
- /* 90 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148269
- /* 100 */ 1712, 1712, 1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712,
148270
- /* 110 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 143,
148271
- /* 120 */ 162, 162, 162, 162, 162, 204, 151, 186, 650, 690,
148272
- /* 130 */ 327, 650, 261, 261, 650, 722, 722, 722, 722, 373,
148273
- /* 140 */ 33, 2, 2009, 2009, 330, 330, 330, 346, 289, 278,
148274
- /* 150 */ 289, 289, 517, 517, 459, 510, 15, 799, 650, 650,
148275
- /* 160 */ 650, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148276
- /* 170 */ 650, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148277
- /* 180 */ 331, 365, 995, 995, 265, 365, 50, 1038, 2009, 2009,
148278
- /* 190 */ 2009, 433, 250, 250, 504, 314, 429, 518, 522, 526,
148279
- /* 200 */ 561, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148280
- /* 210 */ 192, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148281
- /* 220 */ 650, 650, 650, 641, 641, 641, 650, 650, 650, 650,
148282
- /* 230 */ 800, 650, 650, 650, 830, 650, 650, 782, 650, 650,
148283
- /* 240 */ 650, 650, 650, 650, 650, 650, 739, 902, 689, 895,
148284
- /* 250 */ 895, 895, 895, 736, 689, 689, 885, 445, 903, 1124,
148285
- /* 260 */ 945, 748, 748, 1066, 945, 945, 1066, 447, 1002, 293,
148286
- /* 270 */ 1195, 1195, 1195, 748, 740, 727, 460, 1157, 1348, 1282,
148287
- /* 280 */ 1282, 1378, 1378, 1282, 1279, 1315, 1402, 1383, 1294, 1419,
148288
- /* 290 */ 1419, 1419, 1419, 1282, 1428, 1294, 1294, 1315, 1402, 1383,
148289
- /* 300 */ 1383, 1294, 1282, 1428, 1314, 1400, 1282, 1428, 1453, 1282,
148290
- /* 310 */ 1428, 1282, 1428, 1453, 1386, 1386, 1386, 1431, 1453, 1386,
148291
- /* 320 */ 1381, 1386, 1431, 1386, 1386, 1453, 1399, 1399, 1453, 1369,
148292
- /* 330 */ 1403, 1369, 1403, 1369, 1403, 1369, 1403, 1282, 1404, 1452,
148293
- /* 340 */ 1521, 1407, 1404, 1524, 1282, 1416, 1407, 1432, 1434, 1294,
148294
- /* 350 */ 1546, 1547, 1569, 1569, 1577, 1577, 1577, 2009, 2009, 2009,
148295
- /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
148296
- /* 370 */ 2009, 2009, 2009, 591, 697, 1059, 1139, 1058, 797, 465,
148297
- /* 380 */ 1159, 1182, 1122, 1062, 1180, 936, 1199, 1201, 1205, 1224,
148298
- /* 390 */ 1225, 1244, 1061, 1145, 1261, 1161, 1194, 1249, 1251, 1256,
148299
- /* 400 */ 1137, 1142, 1263, 1264, 1214, 1207, 1613, 1623, 1605, 1477,
148300
- /* 410 */ 1614, 1541, 1620, 1616, 1617, 1509, 1502, 1525, 1619, 1514,
148301
- /* 420 */ 1626, 1516, 1634, 1650, 1522, 1512, 1535, 1594, 1621, 1517,
148302
- /* 430 */ 1604, 1606, 1607, 1609, 1544, 1559, 1631, 1536, 1666, 1663,
148303
- /* 440 */ 1647, 1567, 1523, 1608, 1648, 1610, 1600, 1636, 1549, 1576,
148304
- /* 450 */ 1657, 1662, 1664, 1565, 1572, 1665, 1624, 1668, 1671, 1672,
148305
- /* 460 */ 1674, 1627, 1660, 1675, 1633, 1667, 1678, 1564, 1681, 1553,
148306
- /* 470 */ 1690, 1692, 1691, 1693, 1696, 1700, 1702, 1705, 1704, 1599,
148307
- /* 480 */ 1707, 1710, 1630, 1703, 1714, 1618, 1716, 1706, 1716, 1717,
148308
- /* 490 */ 1653, 1677, 1670, 1711, 1731, 1732, 1733, 1734, 1723, 1735,
148309
- /* 500 */ 1716, 1740, 1743, 1744, 1745, 1739, 1746, 1748, 1761, 1751,
148310
- /* 510 */ 1752, 1753, 1754, 1758, 1759, 1749, 1658, 1654, 1655, 1656,
148311
- /* 520 */ 1659, 1765, 1776, 1791,
148312
-};
148313
-#define YY_REDUCE_COUNT (372)
148314
-#define YY_REDUCE_MIN (-235)
148315
-#define YY_REDUCE_MAX (1441)
148869
+ /* 0 */ 1814, 1632, 1987, 1426, 1426, 155, 1482, 1633, 1703, 1877,
148870
+ /* 10 */ 1877, 1877, 203, 0, 0, 264, 1106, 1877, 1877, 1877,
148871
+ /* 20 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148872
+ /* 30 */ 60, 60, 380, 380, 99, 569, 155, 155, 155, 155,
148873
+ /* 40 */ 155, 155, 97, 194, 332, 429, 526, 623, 720, 817,
148874
+ /* 50 */ 914, 934, 1086, 1238, 1106, 1106, 1106, 1106, 1106, 1106,
148875
+ /* 60 */ 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,
148876
+ /* 70 */ 1106, 1106, 1258, 1106, 1355, 1375, 1375, 1817, 1877, 1877,
148877
+ /* 80 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148878
+ /* 90 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148879
+ /* 100 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148880
+ /* 110 */ 1937, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148881
+ /* 120 */ 1877, 1877, 1877, 1877, 32, 129, 129, 129, 129, 129,
148882
+ /* 130 */ 169, 152, 73, 582, 583, 782, 582, 117, 117, 582,
148883
+ /* 140 */ 367, 367, 367, 367, 426, 402, 106, 2142, 2142, 284,
148884
+ /* 150 */ 284, 284, 229, 12, 391, 12, 12, 669, 669, 474,
148885
+ /* 160 */ 483, 259, 780, 582, 582, 582, 582, 582, 582, 582,
148886
+ /* 170 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
148887
+ /* 180 */ 582, 582, 582, 582, 558, 558, 582, 530, 718, 718,
148888
+ /* 190 */ 947, 841, 841, 947, 788, 984, 2142, 2142, 2142, 312,
148889
+ /* 200 */ 45, 45, 53, 212, 314, 385, 497, 507, 529, 574,
148890
+ /* 210 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 101,
148891
+ /* 220 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
148892
+ /* 230 */ 582, 582, 478, 478, 478, 582, 582, 582, 582, 820,
148893
+ /* 240 */ 582, 582, 582, 776, 765, 582, 582, 865, 582, 582,
148894
+ /* 250 */ 582, 582, 582, 582, 582, 582, 693, 822, 228, 14,
148895
+ /* 260 */ 14, 14, 14, 723, 228, 228, 810, 1001, 696, 1156,
148896
+ /* 270 */ 163, 486, 486, 1145, 163, 163, 1145, 981, 1025, 963,
148897
+ /* 280 */ 1067, 1067, 1067, 486, 975, 975, 1017, 1144, 39, 1150,
148898
+ /* 290 */ 1338, 1282, 1282, 1399, 1399, 1282, 1298, 1335, 1422, 1404,
148899
+ /* 300 */ 1321, 1447, 1447, 1447, 1447, 1282, 1451, 1321, 1321, 1335,
148900
+ /* 310 */ 1422, 1404, 1404, 1321, 1282, 1451, 1345, 1434, 1282, 1451,
148901
+ /* 320 */ 1483, 1282, 1451, 1282, 1451, 1483, 1405, 1405, 1405, 1450,
148902
+ /* 330 */ 1483, 1405, 1400, 1405, 1450, 1405, 1405, 1483, 1419, 1419,
148903
+ /* 340 */ 1483, 1406, 1437, 1406, 1437, 1406, 1437, 1406, 1437, 1282,
148904
+ /* 350 */ 1460, 1460, 1411, 1417, 1534, 1282, 1413, 1411, 1425, 1427,
148905
+ /* 360 */ 1321, 1542, 1559, 1574, 1574, 1584, 1584, 1584, 2142, 2142,
148906
+ /* 370 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
148907
+ /* 380 */ 2142, 2142, 2142, 2142, 300, 438, 310, 860, 873, 773,
148908
+ /* 390 */ 500, 1153, 1199, 1093, 1053, 1154, 1203, 1206, 1207, 1213,
148909
+ /* 400 */ 1215, 1217, 1230, 1208, 1146, 1261, 1137, 1211, 1240, 1248,
148910
+ /* 410 */ 1249, 1097, 1131, 1273, 1293, 1214, 1233, 1601, 1605, 1589,
148911
+ /* 420 */ 1458, 1599, 1522, 1602, 1594, 1597, 1489, 1492, 1513, 1614,
148912
+ /* 430 */ 1504, 1620, 1510, 1625, 1647, 1515, 1507, 1531, 1595, 1621,
148913
+ /* 440 */ 1514, 1606, 1607, 1608, 1610, 1543, 1556, 1634, 1533, 1669,
148914
+ /* 450 */ 1666, 1651, 1566, 1523, 1609, 1649, 1611, 1603, 1639, 1547,
148915
+ /* 460 */ 1575, 1658, 1664, 1667, 1561, 1569, 1668, 1622, 1671, 1672,
148916
+ /* 470 */ 1665, 1673, 1624, 1670, 1674, 1630, 1662, 1677, 1563, 1679,
148917
+ /* 480 */ 1680, 1549, 1684, 1685, 1683, 1688, 1690, 1692, 1691, 1695,
148918
+ /* 490 */ 1694, 1585, 1698, 1705, 1617, 1696, 1707, 1596, 1709, 1697,
148919
+ /* 500 */ 1702, 1704, 1711, 1652, 1675, 1663, 1708, 1676, 1659, 1714,
148920
+ /* 510 */ 1718, 1731, 1730, 1729, 1733, 1722, 1734, 1709, 1737, 1738,
148921
+ /* 520 */ 1742, 1743, 1741, 1745, 1747, 1759, 1749, 1750, 1752, 1753,
148922
+ /* 530 */ 1751, 1755, 1757, 1656, 1653, 1654, 1655, 1657, 1769, 1778,
148923
+ /* 540 */ 1793,
148924
+};
148925
+#define YY_REDUCE_COUNT (383)
148926
+#define YY_REDUCE_MIN (-241)
148927
+#define YY_REDUCE_MAX (1440)
148316148928
static const short yy_reduce_ofst[] = {
148317
- /* 0 */ -147, 171, 263, -96, 169, -144, -162, -149, -102, -156,
148318
- /* 10 */ -98, 216, 354, -170, -57, -235, 307, 149, 423, 428,
148319
- /* 20 */ 471, 313, 451, 519, 489, 496, 499, 545, 547, 555,
148320
- /* 30 */ -116, 540, 558, 592, 594, 597, 599, -206, -206, -206,
148321
- /* 40 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148322
- /* 50 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148323
- /* 60 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148324
- /* 70 */ -206, -206, 196, 309, 494, 537, 612, 656, 675, 679,
148325
- /* 80 */ 681, 685, 724, 753, 771, 776, 788, 790, 794, 796,
148326
- /* 90 */ 801, 803, 805, 807, 814, 819, 833, 837, 839, 842,
148327
- /* 100 */ 845, 847, 849, 853, 873, 891, 893, 917, 921, 937,
148328
- /* 110 */ 940, 944, 956, 960, 967, 969, 971, 973, 975, -206,
148329
- /* 120 */ -206, -206, -206, -206, -206, -206, -206, -206, 501, -168,
148330
- /* 130 */ 90, -97, 87, 112, 303, 277, 601, 277, 601, 179,
148331
- /* 140 */ -206, -206, -206, -206, -107, -107, -107, -43, -56, 323,
148332
- /* 150 */ 500, 512, -187, -177, 317, 609, 353, 353, 120, 144,
148333
- /* 160 */ 490, 539, 698, 374, 467, 507, 789, 404, -157, 755,
148334
- /* 170 */ 856, 916, 843, 941, 802, 770, 923, 821, 1001, -142,
148335
- /* 180 */ 264, 785, 896, 905, 899, 949, -176, 544, 911, 953,
148336
- /* 190 */ 1012, -182, -59, -30, 16, -22, 117, 172, 291, 369,
148337
- /* 200 */ 407, 415, 566, 586, 647, 699, 754, 813, 850, 892,
148338
- /* 210 */ 121, 1023, 1042, 1086, 1121, 1125, 1128, 1129, 1130, 1131,
148339
- /* 220 */ 1132, 1134, 1135, 284, 1106, 1123, 1152, 1154, 1155, 1156,
148340
- /* 230 */ 397, 1158, 1172, 1173, 1116, 1176, 1177, 1138, 1179, 117,
148341
- /* 240 */ 1184, 1185, 1198, 1200, 1202, 1203, 741, 1094, 1153, 1146,
148342
- /* 250 */ 1160, 1162, 1163, 397, 1153, 1153, 1170, 1204, 1206, 1103,
148343
- /* 260 */ 1168, 1165, 1166, 1133, 1174, 1175, 1140, 1210, 1193, 1208,
148344
- /* 270 */ 1212, 1215, 1216, 1178, 1167, 1189, 1196, 1241, 1148, 1243,
148345
- /* 280 */ 1245, 1181, 1183, 1247, 1188, 1187, 1190, 1227, 1223, 1234,
148346
- /* 290 */ 1236, 1238, 1239, 1274, 1278, 1235, 1237, 1213, 1218, 1253,
148347
- /* 300 */ 1254, 1246, 1287, 1289, 1209, 1219, 1303, 1305, 1293, 1306,
148348
- /* 310 */ 1309, 1313, 1316, 1297, 1301, 1307, 1308, 1298, 1310, 1311,
148349
- /* 320 */ 1312, 1317, 1304, 1318, 1320, 1319, 1265, 1267, 1325, 1295,
148350
- /* 330 */ 1300, 1296, 1302, 1326, 1321, 1327, 1330, 1365, 1323, 1269,
148351
- /* 340 */ 1272, 1328, 1331, 1322, 1388, 1334, 1336, 1349, 1353, 1357,
148352
- /* 350 */ 1405, 1409, 1420, 1421, 1427, 1429, 1430, 1332, 1335, 1339,
148353
- /* 360 */ 1418, 1422, 1423, 1424, 1425, 1433, 1426, 1435, 1436, 1437,
148354
- /* 370 */ 1438, 1441, 1439,
148929
+ /* 0 */ -151, 181, -141, 376, 379, -149, -153, -75, -1, 227,
148930
+ /* 10 */ 273, 279, 232, -176, -133, -241, -179, 321, 349, 447,
148931
+ /* 20 */ 528, 373, 546, 590, 431, 470, 593, -163, 520, 564,
148932
+ /* 30 */ 624, 626, 246, 386, 539, 479, 536, 573, 576, 619,
148933
+ /* 40 */ 627, 634, -202, -202, -202, -202, -202, -202, -202, -202,
148934
+ /* 50 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,
148935
+ /* 60 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,
148936
+ /* 70 */ -202, -202, -202, -202, -202, -202, -202, 113, 137, 304,
148937
+ /* 80 */ 660, 665, 691, 714, 721, 741, 758, 760, 784, 787,
148938
+ /* 90 */ 807, 833, 836, 838, 861, 874, 876, 878, 880, 887,
148939
+ /* 100 */ 889, 891, 893, 903, 905, 907, 919, 921, 923, 930,
148940
+ /* 110 */ 932, 957, 959, 977, 1006, 1011, 1026, 1029, 1031, 1034,
148941
+ /* 120 */ 1046, 1057, 1059, 1061, -202, -202, -202, -202, -202, -202,
148942
+ /* 130 */ -202, -202, -202, 240, -172, -39, 139, 76, 235, 566,
148943
+ /* 140 */ -103, 487, -103, 487, 502, -202, -202, -202, -202, -171,
148944
+ /* 150 */ -171, -171, -134, -161, 110, 52, 274, -113, 678, 261,
148945
+ /* 160 */ 444, 384, 384, -162, 481, 618, 666, 495, 186, 236,
148946
+ /* 170 */ 730, 731, 672, 174, 674, 545, 757, 734, 769, 732,
148947
+ /* 180 */ 418, 830, 826, 879, 480, 667, 729, 427, 777, 809,
148948
+ /* 190 */ 608, 767, 812, 922, 839, 242, 855, 900, 390, -156,
148949
+ /* 200 */ -108, -104, -76, -83, 207, 260, 347, 570, 595, 724,
148950
+ /* 210 */ 738, 744, 768, 906, 916, 1014, 1064, 1091, 1098, 92,
148951
+ /* 220 */ 1113, 1130, 1133, 1155, 1158, 1159, 1160, 1161, 1162, 1163,
148952
+ /* 230 */ 1164, 1165, 448, 553, 971, 1166, 1178, 1179, 1180, 1069,
148953
+ /* 240 */ 1181, 1182, 1183, 1094, 1040, 1184, 1185, 1110, 1186, 260,
148954
+ /* 250 */ 1198, 1201, 1202, 1204, 1205, 1209, 1114, 1111, 1167, 1147,
148955
+ /* 260 */ 1149, 1151, 1152, 1069, 1167, 1167, 1168, 1193, 1216, 1118,
148956
+ /* 270 */ 1169, 1157, 1187, 1123, 1171, 1172, 1124, 1200, 1190, 1195,
148957
+ /* 280 */ 1222, 1223, 1224, 1188, 1173, 1175, 1148, 1218, 1219, 1227,
148958
+ /* 290 */ 1170, 1245, 1262, 1176, 1177, 1266, 1191, 1210, 1225, 1244,
148959
+ /* 300 */ 1250, 1260, 1274, 1275, 1276, 1292, 1297, 1269, 1270, 1251,
148960
+ /* 310 */ 1253, 1283, 1284, 1277, 1316, 1320, 1241, 1243, 1324, 1330,
148961
+ /* 320 */ 1313, 1334, 1336, 1337, 1339, 1317, 1325, 1326, 1327, 1323,
148962
+ /* 330 */ 1329, 1333, 1332, 1341, 1331, 1342, 1344, 1346, 1278, 1288,
148963
+ /* 340 */ 1349, 1312, 1315, 1318, 1328, 1319, 1347, 1322, 1348, 1373,
148964
+ /* 350 */ 1267, 1279, 1356, 1340, 1343, 1388, 1350, 1359, 1351, 1363,
148965
+ /* 360 */ 1367, 1391, 1410, 1430, 1431, 1428, 1429, 1435, 1352, 1353,
148966
+ /* 370 */ 1354, 1420, 1416, 1418, 1421, 1423, 1432, 1409, 1412, 1424,
148967
+ /* 380 */ 1433, 1439, 1440, 1436,
148355148968
};
148356148969
static const YYACTIONTYPE yy_default[] = {
148357
- /* 0 */ 1500, 1500, 1500, 1346, 1129, 1235, 1129, 1129, 1129, 1346,
148358
- /* 10 */ 1346, 1346, 1129, 1265, 1265, 1399, 1160, 1129, 1129, 1129,
148359
- /* 20 */ 1129, 1129, 1129, 1129, 1345, 1129, 1129, 1129, 1129, 1129,
148360
- /* 30 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1271, 1129,
148361
- /* 40 */ 1129, 1129, 1129, 1129, 1347, 1348, 1129, 1129, 1129, 1398,
148362
- /* 50 */ 1400, 1363, 1281, 1280, 1279, 1278, 1381, 1252, 1276, 1269,
148363
- /* 60 */ 1273, 1341, 1342, 1340, 1344, 1348, 1347, 1129, 1272, 1312,
148364
- /* 70 */ 1326, 1311, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148365
- /* 80 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148366
- /* 90 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148367
- /* 100 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148368
- /* 110 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1320,
148369
- /* 120 */ 1325, 1331, 1324, 1321, 1314, 1313, 1315, 1316, 1129, 1150,
148370
- /* 130 */ 1199, 1129, 1129, 1129, 1129, 1417, 1416, 1129, 1129, 1160,
148371
- /* 140 */ 1317, 1318, 1328, 1327, 1406, 1456, 1455, 1364, 1129, 1129,
148372
- /* 150 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148373
- /* 160 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148374
- /* 170 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148375
- /* 180 */ 1160, 1156, 1306, 1305, 1426, 1156, 1259, 1129, 1412, 1235,
148376
- /* 190 */ 1226, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148377
- /* 200 */ 1129, 1129, 1129, 1129, 1403, 1401, 1129, 1129, 1129, 1129,
148378
- /* 210 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148379
- /* 220 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148380
- /* 230 */ 1129, 1129, 1129, 1129, 1231, 1129, 1129, 1129, 1129, 1129,
148381
- /* 240 */ 1129, 1129, 1129, 1129, 1129, 1450, 1129, 1376, 1213, 1231,
148382
- /* 250 */ 1231, 1231, 1231, 1233, 1214, 1212, 1225, 1160, 1136, 1492,
148383
- /* 260 */ 1275, 1254, 1254, 1489, 1275, 1275, 1489, 1174, 1470, 1171,
148384
- /* 270 */ 1265, 1265, 1265, 1254, 1343, 1232, 1225, 1129, 1492, 1240,
148385
- /* 280 */ 1240, 1491, 1491, 1240, 1364, 1284, 1290, 1202, 1275, 1208,
148386
- /* 290 */ 1208, 1208, 1208, 1240, 1147, 1275, 1275, 1284, 1290, 1202,
148387
- /* 300 */ 1202, 1275, 1240, 1147, 1380, 1486, 1240, 1147, 1354, 1240,
148388
- /* 310 */ 1147, 1240, 1147, 1354, 1200, 1200, 1200, 1189, 1354, 1200,
148389
- /* 320 */ 1174, 1200, 1189, 1200, 1200, 1354, 1358, 1358, 1354, 1258,
148390
- /* 330 */ 1253, 1258, 1253, 1258, 1253, 1258, 1253, 1240, 1259, 1425,
148391
- /* 340 */ 1129, 1270, 1259, 1349, 1240, 1129, 1270, 1268, 1266, 1275,
148392
- /* 350 */ 1153, 1192, 1453, 1453, 1449, 1449, 1449, 1497, 1497, 1412,
148393
- /* 360 */ 1465, 1160, 1160, 1160, 1160, 1465, 1176, 1176, 1160, 1160,
148394
- /* 370 */ 1160, 1160, 1465, 1129, 1129, 1129, 1129, 1129, 1129, 1460,
148395
- /* 380 */ 1129, 1365, 1244, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148396
- /* 390 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148397
- /* 400 */ 1129, 1129, 1129, 1129, 1129, 1295, 1129, 1132, 1409, 1129,
148398
- /* 410 */ 1129, 1407, 1129, 1129, 1129, 1129, 1129, 1129, 1245, 1129,
148399
- /* 420 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148400
- /* 430 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1488, 1129, 1129,
148401
- /* 440 */ 1129, 1129, 1129, 1129, 1379, 1378, 1129, 1129, 1242, 1129,
148402
- /* 450 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148403
- /* 460 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148404
- /* 470 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148405
- /* 480 */ 1129, 1129, 1129, 1129, 1129, 1129, 1267, 1129, 1424, 1129,
148406
- /* 490 */ 1129, 1129, 1129, 1129, 1129, 1129, 1438, 1260, 1129, 1129,
148407
- /* 500 */ 1479, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148408
- /* 510 */ 1129, 1129, 1129, 1129, 1129, 1474, 1216, 1297, 1129, 1296,
148409
- /* 520 */ 1300, 1129, 1141, 1129,
148970
+ /* 0 */ 1536, 1536, 1536, 1376, 1159, 1265, 1159, 1159, 1159, 1376,
148971
+ /* 10 */ 1376, 1376, 1159, 1295, 1295, 1429, 1190, 1159, 1159, 1159,
148972
+ /* 20 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1375, 1159, 1159,
148973
+ /* 30 */ 1159, 1159, 1459, 1459, 1159, 1159, 1159, 1159, 1159, 1159,
148974
+ /* 40 */ 1159, 1159, 1159, 1301, 1159, 1159, 1159, 1159, 1159, 1377,
148975
+ /* 50 */ 1378, 1159, 1159, 1159, 1428, 1430, 1393, 1311, 1310, 1309,
148976
+ /* 60 */ 1308, 1411, 1282, 1306, 1299, 1303, 1371, 1372, 1370, 1374,
148977
+ /* 70 */ 1378, 1377, 1159, 1302, 1342, 1356, 1341, 1159, 1159, 1159,
148978
+ /* 80 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148979
+ /* 90 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148980
+ /* 100 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148981
+ /* 110 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148982
+ /* 120 */ 1159, 1159, 1159, 1159, 1350, 1355, 1361, 1354, 1351, 1344,
148983
+ /* 130 */ 1343, 1345, 1346, 1159, 1180, 1229, 1159, 1159, 1159, 1159,
148984
+ /* 140 */ 1447, 1446, 1159, 1159, 1190, 1347, 1348, 1358, 1357, 1436,
148985
+ /* 150 */ 1492, 1491, 1394, 1159, 1159, 1159, 1159, 1159, 1159, 1459,
148986
+ /* 160 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148987
+ /* 170 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148988
+ /* 180 */ 1159, 1159, 1159, 1159, 1459, 1459, 1159, 1190, 1459, 1459,
148989
+ /* 190 */ 1186, 1336, 1335, 1186, 1289, 1159, 1442, 1265, 1256, 1159,
148990
+ /* 200 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148991
+ /* 210 */ 1159, 1159, 1159, 1433, 1431, 1159, 1159, 1159, 1159, 1159,
148992
+ /* 220 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148993
+ /* 230 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148994
+ /* 240 */ 1159, 1159, 1159, 1261, 1159, 1159, 1159, 1159, 1159, 1159,
148995
+ /* 250 */ 1159, 1159, 1159, 1159, 1159, 1486, 1159, 1406, 1243, 1261,
148996
+ /* 260 */ 1261, 1261, 1261, 1263, 1244, 1242, 1255, 1190, 1166, 1528,
148997
+ /* 270 */ 1305, 1284, 1284, 1525, 1305, 1305, 1525, 1204, 1506, 1201,
148998
+ /* 280 */ 1295, 1295, 1295, 1284, 1289, 1289, 1373, 1262, 1255, 1159,
148999
+ /* 290 */ 1528, 1270, 1270, 1527, 1527, 1270, 1394, 1314, 1320, 1232,
149000
+ /* 300 */ 1305, 1238, 1238, 1238, 1238, 1270, 1177, 1305, 1305, 1314,
149001
+ /* 310 */ 1320, 1232, 1232, 1305, 1270, 1177, 1410, 1522, 1270, 1177,
149002
+ /* 320 */ 1384, 1270, 1177, 1270, 1177, 1384, 1230, 1230, 1230, 1219,
149003
+ /* 330 */ 1384, 1230, 1204, 1230, 1219, 1230, 1230, 1384, 1388, 1388,
149004
+ /* 340 */ 1384, 1288, 1283, 1288, 1283, 1288, 1283, 1288, 1283, 1270,
149005
+ /* 350 */ 1469, 1469, 1300, 1289, 1379, 1270, 1159, 1300, 1298, 1296,
149006
+ /* 360 */ 1305, 1183, 1222, 1489, 1489, 1485, 1485, 1485, 1533, 1533,
149007
+ /* 370 */ 1442, 1501, 1190, 1190, 1190, 1190, 1501, 1206, 1206, 1190,
149008
+ /* 380 */ 1190, 1190, 1190, 1501, 1159, 1159, 1159, 1159, 1159, 1159,
149009
+ /* 390 */ 1496, 1159, 1395, 1274, 1159, 1159, 1159, 1159, 1159, 1159,
149010
+ /* 400 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149011
+ /* 410 */ 1159, 1159, 1159, 1159, 1159, 1159, 1325, 1159, 1162, 1439,
149012
+ /* 420 */ 1159, 1159, 1437, 1159, 1159, 1159, 1159, 1159, 1159, 1275,
149013
+ /* 430 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149014
+ /* 440 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1524, 1159,
149015
+ /* 450 */ 1159, 1159, 1159, 1159, 1159, 1409, 1408, 1159, 1159, 1272,
149016
+ /* 460 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149017
+ /* 470 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149018
+ /* 480 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149019
+ /* 490 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1297, 1159,
149020
+ /* 500 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149021
+ /* 510 */ 1159, 1159, 1159, 1474, 1290, 1159, 1159, 1515, 1159, 1159,
149022
+ /* 520 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149023
+ /* 530 */ 1159, 1159, 1510, 1246, 1327, 1159, 1326, 1330, 1159, 1171,
149024
+ /* 540 */ 1159,
148410149025
};
148411149026
/********** End of lemon-generated parsing tables *****************************/
148412149027
148413149028
/* The next table maps tokens (terminal symbols) into fallback tokens.
148414149029
** If a construct like the following:
@@ -148512,10 +149127,14 @@
148512149127
59, /* FOLLOWING => ID */
148513149128
59, /* PARTITION => ID */
148514149129
59, /* PRECEDING => ID */
148515149130
59, /* RANGE => ID */
148516149131
59, /* UNBOUNDED => ID */
149132
+ 59, /* EXCLUDE => ID */
149133
+ 59, /* GROUPS => ID */
149134
+ 59, /* OTHERS => ID */
149135
+ 59, /* TIES => ID */
148517149136
59, /* REINDEX => ID */
148518149137
59, /* RENAME => ID */
148519149138
59, /* CTIME_KW => ID */
148520149139
};
148521149140
#endif /* YYFALLBACK */
@@ -148690,200 +149309,206 @@
148690149309
/* 83 */ "FOLLOWING",
148691149310
/* 84 */ "PARTITION",
148692149311
/* 85 */ "PRECEDING",
148693149312
/* 86 */ "RANGE",
148694149313
/* 87 */ "UNBOUNDED",
148695
- /* 88 */ "REINDEX",
148696
- /* 89 */ "RENAME",
148697
- /* 90 */ "CTIME_KW",
148698
- /* 91 */ "ANY",
148699
- /* 92 */ "BITAND",
148700
- /* 93 */ "BITOR",
148701
- /* 94 */ "LSHIFT",
148702
- /* 95 */ "RSHIFT",
148703
- /* 96 */ "PLUS",
148704
- /* 97 */ "MINUS",
148705
- /* 98 */ "STAR",
148706
- /* 99 */ "SLASH",
148707
- /* 100 */ "REM",
148708
- /* 101 */ "CONCAT",
148709
- /* 102 */ "COLLATE",
148710
- /* 103 */ "BITNOT",
148711
- /* 104 */ "ON",
148712
- /* 105 */ "INDEXED",
148713
- /* 106 */ "STRING",
148714
- /* 107 */ "JOIN_KW",
148715
- /* 108 */ "CONSTRAINT",
148716
- /* 109 */ "DEFAULT",
148717
- /* 110 */ "NULL",
148718
- /* 111 */ "PRIMARY",
148719
- /* 112 */ "UNIQUE",
148720
- /* 113 */ "CHECK",
148721
- /* 114 */ "REFERENCES",
148722
- /* 115 */ "AUTOINCR",
148723
- /* 116 */ "INSERT",
148724
- /* 117 */ "DELETE",
148725
- /* 118 */ "UPDATE",
148726
- /* 119 */ "SET",
148727
- /* 120 */ "DEFERRABLE",
148728
- /* 121 */ "FOREIGN",
148729
- /* 122 */ "DROP",
148730
- /* 123 */ "UNION",
148731
- /* 124 */ "ALL",
148732
- /* 125 */ "EXCEPT",
148733
- /* 126 */ "INTERSECT",
148734
- /* 127 */ "SELECT",
148735
- /* 128 */ "VALUES",
148736
- /* 129 */ "DISTINCT",
148737
- /* 130 */ "DOT",
148738
- /* 131 */ "FROM",
148739
- /* 132 */ "JOIN",
148740
- /* 133 */ "USING",
148741
- /* 134 */ "ORDER",
148742
- /* 135 */ "GROUP",
148743
- /* 136 */ "HAVING",
148744
- /* 137 */ "LIMIT",
148745
- /* 138 */ "WHERE",
148746
- /* 139 */ "INTO",
148747
- /* 140 */ "NOTHING",
148748
- /* 141 */ "FLOAT",
148749
- /* 142 */ "BLOB",
148750
- /* 143 */ "INTEGER",
148751
- /* 144 */ "VARIABLE",
148752
- /* 145 */ "CASE",
148753
- /* 146 */ "WHEN",
148754
- /* 147 */ "THEN",
148755
- /* 148 */ "ELSE",
148756
- /* 149 */ "INDEX",
148757
- /* 150 */ "ALTER",
148758
- /* 151 */ "ADD",
148759
- /* 152 */ "WINDOW",
148760
- /* 153 */ "OVER",
148761
- /* 154 */ "FILTER",
148762
- /* 155 */ "input",
148763
- /* 156 */ "cmdlist",
148764
- /* 157 */ "ecmd",
148765
- /* 158 */ "cmdx",
148766
- /* 159 */ "explain",
148767
- /* 160 */ "cmd",
148768
- /* 161 */ "transtype",
148769
- /* 162 */ "trans_opt",
148770
- /* 163 */ "nm",
148771
- /* 164 */ "savepoint_opt",
148772
- /* 165 */ "create_table",
148773
- /* 166 */ "create_table_args",
148774
- /* 167 */ "createkw",
148775
- /* 168 */ "temp",
148776
- /* 169 */ "ifnotexists",
148777
- /* 170 */ "dbnm",
148778
- /* 171 */ "columnlist",
148779
- /* 172 */ "conslist_opt",
148780
- /* 173 */ "table_options",
148781
- /* 174 */ "select",
148782
- /* 175 */ "columnname",
148783
- /* 176 */ "carglist",
148784
- /* 177 */ "typetoken",
148785
- /* 178 */ "typename",
148786
- /* 179 */ "signed",
148787
- /* 180 */ "plus_num",
148788
- /* 181 */ "minus_num",
148789
- /* 182 */ "scanpt",
148790
- /* 183 */ "ccons",
148791
- /* 184 */ "term",
148792
- /* 185 */ "expr",
148793
- /* 186 */ "onconf",
148794
- /* 187 */ "sortorder",
148795
- /* 188 */ "autoinc",
148796
- /* 189 */ "eidlist_opt",
148797
- /* 190 */ "refargs",
148798
- /* 191 */ "defer_subclause",
148799
- /* 192 */ "refarg",
148800
- /* 193 */ "refact",
148801
- /* 194 */ "init_deferred_pred_opt",
148802
- /* 195 */ "conslist",
148803
- /* 196 */ "tconscomma",
148804
- /* 197 */ "tcons",
148805
- /* 198 */ "sortlist",
148806
- /* 199 */ "eidlist",
148807
- /* 200 */ "defer_subclause_opt",
148808
- /* 201 */ "orconf",
148809
- /* 202 */ "resolvetype",
148810
- /* 203 */ "raisetype",
148811
- /* 204 */ "ifexists",
148812
- /* 205 */ "fullname",
148813
- /* 206 */ "selectnowith",
148814
- /* 207 */ "oneselect",
148815
- /* 208 */ "wqlist",
148816
- /* 209 */ "multiselect_op",
148817
- /* 210 */ "distinct",
148818
- /* 211 */ "selcollist",
148819
- /* 212 */ "from",
148820
- /* 213 */ "where_opt",
148821
- /* 214 */ "groupby_opt",
148822
- /* 215 */ "having_opt",
148823
- /* 216 */ "orderby_opt",
148824
- /* 217 */ "limit_opt",
148825
- /* 218 */ "window_clause",
148826
- /* 219 */ "values",
148827
- /* 220 */ "nexprlist",
148828
- /* 221 */ "sclp",
148829
- /* 222 */ "as",
148830
- /* 223 */ "seltablist",
148831
- /* 224 */ "stl_prefix",
148832
- /* 225 */ "joinop",
148833
- /* 226 */ "indexed_opt",
148834
- /* 227 */ "on_opt",
148835
- /* 228 */ "using_opt",
148836
- /* 229 */ "exprlist",
148837
- /* 230 */ "xfullname",
148838
- /* 231 */ "idlist",
148839
- /* 232 */ "with",
148840
- /* 233 */ "setlist",
148841
- /* 234 */ "insert_cmd",
148842
- /* 235 */ "idlist_opt",
148843
- /* 236 */ "upsert",
148844
- /* 237 */ "over_clause",
148845
- /* 238 */ "likeop",
148846
- /* 239 */ "between_op",
148847
- /* 240 */ "in_op",
148848
- /* 241 */ "paren_exprlist",
148849
- /* 242 */ "case_operand",
148850
- /* 243 */ "case_exprlist",
148851
- /* 244 */ "case_else",
148852
- /* 245 */ "uniqueflag",
148853
- /* 246 */ "collate",
148854
- /* 247 */ "vinto",
148855
- /* 248 */ "nmnum",
148856
- /* 249 */ "trigger_decl",
148857
- /* 250 */ "trigger_cmd_list",
148858
- /* 251 */ "trigger_time",
148859
- /* 252 */ "trigger_event",
148860
- /* 253 */ "foreach_clause",
148861
- /* 254 */ "when_clause",
148862
- /* 255 */ "trigger_cmd",
148863
- /* 256 */ "trnm",
148864
- /* 257 */ "tridxby",
148865
- /* 258 */ "database_kw_opt",
148866
- /* 259 */ "key_opt",
148867
- /* 260 */ "add_column_fullname",
148868
- /* 261 */ "kwcolumn_opt",
148869
- /* 262 */ "create_vtab",
148870
- /* 263 */ "vtabarglist",
148871
- /* 264 */ "vtabarg",
148872
- /* 265 */ "vtabargtoken",
148873
- /* 266 */ "lp",
148874
- /* 267 */ "anylist",
148875
- /* 268 */ "windowdefn_list",
148876
- /* 269 */ "windowdefn",
148877
- /* 270 */ "window",
148878
- /* 271 */ "frame_opt",
148879
- /* 272 */ "part_opt",
148880
- /* 273 */ "filter_opt",
148881
- /* 274 */ "range_or_rows",
148882
- /* 275 */ "frame_bound",
148883
- /* 276 */ "frame_bound_s",
148884
- /* 277 */ "frame_bound_e",
149314
+ /* 88 */ "EXCLUDE",
149315
+ /* 89 */ "GROUPS",
149316
+ /* 90 */ "OTHERS",
149317
+ /* 91 */ "TIES",
149318
+ /* 92 */ "REINDEX",
149319
+ /* 93 */ "RENAME",
149320
+ /* 94 */ "CTIME_KW",
149321
+ /* 95 */ "ANY",
149322
+ /* 96 */ "BITAND",
149323
+ /* 97 */ "BITOR",
149324
+ /* 98 */ "LSHIFT",
149325
+ /* 99 */ "RSHIFT",
149326
+ /* 100 */ "PLUS",
149327
+ /* 101 */ "MINUS",
149328
+ /* 102 */ "STAR",
149329
+ /* 103 */ "SLASH",
149330
+ /* 104 */ "REM",
149331
+ /* 105 */ "CONCAT",
149332
+ /* 106 */ "COLLATE",
149333
+ /* 107 */ "BITNOT",
149334
+ /* 108 */ "ON",
149335
+ /* 109 */ "INDEXED",
149336
+ /* 110 */ "STRING",
149337
+ /* 111 */ "JOIN_KW",
149338
+ /* 112 */ "CONSTRAINT",
149339
+ /* 113 */ "DEFAULT",
149340
+ /* 114 */ "NULL",
149341
+ /* 115 */ "PRIMARY",
149342
+ /* 116 */ "UNIQUE",
149343
+ /* 117 */ "CHECK",
149344
+ /* 118 */ "REFERENCES",
149345
+ /* 119 */ "AUTOINCR",
149346
+ /* 120 */ "INSERT",
149347
+ /* 121 */ "DELETE",
149348
+ /* 122 */ "UPDATE",
149349
+ /* 123 */ "SET",
149350
+ /* 124 */ "DEFERRABLE",
149351
+ /* 125 */ "FOREIGN",
149352
+ /* 126 */ "DROP",
149353
+ /* 127 */ "UNION",
149354
+ /* 128 */ "ALL",
149355
+ /* 129 */ "EXCEPT",
149356
+ /* 130 */ "INTERSECT",
149357
+ /* 131 */ "SELECT",
149358
+ /* 132 */ "VALUES",
149359
+ /* 133 */ "DISTINCT",
149360
+ /* 134 */ "DOT",
149361
+ /* 135 */ "FROM",
149362
+ /* 136 */ "JOIN",
149363
+ /* 137 */ "USING",
149364
+ /* 138 */ "ORDER",
149365
+ /* 139 */ "GROUP",
149366
+ /* 140 */ "HAVING",
149367
+ /* 141 */ "LIMIT",
149368
+ /* 142 */ "WHERE",
149369
+ /* 143 */ "INTO",
149370
+ /* 144 */ "NOTHING",
149371
+ /* 145 */ "FLOAT",
149372
+ /* 146 */ "BLOB",
149373
+ /* 147 */ "INTEGER",
149374
+ /* 148 */ "VARIABLE",
149375
+ /* 149 */ "CASE",
149376
+ /* 150 */ "WHEN",
149377
+ /* 151 */ "THEN",
149378
+ /* 152 */ "ELSE",
149379
+ /* 153 */ "INDEX",
149380
+ /* 154 */ "ALTER",
149381
+ /* 155 */ "ADD",
149382
+ /* 156 */ "WINDOW",
149383
+ /* 157 */ "OVER",
149384
+ /* 158 */ "FILTER",
149385
+ /* 159 */ "input",
149386
+ /* 160 */ "cmdlist",
149387
+ /* 161 */ "ecmd",
149388
+ /* 162 */ "cmdx",
149389
+ /* 163 */ "explain",
149390
+ /* 164 */ "cmd",
149391
+ /* 165 */ "transtype",
149392
+ /* 166 */ "trans_opt",
149393
+ /* 167 */ "nm",
149394
+ /* 168 */ "savepoint_opt",
149395
+ /* 169 */ "create_table",
149396
+ /* 170 */ "create_table_args",
149397
+ /* 171 */ "createkw",
149398
+ /* 172 */ "temp",
149399
+ /* 173 */ "ifnotexists",
149400
+ /* 174 */ "dbnm",
149401
+ /* 175 */ "columnlist",
149402
+ /* 176 */ "conslist_opt",
149403
+ /* 177 */ "table_options",
149404
+ /* 178 */ "select",
149405
+ /* 179 */ "columnname",
149406
+ /* 180 */ "carglist",
149407
+ /* 181 */ "typetoken",
149408
+ /* 182 */ "typename",
149409
+ /* 183 */ "signed",
149410
+ /* 184 */ "plus_num",
149411
+ /* 185 */ "minus_num",
149412
+ /* 186 */ "scanpt",
149413
+ /* 187 */ "ccons",
149414
+ /* 188 */ "term",
149415
+ /* 189 */ "expr",
149416
+ /* 190 */ "onconf",
149417
+ /* 191 */ "sortorder",
149418
+ /* 192 */ "autoinc",
149419
+ /* 193 */ "eidlist_opt",
149420
+ /* 194 */ "refargs",
149421
+ /* 195 */ "defer_subclause",
149422
+ /* 196 */ "refarg",
149423
+ /* 197 */ "refact",
149424
+ /* 198 */ "init_deferred_pred_opt",
149425
+ /* 199 */ "conslist",
149426
+ /* 200 */ "tconscomma",
149427
+ /* 201 */ "tcons",
149428
+ /* 202 */ "sortlist",
149429
+ /* 203 */ "eidlist",
149430
+ /* 204 */ "defer_subclause_opt",
149431
+ /* 205 */ "orconf",
149432
+ /* 206 */ "resolvetype",
149433
+ /* 207 */ "raisetype",
149434
+ /* 208 */ "ifexists",
149435
+ /* 209 */ "fullname",
149436
+ /* 210 */ "selectnowith",
149437
+ /* 211 */ "oneselect",
149438
+ /* 212 */ "wqlist",
149439
+ /* 213 */ "multiselect_op",
149440
+ /* 214 */ "distinct",
149441
+ /* 215 */ "selcollist",
149442
+ /* 216 */ "from",
149443
+ /* 217 */ "where_opt",
149444
+ /* 218 */ "groupby_opt",
149445
+ /* 219 */ "having_opt",
149446
+ /* 220 */ "orderby_opt",
149447
+ /* 221 */ "limit_opt",
149448
+ /* 222 */ "window_clause",
149449
+ /* 223 */ "values",
149450
+ /* 224 */ "nexprlist",
149451
+ /* 225 */ "sclp",
149452
+ /* 226 */ "as",
149453
+ /* 227 */ "seltablist",
149454
+ /* 228 */ "stl_prefix",
149455
+ /* 229 */ "joinop",
149456
+ /* 230 */ "indexed_opt",
149457
+ /* 231 */ "on_opt",
149458
+ /* 232 */ "using_opt",
149459
+ /* 233 */ "exprlist",
149460
+ /* 234 */ "xfullname",
149461
+ /* 235 */ "idlist",
149462
+ /* 236 */ "with",
149463
+ /* 237 */ "setlist",
149464
+ /* 238 */ "insert_cmd",
149465
+ /* 239 */ "idlist_opt",
149466
+ /* 240 */ "upsert",
149467
+ /* 241 */ "over_clause",
149468
+ /* 242 */ "likeop",
149469
+ /* 243 */ "between_op",
149470
+ /* 244 */ "in_op",
149471
+ /* 245 */ "paren_exprlist",
149472
+ /* 246 */ "case_operand",
149473
+ /* 247 */ "case_exprlist",
149474
+ /* 248 */ "case_else",
149475
+ /* 249 */ "uniqueflag",
149476
+ /* 250 */ "collate",
149477
+ /* 251 */ "vinto",
149478
+ /* 252 */ "nmnum",
149479
+ /* 253 */ "trigger_decl",
149480
+ /* 254 */ "trigger_cmd_list",
149481
+ /* 255 */ "trigger_time",
149482
+ /* 256 */ "trigger_event",
149483
+ /* 257 */ "foreach_clause",
149484
+ /* 258 */ "when_clause",
149485
+ /* 259 */ "trigger_cmd",
149486
+ /* 260 */ "trnm",
149487
+ /* 261 */ "tridxby",
149488
+ /* 262 */ "database_kw_opt",
149489
+ /* 263 */ "key_opt",
149490
+ /* 264 */ "add_column_fullname",
149491
+ /* 265 */ "kwcolumn_opt",
149492
+ /* 266 */ "create_vtab",
149493
+ /* 267 */ "vtabarglist",
149494
+ /* 268 */ "vtabarg",
149495
+ /* 269 */ "vtabargtoken",
149496
+ /* 270 */ "lp",
149497
+ /* 271 */ "anylist",
149498
+ /* 272 */ "windowdefn_list",
149499
+ /* 273 */ "windowdefn",
149500
+ /* 274 */ "window",
149501
+ /* 275 */ "frame_opt",
149502
+ /* 276 */ "part_opt",
149503
+ /* 277 */ "filter_opt",
149504
+ /* 278 */ "range_or_rows",
149505
+ /* 279 */ "frame_bound",
149506
+ /* 280 */ "frame_bound_s",
149507
+ /* 281 */ "frame_bound_e",
149508
+ /* 282 */ "frame_exclude_opt",
149509
+ /* 283 */ "frame_exclude",
148885149510
};
148886149511
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
148887149512
148888149513
#ifndef NDEBUG
148889149514
/* For tracing reduce actions, the names of all rules are required.
@@ -149177,89 +149802,95 @@
149177149802
/* 285 */ "with ::= WITH RECURSIVE wqlist",
149178149803
/* 286 */ "wqlist ::= nm eidlist_opt AS LP select RP",
149179149804
/* 287 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
149180149805
/* 288 */ "windowdefn_list ::= windowdefn",
149181149806
/* 289 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
149182
- /* 290 */ "windowdefn ::= nm AS window",
149183
- /* 291 */ "window ::= LP part_opt orderby_opt frame_opt RP",
149184
- /* 292 */ "part_opt ::= PARTITION BY nexprlist",
149185
- /* 293 */ "part_opt ::=",
149186
- /* 294 */ "frame_opt ::=",
149187
- /* 295 */ "frame_opt ::= range_or_rows frame_bound_s",
149188
- /* 296 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
149189
- /* 297 */ "range_or_rows ::= RANGE",
149190
- /* 298 */ "range_or_rows ::= ROWS",
149191
- /* 299 */ "frame_bound_s ::= frame_bound",
149192
- /* 300 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
149193
- /* 301 */ "frame_bound_e ::= frame_bound",
149194
- /* 302 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
149195
- /* 303 */ "frame_bound ::= expr PRECEDING",
149196
- /* 304 */ "frame_bound ::= CURRENT ROW",
149197
- /* 305 */ "frame_bound ::= expr FOLLOWING",
149198
- /* 306 */ "window_clause ::= WINDOW windowdefn_list",
149199
- /* 307 */ "over_clause ::= filter_opt OVER window",
149200
- /* 308 */ "over_clause ::= filter_opt OVER nm",
149201
- /* 309 */ "filter_opt ::=",
149202
- /* 310 */ "filter_opt ::= FILTER LP WHERE expr RP",
149203
- /* 311 */ "input ::= cmdlist",
149204
- /* 312 */ "cmdlist ::= cmdlist ecmd",
149205
- /* 313 */ "cmdlist ::= ecmd",
149206
- /* 314 */ "ecmd ::= SEMI",
149207
- /* 315 */ "ecmd ::= cmdx SEMI",
149208
- /* 316 */ "ecmd ::= explain cmdx",
149209
- /* 317 */ "trans_opt ::=",
149210
- /* 318 */ "trans_opt ::= TRANSACTION",
149211
- /* 319 */ "trans_opt ::= TRANSACTION nm",
149212
- /* 320 */ "savepoint_opt ::= SAVEPOINT",
149213
- /* 321 */ "savepoint_opt ::=",
149214
- /* 322 */ "cmd ::= create_table create_table_args",
149215
- /* 323 */ "columnlist ::= columnlist COMMA columnname carglist",
149216
- /* 324 */ "columnlist ::= columnname carglist",
149217
- /* 325 */ "nm ::= ID|INDEXED",
149218
- /* 326 */ "nm ::= STRING",
149219
- /* 327 */ "nm ::= JOIN_KW",
149220
- /* 328 */ "typetoken ::= typename",
149221
- /* 329 */ "typename ::= ID|STRING",
149222
- /* 330 */ "signed ::= plus_num",
149223
- /* 331 */ "signed ::= minus_num",
149224
- /* 332 */ "carglist ::= carglist ccons",
149225
- /* 333 */ "carglist ::=",
149226
- /* 334 */ "ccons ::= NULL onconf",
149227
- /* 335 */ "conslist_opt ::= COMMA conslist",
149228
- /* 336 */ "conslist ::= conslist tconscomma tcons",
149229
- /* 337 */ "conslist ::= tcons",
149230
- /* 338 */ "tconscomma ::=",
149231
- /* 339 */ "defer_subclause_opt ::= defer_subclause",
149232
- /* 340 */ "resolvetype ::= raisetype",
149233
- /* 341 */ "selectnowith ::= oneselect",
149234
- /* 342 */ "oneselect ::= values",
149235
- /* 343 */ "sclp ::= selcollist COMMA",
149236
- /* 344 */ "as ::= ID|STRING",
149237
- /* 345 */ "expr ::= term",
149238
- /* 346 */ "likeop ::= LIKE_KW|MATCH",
149239
- /* 347 */ "exprlist ::= nexprlist",
149240
- /* 348 */ "nmnum ::= plus_num",
149241
- /* 349 */ "nmnum ::= nm",
149242
- /* 350 */ "nmnum ::= ON",
149243
- /* 351 */ "nmnum ::= DELETE",
149244
- /* 352 */ "nmnum ::= DEFAULT",
149245
- /* 353 */ "plus_num ::= INTEGER|FLOAT",
149246
- /* 354 */ "foreach_clause ::=",
149247
- /* 355 */ "foreach_clause ::= FOR EACH ROW",
149248
- /* 356 */ "trnm ::= nm",
149249
- /* 357 */ "tridxby ::=",
149250
- /* 358 */ "database_kw_opt ::= DATABASE",
149251
- /* 359 */ "database_kw_opt ::=",
149252
- /* 360 */ "kwcolumn_opt ::=",
149253
- /* 361 */ "kwcolumn_opt ::= COLUMNKW",
149254
- /* 362 */ "vtabarglist ::= vtabarg",
149255
- /* 363 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
149256
- /* 364 */ "vtabarg ::= vtabarg vtabargtoken",
149257
- /* 365 */ "anylist ::=",
149258
- /* 366 */ "anylist ::= anylist LP anylist RP",
149259
- /* 367 */ "anylist ::= anylist ANY",
149260
- /* 368 */ "with ::=",
149807
+ /* 290 */ "windowdefn ::= nm AS LP window RP",
149808
+ /* 291 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
149809
+ /* 292 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
149810
+ /* 293 */ "window ::= ORDER BY sortlist frame_opt",
149811
+ /* 294 */ "window ::= nm ORDER BY sortlist frame_opt",
149812
+ /* 295 */ "window ::= frame_opt",
149813
+ /* 296 */ "window ::= nm frame_opt",
149814
+ /* 297 */ "frame_opt ::=",
149815
+ /* 298 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
149816
+ /* 299 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
149817
+ /* 300 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
149818
+ /* 301 */ "frame_bound_s ::= frame_bound",
149819
+ /* 302 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
149820
+ /* 303 */ "frame_bound_e ::= frame_bound",
149821
+ /* 304 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
149822
+ /* 305 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
149823
+ /* 306 */ "frame_bound ::= CURRENT ROW",
149824
+ /* 307 */ "frame_exclude_opt ::=",
149825
+ /* 308 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
149826
+ /* 309 */ "frame_exclude ::= NO OTHERS",
149827
+ /* 310 */ "frame_exclude ::= CURRENT ROW",
149828
+ /* 311 */ "frame_exclude ::= GROUP|TIES",
149829
+ /* 312 */ "window_clause ::= WINDOW windowdefn_list",
149830
+ /* 313 */ "over_clause ::= filter_opt OVER LP window RP",
149831
+ /* 314 */ "over_clause ::= filter_opt OVER nm",
149832
+ /* 315 */ "filter_opt ::=",
149833
+ /* 316 */ "filter_opt ::= FILTER LP WHERE expr RP",
149834
+ /* 317 */ "input ::= cmdlist",
149835
+ /* 318 */ "cmdlist ::= cmdlist ecmd",
149836
+ /* 319 */ "cmdlist ::= ecmd",
149837
+ /* 320 */ "ecmd ::= SEMI",
149838
+ /* 321 */ "ecmd ::= cmdx SEMI",
149839
+ /* 322 */ "ecmd ::= explain cmdx",
149840
+ /* 323 */ "trans_opt ::=",
149841
+ /* 324 */ "trans_opt ::= TRANSACTION",
149842
+ /* 325 */ "trans_opt ::= TRANSACTION nm",
149843
+ /* 326 */ "savepoint_opt ::= SAVEPOINT",
149844
+ /* 327 */ "savepoint_opt ::=",
149845
+ /* 328 */ "cmd ::= create_table create_table_args",
149846
+ /* 329 */ "columnlist ::= columnlist COMMA columnname carglist",
149847
+ /* 330 */ "columnlist ::= columnname carglist",
149848
+ /* 331 */ "nm ::= ID|INDEXED",
149849
+ /* 332 */ "nm ::= STRING",
149850
+ /* 333 */ "nm ::= JOIN_KW",
149851
+ /* 334 */ "typetoken ::= typename",
149852
+ /* 335 */ "typename ::= ID|STRING",
149853
+ /* 336 */ "signed ::= plus_num",
149854
+ /* 337 */ "signed ::= minus_num",
149855
+ /* 338 */ "carglist ::= carglist ccons",
149856
+ /* 339 */ "carglist ::=",
149857
+ /* 340 */ "ccons ::= NULL onconf",
149858
+ /* 341 */ "conslist_opt ::= COMMA conslist",
149859
+ /* 342 */ "conslist ::= conslist tconscomma tcons",
149860
+ /* 343 */ "conslist ::= tcons",
149861
+ /* 344 */ "tconscomma ::=",
149862
+ /* 345 */ "defer_subclause_opt ::= defer_subclause",
149863
+ /* 346 */ "resolvetype ::= raisetype",
149864
+ /* 347 */ "selectnowith ::= oneselect",
149865
+ /* 348 */ "oneselect ::= values",
149866
+ /* 349 */ "sclp ::= selcollist COMMA",
149867
+ /* 350 */ "as ::= ID|STRING",
149868
+ /* 351 */ "expr ::= term",
149869
+ /* 352 */ "likeop ::= LIKE_KW|MATCH",
149870
+ /* 353 */ "exprlist ::= nexprlist",
149871
+ /* 354 */ "nmnum ::= plus_num",
149872
+ /* 355 */ "nmnum ::= nm",
149873
+ /* 356 */ "nmnum ::= ON",
149874
+ /* 357 */ "nmnum ::= DELETE",
149875
+ /* 358 */ "nmnum ::= DEFAULT",
149876
+ /* 359 */ "plus_num ::= INTEGER|FLOAT",
149877
+ /* 360 */ "foreach_clause ::=",
149878
+ /* 361 */ "foreach_clause ::= FOR EACH ROW",
149879
+ /* 362 */ "trnm ::= nm",
149880
+ /* 363 */ "tridxby ::=",
149881
+ /* 364 */ "database_kw_opt ::= DATABASE",
149882
+ /* 365 */ "database_kw_opt ::=",
149883
+ /* 366 */ "kwcolumn_opt ::=",
149884
+ /* 367 */ "kwcolumn_opt ::= COLUMNKW",
149885
+ /* 368 */ "vtabarglist ::= vtabarg",
149886
+ /* 369 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
149887
+ /* 370 */ "vtabarg ::= vtabarg vtabargtoken",
149888
+ /* 371 */ "anylist ::=",
149889
+ /* 372 */ "anylist ::= anylist LP anylist RP",
149890
+ /* 373 */ "anylist ::= anylist ANY",
149891
+ /* 374 */ "with ::=",
149261149892
};
149262149893
#endif /* NDEBUG */
149263149894
149264149895
149265149896
#if YYSTACKDEPTH<=0
@@ -149381,101 +150012,101 @@
149381150012
** Note: during a reduce, the only symbols destroyed are those
149382150013
** which appear on the RHS of the rule, but which are *not* used
149383150014
** inside the C code.
149384150015
*/
149385150016
/********* Begin destructor definitions ***************************************/
149386
- case 174: /* select */
149387
- case 206: /* selectnowith */
149388
- case 207: /* oneselect */
149389
- case 219: /* values */
149390
-{
149391
-sqlite3SelectDelete(pParse->db, (yypminor->yy423));
149392
-}
149393
- break;
149394
- case 184: /* term */
149395
- case 185: /* expr */
149396
- case 213: /* where_opt */
149397
- case 215: /* having_opt */
149398
- case 227: /* on_opt */
149399
- case 242: /* case_operand */
149400
- case 244: /* case_else */
149401
- case 247: /* vinto */
149402
- case 254: /* when_clause */
149403
- case 259: /* key_opt */
149404
- case 273: /* filter_opt */
149405
-{
149406
-sqlite3ExprDelete(pParse->db, (yypminor->yy490));
149407
-}
149408
- break;
149409
- case 189: /* eidlist_opt */
149410
- case 198: /* sortlist */
149411
- case 199: /* eidlist */
149412
- case 211: /* selcollist */
149413
- case 214: /* groupby_opt */
149414
- case 216: /* orderby_opt */
149415
- case 220: /* nexprlist */
149416
- case 221: /* sclp */
149417
- case 229: /* exprlist */
149418
- case 233: /* setlist */
149419
- case 241: /* paren_exprlist */
149420
- case 243: /* case_exprlist */
149421
- case 272: /* part_opt */
149422
-{
149423
-sqlite3ExprListDelete(pParse->db, (yypminor->yy42));
149424
-}
149425
- break;
149426
- case 205: /* fullname */
149427
- case 212: /* from */
149428
- case 223: /* seltablist */
149429
- case 224: /* stl_prefix */
149430
- case 230: /* xfullname */
149431
-{
149432
-sqlite3SrcListDelete(pParse->db, (yypminor->yy167));
149433
-}
149434
- break;
149435
- case 208: /* wqlist */
149436
-{
149437
-sqlite3WithDelete(pParse->db, (yypminor->yy499));
149438
-}
149439
- break;
149440
- case 218: /* window_clause */
149441
- case 268: /* windowdefn_list */
149442
-{
149443
-sqlite3WindowListDelete(pParse->db, (yypminor->yy147));
149444
-}
149445
- break;
149446
- case 228: /* using_opt */
149447
- case 231: /* idlist */
149448
- case 235: /* idlist_opt */
149449
-{
149450
-sqlite3IdListDelete(pParse->db, (yypminor->yy336));
149451
-}
149452
- break;
149453
- case 237: /* over_clause */
149454
- case 269: /* windowdefn */
149455
- case 270: /* window */
149456
- case 271: /* frame_opt */
149457
-{
149458
-sqlite3WindowDelete(pParse->db, (yypminor->yy147));
149459
-}
149460
- break;
149461
- case 250: /* trigger_cmd_list */
149462
- case 255: /* trigger_cmd */
149463
-{
149464
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy119));
149465
-}
149466
- break;
149467
- case 252: /* trigger_event */
149468
-{
149469
-sqlite3IdListDelete(pParse->db, (yypminor->yy350).b);
149470
-}
149471
- break;
149472
- case 275: /* frame_bound */
149473
- case 276: /* frame_bound_s */
149474
- case 277: /* frame_bound_e */
149475
-{
149476
-sqlite3ExprDelete(pParse->db, (yypminor->yy317).pExpr);
150017
+ case 178: /* select */
150018
+ case 210: /* selectnowith */
150019
+ case 211: /* oneselect */
150020
+ case 223: /* values */
150021
+{
150022
+sqlite3SelectDelete(pParse->db, (yypminor->yy491));
150023
+}
150024
+ break;
150025
+ case 188: /* term */
150026
+ case 189: /* expr */
150027
+ case 217: /* where_opt */
150028
+ case 219: /* having_opt */
150029
+ case 231: /* on_opt */
150030
+ case 246: /* case_operand */
150031
+ case 248: /* case_else */
150032
+ case 251: /* vinto */
150033
+ case 258: /* when_clause */
150034
+ case 263: /* key_opt */
150035
+ case 277: /* filter_opt */
150036
+{
150037
+sqlite3ExprDelete(pParse->db, (yypminor->yy130));
150038
+}
150039
+ break;
150040
+ case 193: /* eidlist_opt */
150041
+ case 202: /* sortlist */
150042
+ case 203: /* eidlist */
150043
+ case 215: /* selcollist */
150044
+ case 218: /* groupby_opt */
150045
+ case 220: /* orderby_opt */
150046
+ case 224: /* nexprlist */
150047
+ case 225: /* sclp */
150048
+ case 233: /* exprlist */
150049
+ case 237: /* setlist */
150050
+ case 245: /* paren_exprlist */
150051
+ case 247: /* case_exprlist */
150052
+ case 276: /* part_opt */
150053
+{
150054
+sqlite3ExprListDelete(pParse->db, (yypminor->yy442));
150055
+}
150056
+ break;
150057
+ case 209: /* fullname */
150058
+ case 216: /* from */
150059
+ case 227: /* seltablist */
150060
+ case 228: /* stl_prefix */
150061
+ case 234: /* xfullname */
150062
+{
150063
+sqlite3SrcListDelete(pParse->db, (yypminor->yy147));
150064
+}
150065
+ break;
150066
+ case 212: /* wqlist */
150067
+{
150068
+sqlite3WithDelete(pParse->db, (yypminor->yy523));
150069
+}
150070
+ break;
150071
+ case 222: /* window_clause */
150072
+ case 272: /* windowdefn_list */
150073
+{
150074
+sqlite3WindowListDelete(pParse->db, (yypminor->yy395));
150075
+}
150076
+ break;
150077
+ case 232: /* using_opt */
150078
+ case 235: /* idlist */
150079
+ case 239: /* idlist_opt */
150080
+{
150081
+sqlite3IdListDelete(pParse->db, (yypminor->yy200));
150082
+}
150083
+ break;
150084
+ case 241: /* over_clause */
150085
+ case 273: /* windowdefn */
150086
+ case 274: /* window */
150087
+ case 275: /* frame_opt */
150088
+{
150089
+sqlite3WindowDelete(pParse->db, (yypminor->yy395));
150090
+}
150091
+ break;
150092
+ case 254: /* trigger_cmd_list */
150093
+ case 259: /* trigger_cmd */
150094
+{
150095
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy524));
150096
+}
150097
+ break;
150098
+ case 256: /* trigger_event */
150099
+{
150100
+sqlite3IdListDelete(pParse->db, (yypminor->yy498).b);
150101
+}
150102
+ break;
150103
+ case 279: /* frame_bound */
150104
+ case 280: /* frame_bound_s */
150105
+ case 281: /* frame_bound_e */
150106
+{
150107
+sqlite3ExprDelete(pParse->db, (yypminor->yy273).pExpr);
149477150108
}
149478150109
break;
149479150110
/********* End destructor definitions *****************************************/
149480150111
default: break; /* If no destructor action specified: do nothing */
149481150112
}
@@ -149766,379 +150397,385 @@
149766150397
}
149767150398
149768150399
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
149769150400
** of that rule */
149770150401
static const YYCODETYPE yyRuleInfoLhs[] = {
149771
- 159, /* (0) explain ::= EXPLAIN */
149772
- 159, /* (1) explain ::= EXPLAIN QUERY PLAN */
149773
- 158, /* (2) cmdx ::= cmd */
149774
- 160, /* (3) cmd ::= BEGIN transtype trans_opt */
149775
- 161, /* (4) transtype ::= */
149776
- 161, /* (5) transtype ::= DEFERRED */
149777
- 161, /* (6) transtype ::= IMMEDIATE */
149778
- 161, /* (7) transtype ::= EXCLUSIVE */
149779
- 160, /* (8) cmd ::= COMMIT|END trans_opt */
149780
- 160, /* (9) cmd ::= ROLLBACK trans_opt */
149781
- 160, /* (10) cmd ::= SAVEPOINT nm */
149782
- 160, /* (11) cmd ::= RELEASE savepoint_opt nm */
149783
- 160, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
149784
- 165, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
149785
- 167, /* (14) createkw ::= CREATE */
149786
- 169, /* (15) ifnotexists ::= */
149787
- 169, /* (16) ifnotexists ::= IF NOT EXISTS */
149788
- 168, /* (17) temp ::= TEMP */
149789
- 168, /* (18) temp ::= */
149790
- 166, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
149791
- 166, /* (20) create_table_args ::= AS select */
149792
- 173, /* (21) table_options ::= */
149793
- 173, /* (22) table_options ::= WITHOUT nm */
149794
- 175, /* (23) columnname ::= nm typetoken */
149795
- 177, /* (24) typetoken ::= */
149796
- 177, /* (25) typetoken ::= typename LP signed RP */
149797
- 177, /* (26) typetoken ::= typename LP signed COMMA signed RP */
149798
- 178, /* (27) typename ::= typename ID|STRING */
149799
- 182, /* (28) scanpt ::= */
149800
- 183, /* (29) ccons ::= CONSTRAINT nm */
149801
- 183, /* (30) ccons ::= DEFAULT scanpt term scanpt */
149802
- 183, /* (31) ccons ::= DEFAULT LP expr RP */
149803
- 183, /* (32) ccons ::= DEFAULT PLUS term scanpt */
149804
- 183, /* (33) ccons ::= DEFAULT MINUS term scanpt */
149805
- 183, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
149806
- 183, /* (35) ccons ::= NOT NULL onconf */
149807
- 183, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
149808
- 183, /* (37) ccons ::= UNIQUE onconf */
149809
- 183, /* (38) ccons ::= CHECK LP expr RP */
149810
- 183, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
149811
- 183, /* (40) ccons ::= defer_subclause */
149812
- 183, /* (41) ccons ::= COLLATE ID|STRING */
149813
- 188, /* (42) autoinc ::= */
149814
- 188, /* (43) autoinc ::= AUTOINCR */
149815
- 190, /* (44) refargs ::= */
149816
- 190, /* (45) refargs ::= refargs refarg */
149817
- 192, /* (46) refarg ::= MATCH nm */
149818
- 192, /* (47) refarg ::= ON INSERT refact */
149819
- 192, /* (48) refarg ::= ON DELETE refact */
149820
- 192, /* (49) refarg ::= ON UPDATE refact */
149821
- 193, /* (50) refact ::= SET NULL */
149822
- 193, /* (51) refact ::= SET DEFAULT */
149823
- 193, /* (52) refact ::= CASCADE */
149824
- 193, /* (53) refact ::= RESTRICT */
149825
- 193, /* (54) refact ::= NO ACTION */
149826
- 191, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
149827
- 191, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
149828
- 194, /* (57) init_deferred_pred_opt ::= */
149829
- 194, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
149830
- 194, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
149831
- 172, /* (60) conslist_opt ::= */
149832
- 196, /* (61) tconscomma ::= COMMA */
149833
- 197, /* (62) tcons ::= CONSTRAINT nm */
149834
- 197, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
149835
- 197, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
149836
- 197, /* (65) tcons ::= CHECK LP expr RP onconf */
149837
- 197, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
149838
- 200, /* (67) defer_subclause_opt ::= */
149839
- 186, /* (68) onconf ::= */
149840
- 186, /* (69) onconf ::= ON CONFLICT resolvetype */
149841
- 201, /* (70) orconf ::= */
149842
- 201, /* (71) orconf ::= OR resolvetype */
149843
- 202, /* (72) resolvetype ::= IGNORE */
149844
- 202, /* (73) resolvetype ::= REPLACE */
149845
- 160, /* (74) cmd ::= DROP TABLE ifexists fullname */
149846
- 204, /* (75) ifexists ::= IF EXISTS */
149847
- 204, /* (76) ifexists ::= */
149848
- 160, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
149849
- 160, /* (78) cmd ::= DROP VIEW ifexists fullname */
149850
- 160, /* (79) cmd ::= select */
149851
- 174, /* (80) select ::= WITH wqlist selectnowith */
149852
- 174, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
149853
- 174, /* (82) select ::= selectnowith */
149854
- 206, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
149855
- 209, /* (84) multiselect_op ::= UNION */
149856
- 209, /* (85) multiselect_op ::= UNION ALL */
149857
- 209, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
149858
- 207, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
149859
- 207, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
149860
- 219, /* (89) values ::= VALUES LP nexprlist RP */
149861
- 219, /* (90) values ::= values COMMA LP nexprlist RP */
149862
- 210, /* (91) distinct ::= DISTINCT */
149863
- 210, /* (92) distinct ::= ALL */
149864
- 210, /* (93) distinct ::= */
149865
- 221, /* (94) sclp ::= */
149866
- 211, /* (95) selcollist ::= sclp scanpt expr scanpt as */
149867
- 211, /* (96) selcollist ::= sclp scanpt STAR */
149868
- 211, /* (97) selcollist ::= sclp scanpt nm DOT STAR */
149869
- 222, /* (98) as ::= AS nm */
149870
- 222, /* (99) as ::= */
149871
- 212, /* (100) from ::= */
149872
- 212, /* (101) from ::= FROM seltablist */
149873
- 224, /* (102) stl_prefix ::= seltablist joinop */
149874
- 224, /* (103) stl_prefix ::= */
149875
- 223, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
149876
- 223, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
149877
- 223, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
149878
- 223, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
149879
- 170, /* (108) dbnm ::= */
149880
- 170, /* (109) dbnm ::= DOT nm */
149881
- 205, /* (110) fullname ::= nm */
149882
- 205, /* (111) fullname ::= nm DOT nm */
149883
- 230, /* (112) xfullname ::= nm */
149884
- 230, /* (113) xfullname ::= nm DOT nm */
149885
- 230, /* (114) xfullname ::= nm DOT nm AS nm */
149886
- 230, /* (115) xfullname ::= nm AS nm */
149887
- 225, /* (116) joinop ::= COMMA|JOIN */
149888
- 225, /* (117) joinop ::= JOIN_KW JOIN */
149889
- 225, /* (118) joinop ::= JOIN_KW nm JOIN */
149890
- 225, /* (119) joinop ::= JOIN_KW nm nm JOIN */
149891
- 227, /* (120) on_opt ::= ON expr */
149892
- 227, /* (121) on_opt ::= */
149893
- 226, /* (122) indexed_opt ::= */
149894
- 226, /* (123) indexed_opt ::= INDEXED BY nm */
149895
- 226, /* (124) indexed_opt ::= NOT INDEXED */
149896
- 228, /* (125) using_opt ::= USING LP idlist RP */
149897
- 228, /* (126) using_opt ::= */
149898
- 216, /* (127) orderby_opt ::= */
149899
- 216, /* (128) orderby_opt ::= ORDER BY sortlist */
149900
- 198, /* (129) sortlist ::= sortlist COMMA expr sortorder */
149901
- 198, /* (130) sortlist ::= expr sortorder */
149902
- 187, /* (131) sortorder ::= ASC */
149903
- 187, /* (132) sortorder ::= DESC */
149904
- 187, /* (133) sortorder ::= */
149905
- 214, /* (134) groupby_opt ::= */
149906
- 214, /* (135) groupby_opt ::= GROUP BY nexprlist */
149907
- 215, /* (136) having_opt ::= */
149908
- 215, /* (137) having_opt ::= HAVING expr */
149909
- 217, /* (138) limit_opt ::= */
149910
- 217, /* (139) limit_opt ::= LIMIT expr */
149911
- 217, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
149912
- 217, /* (141) limit_opt ::= LIMIT expr COMMA expr */
149913
- 160, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
149914
- 213, /* (143) where_opt ::= */
149915
- 213, /* (144) where_opt ::= WHERE expr */
149916
- 160, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
149917
- 233, /* (146) setlist ::= setlist COMMA nm EQ expr */
149918
- 233, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
149919
- 233, /* (148) setlist ::= nm EQ expr */
149920
- 233, /* (149) setlist ::= LP idlist RP EQ expr */
149921
- 160, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
149922
- 160, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
149923
- 236, /* (152) upsert ::= */
149924
- 236, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
149925
- 236, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
149926
- 236, /* (155) upsert ::= ON CONFLICT DO NOTHING */
149927
- 234, /* (156) insert_cmd ::= INSERT orconf */
149928
- 234, /* (157) insert_cmd ::= REPLACE */
149929
- 235, /* (158) idlist_opt ::= */
149930
- 235, /* (159) idlist_opt ::= LP idlist RP */
149931
- 231, /* (160) idlist ::= idlist COMMA nm */
149932
- 231, /* (161) idlist ::= nm */
149933
- 185, /* (162) expr ::= LP expr RP */
149934
- 185, /* (163) expr ::= ID|INDEXED */
149935
- 185, /* (164) expr ::= JOIN_KW */
149936
- 185, /* (165) expr ::= nm DOT nm */
149937
- 185, /* (166) expr ::= nm DOT nm DOT nm */
149938
- 184, /* (167) term ::= NULL|FLOAT|BLOB */
149939
- 184, /* (168) term ::= STRING */
149940
- 184, /* (169) term ::= INTEGER */
149941
- 185, /* (170) expr ::= VARIABLE */
149942
- 185, /* (171) expr ::= expr COLLATE ID|STRING */
149943
- 185, /* (172) expr ::= CAST LP expr AS typetoken RP */
149944
- 185, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */
149945
- 185, /* (174) expr ::= ID|INDEXED LP STAR RP */
149946
- 185, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
149947
- 185, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */
149948
- 184, /* (177) term ::= CTIME_KW */
149949
- 185, /* (178) expr ::= LP nexprlist COMMA expr RP */
149950
- 185, /* (179) expr ::= expr AND expr */
149951
- 185, /* (180) expr ::= expr OR expr */
149952
- 185, /* (181) expr ::= expr LT|GT|GE|LE expr */
149953
- 185, /* (182) expr ::= expr EQ|NE expr */
149954
- 185, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
149955
- 185, /* (184) expr ::= expr PLUS|MINUS expr */
149956
- 185, /* (185) expr ::= expr STAR|SLASH|REM expr */
149957
- 185, /* (186) expr ::= expr CONCAT expr */
149958
- 238, /* (187) likeop ::= NOT LIKE_KW|MATCH */
149959
- 185, /* (188) expr ::= expr likeop expr */
149960
- 185, /* (189) expr ::= expr likeop expr ESCAPE expr */
149961
- 185, /* (190) expr ::= expr ISNULL|NOTNULL */
149962
- 185, /* (191) expr ::= expr NOT NULL */
149963
- 185, /* (192) expr ::= expr IS expr */
149964
- 185, /* (193) expr ::= expr IS NOT expr */
149965
- 185, /* (194) expr ::= NOT expr */
149966
- 185, /* (195) expr ::= BITNOT expr */
149967
- 185, /* (196) expr ::= PLUS|MINUS expr */
149968
- 239, /* (197) between_op ::= BETWEEN */
149969
- 239, /* (198) between_op ::= NOT BETWEEN */
149970
- 185, /* (199) expr ::= expr between_op expr AND expr */
149971
- 240, /* (200) in_op ::= IN */
149972
- 240, /* (201) in_op ::= NOT IN */
149973
- 185, /* (202) expr ::= expr in_op LP exprlist RP */
149974
- 185, /* (203) expr ::= LP select RP */
149975
- 185, /* (204) expr ::= expr in_op LP select RP */
149976
- 185, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */
149977
- 185, /* (206) expr ::= EXISTS LP select RP */
149978
- 185, /* (207) expr ::= CASE case_operand case_exprlist case_else END */
149979
- 243, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */
149980
- 243, /* (209) case_exprlist ::= WHEN expr THEN expr */
149981
- 244, /* (210) case_else ::= ELSE expr */
149982
- 244, /* (211) case_else ::= */
149983
- 242, /* (212) case_operand ::= expr */
149984
- 242, /* (213) case_operand ::= */
149985
- 229, /* (214) exprlist ::= */
149986
- 220, /* (215) nexprlist ::= nexprlist COMMA expr */
149987
- 220, /* (216) nexprlist ::= expr */
149988
- 241, /* (217) paren_exprlist ::= */
149989
- 241, /* (218) paren_exprlist ::= LP exprlist RP */
149990
- 160, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
149991
- 245, /* (220) uniqueflag ::= UNIQUE */
149992
- 245, /* (221) uniqueflag ::= */
149993
- 189, /* (222) eidlist_opt ::= */
149994
- 189, /* (223) eidlist_opt ::= LP eidlist RP */
149995
- 199, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */
149996
- 199, /* (225) eidlist ::= nm collate sortorder */
149997
- 246, /* (226) collate ::= */
149998
- 246, /* (227) collate ::= COLLATE ID|STRING */
149999
- 160, /* (228) cmd ::= DROP INDEX ifexists fullname */
150000
- 160, /* (229) cmd ::= VACUUM vinto */
150001
- 160, /* (230) cmd ::= VACUUM nm vinto */
150002
- 247, /* (231) vinto ::= INTO expr */
150003
- 247, /* (232) vinto ::= */
150004
- 160, /* (233) cmd ::= PRAGMA nm dbnm */
150005
- 160, /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */
150006
- 160, /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */
150007
- 160, /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */
150008
- 160, /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */
150009
- 180, /* (238) plus_num ::= PLUS INTEGER|FLOAT */
150010
- 181, /* (239) minus_num ::= MINUS INTEGER|FLOAT */
150011
- 160, /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
150012
- 249, /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
150013
- 251, /* (242) trigger_time ::= BEFORE|AFTER */
150014
- 251, /* (243) trigger_time ::= INSTEAD OF */
150015
- 251, /* (244) trigger_time ::= */
150016
- 252, /* (245) trigger_event ::= DELETE|INSERT */
150017
- 252, /* (246) trigger_event ::= UPDATE */
150018
- 252, /* (247) trigger_event ::= UPDATE OF idlist */
150019
- 254, /* (248) when_clause ::= */
150020
- 254, /* (249) when_clause ::= WHEN expr */
150021
- 250, /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
150022
- 250, /* (251) trigger_cmd_list ::= trigger_cmd SEMI */
150023
- 256, /* (252) trnm ::= nm DOT nm */
150024
- 257, /* (253) tridxby ::= INDEXED BY nm */
150025
- 257, /* (254) tridxby ::= NOT INDEXED */
150026
- 255, /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
150027
- 255, /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
150028
- 255, /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
150029
- 255, /* (258) trigger_cmd ::= scanpt select scanpt */
150030
- 185, /* (259) expr ::= RAISE LP IGNORE RP */
150031
- 185, /* (260) expr ::= RAISE LP raisetype COMMA nm RP */
150032
- 203, /* (261) raisetype ::= ROLLBACK */
150033
- 203, /* (262) raisetype ::= ABORT */
150034
- 203, /* (263) raisetype ::= FAIL */
150035
- 160, /* (264) cmd ::= DROP TRIGGER ifexists fullname */
150036
- 160, /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
150037
- 160, /* (266) cmd ::= DETACH database_kw_opt expr */
150038
- 259, /* (267) key_opt ::= */
150039
- 259, /* (268) key_opt ::= KEY expr */
150040
- 160, /* (269) cmd ::= REINDEX */
150041
- 160, /* (270) cmd ::= REINDEX nm dbnm */
150042
- 160, /* (271) cmd ::= ANALYZE */
150043
- 160, /* (272) cmd ::= ANALYZE nm dbnm */
150044
- 160, /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */
150045
- 160, /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
150046
- 260, /* (275) add_column_fullname ::= fullname */
150047
- 160, /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
150048
- 160, /* (277) cmd ::= create_vtab */
150049
- 160, /* (278) cmd ::= create_vtab LP vtabarglist RP */
150050
- 262, /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
150051
- 264, /* (280) vtabarg ::= */
150052
- 265, /* (281) vtabargtoken ::= ANY */
150053
- 265, /* (282) vtabargtoken ::= lp anylist RP */
150054
- 266, /* (283) lp ::= LP */
150055
- 232, /* (284) with ::= WITH wqlist */
150056
- 232, /* (285) with ::= WITH RECURSIVE wqlist */
150057
- 208, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150058
- 208, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150059
- 268, /* (288) windowdefn_list ::= windowdefn */
150060
- 268, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150061
- 269, /* (290) windowdefn ::= nm AS window */
150062
- 270, /* (291) window ::= LP part_opt orderby_opt frame_opt RP */
150063
- 272, /* (292) part_opt ::= PARTITION BY nexprlist */
150064
- 272, /* (293) part_opt ::= */
150065
- 271, /* (294) frame_opt ::= */
150066
- 271, /* (295) frame_opt ::= range_or_rows frame_bound_s */
150067
- 271, /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
150068
- 274, /* (297) range_or_rows ::= RANGE */
150069
- 274, /* (298) range_or_rows ::= ROWS */
150070
- 276, /* (299) frame_bound_s ::= frame_bound */
150071
- 276, /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */
150072
- 277, /* (301) frame_bound_e ::= frame_bound */
150073
- 277, /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */
150074
- 275, /* (303) frame_bound ::= expr PRECEDING */
150075
- 275, /* (304) frame_bound ::= CURRENT ROW */
150076
- 275, /* (305) frame_bound ::= expr FOLLOWING */
150077
- 218, /* (306) window_clause ::= WINDOW windowdefn_list */
150078
- 237, /* (307) over_clause ::= filter_opt OVER window */
150079
- 237, /* (308) over_clause ::= filter_opt OVER nm */
150080
- 273, /* (309) filter_opt ::= */
150081
- 273, /* (310) filter_opt ::= FILTER LP WHERE expr RP */
150082
- 155, /* (311) input ::= cmdlist */
150083
- 156, /* (312) cmdlist ::= cmdlist ecmd */
150084
- 156, /* (313) cmdlist ::= ecmd */
150085
- 157, /* (314) ecmd ::= SEMI */
150086
- 157, /* (315) ecmd ::= cmdx SEMI */
150087
- 157, /* (316) ecmd ::= explain cmdx */
150088
- 162, /* (317) trans_opt ::= */
150089
- 162, /* (318) trans_opt ::= TRANSACTION */
150090
- 162, /* (319) trans_opt ::= TRANSACTION nm */
150091
- 164, /* (320) savepoint_opt ::= SAVEPOINT */
150092
- 164, /* (321) savepoint_opt ::= */
150093
- 160, /* (322) cmd ::= create_table create_table_args */
150094
- 171, /* (323) columnlist ::= columnlist COMMA columnname carglist */
150095
- 171, /* (324) columnlist ::= columnname carglist */
150096
- 163, /* (325) nm ::= ID|INDEXED */
150097
- 163, /* (326) nm ::= STRING */
150098
- 163, /* (327) nm ::= JOIN_KW */
150099
- 177, /* (328) typetoken ::= typename */
150100
- 178, /* (329) typename ::= ID|STRING */
150101
- 179, /* (330) signed ::= plus_num */
150102
- 179, /* (331) signed ::= minus_num */
150103
- 176, /* (332) carglist ::= carglist ccons */
150104
- 176, /* (333) carglist ::= */
150105
- 183, /* (334) ccons ::= NULL onconf */
150106
- 172, /* (335) conslist_opt ::= COMMA conslist */
150107
- 195, /* (336) conslist ::= conslist tconscomma tcons */
150108
- 195, /* (337) conslist ::= tcons */
150109
- 196, /* (338) tconscomma ::= */
150110
- 200, /* (339) defer_subclause_opt ::= defer_subclause */
150111
- 202, /* (340) resolvetype ::= raisetype */
150112
- 206, /* (341) selectnowith ::= oneselect */
150113
- 207, /* (342) oneselect ::= values */
150114
- 221, /* (343) sclp ::= selcollist COMMA */
150115
- 222, /* (344) as ::= ID|STRING */
150116
- 185, /* (345) expr ::= term */
150117
- 238, /* (346) likeop ::= LIKE_KW|MATCH */
150118
- 229, /* (347) exprlist ::= nexprlist */
150119
- 248, /* (348) nmnum ::= plus_num */
150120
- 248, /* (349) nmnum ::= nm */
150121
- 248, /* (350) nmnum ::= ON */
150122
- 248, /* (351) nmnum ::= DELETE */
150123
- 248, /* (352) nmnum ::= DEFAULT */
150124
- 180, /* (353) plus_num ::= INTEGER|FLOAT */
150125
- 253, /* (354) foreach_clause ::= */
150126
- 253, /* (355) foreach_clause ::= FOR EACH ROW */
150127
- 256, /* (356) trnm ::= nm */
150128
- 257, /* (357) tridxby ::= */
150129
- 258, /* (358) database_kw_opt ::= DATABASE */
150130
- 258, /* (359) database_kw_opt ::= */
150131
- 261, /* (360) kwcolumn_opt ::= */
150132
- 261, /* (361) kwcolumn_opt ::= COLUMNKW */
150133
- 263, /* (362) vtabarglist ::= vtabarg */
150134
- 263, /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */
150135
- 264, /* (364) vtabarg ::= vtabarg vtabargtoken */
150136
- 267, /* (365) anylist ::= */
150137
- 267, /* (366) anylist ::= anylist LP anylist RP */
150138
- 267, /* (367) anylist ::= anylist ANY */
150139
- 232, /* (368) with ::= */
150402
+ 163, /* (0) explain ::= EXPLAIN */
150403
+ 163, /* (1) explain ::= EXPLAIN QUERY PLAN */
150404
+ 162, /* (2) cmdx ::= cmd */
150405
+ 164, /* (3) cmd ::= BEGIN transtype trans_opt */
150406
+ 165, /* (4) transtype ::= */
150407
+ 165, /* (5) transtype ::= DEFERRED */
150408
+ 165, /* (6) transtype ::= IMMEDIATE */
150409
+ 165, /* (7) transtype ::= EXCLUSIVE */
150410
+ 164, /* (8) cmd ::= COMMIT|END trans_opt */
150411
+ 164, /* (9) cmd ::= ROLLBACK trans_opt */
150412
+ 164, /* (10) cmd ::= SAVEPOINT nm */
150413
+ 164, /* (11) cmd ::= RELEASE savepoint_opt nm */
150414
+ 164, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
150415
+ 169, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
150416
+ 171, /* (14) createkw ::= CREATE */
150417
+ 173, /* (15) ifnotexists ::= */
150418
+ 173, /* (16) ifnotexists ::= IF NOT EXISTS */
150419
+ 172, /* (17) temp ::= TEMP */
150420
+ 172, /* (18) temp ::= */
150421
+ 170, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
150422
+ 170, /* (20) create_table_args ::= AS select */
150423
+ 177, /* (21) table_options ::= */
150424
+ 177, /* (22) table_options ::= WITHOUT nm */
150425
+ 179, /* (23) columnname ::= nm typetoken */
150426
+ 181, /* (24) typetoken ::= */
150427
+ 181, /* (25) typetoken ::= typename LP signed RP */
150428
+ 181, /* (26) typetoken ::= typename LP signed COMMA signed RP */
150429
+ 182, /* (27) typename ::= typename ID|STRING */
150430
+ 186, /* (28) scanpt ::= */
150431
+ 187, /* (29) ccons ::= CONSTRAINT nm */
150432
+ 187, /* (30) ccons ::= DEFAULT scanpt term scanpt */
150433
+ 187, /* (31) ccons ::= DEFAULT LP expr RP */
150434
+ 187, /* (32) ccons ::= DEFAULT PLUS term scanpt */
150435
+ 187, /* (33) ccons ::= DEFAULT MINUS term scanpt */
150436
+ 187, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
150437
+ 187, /* (35) ccons ::= NOT NULL onconf */
150438
+ 187, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
150439
+ 187, /* (37) ccons ::= UNIQUE onconf */
150440
+ 187, /* (38) ccons ::= CHECK LP expr RP */
150441
+ 187, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
150442
+ 187, /* (40) ccons ::= defer_subclause */
150443
+ 187, /* (41) ccons ::= COLLATE ID|STRING */
150444
+ 192, /* (42) autoinc ::= */
150445
+ 192, /* (43) autoinc ::= AUTOINCR */
150446
+ 194, /* (44) refargs ::= */
150447
+ 194, /* (45) refargs ::= refargs refarg */
150448
+ 196, /* (46) refarg ::= MATCH nm */
150449
+ 196, /* (47) refarg ::= ON INSERT refact */
150450
+ 196, /* (48) refarg ::= ON DELETE refact */
150451
+ 196, /* (49) refarg ::= ON UPDATE refact */
150452
+ 197, /* (50) refact ::= SET NULL */
150453
+ 197, /* (51) refact ::= SET DEFAULT */
150454
+ 197, /* (52) refact ::= CASCADE */
150455
+ 197, /* (53) refact ::= RESTRICT */
150456
+ 197, /* (54) refact ::= NO ACTION */
150457
+ 195, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
150458
+ 195, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
150459
+ 198, /* (57) init_deferred_pred_opt ::= */
150460
+ 198, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
150461
+ 198, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
150462
+ 176, /* (60) conslist_opt ::= */
150463
+ 200, /* (61) tconscomma ::= COMMA */
150464
+ 201, /* (62) tcons ::= CONSTRAINT nm */
150465
+ 201, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
150466
+ 201, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
150467
+ 201, /* (65) tcons ::= CHECK LP expr RP onconf */
150468
+ 201, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
150469
+ 204, /* (67) defer_subclause_opt ::= */
150470
+ 190, /* (68) onconf ::= */
150471
+ 190, /* (69) onconf ::= ON CONFLICT resolvetype */
150472
+ 205, /* (70) orconf ::= */
150473
+ 205, /* (71) orconf ::= OR resolvetype */
150474
+ 206, /* (72) resolvetype ::= IGNORE */
150475
+ 206, /* (73) resolvetype ::= REPLACE */
150476
+ 164, /* (74) cmd ::= DROP TABLE ifexists fullname */
150477
+ 208, /* (75) ifexists ::= IF EXISTS */
150478
+ 208, /* (76) ifexists ::= */
150479
+ 164, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
150480
+ 164, /* (78) cmd ::= DROP VIEW ifexists fullname */
150481
+ 164, /* (79) cmd ::= select */
150482
+ 178, /* (80) select ::= WITH wqlist selectnowith */
150483
+ 178, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
150484
+ 178, /* (82) select ::= selectnowith */
150485
+ 210, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
150486
+ 213, /* (84) multiselect_op ::= UNION */
150487
+ 213, /* (85) multiselect_op ::= UNION ALL */
150488
+ 213, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
150489
+ 211, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
150490
+ 211, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
150491
+ 223, /* (89) values ::= VALUES LP nexprlist RP */
150492
+ 223, /* (90) values ::= values COMMA LP nexprlist RP */
150493
+ 214, /* (91) distinct ::= DISTINCT */
150494
+ 214, /* (92) distinct ::= ALL */
150495
+ 214, /* (93) distinct ::= */
150496
+ 225, /* (94) sclp ::= */
150497
+ 215, /* (95) selcollist ::= sclp scanpt expr scanpt as */
150498
+ 215, /* (96) selcollist ::= sclp scanpt STAR */
150499
+ 215, /* (97) selcollist ::= sclp scanpt nm DOT STAR */
150500
+ 226, /* (98) as ::= AS nm */
150501
+ 226, /* (99) as ::= */
150502
+ 216, /* (100) from ::= */
150503
+ 216, /* (101) from ::= FROM seltablist */
150504
+ 228, /* (102) stl_prefix ::= seltablist joinop */
150505
+ 228, /* (103) stl_prefix ::= */
150506
+ 227, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
150507
+ 227, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
150508
+ 227, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
150509
+ 227, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
150510
+ 174, /* (108) dbnm ::= */
150511
+ 174, /* (109) dbnm ::= DOT nm */
150512
+ 209, /* (110) fullname ::= nm */
150513
+ 209, /* (111) fullname ::= nm DOT nm */
150514
+ 234, /* (112) xfullname ::= nm */
150515
+ 234, /* (113) xfullname ::= nm DOT nm */
150516
+ 234, /* (114) xfullname ::= nm DOT nm AS nm */
150517
+ 234, /* (115) xfullname ::= nm AS nm */
150518
+ 229, /* (116) joinop ::= COMMA|JOIN */
150519
+ 229, /* (117) joinop ::= JOIN_KW JOIN */
150520
+ 229, /* (118) joinop ::= JOIN_KW nm JOIN */
150521
+ 229, /* (119) joinop ::= JOIN_KW nm nm JOIN */
150522
+ 231, /* (120) on_opt ::= ON expr */
150523
+ 231, /* (121) on_opt ::= */
150524
+ 230, /* (122) indexed_opt ::= */
150525
+ 230, /* (123) indexed_opt ::= INDEXED BY nm */
150526
+ 230, /* (124) indexed_opt ::= NOT INDEXED */
150527
+ 232, /* (125) using_opt ::= USING LP idlist RP */
150528
+ 232, /* (126) using_opt ::= */
150529
+ 220, /* (127) orderby_opt ::= */
150530
+ 220, /* (128) orderby_opt ::= ORDER BY sortlist */
150531
+ 202, /* (129) sortlist ::= sortlist COMMA expr sortorder */
150532
+ 202, /* (130) sortlist ::= expr sortorder */
150533
+ 191, /* (131) sortorder ::= ASC */
150534
+ 191, /* (132) sortorder ::= DESC */
150535
+ 191, /* (133) sortorder ::= */
150536
+ 218, /* (134) groupby_opt ::= */
150537
+ 218, /* (135) groupby_opt ::= GROUP BY nexprlist */
150538
+ 219, /* (136) having_opt ::= */
150539
+ 219, /* (137) having_opt ::= HAVING expr */
150540
+ 221, /* (138) limit_opt ::= */
150541
+ 221, /* (139) limit_opt ::= LIMIT expr */
150542
+ 221, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
150543
+ 221, /* (141) limit_opt ::= LIMIT expr COMMA expr */
150544
+ 164, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
150545
+ 217, /* (143) where_opt ::= */
150546
+ 217, /* (144) where_opt ::= WHERE expr */
150547
+ 164, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
150548
+ 237, /* (146) setlist ::= setlist COMMA nm EQ expr */
150549
+ 237, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
150550
+ 237, /* (148) setlist ::= nm EQ expr */
150551
+ 237, /* (149) setlist ::= LP idlist RP EQ expr */
150552
+ 164, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
150553
+ 164, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
150554
+ 240, /* (152) upsert ::= */
150555
+ 240, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
150556
+ 240, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
150557
+ 240, /* (155) upsert ::= ON CONFLICT DO NOTHING */
150558
+ 238, /* (156) insert_cmd ::= INSERT orconf */
150559
+ 238, /* (157) insert_cmd ::= REPLACE */
150560
+ 239, /* (158) idlist_opt ::= */
150561
+ 239, /* (159) idlist_opt ::= LP idlist RP */
150562
+ 235, /* (160) idlist ::= idlist COMMA nm */
150563
+ 235, /* (161) idlist ::= nm */
150564
+ 189, /* (162) expr ::= LP expr RP */
150565
+ 189, /* (163) expr ::= ID|INDEXED */
150566
+ 189, /* (164) expr ::= JOIN_KW */
150567
+ 189, /* (165) expr ::= nm DOT nm */
150568
+ 189, /* (166) expr ::= nm DOT nm DOT nm */
150569
+ 188, /* (167) term ::= NULL|FLOAT|BLOB */
150570
+ 188, /* (168) term ::= STRING */
150571
+ 188, /* (169) term ::= INTEGER */
150572
+ 189, /* (170) expr ::= VARIABLE */
150573
+ 189, /* (171) expr ::= expr COLLATE ID|STRING */
150574
+ 189, /* (172) expr ::= CAST LP expr AS typetoken RP */
150575
+ 189, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */
150576
+ 189, /* (174) expr ::= ID|INDEXED LP STAR RP */
150577
+ 189, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
150578
+ 189, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */
150579
+ 188, /* (177) term ::= CTIME_KW */
150580
+ 189, /* (178) expr ::= LP nexprlist COMMA expr RP */
150581
+ 189, /* (179) expr ::= expr AND expr */
150582
+ 189, /* (180) expr ::= expr OR expr */
150583
+ 189, /* (181) expr ::= expr LT|GT|GE|LE expr */
150584
+ 189, /* (182) expr ::= expr EQ|NE expr */
150585
+ 189, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
150586
+ 189, /* (184) expr ::= expr PLUS|MINUS expr */
150587
+ 189, /* (185) expr ::= expr STAR|SLASH|REM expr */
150588
+ 189, /* (186) expr ::= expr CONCAT expr */
150589
+ 242, /* (187) likeop ::= NOT LIKE_KW|MATCH */
150590
+ 189, /* (188) expr ::= expr likeop expr */
150591
+ 189, /* (189) expr ::= expr likeop expr ESCAPE expr */
150592
+ 189, /* (190) expr ::= expr ISNULL|NOTNULL */
150593
+ 189, /* (191) expr ::= expr NOT NULL */
150594
+ 189, /* (192) expr ::= expr IS expr */
150595
+ 189, /* (193) expr ::= expr IS NOT expr */
150596
+ 189, /* (194) expr ::= NOT expr */
150597
+ 189, /* (195) expr ::= BITNOT expr */
150598
+ 189, /* (196) expr ::= PLUS|MINUS expr */
150599
+ 243, /* (197) between_op ::= BETWEEN */
150600
+ 243, /* (198) between_op ::= NOT BETWEEN */
150601
+ 189, /* (199) expr ::= expr between_op expr AND expr */
150602
+ 244, /* (200) in_op ::= IN */
150603
+ 244, /* (201) in_op ::= NOT IN */
150604
+ 189, /* (202) expr ::= expr in_op LP exprlist RP */
150605
+ 189, /* (203) expr ::= LP select RP */
150606
+ 189, /* (204) expr ::= expr in_op LP select RP */
150607
+ 189, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */
150608
+ 189, /* (206) expr ::= EXISTS LP select RP */
150609
+ 189, /* (207) expr ::= CASE case_operand case_exprlist case_else END */
150610
+ 247, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */
150611
+ 247, /* (209) case_exprlist ::= WHEN expr THEN expr */
150612
+ 248, /* (210) case_else ::= ELSE expr */
150613
+ 248, /* (211) case_else ::= */
150614
+ 246, /* (212) case_operand ::= expr */
150615
+ 246, /* (213) case_operand ::= */
150616
+ 233, /* (214) exprlist ::= */
150617
+ 224, /* (215) nexprlist ::= nexprlist COMMA expr */
150618
+ 224, /* (216) nexprlist ::= expr */
150619
+ 245, /* (217) paren_exprlist ::= */
150620
+ 245, /* (218) paren_exprlist ::= LP exprlist RP */
150621
+ 164, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
150622
+ 249, /* (220) uniqueflag ::= UNIQUE */
150623
+ 249, /* (221) uniqueflag ::= */
150624
+ 193, /* (222) eidlist_opt ::= */
150625
+ 193, /* (223) eidlist_opt ::= LP eidlist RP */
150626
+ 203, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */
150627
+ 203, /* (225) eidlist ::= nm collate sortorder */
150628
+ 250, /* (226) collate ::= */
150629
+ 250, /* (227) collate ::= COLLATE ID|STRING */
150630
+ 164, /* (228) cmd ::= DROP INDEX ifexists fullname */
150631
+ 164, /* (229) cmd ::= VACUUM vinto */
150632
+ 164, /* (230) cmd ::= VACUUM nm vinto */
150633
+ 251, /* (231) vinto ::= INTO expr */
150634
+ 251, /* (232) vinto ::= */
150635
+ 164, /* (233) cmd ::= PRAGMA nm dbnm */
150636
+ 164, /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */
150637
+ 164, /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */
150638
+ 164, /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */
150639
+ 164, /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */
150640
+ 184, /* (238) plus_num ::= PLUS INTEGER|FLOAT */
150641
+ 185, /* (239) minus_num ::= MINUS INTEGER|FLOAT */
150642
+ 164, /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
150643
+ 253, /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
150644
+ 255, /* (242) trigger_time ::= BEFORE|AFTER */
150645
+ 255, /* (243) trigger_time ::= INSTEAD OF */
150646
+ 255, /* (244) trigger_time ::= */
150647
+ 256, /* (245) trigger_event ::= DELETE|INSERT */
150648
+ 256, /* (246) trigger_event ::= UPDATE */
150649
+ 256, /* (247) trigger_event ::= UPDATE OF idlist */
150650
+ 258, /* (248) when_clause ::= */
150651
+ 258, /* (249) when_clause ::= WHEN expr */
150652
+ 254, /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
150653
+ 254, /* (251) trigger_cmd_list ::= trigger_cmd SEMI */
150654
+ 260, /* (252) trnm ::= nm DOT nm */
150655
+ 261, /* (253) tridxby ::= INDEXED BY nm */
150656
+ 261, /* (254) tridxby ::= NOT INDEXED */
150657
+ 259, /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
150658
+ 259, /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
150659
+ 259, /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
150660
+ 259, /* (258) trigger_cmd ::= scanpt select scanpt */
150661
+ 189, /* (259) expr ::= RAISE LP IGNORE RP */
150662
+ 189, /* (260) expr ::= RAISE LP raisetype COMMA nm RP */
150663
+ 207, /* (261) raisetype ::= ROLLBACK */
150664
+ 207, /* (262) raisetype ::= ABORT */
150665
+ 207, /* (263) raisetype ::= FAIL */
150666
+ 164, /* (264) cmd ::= DROP TRIGGER ifexists fullname */
150667
+ 164, /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
150668
+ 164, /* (266) cmd ::= DETACH database_kw_opt expr */
150669
+ 263, /* (267) key_opt ::= */
150670
+ 263, /* (268) key_opt ::= KEY expr */
150671
+ 164, /* (269) cmd ::= REINDEX */
150672
+ 164, /* (270) cmd ::= REINDEX nm dbnm */
150673
+ 164, /* (271) cmd ::= ANALYZE */
150674
+ 164, /* (272) cmd ::= ANALYZE nm dbnm */
150675
+ 164, /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */
150676
+ 164, /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
150677
+ 264, /* (275) add_column_fullname ::= fullname */
150678
+ 164, /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
150679
+ 164, /* (277) cmd ::= create_vtab */
150680
+ 164, /* (278) cmd ::= create_vtab LP vtabarglist RP */
150681
+ 266, /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
150682
+ 268, /* (280) vtabarg ::= */
150683
+ 269, /* (281) vtabargtoken ::= ANY */
150684
+ 269, /* (282) vtabargtoken ::= lp anylist RP */
150685
+ 270, /* (283) lp ::= LP */
150686
+ 236, /* (284) with ::= WITH wqlist */
150687
+ 236, /* (285) with ::= WITH RECURSIVE wqlist */
150688
+ 212, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150689
+ 212, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150690
+ 272, /* (288) windowdefn_list ::= windowdefn */
150691
+ 272, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150692
+ 273, /* (290) windowdefn ::= nm AS LP window RP */
150693
+ 274, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
150694
+ 274, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
150695
+ 274, /* (293) window ::= ORDER BY sortlist frame_opt */
150696
+ 274, /* (294) window ::= nm ORDER BY sortlist frame_opt */
150697
+ 274, /* (295) window ::= frame_opt */
150698
+ 274, /* (296) window ::= nm frame_opt */
150699
+ 275, /* (297) frame_opt ::= */
150700
+ 275, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
150701
+ 275, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
150702
+ 278, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */
150703
+ 280, /* (301) frame_bound_s ::= frame_bound */
150704
+ 280, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */
150705
+ 281, /* (303) frame_bound_e ::= frame_bound */
150706
+ 281, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */
150707
+ 279, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */
150708
+ 279, /* (306) frame_bound ::= CURRENT ROW */
150709
+ 282, /* (307) frame_exclude_opt ::= */
150710
+ 282, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */
150711
+ 283, /* (309) frame_exclude ::= NO OTHERS */
150712
+ 283, /* (310) frame_exclude ::= CURRENT ROW */
150713
+ 283, /* (311) frame_exclude ::= GROUP|TIES */
150714
+ 222, /* (312) window_clause ::= WINDOW windowdefn_list */
150715
+ 241, /* (313) over_clause ::= filter_opt OVER LP window RP */
150716
+ 241, /* (314) over_clause ::= filter_opt OVER nm */
150717
+ 277, /* (315) filter_opt ::= */
150718
+ 277, /* (316) filter_opt ::= FILTER LP WHERE expr RP */
150719
+ 159, /* (317) input ::= cmdlist */
150720
+ 160, /* (318) cmdlist ::= cmdlist ecmd */
150721
+ 160, /* (319) cmdlist ::= ecmd */
150722
+ 161, /* (320) ecmd ::= SEMI */
150723
+ 161, /* (321) ecmd ::= cmdx SEMI */
150724
+ 161, /* (322) ecmd ::= explain cmdx */
150725
+ 166, /* (323) trans_opt ::= */
150726
+ 166, /* (324) trans_opt ::= TRANSACTION */
150727
+ 166, /* (325) trans_opt ::= TRANSACTION nm */
150728
+ 168, /* (326) savepoint_opt ::= SAVEPOINT */
150729
+ 168, /* (327) savepoint_opt ::= */
150730
+ 164, /* (328) cmd ::= create_table create_table_args */
150731
+ 175, /* (329) columnlist ::= columnlist COMMA columnname carglist */
150732
+ 175, /* (330) columnlist ::= columnname carglist */
150733
+ 167, /* (331) nm ::= ID|INDEXED */
150734
+ 167, /* (332) nm ::= STRING */
150735
+ 167, /* (333) nm ::= JOIN_KW */
150736
+ 181, /* (334) typetoken ::= typename */
150737
+ 182, /* (335) typename ::= ID|STRING */
150738
+ 183, /* (336) signed ::= plus_num */
150739
+ 183, /* (337) signed ::= minus_num */
150740
+ 180, /* (338) carglist ::= carglist ccons */
150741
+ 180, /* (339) carglist ::= */
150742
+ 187, /* (340) ccons ::= NULL onconf */
150743
+ 176, /* (341) conslist_opt ::= COMMA conslist */
150744
+ 199, /* (342) conslist ::= conslist tconscomma tcons */
150745
+ 199, /* (343) conslist ::= tcons */
150746
+ 200, /* (344) tconscomma ::= */
150747
+ 204, /* (345) defer_subclause_opt ::= defer_subclause */
150748
+ 206, /* (346) resolvetype ::= raisetype */
150749
+ 210, /* (347) selectnowith ::= oneselect */
150750
+ 211, /* (348) oneselect ::= values */
150751
+ 225, /* (349) sclp ::= selcollist COMMA */
150752
+ 226, /* (350) as ::= ID|STRING */
150753
+ 189, /* (351) expr ::= term */
150754
+ 242, /* (352) likeop ::= LIKE_KW|MATCH */
150755
+ 233, /* (353) exprlist ::= nexprlist */
150756
+ 252, /* (354) nmnum ::= plus_num */
150757
+ 252, /* (355) nmnum ::= nm */
150758
+ 252, /* (356) nmnum ::= ON */
150759
+ 252, /* (357) nmnum ::= DELETE */
150760
+ 252, /* (358) nmnum ::= DEFAULT */
150761
+ 184, /* (359) plus_num ::= INTEGER|FLOAT */
150762
+ 257, /* (360) foreach_clause ::= */
150763
+ 257, /* (361) foreach_clause ::= FOR EACH ROW */
150764
+ 260, /* (362) trnm ::= nm */
150765
+ 261, /* (363) tridxby ::= */
150766
+ 262, /* (364) database_kw_opt ::= DATABASE */
150767
+ 262, /* (365) database_kw_opt ::= */
150768
+ 265, /* (366) kwcolumn_opt ::= */
150769
+ 265, /* (367) kwcolumn_opt ::= COLUMNKW */
150770
+ 267, /* (368) vtabarglist ::= vtabarg */
150771
+ 267, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */
150772
+ 268, /* (370) vtabarg ::= vtabarg vtabargtoken */
150773
+ 271, /* (371) anylist ::= */
150774
+ 271, /* (372) anylist ::= anylist LP anylist RP */
150775
+ 271, /* (373) anylist ::= anylist ANY */
150776
+ 236, /* (374) with ::= */
150140150777
};
150141150778
150142150779
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
150143150780
** of symbols on the right-hand side of that rule. */
150144150781
static const signed char yyRuleInfoNRhs[] = {
@@ -150430,89 +151067,95 @@
150430151067
-3, /* (285) with ::= WITH RECURSIVE wqlist */
150431151068
-6, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150432151069
-8, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150433151070
-1, /* (288) windowdefn_list ::= windowdefn */
150434151071
-3, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150435
- -3, /* (290) windowdefn ::= nm AS window */
150436
- -5, /* (291) window ::= LP part_opt orderby_opt frame_opt RP */
150437
- -3, /* (292) part_opt ::= PARTITION BY nexprlist */
150438
- 0, /* (293) part_opt ::= */
150439
- 0, /* (294) frame_opt ::= */
150440
- -2, /* (295) frame_opt ::= range_or_rows frame_bound_s */
150441
- -5, /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
150442
- -1, /* (297) range_or_rows ::= RANGE */
150443
- -1, /* (298) range_or_rows ::= ROWS */
150444
- -1, /* (299) frame_bound_s ::= frame_bound */
150445
- -2, /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */
150446
- -1, /* (301) frame_bound_e ::= frame_bound */
150447
- -2, /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */
150448
- -2, /* (303) frame_bound ::= expr PRECEDING */
150449
- -2, /* (304) frame_bound ::= CURRENT ROW */
150450
- -2, /* (305) frame_bound ::= expr FOLLOWING */
150451
- -2, /* (306) window_clause ::= WINDOW windowdefn_list */
150452
- -3, /* (307) over_clause ::= filter_opt OVER window */
150453
- -3, /* (308) over_clause ::= filter_opt OVER nm */
150454
- 0, /* (309) filter_opt ::= */
150455
- -5, /* (310) filter_opt ::= FILTER LP WHERE expr RP */
150456
- -1, /* (311) input ::= cmdlist */
150457
- -2, /* (312) cmdlist ::= cmdlist ecmd */
150458
- -1, /* (313) cmdlist ::= ecmd */
150459
- -1, /* (314) ecmd ::= SEMI */
150460
- -2, /* (315) ecmd ::= cmdx SEMI */
150461
- -2, /* (316) ecmd ::= explain cmdx */
150462
- 0, /* (317) trans_opt ::= */
150463
- -1, /* (318) trans_opt ::= TRANSACTION */
150464
- -2, /* (319) trans_opt ::= TRANSACTION nm */
150465
- -1, /* (320) savepoint_opt ::= SAVEPOINT */
150466
- 0, /* (321) savepoint_opt ::= */
150467
- -2, /* (322) cmd ::= create_table create_table_args */
150468
- -4, /* (323) columnlist ::= columnlist COMMA columnname carglist */
150469
- -2, /* (324) columnlist ::= columnname carglist */
150470
- -1, /* (325) nm ::= ID|INDEXED */
150471
- -1, /* (326) nm ::= STRING */
150472
- -1, /* (327) nm ::= JOIN_KW */
150473
- -1, /* (328) typetoken ::= typename */
150474
- -1, /* (329) typename ::= ID|STRING */
150475
- -1, /* (330) signed ::= plus_num */
150476
- -1, /* (331) signed ::= minus_num */
150477
- -2, /* (332) carglist ::= carglist ccons */
150478
- 0, /* (333) carglist ::= */
150479
- -2, /* (334) ccons ::= NULL onconf */
150480
- -2, /* (335) conslist_opt ::= COMMA conslist */
150481
- -3, /* (336) conslist ::= conslist tconscomma tcons */
150482
- -1, /* (337) conslist ::= tcons */
150483
- 0, /* (338) tconscomma ::= */
150484
- -1, /* (339) defer_subclause_opt ::= defer_subclause */
150485
- -1, /* (340) resolvetype ::= raisetype */
150486
- -1, /* (341) selectnowith ::= oneselect */
150487
- -1, /* (342) oneselect ::= values */
150488
- -2, /* (343) sclp ::= selcollist COMMA */
150489
- -1, /* (344) as ::= ID|STRING */
150490
- -1, /* (345) expr ::= term */
150491
- -1, /* (346) likeop ::= LIKE_KW|MATCH */
150492
- -1, /* (347) exprlist ::= nexprlist */
150493
- -1, /* (348) nmnum ::= plus_num */
150494
- -1, /* (349) nmnum ::= nm */
150495
- -1, /* (350) nmnum ::= ON */
150496
- -1, /* (351) nmnum ::= DELETE */
150497
- -1, /* (352) nmnum ::= DEFAULT */
150498
- -1, /* (353) plus_num ::= INTEGER|FLOAT */
150499
- 0, /* (354) foreach_clause ::= */
150500
- -3, /* (355) foreach_clause ::= FOR EACH ROW */
150501
- -1, /* (356) trnm ::= nm */
150502
- 0, /* (357) tridxby ::= */
150503
- -1, /* (358) database_kw_opt ::= DATABASE */
150504
- 0, /* (359) database_kw_opt ::= */
150505
- 0, /* (360) kwcolumn_opt ::= */
150506
- -1, /* (361) kwcolumn_opt ::= COLUMNKW */
150507
- -1, /* (362) vtabarglist ::= vtabarg */
150508
- -3, /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */
150509
- -2, /* (364) vtabarg ::= vtabarg vtabargtoken */
150510
- 0, /* (365) anylist ::= */
150511
- -4, /* (366) anylist ::= anylist LP anylist RP */
150512
- -2, /* (367) anylist ::= anylist ANY */
150513
- 0, /* (368) with ::= */
151072
+ -5, /* (290) windowdefn ::= nm AS LP window RP */
151073
+ -5, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151074
+ -6, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151075
+ -4, /* (293) window ::= ORDER BY sortlist frame_opt */
151076
+ -5, /* (294) window ::= nm ORDER BY sortlist frame_opt */
151077
+ -1, /* (295) window ::= frame_opt */
151078
+ -2, /* (296) window ::= nm frame_opt */
151079
+ 0, /* (297) frame_opt ::= */
151080
+ -3, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151081
+ -6, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151082
+ -1, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */
151083
+ -1, /* (301) frame_bound_s ::= frame_bound */
151084
+ -2, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */
151085
+ -1, /* (303) frame_bound_e ::= frame_bound */
151086
+ -2, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */
151087
+ -2, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */
151088
+ -2, /* (306) frame_bound ::= CURRENT ROW */
151089
+ 0, /* (307) frame_exclude_opt ::= */
151090
+ -2, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */
151091
+ -2, /* (309) frame_exclude ::= NO OTHERS */
151092
+ -2, /* (310) frame_exclude ::= CURRENT ROW */
151093
+ -1, /* (311) frame_exclude ::= GROUP|TIES */
151094
+ -2, /* (312) window_clause ::= WINDOW windowdefn_list */
151095
+ -5, /* (313) over_clause ::= filter_opt OVER LP window RP */
151096
+ -3, /* (314) over_clause ::= filter_opt OVER nm */
151097
+ 0, /* (315) filter_opt ::= */
151098
+ -5, /* (316) filter_opt ::= FILTER LP WHERE expr RP */
151099
+ -1, /* (317) input ::= cmdlist */
151100
+ -2, /* (318) cmdlist ::= cmdlist ecmd */
151101
+ -1, /* (319) cmdlist ::= ecmd */
151102
+ -1, /* (320) ecmd ::= SEMI */
151103
+ -2, /* (321) ecmd ::= cmdx SEMI */
151104
+ -2, /* (322) ecmd ::= explain cmdx */
151105
+ 0, /* (323) trans_opt ::= */
151106
+ -1, /* (324) trans_opt ::= TRANSACTION */
151107
+ -2, /* (325) trans_opt ::= TRANSACTION nm */
151108
+ -1, /* (326) savepoint_opt ::= SAVEPOINT */
151109
+ 0, /* (327) savepoint_opt ::= */
151110
+ -2, /* (328) cmd ::= create_table create_table_args */
151111
+ -4, /* (329) columnlist ::= columnlist COMMA columnname carglist */
151112
+ -2, /* (330) columnlist ::= columnname carglist */
151113
+ -1, /* (331) nm ::= ID|INDEXED */
151114
+ -1, /* (332) nm ::= STRING */
151115
+ -1, /* (333) nm ::= JOIN_KW */
151116
+ -1, /* (334) typetoken ::= typename */
151117
+ -1, /* (335) typename ::= ID|STRING */
151118
+ -1, /* (336) signed ::= plus_num */
151119
+ -1, /* (337) signed ::= minus_num */
151120
+ -2, /* (338) carglist ::= carglist ccons */
151121
+ 0, /* (339) carglist ::= */
151122
+ -2, /* (340) ccons ::= NULL onconf */
151123
+ -2, /* (341) conslist_opt ::= COMMA conslist */
151124
+ -3, /* (342) conslist ::= conslist tconscomma tcons */
151125
+ -1, /* (343) conslist ::= tcons */
151126
+ 0, /* (344) tconscomma ::= */
151127
+ -1, /* (345) defer_subclause_opt ::= defer_subclause */
151128
+ -1, /* (346) resolvetype ::= raisetype */
151129
+ -1, /* (347) selectnowith ::= oneselect */
151130
+ -1, /* (348) oneselect ::= values */
151131
+ -2, /* (349) sclp ::= selcollist COMMA */
151132
+ -1, /* (350) as ::= ID|STRING */
151133
+ -1, /* (351) expr ::= term */
151134
+ -1, /* (352) likeop ::= LIKE_KW|MATCH */
151135
+ -1, /* (353) exprlist ::= nexprlist */
151136
+ -1, /* (354) nmnum ::= plus_num */
151137
+ -1, /* (355) nmnum ::= nm */
151138
+ -1, /* (356) nmnum ::= ON */
151139
+ -1, /* (357) nmnum ::= DELETE */
151140
+ -1, /* (358) nmnum ::= DEFAULT */
151141
+ -1, /* (359) plus_num ::= INTEGER|FLOAT */
151142
+ 0, /* (360) foreach_clause ::= */
151143
+ -3, /* (361) foreach_clause ::= FOR EACH ROW */
151144
+ -1, /* (362) trnm ::= nm */
151145
+ 0, /* (363) tridxby ::= */
151146
+ -1, /* (364) database_kw_opt ::= DATABASE */
151147
+ 0, /* (365) database_kw_opt ::= */
151148
+ 0, /* (366) kwcolumn_opt ::= */
151149
+ -1, /* (367) kwcolumn_opt ::= COLUMNKW */
151150
+ -1, /* (368) vtabarglist ::= vtabarg */
151151
+ -3, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */
151152
+ -2, /* (370) vtabarg ::= vtabarg vtabargtoken */
151153
+ 0, /* (371) anylist ::= */
151154
+ -4, /* (372) anylist ::= anylist LP anylist RP */
151155
+ -2, /* (373) anylist ::= anylist ANY */
151156
+ 0, /* (374) with ::= */
150514151157
};
150515151158
150516151159
static void yy_accept(yyParser*); /* Forward Declaration */
150517151160
150518151161
/*
@@ -150605,19 +151248,20 @@
150605151248
break;
150606151249
case 2: /* cmdx ::= cmd */
150607151250
{ sqlite3FinishCoding(pParse); }
150608151251
break;
150609151252
case 3: /* cmd ::= BEGIN transtype trans_opt */
150610
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy96);}
151253
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy420);}
150611151254
break;
150612151255
case 4: /* transtype ::= */
150613
-{yymsp[1].minor.yy96 = TK_DEFERRED;}
151256
+{yymsp[1].minor.yy420 = TK_DEFERRED;}
150614151257
break;
150615151258
case 5: /* transtype ::= DEFERRED */
150616151259
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
150617151260
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
150618
-{yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/}
151261
+ case 300: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==300);
151262
+{yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/}
150619151263
break;
150620151264
case 8: /* cmd ::= COMMIT|END trans_opt */
150621151265
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
150622151266
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
150623151267
break;
@@ -150636,11 +151280,11 @@
150636151280
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
150637151281
}
150638151282
break;
150639151283
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
150640151284
{
150641
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy96,0,0,yymsp[-2].minor.yy96);
151285
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy420,0,0,yymsp[-2].minor.yy420);
150642151286
}
150643151287
break;
150644151288
case 14: /* createkw ::= CREATE */
150645151289
{disableLookaside(pParse);}
150646151290
break;
@@ -150651,36 +151295,36 @@
150651151295
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
150652151296
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
150653151297
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
150654151298
case 93: /* distinct ::= */ yytestcase(yyruleno==93);
150655151299
case 226: /* collate ::= */ yytestcase(yyruleno==226);
150656
-{yymsp[1].minor.yy96 = 0;}
151300
+{yymsp[1].minor.yy420 = 0;}
150657151301
break;
150658151302
case 16: /* ifnotexists ::= IF NOT EXISTS */
150659
-{yymsp[-2].minor.yy96 = 1;}
151303
+{yymsp[-2].minor.yy420 = 1;}
150660151304
break;
150661151305
case 17: /* temp ::= TEMP */
150662151306
case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
150663
-{yymsp[0].minor.yy96 = 1;}
151307
+{yymsp[0].minor.yy420 = 1;}
150664151308
break;
150665151309
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
150666151310
{
150667
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy96,0);
151311
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy420,0);
150668151312
}
150669151313
break;
150670151314
case 20: /* create_table_args ::= AS select */
150671151315
{
150672
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy423);
150673
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);
151316
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy491);
151317
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491);
150674151318
}
150675151319
break;
150676151320
case 22: /* table_options ::= WITHOUT nm */
150677151321
{
150678151322
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
150679
- yymsp[-1].minor.yy96 = TF_WithoutRowid | TF_NoVisibleRowid;
151323
+ yymsp[-1].minor.yy420 = TF_WithoutRowid | TF_NoVisibleRowid;
150680151324
}else{
150681
- yymsp[-1].minor.yy96 = 0;
151325
+ yymsp[-1].minor.yy420 = 0;
150682151326
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
150683151327
}
150684151328
}
150685151329
break;
150686151330
case 23: /* columnname ::= nm typetoken */
@@ -150705,30 +151349,30 @@
150705151349
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
150706151350
break;
150707151351
case 28: /* scanpt ::= */
150708151352
{
150709151353
assert( yyLookahead!=YYNOCODE );
150710
- yymsp[1].minor.yy464 = yyLookaheadToken.z;
151354
+ yymsp[1].minor.yy104 = yyLookaheadToken.z;
150711151355
}
150712151356
break;
150713151357
case 29: /* ccons ::= CONSTRAINT nm */
150714151358
case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
150715151359
{pParse->constraintName = yymsp[0].minor.yy0;}
150716151360
break;
150717151361
case 30: /* ccons ::= DEFAULT scanpt term scanpt */
150718
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy464,yymsp[0].minor.yy464);}
151362
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy104,yymsp[0].minor.yy104);}
150719151363
break;
150720151364
case 31: /* ccons ::= DEFAULT LP expr RP */
150721
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
151365
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
150722151366
break;
150723151367
case 32: /* ccons ::= DEFAULT PLUS term scanpt */
150724
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);}
151368
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104);}
150725151369
break;
150726151370
case 33: /* ccons ::= DEFAULT MINUS term scanpt */
150727151371
{
150728
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy490, 0);
150729
- sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);
151372
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy130, 0);
151373
+ sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104);
150730151374
}
150731151375
break;
150732151376
case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
150733151377
{
150734151378
Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -150738,319 +151382,319 @@
150738151382
}
150739151383
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
150740151384
}
150741151385
break;
150742151386
case 35: /* ccons ::= NOT NULL onconf */
150743
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy96);}
151387
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy420);}
150744151388
break;
150745151389
case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
150746
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy96,yymsp[0].minor.yy96,yymsp[-2].minor.yy96);}
151390
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy420,yymsp[0].minor.yy420,yymsp[-2].minor.yy420);}
150747151391
break;
150748151392
case 37: /* ccons ::= UNIQUE onconf */
150749
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy96,0,0,0,0,
151393
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy420,0,0,0,0,
150750151394
SQLITE_IDXTYPE_UNIQUE);}
150751151395
break;
150752151396
case 38: /* ccons ::= CHECK LP expr RP */
150753
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy490);}
151397
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy130);}
150754151398
break;
150755151399
case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
150756
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy42,yymsp[0].minor.yy96);}
151400
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy420);}
150757151401
break;
150758151402
case 40: /* ccons ::= defer_subclause */
150759
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy96);}
151403
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy420);}
150760151404
break;
150761151405
case 41: /* ccons ::= COLLATE ID|STRING */
150762151406
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
150763151407
break;
150764151408
case 44: /* refargs ::= */
150765
-{ yymsp[1].minor.yy96 = OE_None*0x0101; /* EV: R-19803-45884 */}
151409
+{ yymsp[1].minor.yy420 = OE_None*0x0101; /* EV: R-19803-45884 */}
150766151410
break;
150767151411
case 45: /* refargs ::= refargs refarg */
150768
-{ yymsp[-1].minor.yy96 = (yymsp[-1].minor.yy96 & ~yymsp[0].minor.yy367.mask) | yymsp[0].minor.yy367.value; }
151412
+{ yymsp[-1].minor.yy420 = (yymsp[-1].minor.yy420 & ~yymsp[0].minor.yy527.mask) | yymsp[0].minor.yy527.value; }
150769151413
break;
150770151414
case 46: /* refarg ::= MATCH nm */
150771
-{ yymsp[-1].minor.yy367.value = 0; yymsp[-1].minor.yy367.mask = 0x000000; }
151415
+{ yymsp[-1].minor.yy527.value = 0; yymsp[-1].minor.yy527.mask = 0x000000; }
150772151416
break;
150773151417
case 47: /* refarg ::= ON INSERT refact */
150774
-{ yymsp[-2].minor.yy367.value = 0; yymsp[-2].minor.yy367.mask = 0x000000; }
151418
+{ yymsp[-2].minor.yy527.value = 0; yymsp[-2].minor.yy527.mask = 0x000000; }
150775151419
break;
150776151420
case 48: /* refarg ::= ON DELETE refact */
150777
-{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96; yymsp[-2].minor.yy367.mask = 0x0000ff; }
151421
+{ yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420; yymsp[-2].minor.yy527.mask = 0x0000ff; }
150778151422
break;
150779151423
case 49: /* refarg ::= ON UPDATE refact */
150780
-{ yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96<<8; yymsp[-2].minor.yy367.mask = 0x00ff00; }
151424
+{ yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420<<8; yymsp[-2].minor.yy527.mask = 0x00ff00; }
150781151425
break;
150782151426
case 50: /* refact ::= SET NULL */
150783
-{ yymsp[-1].minor.yy96 = OE_SetNull; /* EV: R-33326-45252 */}
151427
+{ yymsp[-1].minor.yy420 = OE_SetNull; /* EV: R-33326-45252 */}
150784151428
break;
150785151429
case 51: /* refact ::= SET DEFAULT */
150786
-{ yymsp[-1].minor.yy96 = OE_SetDflt; /* EV: R-33326-45252 */}
151430
+{ yymsp[-1].minor.yy420 = OE_SetDflt; /* EV: R-33326-45252 */}
150787151431
break;
150788151432
case 52: /* refact ::= CASCADE */
150789
-{ yymsp[0].minor.yy96 = OE_Cascade; /* EV: R-33326-45252 */}
151433
+{ yymsp[0].minor.yy420 = OE_Cascade; /* EV: R-33326-45252 */}
150790151434
break;
150791151435
case 53: /* refact ::= RESTRICT */
150792
-{ yymsp[0].minor.yy96 = OE_Restrict; /* EV: R-33326-45252 */}
151436
+{ yymsp[0].minor.yy420 = OE_Restrict; /* EV: R-33326-45252 */}
150793151437
break;
150794151438
case 54: /* refact ::= NO ACTION */
150795
-{ yymsp[-1].minor.yy96 = OE_None; /* EV: R-33326-45252 */}
151439
+{ yymsp[-1].minor.yy420 = OE_None; /* EV: R-33326-45252 */}
150796151440
break;
150797151441
case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
150798
-{yymsp[-2].minor.yy96 = 0;}
151442
+{yymsp[-2].minor.yy420 = 0;}
150799151443
break;
150800151444
case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
150801151445
case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
150802151446
case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156);
150803
-{yymsp[-1].minor.yy96 = yymsp[0].minor.yy96;}
151447
+{yymsp[-1].minor.yy420 = yymsp[0].minor.yy420;}
150804151448
break;
150805151449
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
150806151450
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
150807151451
case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198);
150808151452
case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201);
150809151453
case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227);
150810
-{yymsp[-1].minor.yy96 = 1;}
151454
+{yymsp[-1].minor.yy420 = 1;}
150811151455
break;
150812151456
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
150813
-{yymsp[-1].minor.yy96 = 0;}
151457
+{yymsp[-1].minor.yy420 = 0;}
150814151458
break;
150815151459
case 61: /* tconscomma ::= COMMA */
150816151460
{pParse->constraintName.n = 0;}
150817151461
break;
150818151462
case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
150819
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy42,yymsp[0].minor.yy96,yymsp[-2].minor.yy96,0);}
151463
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy420,yymsp[-2].minor.yy420,0);}
150820151464
break;
150821151465
case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
150822
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy42,yymsp[0].minor.yy96,0,0,0,0,
151466
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy420,0,0,0,0,
150823151467
SQLITE_IDXTYPE_UNIQUE);}
150824151468
break;
150825151469
case 65: /* tcons ::= CHECK LP expr RP onconf */
150826
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy490);}
151470
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy130);}
150827151471
break;
150828151472
case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
150829151473
{
150830
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy42, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy96);
150831
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy96);
151474
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy420);
151475
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy420);
150832151476
}
150833151477
break;
150834151478
case 68: /* onconf ::= */
150835151479
case 70: /* orconf ::= */ yytestcase(yyruleno==70);
150836
-{yymsp[1].minor.yy96 = OE_Default;}
151480
+{yymsp[1].minor.yy420 = OE_Default;}
150837151481
break;
150838151482
case 69: /* onconf ::= ON CONFLICT resolvetype */
150839
-{yymsp[-2].minor.yy96 = yymsp[0].minor.yy96;}
151483
+{yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
150840151484
break;
150841151485
case 72: /* resolvetype ::= IGNORE */
150842
-{yymsp[0].minor.yy96 = OE_Ignore;}
151486
+{yymsp[0].minor.yy420 = OE_Ignore;}
150843151487
break;
150844151488
case 73: /* resolvetype ::= REPLACE */
150845151489
case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157);
150846
-{yymsp[0].minor.yy96 = OE_Replace;}
151490
+{yymsp[0].minor.yy420 = OE_Replace;}
150847151491
break;
150848151492
case 74: /* cmd ::= DROP TABLE ifexists fullname */
150849151493
{
150850
- sqlite3DropTable(pParse, yymsp[0].minor.yy167, 0, yymsp[-1].minor.yy96);
151494
+ sqlite3DropTable(pParse, yymsp[0].minor.yy147, 0, yymsp[-1].minor.yy420);
150851151495
}
150852151496
break;
150853151497
case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
150854151498
{
150855
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[0].minor.yy423, yymsp[-7].minor.yy96, yymsp[-5].minor.yy96);
151499
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy491, yymsp[-7].minor.yy420, yymsp[-5].minor.yy420);
150856151500
}
150857151501
break;
150858151502
case 78: /* cmd ::= DROP VIEW ifexists fullname */
150859151503
{
150860
- sqlite3DropTable(pParse, yymsp[0].minor.yy167, 1, yymsp[-1].minor.yy96);
151504
+ sqlite3DropTable(pParse, yymsp[0].minor.yy147, 1, yymsp[-1].minor.yy420);
150861151505
}
150862151506
break;
150863151507
case 79: /* cmd ::= select */
150864151508
{
150865151509
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
150866
- sqlite3Select(pParse, yymsp[0].minor.yy423, &dest);
150867
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);
151510
+ sqlite3Select(pParse, yymsp[0].minor.yy491, &dest);
151511
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491);
150868151512
}
150869151513
break;
150870151514
case 80: /* select ::= WITH wqlist selectnowith */
150871151515
{
150872
- Select *p = yymsp[0].minor.yy423;
151516
+ Select *p = yymsp[0].minor.yy491;
150873151517
if( p ){
150874
- p->pWith = yymsp[-1].minor.yy499;
151518
+ p->pWith = yymsp[-1].minor.yy523;
150875151519
parserDoubleLinkSelect(pParse, p);
150876151520
}else{
150877
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);
151521
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523);
150878151522
}
150879
- yymsp[-2].minor.yy423 = p;
151523
+ yymsp[-2].minor.yy491 = p;
150880151524
}
150881151525
break;
150882151526
case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
150883151527
{
150884
- Select *p = yymsp[0].minor.yy423;
151528
+ Select *p = yymsp[0].minor.yy491;
150885151529
if( p ){
150886
- p->pWith = yymsp[-1].minor.yy499;
151530
+ p->pWith = yymsp[-1].minor.yy523;
150887151531
parserDoubleLinkSelect(pParse, p);
150888151532
}else{
150889
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);
151533
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523);
150890151534
}
150891
- yymsp[-3].minor.yy423 = p;
151535
+ yymsp[-3].minor.yy491 = p;
150892151536
}
150893151537
break;
150894151538
case 82: /* select ::= selectnowith */
150895151539
{
150896
- Select *p = yymsp[0].minor.yy423;
151540
+ Select *p = yymsp[0].minor.yy491;
150897151541
if( p ){
150898151542
parserDoubleLinkSelect(pParse, p);
150899151543
}
150900
- yymsp[0].minor.yy423 = p; /*A-overwrites-X*/
151544
+ yymsp[0].minor.yy491 = p; /*A-overwrites-X*/
150901151545
}
150902151546
break;
150903151547
case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
150904151548
{
150905
- Select *pRhs = yymsp[0].minor.yy423;
150906
- Select *pLhs = yymsp[-2].minor.yy423;
151549
+ Select *pRhs = yymsp[0].minor.yy491;
151550
+ Select *pLhs = yymsp[-2].minor.yy491;
150907151551
if( pRhs && pRhs->pPrior ){
150908151552
SrcList *pFrom;
150909151553
Token x;
150910151554
x.n = 0;
150911151555
parserDoubleLinkSelect(pParse, pRhs);
150912151556
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
150913151557
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
150914151558
}
150915151559
if( pRhs ){
150916
- pRhs->op = (u8)yymsp[-1].minor.yy96;
151560
+ pRhs->op = (u8)yymsp[-1].minor.yy420;
150917151561
pRhs->pPrior = pLhs;
150918151562
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
150919151563
pRhs->selFlags &= ~SF_MultiValue;
150920
- if( yymsp[-1].minor.yy96!=TK_ALL ) pParse->hasCompound = 1;
151564
+ if( yymsp[-1].minor.yy420!=TK_ALL ) pParse->hasCompound = 1;
150921151565
}else{
150922151566
sqlite3SelectDelete(pParse->db, pLhs);
150923151567
}
150924
- yymsp[-2].minor.yy423 = pRhs;
151568
+ yymsp[-2].minor.yy491 = pRhs;
150925151569
}
150926151570
break;
150927151571
case 84: /* multiselect_op ::= UNION */
150928151572
case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
150929
-{yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-OP*/}
151573
+{yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-OP*/}
150930151574
break;
150931151575
case 85: /* multiselect_op ::= UNION ALL */
150932
-{yymsp[-1].minor.yy96 = TK_ALL;}
151576
+{yymsp[-1].minor.yy420 = TK_ALL;}
150933151577
break;
150934151578
case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
150935151579
{
150936
- yymsp[-8].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy42,yymsp[-5].minor.yy167,yymsp[-4].minor.yy490,yymsp[-3].minor.yy42,yymsp[-2].minor.yy490,yymsp[-1].minor.yy42,yymsp[-7].minor.yy96,yymsp[0].minor.yy490);
151580
+ yymsp[-8].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy147,yymsp[-4].minor.yy130,yymsp[-3].minor.yy442,yymsp[-2].minor.yy130,yymsp[-1].minor.yy442,yymsp[-7].minor.yy420,yymsp[0].minor.yy130);
150937151581
}
150938151582
break;
150939151583
case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
150940151584
{
150941
- yymsp[-9].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy42,yymsp[-6].minor.yy167,yymsp[-5].minor.yy490,yymsp[-4].minor.yy42,yymsp[-3].minor.yy490,yymsp[-1].minor.yy42,yymsp[-8].minor.yy96,yymsp[0].minor.yy490);
150942
- if( yymsp[-9].minor.yy423 ){
150943
- yymsp[-9].minor.yy423->pWinDefn = yymsp[-2].minor.yy147;
151585
+ yymsp[-9].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy442,yymsp[-6].minor.yy147,yymsp[-5].minor.yy130,yymsp[-4].minor.yy442,yymsp[-3].minor.yy130,yymsp[-1].minor.yy442,yymsp[-8].minor.yy420,yymsp[0].minor.yy130);
151586
+ if( yymsp[-9].minor.yy491 ){
151587
+ yymsp[-9].minor.yy491->pWinDefn = yymsp[-2].minor.yy395;
150944151588
}else{
150945
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy147);
151589
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy395);
150946151590
}
150947151591
}
150948151592
break;
150949151593
case 89: /* values ::= VALUES LP nexprlist RP */
150950151594
{
150951
- yymsp[-3].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values,0);
151595
+ yymsp[-3].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0);
150952151596
}
150953151597
break;
150954151598
case 90: /* values ::= values COMMA LP nexprlist RP */
150955151599
{
150956
- Select *pRight, *pLeft = yymsp[-4].minor.yy423;
150957
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values|SF_MultiValue,0);
151600
+ Select *pRight, *pLeft = yymsp[-4].minor.yy491;
151601
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0);
150958151602
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
150959151603
if( pRight ){
150960151604
pRight->op = TK_ALL;
150961151605
pRight->pPrior = pLeft;
150962
- yymsp[-4].minor.yy423 = pRight;
151606
+ yymsp[-4].minor.yy491 = pRight;
150963151607
}else{
150964
- yymsp[-4].minor.yy423 = pLeft;
151608
+ yymsp[-4].minor.yy491 = pLeft;
150965151609
}
150966151610
}
150967151611
break;
150968151612
case 91: /* distinct ::= DISTINCT */
150969
-{yymsp[0].minor.yy96 = SF_Distinct;}
151613
+{yymsp[0].minor.yy420 = SF_Distinct;}
150970151614
break;
150971151615
case 92: /* distinct ::= ALL */
150972
-{yymsp[0].minor.yy96 = SF_All;}
151616
+{yymsp[0].minor.yy420 = SF_All;}
150973151617
break;
150974151618
case 94: /* sclp ::= */
150975151619
case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127);
150976151620
case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134);
150977151621
case 214: /* exprlist ::= */ yytestcase(yyruleno==214);
150978151622
case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217);
150979151623
case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222);
150980
-{yymsp[1].minor.yy42 = 0;}
151624
+{yymsp[1].minor.yy442 = 0;}
150981151625
break;
150982151626
case 95: /* selcollist ::= sclp scanpt expr scanpt as */
150983151627
{
150984
- yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);
150985
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[0].minor.yy0, 1);
150986
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy42,yymsp[-3].minor.yy464,yymsp[-1].minor.yy464);
151628
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[-2].minor.yy130);
151629
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[0].minor.yy0, 1);
151630
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy442,yymsp[-3].minor.yy104,yymsp[-1].minor.yy104);
150987151631
}
150988151632
break;
150989151633
case 96: /* selcollist ::= sclp scanpt STAR */
150990151634
{
150991151635
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
150992
- yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy42, p);
151636
+ yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, p);
150993151637
}
150994151638
break;
150995151639
case 97: /* selcollist ::= sclp scanpt nm DOT STAR */
150996151640
{
150997151641
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
150998151642
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
150999151643
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
151000
- yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, pDot);
151644
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, pDot);
151001151645
}
151002151646
break;
151003151647
case 98: /* as ::= AS nm */
151004151648
case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109);
151005151649
case 238: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==238);
151006151650
case 239: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==239);
151007151651
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
151008151652
break;
151009151653
case 100: /* from ::= */
151010
-{yymsp[1].minor.yy167 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy167));}
151654
+{yymsp[1].minor.yy147 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy147));}
151011151655
break;
151012151656
case 101: /* from ::= FROM seltablist */
151013151657
{
151014
- yymsp[-1].minor.yy167 = yymsp[0].minor.yy167;
151015
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy167);
151658
+ yymsp[-1].minor.yy147 = yymsp[0].minor.yy147;
151659
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy147);
151016151660
}
151017151661
break;
151018151662
case 102: /* stl_prefix ::= seltablist joinop */
151019151663
{
151020
- if( ALWAYS(yymsp[-1].minor.yy167 && yymsp[-1].minor.yy167->nSrc>0) ) yymsp[-1].minor.yy167->a[yymsp[-1].minor.yy167->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy96;
151664
+ if( ALWAYS(yymsp[-1].minor.yy147 && yymsp[-1].minor.yy147->nSrc>0) ) yymsp[-1].minor.yy147->a[yymsp[-1].minor.yy147->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy420;
151021151665
}
151022151666
break;
151023151667
case 103: /* stl_prefix ::= */
151024
-{yymsp[1].minor.yy167 = 0;}
151668
+{yymsp[1].minor.yy147 = 0;}
151025151669
break;
151026151670
case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151027151671
{
151028
- yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151029
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy167, &yymsp[-2].minor.yy0);
151672
+ yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151673
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy147, &yymsp[-2].minor.yy0);
151030151674
}
151031151675
break;
151032151676
case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151033151677
{
151034
- yymsp[-8].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy167,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151035
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy167, yymsp[-4].minor.yy42);
151678
+ yymsp[-8].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy147,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151679
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy147, yymsp[-4].minor.yy442);
151036151680
}
151037151681
break;
151038151682
case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151039151683
{
151040
- yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy423,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151684
+ yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy491,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151041151685
}
151042151686
break;
151043151687
case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151044151688
{
151045
- if( yymsp[-6].minor.yy167==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy490==0 && yymsp[0].minor.yy336==0 ){
151046
- yymsp[-6].minor.yy167 = yymsp[-4].minor.yy167;
151047
- }else if( yymsp[-4].minor.yy167->nSrc==1 ){
151048
- yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151049
- if( yymsp[-6].minor.yy167 ){
151050
- struct SrcList_item *pNew = &yymsp[-6].minor.yy167->a[yymsp[-6].minor.yy167->nSrc-1];
151051
- struct SrcList_item *pOld = yymsp[-4].minor.yy167->a;
151689
+ if( yymsp[-6].minor.yy147==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy130==0 && yymsp[0].minor.yy200==0 ){
151690
+ yymsp[-6].minor.yy147 = yymsp[-4].minor.yy147;
151691
+ }else if( yymsp[-4].minor.yy147->nSrc==1 ){
151692
+ yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151693
+ if( yymsp[-6].minor.yy147 ){
151694
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy147->a[yymsp[-6].minor.yy147->nSrc-1];
151695
+ struct SrcList_item *pOld = yymsp[-4].minor.yy147->a;
151052151696
pNew->zName = pOld->zName;
151053151697
pNew->zDatabase = pOld->zDatabase;
151054151698
pNew->pSelect = pOld->pSelect;
151055151699
if( pOld->fg.isTabFunc ){
151056151700
pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -151059,215 +151703,215 @@
151059151703
pNew->fg.isTabFunc = 1;
151060151704
}
151061151705
pOld->zName = pOld->zDatabase = 0;
151062151706
pOld->pSelect = 0;
151063151707
}
151064
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy167);
151708
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy147);
151065151709
}else{
151066151710
Select *pSubquery;
151067
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy167);
151068
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy167,0,0,0,0,SF_NestedFrom,0);
151069
- yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151711
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy147);
151712
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy147,0,0,0,0,SF_NestedFrom,0);
151713
+ yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151070151714
}
151071151715
}
151072151716
break;
151073151717
case 108: /* dbnm ::= */
151074151718
case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
151075151719
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
151076151720
break;
151077151721
case 110: /* fullname ::= nm */
151078151722
{
151079
- yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
151080
- if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);
151723
+ yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
151724
+ if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0);
151081151725
}
151082
- yymsp[0].minor.yy167 = yylhsminor.yy167;
151726
+ yymsp[0].minor.yy147 = yylhsminor.yy147;
151083151727
break;
151084151728
case 111: /* fullname ::= nm DOT nm */
151085151729
{
151086
- yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
151087
- if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);
151730
+ yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
151731
+ if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0);
151088151732
}
151089
- yymsp[-2].minor.yy167 = yylhsminor.yy167;
151733
+ yymsp[-2].minor.yy147 = yylhsminor.yy147;
151090151734
break;
151091151735
case 112: /* xfullname ::= nm */
151092
-{yymsp[0].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
151736
+{yymsp[0].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
151093151737
break;
151094151738
case 113: /* xfullname ::= nm DOT nm */
151095
-{yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
151739
+{yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
151096151740
break;
151097151741
case 114: /* xfullname ::= nm DOT nm AS nm */
151098151742
{
151099
- yymsp[-4].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
151100
- if( yymsp[-4].minor.yy167 ) yymsp[-4].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151743
+ yymsp[-4].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
151744
+ if( yymsp[-4].minor.yy147 ) yymsp[-4].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151101151745
}
151102151746
break;
151103151747
case 115: /* xfullname ::= nm AS nm */
151104151748
{
151105
- yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
151106
- if( yymsp[-2].minor.yy167 ) yymsp[-2].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151749
+ yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
151750
+ if( yymsp[-2].minor.yy147 ) yymsp[-2].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151107151751
}
151108151752
break;
151109151753
case 116: /* joinop ::= COMMA|JOIN */
151110
-{ yymsp[0].minor.yy96 = JT_INNER; }
151754
+{ yymsp[0].minor.yy420 = JT_INNER; }
151111151755
break;
151112151756
case 117: /* joinop ::= JOIN_KW JOIN */
151113
-{yymsp[-1].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
151757
+{yymsp[-1].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
151114151758
break;
151115151759
case 118: /* joinop ::= JOIN_KW nm JOIN */
151116
-{yymsp[-2].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
151760
+{yymsp[-2].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
151117151761
break;
151118151762
case 119: /* joinop ::= JOIN_KW nm nm JOIN */
151119
-{yymsp[-3].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
151763
+{yymsp[-3].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
151120151764
break;
151121151765
case 120: /* on_opt ::= ON expr */
151122151766
case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137);
151123151767
case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144);
151124151768
case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210);
151125151769
case 231: /* vinto ::= INTO expr */ yytestcase(yyruleno==231);
151126
-{yymsp[-1].minor.yy490 = yymsp[0].minor.yy490;}
151770
+{yymsp[-1].minor.yy130 = yymsp[0].minor.yy130;}
151127151771
break;
151128151772
case 121: /* on_opt ::= */
151129151773
case 136: /* having_opt ::= */ yytestcase(yyruleno==136);
151130151774
case 138: /* limit_opt ::= */ yytestcase(yyruleno==138);
151131151775
case 143: /* where_opt ::= */ yytestcase(yyruleno==143);
151132151776
case 211: /* case_else ::= */ yytestcase(yyruleno==211);
151133151777
case 213: /* case_operand ::= */ yytestcase(yyruleno==213);
151134151778
case 232: /* vinto ::= */ yytestcase(yyruleno==232);
151135
-{yymsp[1].minor.yy490 = 0;}
151779
+{yymsp[1].minor.yy130 = 0;}
151136151780
break;
151137151781
case 123: /* indexed_opt ::= INDEXED BY nm */
151138151782
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
151139151783
break;
151140151784
case 124: /* indexed_opt ::= NOT INDEXED */
151141151785
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
151142151786
break;
151143151787
case 125: /* using_opt ::= USING LP idlist RP */
151144
-{yymsp[-3].minor.yy336 = yymsp[-1].minor.yy336;}
151788
+{yymsp[-3].minor.yy200 = yymsp[-1].minor.yy200;}
151145151789
break;
151146151790
case 126: /* using_opt ::= */
151147151791
case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158);
151148
-{yymsp[1].minor.yy336 = 0;}
151792
+{yymsp[1].minor.yy200 = 0;}
151149151793
break;
151150151794
case 128: /* orderby_opt ::= ORDER BY sortlist */
151151151795
case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135);
151152
-{yymsp[-2].minor.yy42 = yymsp[0].minor.yy42;}
151796
+{yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;}
151153151797
break;
151154151798
case 129: /* sortlist ::= sortlist COMMA expr sortorder */
151155151799
{
151156
- yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42,yymsp[-1].minor.yy490);
151157
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy42,yymsp[0].minor.yy96);
151800
+ yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy130);
151801
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy420);
151158151802
}
151159151803
break;
151160151804
case 130: /* sortlist ::= expr sortorder */
151161151805
{
151162
- yymsp[-1].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy490); /*A-overwrites-Y*/
151163
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy42,yymsp[0].minor.yy96);
151806
+ yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy130); /*A-overwrites-Y*/
151807
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy420);
151164151808
}
151165151809
break;
151166151810
case 131: /* sortorder ::= ASC */
151167
-{yymsp[0].minor.yy96 = SQLITE_SO_ASC;}
151811
+{yymsp[0].minor.yy420 = SQLITE_SO_ASC;}
151168151812
break;
151169151813
case 132: /* sortorder ::= DESC */
151170
-{yymsp[0].minor.yy96 = SQLITE_SO_DESC;}
151814
+{yymsp[0].minor.yy420 = SQLITE_SO_DESC;}
151171151815
break;
151172151816
case 133: /* sortorder ::= */
151173
-{yymsp[1].minor.yy96 = SQLITE_SO_UNDEFINED;}
151817
+{yymsp[1].minor.yy420 = SQLITE_SO_UNDEFINED;}
151174151818
break;
151175151819
case 139: /* limit_opt ::= LIMIT expr */
151176
-{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,0);}
151820
+{yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,0);}
151177151821
break;
151178151822
case 140: /* limit_opt ::= LIMIT expr OFFSET expr */
151179
-{yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}
151823
+{yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);}
151180151824
break;
151181151825
case 141: /* limit_opt ::= LIMIT expr COMMA expr */
151182
-{yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,yymsp[-2].minor.yy490);}
151826
+{yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,yymsp[-2].minor.yy130);}
151183151827
break;
151184151828
case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151185151829
{
151186
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy167, &yymsp[-1].minor.yy0);
151187
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy167,yymsp[0].minor.yy490,0,0);
151830
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy147, &yymsp[-1].minor.yy0);
151831
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy147,yymsp[0].minor.yy130,0,0);
151188151832
}
151189151833
break;
151190151834
case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151191151835
{
151192
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy167, &yymsp[-3].minor.yy0);
151193
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy42,"set list");
151194
- sqlite3Update(pParse,yymsp[-4].minor.yy167,yymsp[-1].minor.yy42,yymsp[0].minor.yy490,yymsp[-5].minor.yy96,0,0,0);
151836
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy147, &yymsp[-3].minor.yy0);
151837
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
151838
+ sqlite3Update(pParse,yymsp[-4].minor.yy147,yymsp[-1].minor.yy442,yymsp[0].minor.yy130,yymsp[-5].minor.yy420,0,0,0);
151195151839
}
151196151840
break;
151197151841
case 146: /* setlist ::= setlist COMMA nm EQ expr */
151198151842
{
151199
- yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[0].minor.yy490);
151200
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, 1);
151843
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy130);
151844
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1);
151201151845
}
151202151846
break;
151203151847
case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
151204151848
{
151205
- yymsp[-6].minor.yy42 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy42, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);
151849
+ yymsp[-6].minor.yy442 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy442, yymsp[-3].minor.yy200, yymsp[0].minor.yy130);
151206151850
}
151207151851
break;
151208151852
case 148: /* setlist ::= nm EQ expr */
151209151853
{
151210
- yylhsminor.yy42 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy490);
151211
- sqlite3ExprListSetName(pParse, yylhsminor.yy42, &yymsp[-2].minor.yy0, 1);
151854
+ yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy130);
151855
+ sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1);
151212151856
}
151213
- yymsp[-2].minor.yy42 = yylhsminor.yy42;
151857
+ yymsp[-2].minor.yy442 = yylhsminor.yy442;
151214151858
break;
151215151859
case 149: /* setlist ::= LP idlist RP EQ expr */
151216151860
{
151217
- yymsp[-4].minor.yy42 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);
151861
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy200, yymsp[0].minor.yy130);
151218151862
}
151219151863
break;
151220151864
case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151221151865
{
151222
- sqlite3Insert(pParse, yymsp[-3].minor.yy167, yymsp[-1].minor.yy423, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, yymsp[0].minor.yy266);
151866
+ sqlite3Insert(pParse, yymsp[-3].minor.yy147, yymsp[-1].minor.yy491, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, yymsp[0].minor.yy426);
151223151867
}
151224151868
break;
151225151869
case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151226151870
{
151227
- sqlite3Insert(pParse, yymsp[-3].minor.yy167, 0, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, 0);
151871
+ sqlite3Insert(pParse, yymsp[-3].minor.yy147, 0, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, 0);
151228151872
}
151229151873
break;
151230151874
case 152: /* upsert ::= */
151231
-{ yymsp[1].minor.yy266 = 0; }
151875
+{ yymsp[1].minor.yy426 = 0; }
151232151876
break;
151233151877
case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151234
-{ yymsp[-10].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy42,yymsp[-5].minor.yy490,yymsp[-1].minor.yy42,yymsp[0].minor.yy490);}
151878
+{ yymsp[-10].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy442,yymsp[-5].minor.yy130,yymsp[-1].minor.yy442,yymsp[0].minor.yy130);}
151235151879
break;
151236151880
case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151237
-{ yymsp[-7].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy42,yymsp[-2].minor.yy490,0,0); }
151881
+{ yymsp[-7].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy442,yymsp[-2].minor.yy130,0,0); }
151238151882
break;
151239151883
case 155: /* upsert ::= ON CONFLICT DO NOTHING */
151240
-{ yymsp[-3].minor.yy266 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
151884
+{ yymsp[-3].minor.yy426 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
151241151885
break;
151242151886
case 159: /* idlist_opt ::= LP idlist RP */
151243
-{yymsp[-2].minor.yy336 = yymsp[-1].minor.yy336;}
151887
+{yymsp[-2].minor.yy200 = yymsp[-1].minor.yy200;}
151244151888
break;
151245151889
case 160: /* idlist ::= idlist COMMA nm */
151246
-{yymsp[-2].minor.yy336 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy336,&yymsp[0].minor.yy0);}
151890
+{yymsp[-2].minor.yy200 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy200,&yymsp[0].minor.yy0);}
151247151891
break;
151248151892
case 161: /* idlist ::= nm */
151249
-{yymsp[0].minor.yy336 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
151893
+{yymsp[0].minor.yy200 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
151250151894
break;
151251151895
case 162: /* expr ::= LP expr RP */
151252
-{yymsp[-2].minor.yy490 = yymsp[-1].minor.yy490;}
151896
+{yymsp[-2].minor.yy130 = yymsp[-1].minor.yy130;}
151253151897
break;
151254151898
case 163: /* expr ::= ID|INDEXED */
151255151899
case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164);
151256
-{yymsp[0].minor.yy490=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151900
+{yymsp[0].minor.yy130=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151257151901
break;
151258151902
case 165: /* expr ::= nm DOT nm */
151259151903
{
151260151904
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
151261151905
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
151262151906
if( IN_RENAME_OBJECT ){
151263151907
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
151264151908
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
151265151909
}
151266
- yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
151910
+ yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
151267151911
}
151268
- yymsp[-2].minor.yy490 = yylhsminor.yy490;
151912
+ yymsp[-2].minor.yy130 = yylhsminor.yy130;
151269151913
break;
151270151914
case 166: /* expr ::= nm DOT nm DOT nm */
151271151915
{
151272151916
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
151273151917
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -151275,95 +151919,95 @@
151275151919
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
151276151920
if( IN_RENAME_OBJECT ){
151277151921
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
151278151922
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
151279151923
}
151280
- yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
151924
+ yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
151281151925
}
151282
- yymsp[-4].minor.yy490 = yylhsminor.yy490;
151926
+ yymsp[-4].minor.yy130 = yylhsminor.yy130;
151283151927
break;
151284151928
case 167: /* term ::= NULL|FLOAT|BLOB */
151285151929
case 168: /* term ::= STRING */ yytestcase(yyruleno==168);
151286
-{yymsp[0].minor.yy490=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151930
+{yymsp[0].minor.yy130=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151287151931
break;
151288151932
case 169: /* term ::= INTEGER */
151289151933
{
151290
- yylhsminor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
151934
+ yylhsminor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
151291151935
}
151292
- yymsp[0].minor.yy490 = yylhsminor.yy490;
151936
+ yymsp[0].minor.yy130 = yylhsminor.yy130;
151293151937
break;
151294151938
case 170: /* expr ::= VARIABLE */
151295151939
{
151296151940
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
151297151941
u32 n = yymsp[0].minor.yy0.n;
151298
- yymsp[0].minor.yy490 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
151299
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy490, n);
151942
+ yymsp[0].minor.yy130 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
151943
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy130, n);
151300151944
}else{
151301151945
/* When doing a nested parse, one can include terms in an expression
151302151946
** that look like this: #1 #2 ... These terms refer to registers
151303151947
** in the virtual machine. #N is the N-th register. */
151304151948
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
151305151949
assert( t.n>=2 );
151306151950
if( pParse->nested==0 ){
151307151951
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
151308
- yymsp[0].minor.yy490 = 0;
151952
+ yymsp[0].minor.yy130 = 0;
151309151953
}else{
151310
- yymsp[0].minor.yy490 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
151311
- if( yymsp[0].minor.yy490 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy490->iTable);
151954
+ yymsp[0].minor.yy130 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
151955
+ if( yymsp[0].minor.yy130 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy130->iTable);
151312151956
}
151313151957
}
151314151958
}
151315151959
break;
151316151960
case 171: /* expr ::= expr COLLATE ID|STRING */
151317151961
{
151318
- yymsp[-2].minor.yy490 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0, 1);
151962
+ yymsp[-2].minor.yy130 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy130, &yymsp[0].minor.yy0, 1);
151319151963
}
151320151964
break;
151321151965
case 172: /* expr ::= CAST LP expr AS typetoken RP */
151322151966
{
151323
- yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
151324
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy490, yymsp[-3].minor.yy490, 0);
151967
+ yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
151968
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy130, yymsp[-3].minor.yy130, 0);
151325151969
}
151326151970
break;
151327151971
case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */
151328151972
{
151329
- yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy42, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy96);
151973
+ yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy420);
151330151974
}
151331
- yymsp[-4].minor.yy490 = yylhsminor.yy490;
151975
+ yymsp[-4].minor.yy130 = yylhsminor.yy130;
151332151976
break;
151333151977
case 174: /* expr ::= ID|INDEXED LP STAR RP */
151334151978
{
151335
- yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
151979
+ yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
151336151980
}
151337
- yymsp[-3].minor.yy490 = yylhsminor.yy490;
151981
+ yymsp[-3].minor.yy130 = yylhsminor.yy130;
151338151982
break;
151339151983
case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151340151984
{
151341
- yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy42, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy96);
151342
- sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);
151985
+ yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy442, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy420);
151986
+ sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395);
151343151987
}
151344
- yymsp[-5].minor.yy490 = yylhsminor.yy490;
151988
+ yymsp[-5].minor.yy130 = yylhsminor.yy130;
151345151989
break;
151346151990
case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */
151347151991
{
151348
- yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
151349
- sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);
151992
+ yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
151993
+ sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395);
151350151994
}
151351
- yymsp[-4].minor.yy490 = yylhsminor.yy490;
151995
+ yymsp[-4].minor.yy130 = yylhsminor.yy130;
151352151996
break;
151353151997
case 177: /* term ::= CTIME_KW */
151354151998
{
151355
- yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
151999
+ yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
151356152000
}
151357
- yymsp[0].minor.yy490 = yylhsminor.yy490;
152001
+ yymsp[0].minor.yy130 = yylhsminor.yy130;
151358152002
break;
151359152003
case 178: /* expr ::= LP nexprlist COMMA expr RP */
151360152004
{
151361
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy42, yymsp[-1].minor.yy490);
151362
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
151363
- if( yymsp[-4].minor.yy490 ){
151364
- yymsp[-4].minor.yy490->x.pList = pList;
152005
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy442, yymsp[-1].minor.yy130);
152006
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
152007
+ if( yymsp[-4].minor.yy130 ){
152008
+ yymsp[-4].minor.yy130->x.pList = pList;
151365152009
}else{
151366152010
sqlite3ExprListDelete(pParse->db, pList);
151367152011
}
151368152012
}
151369152013
break;
@@ -151373,101 +152017,101 @@
151373152017
case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182);
151374152018
case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183);
151375152019
case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184);
151376152020
case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185);
151377152021
case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186);
151378
-{yymsp[-2].minor.yy490=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}
152022
+{yymsp[-2].minor.yy130=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);}
151379152023
break;
151380152024
case 187: /* likeop ::= NOT LIKE_KW|MATCH */
151381152025
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
151382152026
break;
151383152027
case 188: /* expr ::= expr likeop expr */
151384152028
{
151385152029
ExprList *pList;
151386152030
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
151387152031
yymsp[-1].minor.yy0.n &= 0x7fffffff;
151388
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy490);
151389
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy490);
151390
- yymsp[-2].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
151391
- if( bNot ) yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy490, 0);
151392
- if( yymsp[-2].minor.yy490 ) yymsp[-2].minor.yy490->flags |= EP_InfixFunc;
152032
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy130);
152033
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy130);
152034
+ yymsp[-2].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
152035
+ if( bNot ) yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy130, 0);
152036
+ if( yymsp[-2].minor.yy130 ) yymsp[-2].minor.yy130->flags |= EP_InfixFunc;
151393152037
}
151394152038
break;
151395152039
case 189: /* expr ::= expr likeop expr ESCAPE expr */
151396152040
{
151397152041
ExprList *pList;
151398152042
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
151399152043
yymsp[-3].minor.yy0.n &= 0x7fffffff;
151400
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151401
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy490);
151402
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);
151403
- yymsp[-4].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
151404
- if( bNot ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151405
- if( yymsp[-4].minor.yy490 ) yymsp[-4].minor.yy490->flags |= EP_InfixFunc;
152044
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152045
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy130);
152046
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130);
152047
+ yymsp[-4].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
152048
+ if( bNot ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152049
+ if( yymsp[-4].minor.yy130 ) yymsp[-4].minor.yy130->flags |= EP_InfixFunc;
151406152050
}
151407152051
break;
151408152052
case 190: /* expr ::= expr ISNULL|NOTNULL */
151409
-{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy490,0);}
152053
+{yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy130,0);}
151410152054
break;
151411152055
case 191: /* expr ::= expr NOT NULL */
151412
-{yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy490,0);}
152056
+{yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy130,0);}
151413152057
break;
151414152058
case 192: /* expr ::= expr IS expr */
151415152059
{
151416
- yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);
151417
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-2].minor.yy490, TK_ISNULL);
152060
+ yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);
152061
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-2].minor.yy130, TK_ISNULL);
151418152062
}
151419152063
break;
151420152064
case 193: /* expr ::= expr IS NOT expr */
151421152065
{
151422
- yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy490,yymsp[0].minor.yy490);
151423
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-3].minor.yy490, TK_NOTNULL);
152066
+ yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy130,yymsp[0].minor.yy130);
152067
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-3].minor.yy130, TK_NOTNULL);
151424152068
}
151425152069
break;
151426152070
case 194: /* expr ::= NOT expr */
151427152071
case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195);
151428
-{yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy490, 0);/*A-overwrites-B*/}
152072
+{yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy130, 0);/*A-overwrites-B*/}
151429152073
break;
151430152074
case 196: /* expr ::= PLUS|MINUS expr */
151431152075
{
151432
- yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy490, 0);
152076
+ yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy130, 0);
151433152077
/*A-overwrites-B*/
151434152078
}
151435152079
break;
151436152080
case 197: /* between_op ::= BETWEEN */
151437152081
case 200: /* in_op ::= IN */ yytestcase(yyruleno==200);
151438
-{yymsp[0].minor.yy96 = 0;}
152082
+{yymsp[0].minor.yy420 = 0;}
151439152083
break;
151440152084
case 199: /* expr ::= expr between_op expr AND expr */
151441152085
{
151442
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151443
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);
151444
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy490, 0);
151445
- if( yymsp[-4].minor.yy490 ){
151446
- yymsp[-4].minor.yy490->x.pList = pList;
152086
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152087
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130);
152088
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy130, 0);
152089
+ if( yymsp[-4].minor.yy130 ){
152090
+ yymsp[-4].minor.yy130->x.pList = pList;
151447152091
}else{
151448152092
sqlite3ExprListDelete(pParse->db, pList);
151449152093
}
151450
- if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
152094
+ if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
151451152095
}
151452152096
break;
151453152097
case 202: /* expr ::= expr in_op LP exprlist RP */
151454152098
{
151455
- if( yymsp[-1].minor.yy42==0 ){
152099
+ if( yymsp[-1].minor.yy442==0 ){
151456152100
/* Expressions of the form
151457152101
**
151458152102
** expr1 IN ()
151459152103
** expr1 NOT IN ()
151460152104
**
151461152105
** simplify to constants 0 (false) and 1 (true), respectively,
151462152106
** regardless of the value of expr1.
151463152107
*/
151464152108
if( IN_RENAME_OBJECT==0 ){
151465
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy490);
151466
- yymsp[-4].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy96],1);
152109
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy130);
152110
+ yymsp[-4].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy420],1);
151467152111
}
151468
- }else if( yymsp[-1].minor.yy42->nExpr==1 ){
152112
+ }else if( yymsp[-1].minor.yy442->nExpr==1 ){
151469152113
/* Expressions of the form:
151470152114
**
151471152115
** expr1 IN (?1)
151472152116
** expr1 NOT IN (?2)
151473152117
**
@@ -151480,134 +152124,134 @@
151480152124
** But, the RHS of the == or <> is marked with the EP_Generic flag
151481152125
** so that it may not contribute to the computation of comparison
151482152126
** affinity or the collating sequence to use for comparison. Otherwise,
151483152127
** the semantics would be subtly different from IN or NOT IN.
151484152128
*/
151485
- Expr *pRHS = yymsp[-1].minor.yy42->a[0].pExpr;
151486
- yymsp[-1].minor.yy42->a[0].pExpr = 0;
151487
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);
152129
+ Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr;
152130
+ yymsp[-1].minor.yy442->a[0].pExpr = 0;
152131
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
151488152132
/* pRHS cannot be NULL because a malloc error would have been detected
151489152133
** before now and control would have never reached this point */
151490152134
if( ALWAYS(pRHS) ){
151491152135
pRHS->flags &= ~EP_Collate;
151492152136
pRHS->flags |= EP_Generic;
151493152137
}
151494
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, yymsp[-3].minor.yy96 ? TK_NE : TK_EQ, yymsp[-4].minor.yy490, pRHS);
151495
- }else{
151496
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151497
- if( yymsp[-4].minor.yy490 ){
151498
- yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy42;
151499
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);
151500
- }else{
151501
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);
151502
- }
151503
- if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
152138
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, yymsp[-3].minor.yy420 ? TK_NE : TK_EQ, yymsp[-4].minor.yy130, pRHS);
152139
+ }else{
152140
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152141
+ if( yymsp[-4].minor.yy130 ){
152142
+ yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy442;
152143
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130);
152144
+ }else{
152145
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
152146
+ }
152147
+ if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
151504152148
}
151505152149
}
151506152150
break;
151507152151
case 203: /* expr ::= LP select RP */
151508152152
{
151509
- yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
151510
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy490, yymsp[-1].minor.yy423);
152153
+ yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
152154
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy130, yymsp[-1].minor.yy491);
151511152155
}
151512152156
break;
151513152157
case 204: /* expr ::= expr in_op LP select RP */
151514152158
{
151515
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151516
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, yymsp[-1].minor.yy423);
151517
- if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
152159
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152160
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, yymsp[-1].minor.yy491);
152161
+ if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
151518152162
}
151519152163
break;
151520152164
case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */
151521152165
{
151522152166
SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
151523152167
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
151524
- if( yymsp[0].minor.yy42 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy42);
151525
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151526
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, pSelect);
151527
- if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
152168
+ if( yymsp[0].minor.yy442 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy442);
152169
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152170
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, pSelect);
152171
+ if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
151528152172
}
151529152173
break;
151530152174
case 206: /* expr ::= EXISTS LP select RP */
151531152175
{
151532152176
Expr *p;
151533
- p = yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
151534
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy423);
152177
+ p = yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
152178
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy491);
151535152179
}
151536152180
break;
151537152181
case 207: /* expr ::= CASE case_operand case_exprlist case_else END */
151538152182
{
151539
- yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy490, 0);
151540
- if( yymsp[-4].minor.yy490 ){
151541
- yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy490 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[-1].minor.yy490) : yymsp[-2].minor.yy42;
151542
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);
152183
+ yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy130, 0);
152184
+ if( yymsp[-4].minor.yy130 ){
152185
+ yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy130 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy130) : yymsp[-2].minor.yy442;
152186
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130);
151543152187
}else{
151544
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy42);
151545
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy490);
152188
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
152189
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy130);
151546152190
}
151547152191
}
151548152192
break;
151549152193
case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
151550152194
{
151551
- yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);
151552
- yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[0].minor.yy490);
152195
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy130);
152196
+ yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy130);
151553152197
}
151554152198
break;
151555152199
case 209: /* case_exprlist ::= WHEN expr THEN expr */
151556152200
{
151557
- yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151558
- yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42, yymsp[0].minor.yy490);
152201
+ yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152202
+ yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy130);
151559152203
}
151560152204
break;
151561152205
case 212: /* case_operand ::= expr */
151562
-{yymsp[0].minor.yy490 = yymsp[0].minor.yy490; /*A-overwrites-X*/}
152206
+{yymsp[0].minor.yy130 = yymsp[0].minor.yy130; /*A-overwrites-X*/}
151563152207
break;
151564152208
case 215: /* nexprlist ::= nexprlist COMMA expr */
151565
-{yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[0].minor.yy490);}
152209
+{yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy130);}
151566152210
break;
151567152211
case 216: /* nexprlist ::= expr */
151568
-{yymsp[0].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy490); /*A-overwrites-Y*/}
152212
+{yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy130); /*A-overwrites-Y*/}
151569152213
break;
151570152214
case 218: /* paren_exprlist ::= LP exprlist RP */
151571152215
case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223);
151572
-{yymsp[-2].minor.yy42 = yymsp[-1].minor.yy42;}
152216
+{yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;}
151573152217
break;
151574152218
case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151575152219
{
151576152220
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
151577
- sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy42, yymsp[-10].minor.yy96,
151578
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy490, SQLITE_SO_ASC, yymsp[-8].minor.yy96, SQLITE_IDXTYPE_APPDEF);
152221
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy420,
152222
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy130, SQLITE_SO_ASC, yymsp[-8].minor.yy420, SQLITE_IDXTYPE_APPDEF);
151579152223
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
151580152224
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
151581152225
}
151582152226
}
151583152227
break;
151584152228
case 220: /* uniqueflag ::= UNIQUE */
151585152229
case 262: /* raisetype ::= ABORT */ yytestcase(yyruleno==262);
151586
-{yymsp[0].minor.yy96 = OE_Abort;}
152230
+{yymsp[0].minor.yy420 = OE_Abort;}
151587152231
break;
151588152232
case 221: /* uniqueflag ::= */
151589
-{yymsp[1].minor.yy96 = OE_None;}
152233
+{yymsp[1].minor.yy420 = OE_None;}
151590152234
break;
151591152235
case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */
151592152236
{
151593
- yymsp[-4].minor.yy42 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96);
152237
+ yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420);
151594152238
}
151595152239
break;
151596152240
case 225: /* eidlist ::= nm collate sortorder */
151597152241
{
151598
- yymsp[-2].minor.yy42 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96); /*A-overwrites-Y*/
152242
+ yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420); /*A-overwrites-Y*/
151599152243
}
151600152244
break;
151601152245
case 228: /* cmd ::= DROP INDEX ifexists fullname */
151602
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy167, yymsp[-1].minor.yy96);}
152246
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy147, yymsp[-1].minor.yy420);}
151603152247
break;
151604152248
case 229: /* cmd ::= VACUUM vinto */
151605
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy490);}
152249
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy130);}
151606152250
break;
151607152251
case 230: /* cmd ::= VACUUM nm vinto */
151608
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy490);}
152252
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy130);}
151609152253
break;
151610152254
case 233: /* cmd ::= PRAGMA nm dbnm */
151611152255
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
151612152256
break;
151613152257
case 234: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -151625,55 +152269,55 @@
151625152269
case 240: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151626152270
{
151627152271
Token all;
151628152272
all.z = yymsp[-3].minor.yy0.z;
151629152273
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
151630
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy119, &all);
152274
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy524, &all);
151631152275
}
151632152276
break;
151633152277
case 241: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151634152278
{
151635
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy96, yymsp[-4].minor.yy350.a, yymsp[-4].minor.yy350.b, yymsp[-2].minor.yy167, yymsp[0].minor.yy490, yymsp[-10].minor.yy96, yymsp[-8].minor.yy96);
152279
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy420, yymsp[-4].minor.yy498.a, yymsp[-4].minor.yy498.b, yymsp[-2].minor.yy147, yymsp[0].minor.yy130, yymsp[-10].minor.yy420, yymsp[-8].minor.yy420);
151636152280
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
151637152281
}
151638152282
break;
151639152283
case 242: /* trigger_time ::= BEFORE|AFTER */
151640
-{ yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/ }
152284
+{ yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/ }
151641152285
break;
151642152286
case 243: /* trigger_time ::= INSTEAD OF */
151643
-{ yymsp[-1].minor.yy96 = TK_INSTEAD;}
152287
+{ yymsp[-1].minor.yy420 = TK_INSTEAD;}
151644152288
break;
151645152289
case 244: /* trigger_time ::= */
151646
-{ yymsp[1].minor.yy96 = TK_BEFORE; }
152290
+{ yymsp[1].minor.yy420 = TK_BEFORE; }
151647152291
break;
151648152292
case 245: /* trigger_event ::= DELETE|INSERT */
151649152293
case 246: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==246);
151650
-{yymsp[0].minor.yy350.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy350.b = 0;}
152294
+{yymsp[0].minor.yy498.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy498.b = 0;}
151651152295
break;
151652152296
case 247: /* trigger_event ::= UPDATE OF idlist */
151653
-{yymsp[-2].minor.yy350.a = TK_UPDATE; yymsp[-2].minor.yy350.b = yymsp[0].minor.yy336;}
152297
+{yymsp[-2].minor.yy498.a = TK_UPDATE; yymsp[-2].minor.yy498.b = yymsp[0].minor.yy200;}
151654152298
break;
151655152299
case 248: /* when_clause ::= */
151656152300
case 267: /* key_opt ::= */ yytestcase(yyruleno==267);
151657
- case 309: /* filter_opt ::= */ yytestcase(yyruleno==309);
151658
-{ yymsp[1].minor.yy490 = 0; }
152301
+ case 315: /* filter_opt ::= */ yytestcase(yyruleno==315);
152302
+{ yymsp[1].minor.yy130 = 0; }
151659152303
break;
151660152304
case 249: /* when_clause ::= WHEN expr */
151661152305
case 268: /* key_opt ::= KEY expr */ yytestcase(yyruleno==268);
151662
-{ yymsp[-1].minor.yy490 = yymsp[0].minor.yy490; }
152306
+{ yymsp[-1].minor.yy130 = yymsp[0].minor.yy130; }
151663152307
break;
151664152308
case 250: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151665152309
{
151666
- assert( yymsp[-2].minor.yy119!=0 );
151667
- yymsp[-2].minor.yy119->pLast->pNext = yymsp[-1].minor.yy119;
151668
- yymsp[-2].minor.yy119->pLast = yymsp[-1].minor.yy119;
152310
+ assert( yymsp[-2].minor.yy524!=0 );
152311
+ yymsp[-2].minor.yy524->pLast->pNext = yymsp[-1].minor.yy524;
152312
+ yymsp[-2].minor.yy524->pLast = yymsp[-1].minor.yy524;
151669152313
}
151670152314
break;
151671152315
case 251: /* trigger_cmd_list ::= trigger_cmd SEMI */
151672152316
{
151673
- assert( yymsp[-1].minor.yy119!=0 );
151674
- yymsp[-1].minor.yy119->pLast = yymsp[-1].minor.yy119;
152317
+ assert( yymsp[-1].minor.yy524!=0 );
152318
+ yymsp[-1].minor.yy524->pLast = yymsp[-1].minor.yy524;
151675152319
}
151676152320
break;
151677152321
case 252: /* trnm ::= nm DOT nm */
151678152322
{
151679152323
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -151695,62 +152339,62 @@
151695152339
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
151696152340
"within triggers");
151697152341
}
151698152342
break;
151699152343
case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151700
-{yylhsminor.yy119 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy490, yymsp[-6].minor.yy96, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy464);}
151701
- yymsp[-7].minor.yy119 = yylhsminor.yy119;
152344
+{yylhsminor.yy524 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy130, yymsp[-6].minor.yy420, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy104);}
152345
+ yymsp[-7].minor.yy524 = yylhsminor.yy524;
151702152346
break;
151703152347
case 256: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151704152348
{
151705
- yylhsminor.yy119 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy336,yymsp[-2].minor.yy423,yymsp[-6].minor.yy96,yymsp[-1].minor.yy266,yymsp[-7].minor.yy464,yymsp[0].minor.yy464);/*yylhsminor.yy119-overwrites-yymsp[-6].minor.yy96*/
152349
+ yylhsminor.yy524 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy200,yymsp[-2].minor.yy491,yymsp[-6].minor.yy420,yymsp[-1].minor.yy426,yymsp[-7].minor.yy104,yymsp[0].minor.yy104);/*yylhsminor.yy524-overwrites-yymsp[-6].minor.yy420*/
151706152350
}
151707
- yymsp[-7].minor.yy119 = yylhsminor.yy119;
152351
+ yymsp[-7].minor.yy524 = yylhsminor.yy524;
151708152352
break;
151709152353
case 257: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151710
-{yylhsminor.yy119 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy490, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy464);}
151711
- yymsp[-5].minor.yy119 = yylhsminor.yy119;
152354
+{yylhsminor.yy524 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy130, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy104);}
152355
+ yymsp[-5].minor.yy524 = yylhsminor.yy524;
151712152356
break;
151713152357
case 258: /* trigger_cmd ::= scanpt select scanpt */
151714
-{yylhsminor.yy119 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy423, yymsp[-2].minor.yy464, yymsp[0].minor.yy464); /*yylhsminor.yy119-overwrites-yymsp[-1].minor.yy423*/}
151715
- yymsp[-2].minor.yy119 = yylhsminor.yy119;
152358
+{yylhsminor.yy524 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy491, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); /*yylhsminor.yy524-overwrites-yymsp[-1].minor.yy491*/}
152359
+ yymsp[-2].minor.yy524 = yylhsminor.yy524;
151716152360
break;
151717152361
case 259: /* expr ::= RAISE LP IGNORE RP */
151718152362
{
151719
- yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
151720
- if( yymsp[-3].minor.yy490 ){
151721
- yymsp[-3].minor.yy490->affinity = OE_Ignore;
152363
+ yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
152364
+ if( yymsp[-3].minor.yy130 ){
152365
+ yymsp[-3].minor.yy130->affinity = OE_Ignore;
151722152366
}
151723152367
}
151724152368
break;
151725152369
case 260: /* expr ::= RAISE LP raisetype COMMA nm RP */
151726152370
{
151727
- yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
151728
- if( yymsp[-5].minor.yy490 ) {
151729
- yymsp[-5].minor.yy490->affinity = (char)yymsp[-3].minor.yy96;
152371
+ yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
152372
+ if( yymsp[-5].minor.yy130 ) {
152373
+ yymsp[-5].minor.yy130->affinity = (char)yymsp[-3].minor.yy420;
151730152374
}
151731152375
}
151732152376
break;
151733152377
case 261: /* raisetype ::= ROLLBACK */
151734
-{yymsp[0].minor.yy96 = OE_Rollback;}
152378
+{yymsp[0].minor.yy420 = OE_Rollback;}
151735152379
break;
151736152380
case 263: /* raisetype ::= FAIL */
151737
-{yymsp[0].minor.yy96 = OE_Fail;}
152381
+{yymsp[0].minor.yy420 = OE_Fail;}
151738152382
break;
151739152383
case 264: /* cmd ::= DROP TRIGGER ifexists fullname */
151740152384
{
151741
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy167,yymsp[-1].minor.yy96);
152385
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy147,yymsp[-1].minor.yy420);
151742152386
}
151743152387
break;
151744152388
case 265: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151745152389
{
151746
- sqlite3Attach(pParse, yymsp[-3].minor.yy490, yymsp[-1].minor.yy490, yymsp[0].minor.yy490);
152390
+ sqlite3Attach(pParse, yymsp[-3].minor.yy130, yymsp[-1].minor.yy130, yymsp[0].minor.yy130);
151747152391
}
151748152392
break;
151749152393
case 266: /* cmd ::= DETACH database_kw_opt expr */
151750152394
{
151751
- sqlite3Detach(pParse, yymsp[0].minor.yy490);
152395
+ sqlite3Detach(pParse, yymsp[0].minor.yy130);
151752152396
}
151753152397
break;
151754152398
case 269: /* cmd ::= REINDEX */
151755152399
{sqlite3Reindex(pParse, 0, 0);}
151756152400
break;
@@ -151763,11 +152407,11 @@
151763152407
case 272: /* cmd ::= ANALYZE nm dbnm */
151764152408
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
151765152409
break;
151766152410
case 273: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
151767152411
{
151768
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy167,&yymsp[0].minor.yy0);
152412
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy147,&yymsp[0].minor.yy0);
151769152413
}
151770152414
break;
151771152415
case 274: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151772152416
{
151773152417
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -151775,16 +152419,16 @@
151775152419
}
151776152420
break;
151777152421
case 275: /* add_column_fullname ::= fullname */
151778152422
{
151779152423
disableLookaside(pParse);
151780
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy167);
152424
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy147);
151781152425
}
151782152426
break;
151783152427
case 276: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151784152428
{
151785
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy167, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
152429
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy147, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
151786152430
}
151787152431
break;
151788152432
case 277: /* cmd ::= create_vtab */
151789152433
{sqlite3VtabFinishParse(pParse,0);}
151790152434
break;
@@ -151791,11 +152435,11 @@
151791152435
case 278: /* cmd ::= create_vtab LP vtabarglist RP */
151792152436
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
151793152437
break;
151794152438
case 279: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151795152439
{
151796
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy96);
152440
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy420);
151797152441
}
151798152442
break;
151799152443
case 280: /* vtabarg ::= */
151800152444
{sqlite3VtabArgInit(pParse);}
151801152445
break;
@@ -151804,186 +152448,208 @@
151804152448
case 283: /* lp ::= LP */ yytestcase(yyruleno==283);
151805152449
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
151806152450
break;
151807152451
case 284: /* with ::= WITH wqlist */
151808152452
case 285: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==285);
151809
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy499, 1); }
152453
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy523, 1); }
151810152454
break;
151811152455
case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */
151812152456
{
151813
- yymsp[-5].minor.yy499 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423); /*A-overwrites-X*/
152457
+ yymsp[-5].minor.yy523 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491); /*A-overwrites-X*/
151814152458
}
151815152459
break;
151816152460
case 287: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151817152461
{
151818
- yymsp[-7].minor.yy499 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy499, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423);
152462
+ yymsp[-7].minor.yy523 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491);
151819152463
}
151820152464
break;
151821152465
case 288: /* windowdefn_list ::= windowdefn */
151822
-{ yylhsminor.yy147 = yymsp[0].minor.yy147; }
151823
- yymsp[0].minor.yy147 = yylhsminor.yy147;
152466
+{ yylhsminor.yy395 = yymsp[0].minor.yy395; }
152467
+ yymsp[0].minor.yy395 = yylhsminor.yy395;
151824152468
break;
151825152469
case 289: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
151826152470
{
151827
- assert( yymsp[0].minor.yy147!=0 );
151828
- yymsp[0].minor.yy147->pNextWin = yymsp[-2].minor.yy147;
151829
- yylhsminor.yy147 = yymsp[0].minor.yy147;
151830
-}
151831
- yymsp[-2].minor.yy147 = yylhsminor.yy147;
151832
- break;
151833
- case 290: /* windowdefn ::= nm AS window */
151834
-{
151835
- if( ALWAYS(yymsp[0].minor.yy147) ){
151836
- yymsp[0].minor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
151837
- }
151838
- yylhsminor.yy147 = yymsp[0].minor.yy147;
151839
-}
151840
- yymsp[-2].minor.yy147 = yylhsminor.yy147;
151841
- break;
151842
- case 291: /* window ::= LP part_opt orderby_opt frame_opt RP */
151843
-{
151844
- yymsp[-4].minor.yy147 = yymsp[-1].minor.yy147;
151845
- if( ALWAYS(yymsp[-4].minor.yy147) ){
151846
- yymsp[-4].minor.yy147->pPartition = yymsp[-3].minor.yy42;
151847
- yymsp[-4].minor.yy147->pOrderBy = yymsp[-2].minor.yy42;
151848
- }
151849
-}
151850
- break;
151851
- case 292: /* part_opt ::= PARTITION BY nexprlist */
151852
-{ yymsp[-2].minor.yy42 = yymsp[0].minor.yy42; }
151853
- break;
151854
- case 293: /* part_opt ::= */
151855
-{ yymsp[1].minor.yy42 = 0; }
151856
- break;
151857
- case 294: /* frame_opt ::= */
151858
-{
151859
- yymsp[1].minor.yy147 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
151860
-}
151861
- break;
151862
- case 295: /* frame_opt ::= range_or_rows frame_bound_s */
151863
-{
151864
- yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy96, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr, TK_CURRENT, 0);
151865
-}
151866
- yymsp[-1].minor.yy147 = yylhsminor.yy147;
151867
- break;
151868
- case 296: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
151869
-{
151870
- yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy96, yymsp[-2].minor.yy317.eType, yymsp[-2].minor.yy317.pExpr, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr);
151871
-}
151872
- yymsp[-4].minor.yy147 = yylhsminor.yy147;
151873
- break;
151874
- case 297: /* range_or_rows ::= RANGE */
151875
-{ yymsp[0].minor.yy96 = TK_RANGE; }
151876
- break;
151877
- case 298: /* range_or_rows ::= ROWS */
151878
-{ yymsp[0].minor.yy96 = TK_ROWS; }
151879
- break;
151880
- case 299: /* frame_bound_s ::= frame_bound */
151881
- case 301: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==301);
151882
-{ yylhsminor.yy317 = yymsp[0].minor.yy317; }
151883
- yymsp[0].minor.yy317 = yylhsminor.yy317;
151884
- break;
151885
- case 300: /* frame_bound_s ::= UNBOUNDED PRECEDING */
151886
- case 302: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==302);
151887
-{yymsp[-1].minor.yy317.eType = TK_UNBOUNDED; yymsp[-1].minor.yy317.pExpr = 0;}
151888
- break;
151889
- case 303: /* frame_bound ::= expr PRECEDING */
151890
-{ yylhsminor.yy317.eType = TK_PRECEDING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }
151891
- yymsp[-1].minor.yy317 = yylhsminor.yy317;
151892
- break;
151893
- case 304: /* frame_bound ::= CURRENT ROW */
151894
-{ yymsp[-1].minor.yy317.eType = TK_CURRENT ; yymsp[-1].minor.yy317.pExpr = 0; }
151895
- break;
151896
- case 305: /* frame_bound ::= expr FOLLOWING */
151897
-{ yylhsminor.yy317.eType = TK_FOLLOWING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }
151898
- yymsp[-1].minor.yy317 = yylhsminor.yy317;
151899
- break;
151900
- case 306: /* window_clause ::= WINDOW windowdefn_list */
151901
-{ yymsp[-1].minor.yy147 = yymsp[0].minor.yy147; }
151902
- break;
151903
- case 307: /* over_clause ::= filter_opt OVER window */
151904
-{
151905
- yylhsminor.yy147 = yymsp[0].minor.yy147;
151906
- assert( yylhsminor.yy147!=0 );
151907
- yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;
151908
-}
151909
- yymsp[-2].minor.yy147 = yylhsminor.yy147;
151910
- break;
151911
- case 308: /* over_clause ::= filter_opt OVER nm */
151912
-{
151913
- yylhsminor.yy147 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
151914
- if( yylhsminor.yy147 ){
151915
- yylhsminor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
151916
- yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;
151917
- }else{
151918
- sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy490);
151919
- }
151920
-}
151921
- yymsp[-2].minor.yy147 = yylhsminor.yy147;
151922
- break;
151923
- case 310: /* filter_opt ::= FILTER LP WHERE expr RP */
151924
-{ yymsp[-4].minor.yy490 = yymsp[-1].minor.yy490; }
152471
+ assert( yymsp[0].minor.yy395!=0 );
152472
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy395);
152473
+ yymsp[0].minor.yy395->pNextWin = yymsp[-2].minor.yy395;
152474
+ yylhsminor.yy395 = yymsp[0].minor.yy395;
152475
+}
152476
+ yymsp[-2].minor.yy395 = yylhsminor.yy395;
152477
+ break;
152478
+ case 290: /* windowdefn ::= nm AS LP window RP */
152479
+{
152480
+ if( ALWAYS(yymsp[-1].minor.yy395) ){
152481
+ yymsp[-1].minor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
152482
+ }
152483
+ yylhsminor.yy395 = yymsp[-1].minor.yy395;
152484
+}
152485
+ yymsp[-4].minor.yy395 = yylhsminor.yy395;
152486
+ break;
152487
+ case 291: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152488
+{
152489
+ yymsp[-4].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, 0);
152490
+}
152491
+ break;
152492
+ case 292: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152493
+{
152494
+ yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, &yymsp[-5].minor.yy0);
152495
+}
152496
+ yymsp[-5].minor.yy395 = yylhsminor.yy395;
152497
+ break;
152498
+ case 293: /* window ::= ORDER BY sortlist frame_opt */
152499
+{
152500
+ yymsp[-3].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, 0);
152501
+}
152502
+ break;
152503
+ case 294: /* window ::= nm ORDER BY sortlist frame_opt */
152504
+{
152505
+ yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
152506
+}
152507
+ yymsp[-4].minor.yy395 = yylhsminor.yy395;
152508
+ break;
152509
+ case 295: /* window ::= frame_opt */
152510
+{
152511
+ yylhsminor.yy395 = yymsp[0].minor.yy395;
152512
+}
152513
+ yymsp[0].minor.yy395 = yylhsminor.yy395;
152514
+ break;
152515
+ case 296: /* window ::= nm frame_opt */
152516
+{
152517
+ yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, 0, &yymsp[-1].minor.yy0);
152518
+}
152519
+ yymsp[-1].minor.yy395 = yylhsminor.yy395;
152520
+ break;
152521
+ case 297: /* frame_opt ::= */
152522
+{
152523
+ yymsp[1].minor.yy395 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
152524
+}
152525
+ break;
152526
+ case 298: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152527
+{
152528
+ yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy420, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy10);
152529
+}
152530
+ yymsp[-2].minor.yy395 = yylhsminor.yy395;
152531
+ break;
152532
+ case 299: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152533
+{
152534
+ yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy420, yymsp[-3].minor.yy273.eType, yymsp[-3].minor.yy273.pExpr, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, yymsp[0].minor.yy10);
152535
+}
152536
+ yymsp[-5].minor.yy395 = yylhsminor.yy395;
152537
+ break;
152538
+ case 301: /* frame_bound_s ::= frame_bound */
152539
+ case 303: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==303);
152540
+{yylhsminor.yy273 = yymsp[0].minor.yy273;}
152541
+ yymsp[0].minor.yy273 = yylhsminor.yy273;
152542
+ break;
152543
+ case 302: /* frame_bound_s ::= UNBOUNDED PRECEDING */
152544
+ case 304: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==304);
152545
+ case 306: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==306);
152546
+{yylhsminor.yy273.eType = yymsp[-1].major; yylhsminor.yy273.pExpr = 0;}
152547
+ yymsp[-1].minor.yy273 = yylhsminor.yy273;
152548
+ break;
152549
+ case 305: /* frame_bound ::= expr PRECEDING|FOLLOWING */
152550
+{yylhsminor.yy273.eType = yymsp[0].major; yylhsminor.yy273.pExpr = yymsp[-1].minor.yy130;}
152551
+ yymsp[-1].minor.yy273 = yylhsminor.yy273;
152552
+ break;
152553
+ case 307: /* frame_exclude_opt ::= */
152554
+{yymsp[1].minor.yy10 = 0;}
152555
+ break;
152556
+ case 308: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
152557
+{yymsp[-1].minor.yy10 = yymsp[0].minor.yy10;}
152558
+ break;
152559
+ case 309: /* frame_exclude ::= NO OTHERS */
152560
+ case 310: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==310);
152561
+{yymsp[-1].minor.yy10 = yymsp[-1].major; /*A-overwrites-X*/}
152562
+ break;
152563
+ case 311: /* frame_exclude ::= GROUP|TIES */
152564
+{yymsp[0].minor.yy10 = yymsp[0].major; /*A-overwrites-X*/}
152565
+ break;
152566
+ case 312: /* window_clause ::= WINDOW windowdefn_list */
152567
+{ yymsp[-1].minor.yy395 = yymsp[0].minor.yy395; }
152568
+ break;
152569
+ case 313: /* over_clause ::= filter_opt OVER LP window RP */
152570
+{
152571
+ yylhsminor.yy395 = yymsp[-1].minor.yy395;
152572
+ assert( yylhsminor.yy395!=0 );
152573
+ yylhsminor.yy395->pFilter = yymsp[-4].minor.yy130;
152574
+}
152575
+ yymsp[-4].minor.yy395 = yylhsminor.yy395;
152576
+ break;
152577
+ case 314: /* over_clause ::= filter_opt OVER nm */
152578
+{
152579
+ yylhsminor.yy395 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
152580
+ if( yylhsminor.yy395 ){
152581
+ yylhsminor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
152582
+ yylhsminor.yy395->pFilter = yymsp[-2].minor.yy130;
152583
+ }else{
152584
+ sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy130);
152585
+ }
152586
+}
152587
+ yymsp[-2].minor.yy395 = yylhsminor.yy395;
152588
+ break;
152589
+ case 316: /* filter_opt ::= FILTER LP WHERE expr RP */
152590
+{ yymsp[-4].minor.yy130 = yymsp[-1].minor.yy130; }
151925152591
break;
151926152592
default:
151927
- /* (311) input ::= cmdlist */ yytestcase(yyruleno==311);
151928
- /* (312) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==312);
151929
- /* (313) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=313);
151930
- /* (314) ecmd ::= SEMI */ yytestcase(yyruleno==314);
151931
- /* (315) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==315);
151932
- /* (316) ecmd ::= explain cmdx */ yytestcase(yyruleno==316);
151933
- /* (317) trans_opt ::= */ yytestcase(yyruleno==317);
151934
- /* (318) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==318);
151935
- /* (319) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==319);
151936
- /* (320) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==320);
151937
- /* (321) savepoint_opt ::= */ yytestcase(yyruleno==321);
151938
- /* (322) cmd ::= create_table create_table_args */ yytestcase(yyruleno==322);
151939
- /* (323) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==323);
151940
- /* (324) columnlist ::= columnname carglist */ yytestcase(yyruleno==324);
151941
- /* (325) nm ::= ID|INDEXED */ yytestcase(yyruleno==325);
151942
- /* (326) nm ::= STRING */ yytestcase(yyruleno==326);
151943
- /* (327) nm ::= JOIN_KW */ yytestcase(yyruleno==327);
151944
- /* (328) typetoken ::= typename */ yytestcase(yyruleno==328);
151945
- /* (329) typename ::= ID|STRING */ yytestcase(yyruleno==329);
151946
- /* (330) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=330);
151947
- /* (331) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=331);
151948
- /* (332) carglist ::= carglist ccons */ yytestcase(yyruleno==332);
151949
- /* (333) carglist ::= */ yytestcase(yyruleno==333);
151950
- /* (334) ccons ::= NULL onconf */ yytestcase(yyruleno==334);
151951
- /* (335) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==335);
151952
- /* (336) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==336);
151953
- /* (337) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=337);
151954
- /* (338) tconscomma ::= */ yytestcase(yyruleno==338);
151955
- /* (339) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=339);
151956
- /* (340) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=340);
151957
- /* (341) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=341);
151958
- /* (342) oneselect ::= values */ yytestcase(yyruleno==342);
151959
- /* (343) sclp ::= selcollist COMMA */ yytestcase(yyruleno==343);
151960
- /* (344) as ::= ID|STRING */ yytestcase(yyruleno==344);
151961
- /* (345) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=345);
151962
- /* (346) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==346);
151963
- /* (347) exprlist ::= nexprlist */ yytestcase(yyruleno==347);
151964
- /* (348) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=348);
151965
- /* (349) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=349);
151966
- /* (350) nmnum ::= ON */ yytestcase(yyruleno==350);
151967
- /* (351) nmnum ::= DELETE */ yytestcase(yyruleno==351);
151968
- /* (352) nmnum ::= DEFAULT */ yytestcase(yyruleno==352);
151969
- /* (353) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==353);
151970
- /* (354) foreach_clause ::= */ yytestcase(yyruleno==354);
151971
- /* (355) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==355);
151972
- /* (356) trnm ::= nm */ yytestcase(yyruleno==356);
151973
- /* (357) tridxby ::= */ yytestcase(yyruleno==357);
151974
- /* (358) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==358);
151975
- /* (359) database_kw_opt ::= */ yytestcase(yyruleno==359);
151976
- /* (360) kwcolumn_opt ::= */ yytestcase(yyruleno==360);
151977
- /* (361) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==361);
151978
- /* (362) vtabarglist ::= vtabarg */ yytestcase(yyruleno==362);
151979
- /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==363);
151980
- /* (364) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==364);
151981
- /* (365) anylist ::= */ yytestcase(yyruleno==365);
151982
- /* (366) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==366);
151983
- /* (367) anylist ::= anylist ANY */ yytestcase(yyruleno==367);
151984
- /* (368) with ::= */ yytestcase(yyruleno==368);
152593
+ /* (317) input ::= cmdlist */ yytestcase(yyruleno==317);
152594
+ /* (318) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==318);
152595
+ /* (319) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=319);
152596
+ /* (320) ecmd ::= SEMI */ yytestcase(yyruleno==320);
152597
+ /* (321) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==321);
152598
+ /* (322) ecmd ::= explain cmdx */ yytestcase(yyruleno==322);
152599
+ /* (323) trans_opt ::= */ yytestcase(yyruleno==323);
152600
+ /* (324) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==324);
152601
+ /* (325) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==325);
152602
+ /* (326) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==326);
152603
+ /* (327) savepoint_opt ::= */ yytestcase(yyruleno==327);
152604
+ /* (328) cmd ::= create_table create_table_args */ yytestcase(yyruleno==328);
152605
+ /* (329) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==329);
152606
+ /* (330) columnlist ::= columnname carglist */ yytestcase(yyruleno==330);
152607
+ /* (331) nm ::= ID|INDEXED */ yytestcase(yyruleno==331);
152608
+ /* (332) nm ::= STRING */ yytestcase(yyruleno==332);
152609
+ /* (333) nm ::= JOIN_KW */ yytestcase(yyruleno==333);
152610
+ /* (334) typetoken ::= typename */ yytestcase(yyruleno==334);
152611
+ /* (335) typename ::= ID|STRING */ yytestcase(yyruleno==335);
152612
+ /* (336) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=336);
152613
+ /* (337) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=337);
152614
+ /* (338) carglist ::= carglist ccons */ yytestcase(yyruleno==338);
152615
+ /* (339) carglist ::= */ yytestcase(yyruleno==339);
152616
+ /* (340) ccons ::= NULL onconf */ yytestcase(yyruleno==340);
152617
+ /* (341) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==341);
152618
+ /* (342) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==342);
152619
+ /* (343) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=343);
152620
+ /* (344) tconscomma ::= */ yytestcase(yyruleno==344);
152621
+ /* (345) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=345);
152622
+ /* (346) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=346);
152623
+ /* (347) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=347);
152624
+ /* (348) oneselect ::= values */ yytestcase(yyruleno==348);
152625
+ /* (349) sclp ::= selcollist COMMA */ yytestcase(yyruleno==349);
152626
+ /* (350) as ::= ID|STRING */ yytestcase(yyruleno==350);
152627
+ /* (351) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=351);
152628
+ /* (352) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==352);
152629
+ /* (353) exprlist ::= nexprlist */ yytestcase(yyruleno==353);
152630
+ /* (354) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=354);
152631
+ /* (355) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=355);
152632
+ /* (356) nmnum ::= ON */ yytestcase(yyruleno==356);
152633
+ /* (357) nmnum ::= DELETE */ yytestcase(yyruleno==357);
152634
+ /* (358) nmnum ::= DEFAULT */ yytestcase(yyruleno==358);
152635
+ /* (359) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==359);
152636
+ /* (360) foreach_clause ::= */ yytestcase(yyruleno==360);
152637
+ /* (361) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==361);
152638
+ /* (362) trnm ::= nm */ yytestcase(yyruleno==362);
152639
+ /* (363) tridxby ::= */ yytestcase(yyruleno==363);
152640
+ /* (364) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==364);
152641
+ /* (365) database_kw_opt ::= */ yytestcase(yyruleno==365);
152642
+ /* (366) kwcolumn_opt ::= */ yytestcase(yyruleno==366);
152643
+ /* (367) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==367);
152644
+ /* (368) vtabarglist ::= vtabarg */ yytestcase(yyruleno==368);
152645
+ /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==369);
152646
+ /* (370) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==370);
152647
+ /* (371) anylist ::= */ yytestcase(yyruleno==371);
152648
+ /* (372) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==372);
152649
+ /* (373) anylist ::= anylist ANY */ yytestcase(yyruleno==373);
152650
+ /* (374) with ::= */ yytestcase(yyruleno==374);
151985152651
break;
151986152652
/********** End reduce actions ************************************************/
151987152653
};
151988152654
assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
151989152655
yygoto = yyRuleInfoLhs[yyruleno];
@@ -152442,148 +153108,148 @@
152442153108
** might be implemented more directly using a hand-written hash table.
152443153109
** But by using this automatically generated code, the size of the code
152444153110
** is substantially reduced. This is important for embedded applications
152445153111
** on platforms with limited memory.
152446153112
*/
152447
-/* Hash score: 208 */
152448
-/* zKWText[] encodes 923 bytes of keyword text in 614 bytes */
153113
+/* Hash score: 214 */
153114
+/* zKWText[] encodes 950 bytes of keyword text in 629 bytes */
152449153115
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
152450
-/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
152451
-/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
152452
-/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERANGEBETWEEN */
152453
-/* OTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
152454
-/* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT */
152455
-/* WHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULTAUTOINCREMENTCAST */
152456
-/* COLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMPARTITIONDEFERRED */
152457
-/* ISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWINGFROMFULLIFISNULL */
152458
-/* ORDERESTRICTOVERIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEW */
152459
-/* INDOWINITIALLYPRIMARY */
152460
-static const char zKWText[613] = {
153116
+/* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYCONSTRAINTERSECTIES */
153117
+/* AVEPOINTOFFSETRANSACTIONATURALTERAISEXCEPTRIGGEREFERENCES */
153118
+/* UNIQUERYWITHOUTERELEASEXCLUSIVEXISTSATTACHAVINGLOBEGINNERANGE */
153119
+/* BETWEENOTHINGROUPSCASCADETACHCASECOLLATECREATECURRENT_DATE */
153120
+/* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTUPDATEVALUES */
153121
+/* VIRTUALIMITWHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULT */
153122
+/* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
153123
+/* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWING */
153124
+/* FROMFULLIFISNULLORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
153125
+/* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
153126
+static const char zKWText[628] = {
152461153127
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
152462153128
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
152463153129
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
152464153130
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
152465
- 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
152466
- 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
152467
- 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
152468
- 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
152469
- 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
152470
- 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
152471
- 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
152472
- 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
152473
- 'T','E','B','E','G','I','N','N','E','R','A','N','G','E','B','E','T','W',
152474
- 'E','E','N','O','T','H','I','N','G','L','O','B','Y','C','A','S','C','A',
152475
- 'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C',
152476
- 'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D',
152477
- 'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N',
152478
- 'S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N','A',
152479
- 'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
152480
- 'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','O',
152481
- 'T','N','U','L','L','W','H','E','R','E','C','U','R','S','I','V','E','A',
152482
- 'F','T','E','R','E','N','A','M','E','A','N','D','E','F','A','U','L','T',
152483
- 'A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C',
152484
- 'O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C',
152485
- 'T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E',
152486
- 'S','T','A','M','P','A','R','T','I','T','I','O','N','D','E','F','E','R',
152487
- 'R','E','D','I','S','T','I','N','C','T','D','R','O','P','R','E','C','E',
152488
- 'D','I','N','G','F','A','I','L','F','I','L','T','E','R','E','P','L','A',
152489
- 'C','E','F','O','L','L','O','W','I','N','G','F','R','O','M','F','U','L',
152490
- 'L','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R',
152491
- 'I','C','T','O','V','E','R','I','G','H','T','R','O','L','L','B','A','C',
152492
- 'K','R','O','W','S','U','N','B','O','U','N','D','E','D','U','N','I','O',
152493
- 'N','U','S','I','N','G','V','A','C','U','U','M','V','I','E','W','I','N',
152494
- 'D','O','W','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R',
152495
- 'Y',
153131
+ 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
153132
+ 'T','E','M','P','O','R','A','R','Y','C','O','N','S','T','R','A','I','N',
153133
+ 'T','E','R','S','E','C','T','I','E','S','A','V','E','P','O','I','N','T',
153134
+ 'O','F','F','S','E','T','R','A','N','S','A','C','T','I','O','N','A','T',
153135
+ 'U','R','A','L','T','E','R','A','I','S','E','X','C','E','P','T','R','I',
153136
+ 'G','G','E','R','E','F','E','R','E','N','C','E','S','U','N','I','Q','U',
153137
+ 'E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S','E',
153138
+ 'X','C','L','U','S','I','V','E','X','I','S','T','S','A','T','T','A','C',
153139
+ 'H','A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N',
153140
+ 'G','E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U',
153141
+ 'P','S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C',
153142
+ 'O','L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N',
153143
+ 'T','_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I',
153144
+ 'N','S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N',
153145
+ 'A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','U','P','D',
153146
+ 'A','T','E','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M',
153147
+ 'I','T','W','H','E','N','O','T','N','U','L','L','W','H','E','R','E','C',
153148
+ 'U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E','A','N',
153149
+ 'D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E','M','E',
153150
+ 'N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M','I','T',
153151
+ 'C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R','R','E',
153152
+ 'N','T','_','T','I','M','E','S','T','A','M','P','A','R','T','I','T','I',
153153
+ 'O','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
153154
+ 'R','O','P','R','E','C','E','D','I','N','G','F','A','I','L','F','I','L',
153155
+ 'T','E','R','E','P','L','A','C','E','F','O','L','L','O','W','I','N','G',
153156
+ 'F','R','O','M','F','U','L','L','I','F','I','S','N','U','L','L','O','R',
153157
+ 'D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O','V',
153158
+ 'E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S',
153159
+ 'U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I','N',
153160
+ 'G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B','Y',
153161
+ 'I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
152496153162
};
152497153163
/* aKWHash[i] is the hash value for the i-th keyword */
152498153164
static const unsigned char aKWHash[127] = {
152499
- 74, 109, 124, 72, 106, 45, 0, 0, 81, 0, 76, 61, 0,
152500
- 42, 12, 77, 15, 0, 123, 84, 54, 118, 125, 19, 0, 0,
152501
- 130, 0, 128, 121, 0, 22, 96, 0, 9, 0, 0, 115, 69,
152502
- 0, 67, 6, 0, 48, 93, 136, 0, 126, 104, 0, 0, 44,
152503
- 0, 107, 24, 0, 17, 0, 131, 53, 23, 0, 5, 62, 132,
152504
- 99, 0, 0, 135, 110, 60, 134, 57, 113, 55, 0, 94, 0,
152505
- 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 105, 117, 14,
152506
- 39, 116, 0, 80, 0, 133, 114, 92, 59, 0, 129, 79, 119,
152507
- 86, 46, 83, 0, 0, 97, 40, 122, 120, 0, 127, 0, 0,
152508
- 29, 0, 89, 87, 88, 0, 20, 85, 111, 56,
153165
+ 75, 111, 127, 73, 108, 29, 0, 0, 83, 0, 77, 63, 0,
153166
+ 37, 33, 78, 15, 0, 126, 86, 57, 120, 128, 19, 0, 0,
153167
+ 133, 0, 131, 123, 0, 22, 98, 0, 9, 0, 0, 117, 71,
153168
+ 0, 69, 6, 0, 49, 95, 140, 0, 129, 106, 0, 0, 54,
153169
+ 0, 109, 24, 0, 17, 0, 134, 56, 23, 26, 5, 58, 135,
153170
+ 101, 0, 0, 139, 112, 62, 138, 59, 115, 65, 0, 96, 0,
153171
+ 105, 45, 0, 104, 0, 0, 0, 100, 97, 102, 107, 119, 14,
153172
+ 31, 118, 0, 81, 0, 136, 116, 137, 61, 124, 132, 80, 121,
153173
+ 88, 30, 85, 0, 0, 99, 35, 125, 122, 0, 130, 0, 0,
153174
+ 41, 0, 91, 89, 90, 0, 20, 87, 113, 82,
152509153175
};
152510153176
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
152511153177
** then the i-th keyword has no more hash collisions. Otherwise,
152512153178
** the next keyword with the same hash is aKWHash[i]-1. */
152513
-static const unsigned char aKWNext[136] = {
153179
+static const unsigned char aKWNext[140] = {
152514153180
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
152515153181
0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
152516
- 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152517
- 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
152518
- 0, 43, 3, 47, 0, 0, 32, 0, 0, 0, 0, 0, 0,
152519
- 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
152520
- 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 0, 31,
152521
- 63, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
152522
- 91, 0, 0, 8, 0, 108, 0, 101, 28, 52, 68, 0, 112,
152523
- 0, 73, 51, 0, 90, 27, 37, 0, 71, 36, 82, 0, 35,
152524
- 66, 25, 18, 0, 0, 78,
153182
+ 0, 0, 0, 21, 0, 0, 12, 0, 0, 0, 0, 0, 0,
153183
+ 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153184
+ 51, 28, 0, 0, 38, 0, 0, 0, 44, 0, 0, 0, 3,
153185
+ 0, 0, 67, 1, 66, 0, 0, 0, 36, 0, 47, 0, 0,
153186
+ 0, 0, 0, 48, 50, 76, 0, 0, 42, 0, 60, 0, 0,
153187
+ 0, 43, 0, 16, 55, 10, 0, 0, 0, 0, 0, 0, 0,
153188
+ 11, 72, 93, 0, 0, 8, 0, 110, 0, 103, 40, 53, 70,
153189
+ 0, 114, 0, 74, 52, 0, 0, 92, 39, 46, 0, 68, 32,
153190
+ 84, 0, 34, 27, 25, 18, 94, 0, 64, 79,
152525153191
};
152526153192
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
152527
-static const unsigned char aKWLen[136] = {
153193
+static const unsigned char aKWLen[140] = {
152528153194
7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
152529
- 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
152530
- 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
152531
- 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
152532
- 6, 6, 5, 6, 5, 5, 5, 7, 7, 4, 2, 7, 3,
152533
- 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
152534
- 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 9, 5,
152535
- 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
152536
- 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9, 4, 4,
152537
- 2, 6, 5, 8, 4, 5, 8, 4, 3, 9, 5, 5, 6,
152538
- 4, 6, 2, 9, 3, 7,
153195
+ 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
153196
+ 6, 9, 4, 2, 10, 9, 4, 9, 4, 6, 2, 3, 11,
153197
+ 6, 2, 7, 5, 5, 6, 7, 10, 6, 5, 7, 4, 5,
153198
+ 7, 9, 6, 6, 6, 4, 5, 5, 5, 7, 7, 6, 5,
153199
+ 7, 3, 6, 4, 7, 6, 12, 9, 4, 6, 4, 5, 4,
153200
+ 7, 6, 5, 6, 6, 7, 5, 4, 7, 3, 2, 4, 5,
153201
+ 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5,
153202
+ 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9,
153203
+ 4, 4, 2, 6, 5, 8, 6, 4, 5, 8, 4, 3, 9,
153204
+ 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
152539153205
};
152540153206
/* aKWOffset[i] is the index into zKWText[] of the start of
152541153207
** the text for the i-th keyword. */
152542
-static const unsigned short int aKWOffset[136] = {
153208
+static const unsigned short int aKWOffset[140] = {
152543153209
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
152544153210
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
152545
- 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
152546
- 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
152547
- 199, 204, 209, 212, 218, 221, 225, 230, 236, 242, 245, 247, 248,
152548
- 252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 314, 319, 321,
152549
- 328, 333, 338, 344, 350, 355, 358, 358, 358, 361, 365, 368, 377,
152550
- 381, 387, 389, 396, 398, 400, 409, 413, 419, 425, 433, 438, 438,
152551
- 438, 454, 463, 470, 471, 478, 481, 490, 494, 499, 506, 515, 519,
152552
- 523, 525, 531, 535, 543, 546, 551, 559, 559, 563, 572, 577, 582,
152553
- 588, 591, 594, 597, 602, 606,
153211
+ 86, 90, 90, 94, 99, 106, 114, 117, 123, 126, 126, 129, 131,
153212
+ 136, 140, 141, 146, 150, 154, 159, 165, 175, 178, 183, 183, 187,
153213
+ 191, 197, 205, 211, 216, 221, 224, 227, 231, 236, 242, 248, 248,
153214
+ 254, 255, 259, 265, 269, 276, 282, 294, 303, 305, 311, 315, 320,
153215
+ 322, 329, 334, 339, 345, 351, 357, 362, 365, 365, 365, 368, 372,
153216
+ 375, 384, 388, 394, 396, 403, 405, 407, 416, 420, 426, 432, 440,
153217
+ 445, 445, 445, 461, 470, 477, 478, 485, 488, 497, 501, 506, 513,
153218
+ 522, 526, 530, 532, 538, 542, 550, 556, 559, 564, 572, 572, 576,
153219
+ 585, 590, 595, 601, 604, 607, 610, 612, 617, 621,
152554153220
};
152555153221
/* aKWCode[i] is the parser symbol code for the i-th keyword */
152556
-static const unsigned char aKWCode[136] = {
153222
+static const unsigned char aKWCode[140] = {
152557153223
TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
152558153224
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
152559153225
TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
152560153226
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
152561153227
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
152562
- TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
152563
- TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
152564
- TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
152565
- TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
152566
- TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
152567
- TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
152568
- TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN,
152569
- TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
152570
- TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
152571
- TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
152572
- TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
152573
- TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
152574
- TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RECURSIVE,
152575
- TK_AFTER, TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR,
152576
- TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
152577
- TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT,
152578
- TK_PARTITION, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
152579
- TK_PRECEDING, TK_FAIL, TK_FILTER, TK_REPLACE, TK_FOLLOWING,
152580
- TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_ORDER,
152581
- TK_RESTRICT, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS,
152582
- TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM,
152583
- TK_VIEW, TK_WINDOW, TK_DO, TK_INITIALLY, TK_ALL,
152584
- TK_PRIMARY,
153228
+ TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
153229
+ TK_CONSTRAINT, TK_INTERSECT, TK_TIES, TK_SAVEPOINT, TK_INTO,
153230
+ TK_OFFSET, TK_OF, TK_SET, TK_TRANSACTION,TK_ACTION,
153231
+ TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCEPT,
153232
+ TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT,
153233
+ TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_EXCLUSIVE, TK_EXISTS,
153234
+ TK_ATTACH, TK_HAVING, TK_LIKE_KW, TK_BEGIN, TK_JOIN_KW,
153235
+ TK_RANGE, TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP,
153236
+ TK_CASCADE, TK_ASC, TK_DETACH, TK_CASE, TK_COLLATE,
153237
+ TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
153238
+ TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
153239
+ TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
153240
+ TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL,
153241
+ TK_WHERE, TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND,
153242
+ TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
153243
+ TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
153244
+ TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DEFERRED, TK_DISTINCT,
153245
+ TK_IS, TK_DROP, TK_PRECEDING, TK_FAIL, TK_FILTER,
153246
+ TK_REPLACE, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF,
153247
+ TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
153248
+ TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
153249
+ TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
153250
+ TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
152585153251
};
152586153252
/* Check to see if z[0..n-1] is a keyword. If it is, write the
152587153253
** parser symbol code for that keyword into *pType. Always
152588153254
** return the integer n (the length of the token). */
152589153255
static int keywordCode(const char *z, int n, int *pType){
@@ -152625,121 +153291,125 @@
152625153291
testcase( i==20 ); /* LEFT */
152626153292
testcase( i==21 ); /* THEN */
152627153293
testcase( i==22 ); /* END */
152628153294
testcase( i==23 ); /* DEFERRABLE */
152629153295
testcase( i==24 ); /* ELSE */
152630
- testcase( i==25 ); /* EXCEPT */
152631
- testcase( i==26 ); /* TRANSACTION */
152632
- testcase( i==27 ); /* ACTION */
152633
- testcase( i==28 ); /* ON */
152634
- testcase( i==29 ); /* NATURAL */
152635
- testcase( i==30 ); /* ALTER */
152636
- testcase( i==31 ); /* RAISE */
152637
- testcase( i==32 ); /* EXCLUSIVE */
152638
- testcase( i==33 ); /* EXISTS */
152639
- testcase( i==34 ); /* SAVEPOINT */
152640
- testcase( i==35 ); /* INTERSECT */
152641
- testcase( i==36 ); /* TRIGGER */
152642
- testcase( i==37 ); /* REFERENCES */
152643
- testcase( i==38 ); /* CONSTRAINT */
152644
- testcase( i==39 ); /* INTO */
152645
- testcase( i==40 ); /* OFFSET */
152646
- testcase( i==41 ); /* OF */
152647
- testcase( i==42 ); /* SET */
152648
- testcase( i==43 ); /* TEMPORARY */
152649
- testcase( i==44 ); /* TEMP */
152650
- testcase( i==45 ); /* OR */
152651
- testcase( i==46 ); /* UNIQUE */
152652
- testcase( i==47 ); /* QUERY */
152653
- testcase( i==48 ); /* WITHOUT */
152654
- testcase( i==49 ); /* WITH */
152655
- testcase( i==50 ); /* OUTER */
152656
- testcase( i==51 ); /* RELEASE */
152657
- testcase( i==52 ); /* ATTACH */
152658
- testcase( i==53 ); /* HAVING */
152659
- testcase( i==54 ); /* GROUP */
152660
- testcase( i==55 ); /* UPDATE */
152661
- testcase( i==56 ); /* BEGIN */
152662
- testcase( i==57 ); /* INNER */
152663
- testcase( i==58 ); /* RANGE */
152664
- testcase( i==59 ); /* BETWEEN */
152665
- testcase( i==60 ); /* NOTHING */
152666
- testcase( i==61 ); /* GLOB */
152667
- testcase( i==62 ); /* BY */
152668
- testcase( i==63 ); /* CASCADE */
152669
- testcase( i==64 ); /* ASC */
152670
- testcase( i==65 ); /* DELETE */
152671
- testcase( i==66 ); /* CASE */
152672
- testcase( i==67 ); /* COLLATE */
152673
- testcase( i==68 ); /* CREATE */
152674
- testcase( i==69 ); /* CURRENT_DATE */
152675
- testcase( i==70 ); /* DETACH */
152676
- testcase( i==71 ); /* IMMEDIATE */
152677
- testcase( i==72 ); /* JOIN */
152678
- testcase( i==73 ); /* INSERT */
152679
- testcase( i==74 ); /* LIKE */
152680
- testcase( i==75 ); /* MATCH */
152681
- testcase( i==76 ); /* PLAN */
152682
- testcase( i==77 ); /* ANALYZE */
152683
- testcase( i==78 ); /* PRAGMA */
152684
- testcase( i==79 ); /* ABORT */
152685
- testcase( i==80 ); /* VALUES */
152686
- testcase( i==81 ); /* VIRTUAL */
152687
- testcase( i==82 ); /* LIMIT */
152688
- testcase( i==83 ); /* WHEN */
152689
- testcase( i==84 ); /* NOTNULL */
152690
- testcase( i==85 ); /* NOT */
152691
- testcase( i==86 ); /* NO */
152692
- testcase( i==87 ); /* NULL */
152693
- testcase( i==88 ); /* WHERE */
152694
- testcase( i==89 ); /* RECURSIVE */
152695
- testcase( i==90 ); /* AFTER */
152696
- testcase( i==91 ); /* RENAME */
152697
- testcase( i==92 ); /* AND */
152698
- testcase( i==93 ); /* DEFAULT */
152699
- testcase( i==94 ); /* AUTOINCREMENT */
152700
- testcase( i==95 ); /* TO */
152701
- testcase( i==96 ); /* IN */
152702
- testcase( i==97 ); /* CAST */
152703
- testcase( i==98 ); /* COLUMN */
152704
- testcase( i==99 ); /* COMMIT */
152705
- testcase( i==100 ); /* CONFLICT */
152706
- testcase( i==101 ); /* CROSS */
152707
- testcase( i==102 ); /* CURRENT_TIMESTAMP */
152708
- testcase( i==103 ); /* CURRENT_TIME */
152709
- testcase( i==104 ); /* CURRENT */
152710
- testcase( i==105 ); /* PARTITION */
152711
- testcase( i==106 ); /* DEFERRED */
152712
- testcase( i==107 ); /* DISTINCT */
152713
- testcase( i==108 ); /* IS */
152714
- testcase( i==109 ); /* DROP */
152715
- testcase( i==110 ); /* PRECEDING */
152716
- testcase( i==111 ); /* FAIL */
152717
- testcase( i==112 ); /* FILTER */
152718
- testcase( i==113 ); /* REPLACE */
152719
- testcase( i==114 ); /* FOLLOWING */
152720
- testcase( i==115 ); /* FROM */
152721
- testcase( i==116 ); /* FULL */
152722
- testcase( i==117 ); /* IF */
152723
- testcase( i==118 ); /* ISNULL */
152724
- testcase( i==119 ); /* ORDER */
152725
- testcase( i==120 ); /* RESTRICT */
152726
- testcase( i==121 ); /* OVER */
152727
- testcase( i==122 ); /* RIGHT */
152728
- testcase( i==123 ); /* ROLLBACK */
152729
- testcase( i==124 ); /* ROWS */
152730
- testcase( i==125 ); /* ROW */
152731
- testcase( i==126 ); /* UNBOUNDED */
152732
- testcase( i==127 ); /* UNION */
152733
- testcase( i==128 ); /* USING */
152734
- testcase( i==129 ); /* VACUUM */
152735
- testcase( i==130 ); /* VIEW */
152736
- testcase( i==131 ); /* WINDOW */
152737
- testcase( i==132 ); /* DO */
152738
- testcase( i==133 ); /* INITIALLY */
152739
- testcase( i==134 ); /* ALL */
152740
- testcase( i==135 ); /* PRIMARY */
153296
+ testcase( i==25 ); /* EXCLUDE */
153297
+ testcase( i==26 ); /* DELETE */
153298
+ testcase( i==27 ); /* TEMPORARY */
153299
+ testcase( i==28 ); /* TEMP */
153300
+ testcase( i==29 ); /* OR */
153301
+ testcase( i==30 ); /* CONSTRAINT */
153302
+ testcase( i==31 ); /* INTERSECT */
153303
+ testcase( i==32 ); /* TIES */
153304
+ testcase( i==33 ); /* SAVEPOINT */
153305
+ testcase( i==34 ); /* INTO */
153306
+ testcase( i==35 ); /* OFFSET */
153307
+ testcase( i==36 ); /* OF */
153308
+ testcase( i==37 ); /* SET */
153309
+ testcase( i==38 ); /* TRANSACTION */
153310
+ testcase( i==39 ); /* ACTION */
153311
+ testcase( i==40 ); /* ON */
153312
+ testcase( i==41 ); /* NATURAL */
153313
+ testcase( i==42 ); /* ALTER */
153314
+ testcase( i==43 ); /* RAISE */
153315
+ testcase( i==44 ); /* EXCEPT */
153316
+ testcase( i==45 ); /* TRIGGER */
153317
+ testcase( i==46 ); /* REFERENCES */
153318
+ testcase( i==47 ); /* UNIQUE */
153319
+ testcase( i==48 ); /* QUERY */
153320
+ testcase( i==49 ); /* WITHOUT */
153321
+ testcase( i==50 ); /* WITH */
153322
+ testcase( i==51 ); /* OUTER */
153323
+ testcase( i==52 ); /* RELEASE */
153324
+ testcase( i==53 ); /* EXCLUSIVE */
153325
+ testcase( i==54 ); /* EXISTS */
153326
+ testcase( i==55 ); /* ATTACH */
153327
+ testcase( i==56 ); /* HAVING */
153328
+ testcase( i==57 ); /* GLOB */
153329
+ testcase( i==58 ); /* BEGIN */
153330
+ testcase( i==59 ); /* INNER */
153331
+ testcase( i==60 ); /* RANGE */
153332
+ testcase( i==61 ); /* BETWEEN */
153333
+ testcase( i==62 ); /* NOTHING */
153334
+ testcase( i==63 ); /* GROUPS */
153335
+ testcase( i==64 ); /* GROUP */
153336
+ testcase( i==65 ); /* CASCADE */
153337
+ testcase( i==66 ); /* ASC */
153338
+ testcase( i==67 ); /* DETACH */
153339
+ testcase( i==68 ); /* CASE */
153340
+ testcase( i==69 ); /* COLLATE */
153341
+ testcase( i==70 ); /* CREATE */
153342
+ testcase( i==71 ); /* CURRENT_DATE */
153343
+ testcase( i==72 ); /* IMMEDIATE */
153344
+ testcase( i==73 ); /* JOIN */
153345
+ testcase( i==74 ); /* INSERT */
153346
+ testcase( i==75 ); /* LIKE */
153347
+ testcase( i==76 ); /* MATCH */
153348
+ testcase( i==77 ); /* PLAN */
153349
+ testcase( i==78 ); /* ANALYZE */
153350
+ testcase( i==79 ); /* PRAGMA */
153351
+ testcase( i==80 ); /* ABORT */
153352
+ testcase( i==81 ); /* UPDATE */
153353
+ testcase( i==82 ); /* VALUES */
153354
+ testcase( i==83 ); /* VIRTUAL */
153355
+ testcase( i==84 ); /* LIMIT */
153356
+ testcase( i==85 ); /* WHEN */
153357
+ testcase( i==86 ); /* NOTNULL */
153358
+ testcase( i==87 ); /* NOT */
153359
+ testcase( i==88 ); /* NO */
153360
+ testcase( i==89 ); /* NULL */
153361
+ testcase( i==90 ); /* WHERE */
153362
+ testcase( i==91 ); /* RECURSIVE */
153363
+ testcase( i==92 ); /* AFTER */
153364
+ testcase( i==93 ); /* RENAME */
153365
+ testcase( i==94 ); /* AND */
153366
+ testcase( i==95 ); /* DEFAULT */
153367
+ testcase( i==96 ); /* AUTOINCREMENT */
153368
+ testcase( i==97 ); /* TO */
153369
+ testcase( i==98 ); /* IN */
153370
+ testcase( i==99 ); /* CAST */
153371
+ testcase( i==100 ); /* COLUMN */
153372
+ testcase( i==101 ); /* COMMIT */
153373
+ testcase( i==102 ); /* CONFLICT */
153374
+ testcase( i==103 ); /* CROSS */
153375
+ testcase( i==104 ); /* CURRENT_TIMESTAMP */
153376
+ testcase( i==105 ); /* CURRENT_TIME */
153377
+ testcase( i==106 ); /* CURRENT */
153378
+ testcase( i==107 ); /* PARTITION */
153379
+ testcase( i==108 ); /* DEFERRED */
153380
+ testcase( i==109 ); /* DISTINCT */
153381
+ testcase( i==110 ); /* IS */
153382
+ testcase( i==111 ); /* DROP */
153383
+ testcase( i==112 ); /* PRECEDING */
153384
+ testcase( i==113 ); /* FAIL */
153385
+ testcase( i==114 ); /* FILTER */
153386
+ testcase( i==115 ); /* REPLACE */
153387
+ testcase( i==116 ); /* FOLLOWING */
153388
+ testcase( i==117 ); /* FROM */
153389
+ testcase( i==118 ); /* FULL */
153390
+ testcase( i==119 ); /* IF */
153391
+ testcase( i==120 ); /* ISNULL */
153392
+ testcase( i==121 ); /* ORDER */
153393
+ testcase( i==122 ); /* RESTRICT */
153394
+ testcase( i==123 ); /* OTHERS */
153395
+ testcase( i==124 ); /* OVER */
153396
+ testcase( i==125 ); /* RIGHT */
153397
+ testcase( i==126 ); /* ROLLBACK */
153398
+ testcase( i==127 ); /* ROWS */
153399
+ testcase( i==128 ); /* ROW */
153400
+ testcase( i==129 ); /* UNBOUNDED */
153401
+ testcase( i==130 ); /* UNION */
153402
+ testcase( i==131 ); /* USING */
153403
+ testcase( i==132 ); /* VACUUM */
153404
+ testcase( i==133 ); /* VIEW */
153405
+ testcase( i==134 ); /* WINDOW */
153406
+ testcase( i==135 ); /* DO */
153407
+ testcase( i==136 ); /* BY */
153408
+ testcase( i==137 ); /* INITIALLY */
153409
+ testcase( i==138 ); /* ALL */
153410
+ testcase( i==139 ); /* PRIMARY */
152741153411
*pType = aKWCode[i];
152742153412
break;
152743153413
}
152744153414
}
152745153415
return n;
@@ -152747,11 +153417,11 @@
152747153417
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
152748153418
int id = TK_ID;
152749153419
keywordCode((char*)z, n, &id);
152750153420
return id;
152751153421
}
152752
-#define SQLITE_N_KEYWORD 136
153422
+#define SQLITE_N_KEYWORD 140
152753153423
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
152754153424
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
152755153425
*pzName = zKWText + aKWOffset[i];
152756153426
*pnName = aKWLen[i];
152757153427
return SQLITE_OK;
@@ -154715,10 +155385,12 @@
154715155385
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
154716155386
{ SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
154717155387
{ SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
154718155388
{ SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
154719155389
{ SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive },
155390
+ { SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema|
155391
+ SQLITE_NoSchemaError },
154720155392
};
154721155393
unsigned int i;
154722155394
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
154723155395
for(i=0; i<ArraySize(aFlagOp); i++){
154724155396
if( aFlagOp[i].op==op ){
@@ -168496,11 +169168,11 @@
168496169168
168497169169
zName = sqlite3_value_text(argv[0]);
168498169170
nName = sqlite3_value_bytes(argv[0])+1;
168499169171
168500169172
if( argc==2 ){
168501
- if( fts3TokenizerEnabled(context) ){
169173
+ if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[1]) ){
168502169174
void *pOld;
168503169175
int n = sqlite3_value_bytes(argv[1]);
168504169176
if( zName==0 || n!=sizeof(pPtr) ){
168505169177
sqlite3_result_error(context, "argument type mismatch", -1);
168506169178
return;
@@ -168523,11 +169195,11 @@
168523169195
sqlite3_result_error(context, zErr, -1);
168524169196
sqlite3_free(zErr);
168525169197
return;
168526169198
}
168527169199
}
168528
- if( fts3TokenizerEnabled(context) ){
169200
+ if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[0]) ){
168529169201
sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
168530169202
}
168531169203
}
168532169204
168533169205
SQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){
@@ -184160,53 +184832,49 @@
184160184832
** entry for each cell in the r-tree node. Each entry is itself a
184161184833
** list, containing the 8-byte rowid/pageno followed by the
184162184834
** <num-dimension>*2 coordinates.
184163184835
*/
184164184836
static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
184165
- char *zText = 0;
184166184837
RtreeNode node;
184167184838
Rtree tree;
184168184839
int ii;
184840
+ int nData;
184841
+ int errCode;
184842
+ sqlite3_str *pOut;
184169184843
184170184844
UNUSED_PARAMETER(nArg);
184171184845
memset(&node, 0, sizeof(RtreeNode));
184172184846
memset(&tree, 0, sizeof(Rtree));
184173184847
tree.nDim = (u8)sqlite3_value_int(apArg[0]);
184848
+ if( tree.nDim<1 || tree.nDim>5 ) return;
184174184849
tree.nDim2 = tree.nDim*2;
184175184850
tree.nBytesPerCell = 8 + 8 * tree.nDim;
184176184851
node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
184852
+ nData = sqlite3_value_bytes(apArg[1]);
184853
+ if( nData<4 ) return;
184854
+ if( nData<NCELL(&node)*tree.nBytesPerCell ) return;
184177184855
184856
+ pOut = sqlite3_str_new(0);
184178184857
for(ii=0; ii<NCELL(&node); ii++){
184179
- char zCell[512];
184180
- int nCell = 0;
184181184858
RtreeCell cell;
184182184859
int jj;
184183184860
184184184861
nodeGetCell(&tree, &node, ii, &cell);
184185
- sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
184186
- nCell = (int)strlen(zCell);
184862
+ if( ii>0 ) sqlite3_str_append(pOut, " ", 1);
184863
+ sqlite3_str_appendf(pOut, "{%lld", cell.iRowid);
184187184864
for(jj=0; jj<tree.nDim2; jj++){
184188184865
#ifndef SQLITE_RTREE_INT_ONLY
184189
- sqlite3_snprintf(512-nCell,&zCell[nCell], " %g",
184190
- (double)cell.aCoord[jj].f);
184866
+ sqlite3_str_appendf(pOut, " %g", (double)cell.aCoord[jj].f);
184191184867
#else
184192
- sqlite3_snprintf(512-nCell,&zCell[nCell], " %d",
184193
- cell.aCoord[jj].i);
184868
+ sqlite3_str_appendf(pOut, " %d", cell.aCoord[jj].i);
184194184869
#endif
184195
- nCell = (int)strlen(zCell);
184196
- }
184197
-
184198
- if( zText ){
184199
- char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
184200
- sqlite3_free(zText);
184201
- zText = zTextNew;
184202
- }else{
184203
- zText = sqlite3_mprintf("{%s}", zCell);
184204
- }
184205
- }
184206
-
184207
- sqlite3_result_text(ctx, zText, -1, sqlite3_free);
184870
+ }
184871
+ sqlite3_str_append(pOut, "}", 1);
184872
+ }
184873
+ errCode = sqlite3_str_errcode(pOut);
184874
+ sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
184875
+ sqlite3_result_error_code(ctx, errCode);
184208184876
}
184209184877
184210184878
/* This routine implements an SQL function that returns the "depth" parameter
184211184879
** from the front of a blob that is an r-tree node. For example:
184212184880
**
@@ -198080,11 +198748,11 @@
198080198748
198081198749
return rc;
198082198750
}
198083198751
198084198752
/*
198085
-** This function is called from within sqlite3changset_apply_v2() when
198753
+** This function is called from within sqlite3changeset_apply_v2() when
198086198754
** a conflict is encountered and resolved using conflict resolution
198087198755
** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE)..
198088198756
** It adds a conflict resolution record to the buffer in
198089198757
** SessionApplyCtx.rebase, which will eventually be returned to the caller
198090198758
** of apply_v2() as the "rebase" buffer.
@@ -200859,12 +201527,13 @@
200859201527
*/
200860201528
static void sqlite3Fts5HashClear(Fts5Hash*);
200861201529
200862201530
static int sqlite3Fts5HashQuery(
200863201531
Fts5Hash*, /* Hash table to query */
201532
+ int nPre,
200864201533
const char *pTerm, int nTerm, /* Query term */
200865
- const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
201534
+ void **ppObj, /* OUT: Pointer to doclist for pTerm */
200866201535
int *pnDoclist /* OUT: Size of doclist in bytes */
200867201536
);
200868201537
200869201538
static int sqlite3Fts5HashScanInit(
200870201539
Fts5Hash*, /* Hash table to query */
@@ -202930,11 +203599,11 @@
202930203599
*pnScore = nScore;
202931203600
if( piPos ){
202932203601
sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
202933203602
if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
202934203603
if( iAdj<0 ) iAdj = 0;
202935
- *piPos = iAdj;
203604
+ *piPos = (int)iAdj;
202936203605
}
202937203606
202938203607
return rc;
202939203608
}
202940203609
@@ -203158,11 +203827,11 @@
203158203827
nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
203159203828
p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
203160203829
if( p==0 ){
203161203830
rc = SQLITE_NOMEM;
203162203831
}else{
203163
- memset(p, 0, nByte);
203832
+ memset(p, 0, (size_t)nByte);
203164203833
p->nPhrase = nPhrase;
203165203834
p->aIDF = (double*)&p[1];
203166203835
p->aFreq = &p->aIDF[nPhrase];
203167203836
}
203168203837
@@ -203321,11 +203990,11 @@
203321203990
pNew = sqlite3_realloc64(pBuf->p, nNew);
203322203991
if( pNew==0 ){
203323203992
*pRc = SQLITE_NOMEM;
203324203993
return 1;
203325203994
}else{
203326
- pBuf->nSpace = nNew;
203995
+ pBuf->nSpace = (int)nNew;
203327203996
pBuf->p = pNew;
203328203997
}
203329203998
}
203330203999
return 0;
203331204000
}
@@ -203545,11 +204214,11 @@
203545204214
if( *pRc==SQLITE_OK ){
203546204215
pRet = sqlite3_malloc64(nByte);
203547204216
if( pRet==0 ){
203548204217
if( nByte>0 ) *pRc = SQLITE_NOMEM;
203549204218
}else{
203550
- memset(pRet, 0, nByte);
204219
+ memset(pRet, 0, (size_t)nByte);
203551204220
}
203552204221
}
203553204222
return pRet;
203554204223
}
203555204224
@@ -204014,11 +204683,11 @@
204014204683
if( p==0 ){
204015204684
*pzErr = sqlite3_mprintf("parse error in tokenize directive");
204016204685
rc = SQLITE_ERROR;
204017204686
}else{
204018204687
rc = sqlite3Fts5GetTokenizer(pGlobal,
204019
- (const char**)azArg, nArg, &pConfig->pTok, &pConfig->pTokApi,
204688
+ (const char**)azArg, (int)nArg, &pConfig->pTok, &pConfig->pTokApi,
204020204689
pzErr
204021204690
);
204022204691
}
204023204692
}
204024204693
}
@@ -204124,11 +204793,11 @@
204124204793
*pzOut = 0;
204125204794
204126204795
if( zOut==0 ){
204127204796
*pRc = SQLITE_NOMEM;
204128204797
}else{
204129
- memcpy(zOut, zIn, nIn+1);
204798
+ memcpy(zOut, zIn, (size_t)(nIn+1));
204130204799
if( fts5_isopenquote(zOut[0]) ){
204131204800
int ii = fts5Dequote(zOut);
204132204801
zRet = &zIn[ii];
204133204802
*pbQuoted = 1;
204134204803
}else{
@@ -206138,11 +206807,11 @@
206138206807
nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
206139206808
pRet = sqlite3_malloc64(nByte);
206140206809
if( pRet==0 ){
206141206810
pParse->rc = SQLITE_NOMEM;
206142206811
}else{
206143
- memset(pRet, 0, nByte);
206812
+ memset(pRet, 0, (size_t)nByte);
206144206813
}
206145206814
}else if( (pNear->nPhrase % SZALLOC)==0 ){
206146206815
int nNew = pNear->nPhrase + SZALLOC;
206147206816
sqlite3_int64 nByte;
206148206817
@@ -206214,11 +206883,11 @@
206214206883
sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
206215206884
pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
206216206885
if( pSyn==0 ){
206217206886
rc = SQLITE_NOMEM;
206218206887
}else{
206219
- memset(pSyn, 0, nByte);
206888
+ memset(pSyn, 0, (size_t)nByte);
206220206889
pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);
206221206890
memcpy(pSyn->zTerm, pToken, nToken);
206222206891
pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;
206223206892
pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;
206224206893
}
@@ -206374,11 +207043,11 @@
206374207043
sqlite3_int64 nByte;
206375207044
Fts5Colset *pColset;
206376207045
nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
206377207046
pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
206378207047
if( pColset ){
206379
- memcpy(pColset, pColsetOrig, nByte);
207048
+ memcpy(pColset, pColsetOrig, (size_t)nByte);
206380207049
}
206381207050
pNew->pRoot->pNear->pColset = pColset;
206382207051
}
206383207052
}
206384207053
@@ -206591,11 +207260,11 @@
206591207260
Fts5Colset *pRet;
206592207261
if( pOrig ){
206593207262
sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
206594207263
pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
206595207264
if( pRet ){
206596
- memcpy(pRet, pOrig, nByte);
207265
+ memcpy(pRet, pOrig, (size_t)nByte);
206597207266
}
206598207267
}else{
206599207268
pRet = 0;
206600207269
}
206601207270
return pRet;
@@ -207608,11 +208277,11 @@
207608208277
if( pNew->aSlot==0 ){
207609208278
sqlite3_free(pNew);
207610208279
*ppNew = 0;
207611208280
rc = SQLITE_NOMEM;
207612208281
}else{
207613
- memset(pNew->aSlot, 0, nByte);
208282
+ memset(pNew->aSlot, 0, (size_t)nByte);
207614208283
}
207615208284
}
207616208285
return rc;
207617208286
}
207618208287
@@ -207692,40 +208361,51 @@
207692208361
pHash->nSlot = nNew;
207693208362
pHash->aSlot = apNew;
207694208363
return SQLITE_OK;
207695208364
}
207696208365
207697
-static void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){
208366
+static int fts5HashAddPoslistSize(
208367
+ Fts5Hash *pHash,
208368
+ Fts5HashEntry *p,
208369
+ Fts5HashEntry *p2
208370
+){
208371
+ int nRet = 0;
207698208372
if( p->iSzPoslist ){
207699
- u8 *pPtr = (u8*)p;
208373
+ u8 *pPtr = p2 ? (u8*)p2 : (u8*)p;
208374
+ int nData = p->nData;
207700208375
if( pHash->eDetail==FTS5_DETAIL_NONE ){
207701
- assert( p->nData==p->iSzPoslist );
208376
+ assert( nData==p->iSzPoslist );
207702208377
if( p->bDel ){
207703
- pPtr[p->nData++] = 0x00;
208378
+ pPtr[nData++] = 0x00;
207704208379
if( p->bContent ){
207705
- pPtr[p->nData++] = 0x00;
208380
+ pPtr[nData++] = 0x00;
207706208381
}
207707208382
}
207708208383
}else{
207709
- int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */
208384
+ int nSz = (nData - p->iSzPoslist - 1); /* Size in bytes */
207710208385
int nPos = nSz*2 + p->bDel; /* Value of nPos field */
207711208386
207712208387
assert( p->bDel==0 || p->bDel==1 );
207713208388
if( nPos<=127 ){
207714208389
pPtr[p->iSzPoslist] = (u8)nPos;
207715208390
}else{
207716208391
int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
207717208392
memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
207718208393
sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
207719
- p->nData += (nByte-1);
208394
+ nData += (nByte-1);
207720208395
}
207721208396
}
207722208397
207723
- p->iSzPoslist = 0;
207724
- p->bDel = 0;
207725
- p->bContent = 0;
208398
+ nRet = nData - p->nData;
208399
+ if( p2==0 ){
208400
+ p->iSzPoslist = 0;
208401
+ p->bDel = 0;
208402
+ p->bContent = 0;
208403
+ p->nData = nData;
208404
+ }
207726208405
}
208406
+ return nRet;
207727208407
}
207728208408
207729208409
/*
207730208410
** Add an entry to the in-memory hash table. The key is the concatenation
207731208411
** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).
@@ -207778,11 +208458,11 @@
207778208458
207779208459
/* Allocate new Fts5HashEntry and add it to the hash table. */
207780208460
p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
207781208461
if( !p ) return SQLITE_NOMEM;
207782208462
memset(p, 0, sizeof(Fts5HashEntry));
207783
- p->nAlloc = nByte;
208463
+ p->nAlloc = (int)nByte;
207784208464
zKey = fts5EntryKey(p);
207785208465
zKey[0] = bByte;
207786208466
memcpy(&zKey[1], pToken, nToken);
207787208467
assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
207788208468
p->nKey = nToken;
@@ -207833,11 +208513,11 @@
207833208513
pPtr = (u8*)p;
207834208514
207835208515
/* If this is a new rowid, append the 4-byte size field for the previous
207836208516
** entry, and the new rowid for this entry. */
207837208517
if( iRowid!=p->iRowid ){
207838
- fts5HashAddPoslistSize(pHash, p);
208518
+ fts5HashAddPoslistSize(pHash, p, 0);
207839208519
p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);
207840208520
p->iRowid = iRowid;
207841208521
bNew = 1;
207842208522
p->iSzPoslist = p->nData;
207843208523
if( pHash->eDetail!=FTS5_DETAIL_NONE ){
@@ -207950,11 +208630,13 @@
207950208630
memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
207951208631
207952208632
for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
207953208633
Fts5HashEntry *pIter;
207954208634
for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
207955
- if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
208635
+ if( pTerm==0
208636
+ || (pIter->nKey+1>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm))
208637
+ ){
207956208638
Fts5HashEntry *pEntry = pIter;
207957208639
pEntry->pScanNext = 0;
207958208640
for(i=0; ap[i]; i++){
207959208641
pEntry = fts5HashEntryMerge(pEntry, ap[i]);
207960208642
ap[i] = 0;
@@ -207978,12 +208660,13 @@
207978208660
/*
207979208661
** Query the hash table for a doclist associated with term pTerm/nTerm.
207980208662
*/
207981208663
static int sqlite3Fts5HashQuery(
207982208664
Fts5Hash *pHash, /* Hash table to query */
208665
+ int nPre,
207983208666
const char *pTerm, int nTerm, /* Query term */
207984
- const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
208667
+ void **ppOut, /* OUT: Pointer to new object */
207985208668
int *pnDoclist /* OUT: Size of doclist in bytes */
207986208669
){
207987208670
unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
207988208671
char *zKey = 0;
207989208672
Fts5HashEntry *p;
@@ -207993,15 +208676,24 @@
207993208676
assert( p->nKey+1==(int)strlen(zKey) );
207994208677
if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
207995208678
}
207996208679
207997208680
if( p ){
207998
- fts5HashAddPoslistSize(pHash, p);
207999
- *ppDoclist = (const u8*)&zKey[nTerm+1];
208000
- *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
208681
+ int nHashPre = sizeof(Fts5HashEntry) + nTerm + 1;
208682
+ int nList = p->nData - nHashPre;
208683
+ u8 *pRet = (u8*)(*ppOut = sqlite3_malloc64(nPre + nList + 10));
208684
+ if( pRet ){
208685
+ Fts5HashEntry *pFaux = (Fts5HashEntry*)&pRet[nPre-nHashPre];
208686
+ memcpy(&pRet[nPre], &((u8*)p)[nHashPre], nList);
208687
+ nList += fts5HashAddPoslistSize(pHash, p, pFaux);
208688
+ *pnDoclist = nList;
208689
+ }else{
208690
+ *pnDoclist = 0;
208691
+ return SQLITE_NOMEM;
208692
+ }
208001208693
}else{
208002
- *ppDoclist = 0;
208694
+ *ppOut = 0;
208003208695
*pnDoclist = 0;
208004208696
}
208005208697
208006208698
return SQLITE_OK;
208007208699
}
@@ -208030,11 +208722,11 @@
208030208722
){
208031208723
Fts5HashEntry *p;
208032208724
if( (p = pHash->pScan) ){
208033208725
char *zKey = fts5EntryKey(p);
208034208726
int nTerm = (int)strlen(zKey);
208035
- fts5HashAddPoslistSize(pHash, p);
208727
+ fts5HashAddPoslistSize(pHash, p, 0);
208036208728
*pzTerm = zKey;
208037208729
*ppDoclist = (const u8*)&zKey[nTerm+1];
208038208730
*pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
208039208731
}else{
208040208732
*pzTerm = 0;
@@ -210500,35 +211192,44 @@
210500211192
Fts5Index *p, /* FTS5 backend */
210501211193
const u8 *pTerm, int nTerm, /* Term to seek to */
210502211194
int flags, /* Mask of FTS5INDEX_XXX flags */
210503211195
Fts5SegIter *pIter /* Object to populate */
210504211196
){
210505
- const u8 *pList = 0;
210506211197
int nList = 0;
210507211198
const u8 *z = 0;
210508211199
int n = 0;
211200
+ Fts5Data *pLeaf = 0;
210509211201
210510211202
assert( p->pHash );
210511211203
assert( p->rc==SQLITE_OK );
210512211204
210513211205
if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){
211206
+ const u8 *pList = 0;
211207
+
210514211208
p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);
210515211209
sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);
210516211210
n = (z ? (int)strlen((const char*)z) : 0);
211211
+ if( pList ){
211212
+ pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));
211213
+ if( pLeaf ){
211214
+ pLeaf->p = (u8*)pList;
211215
+ }
211216
+ }
210517211217
}else{
210518
- pIter->flags |= FTS5_SEGITER_ONETERM;
210519
- sqlite3Fts5HashQuery(p->pHash, (const char*)pTerm, nTerm, &pList, &nList);
211218
+ p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data),
211219
+ (const char*)pTerm, nTerm, (void**)&pLeaf, &nList
211220
+ );
211221
+ if( pLeaf ){
211222
+ pLeaf->p = (u8*)&pLeaf[1];
211223
+ }
210520211224
z = pTerm;
210521211225
n = nTerm;
211226
+ pIter->flags |= FTS5_SEGITER_ONETERM;
210522211227
}
210523211228
210524
- if( pList ){
210525
- Fts5Data *pLeaf;
211229
+ if( pLeaf ){
210526211230
sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
210527
- pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));
210528
- if( pLeaf==0 ) return;
210529
- pLeaf->p = (u8*)pList;
210530211231
pLeaf->nn = pLeaf->szLeaf = nList;
210531211232
pIter->pLeaf = pLeaf;
210532211233
pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);
210533211234
pIter->iEndofDoclist = pLeaf->nn;
210534211235
@@ -215241,11 +215942,11 @@
215241215942
if( rc==SQLITE_OK ){
215242215943
nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
215243215944
pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
215244215945
if( pCsr ){
215245215946
Fts5Global *pGlobal = pTab->pGlobal;
215246
- memset(pCsr, 0, nByte);
215947
+ memset(pCsr, 0, (size_t)nByte);
215247215948
pCsr->aColumnSize = (int*)&pCsr[1];
215248215949
pCsr->pNext = pGlobal->pCsr;
215249215950
pGlobal->pCsr = pCsr;
215250215951
pCsr->iCsrId = ++pGlobal->iNextId;
215251215952
}else{
@@ -215522,11 +216223,11 @@
215522216223
215523216224
nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
215524216225
nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
215525216226
pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
215526216227
if( pSorter==0 ) return SQLITE_NOMEM;
215527
- memset(pSorter, 0, nByte);
216228
+ memset(pSorter, 0, (size_t)nByte);
215528216229
pSorter->nIdx = nPhrase;
215529216230
215530216231
/* TODO: It would be better to have some system for reusing statement
215531216232
** handles here, rather than preparing a new one for each query. But that
215532216233
** is not possible as SQLite reference counts the virtual table objects.
@@ -217256,11 +217957,11 @@
217256217957
int nArg, /* Number of args */
217257217958
sqlite3_value **apUnused /* Function arguments */
217258217959
){
217259217960
assert( nArg==0 );
217260217961
UNUSED_PARAM2(nArg, apUnused);
217261
- sqlite3_result_text(pCtx, "fts5: 2019-03-15 16:17:32 0f2129f59f7df929106e2af876c2976dea6528c1dc1850d64cddb256f20e121a", -1, SQLITE_TRANSIENT);
217962
+ sqlite3_result_text(pCtx, "fts5: 2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f", -1, SQLITE_TRANSIENT);
217262217963
}
217263217964
217264217965
/*
217265217966
** Return true if zName is the extension on one of the shadow tables used
217266217967
** by this module.
@@ -217679,11 +218380,11 @@
217679218380
nByte = sizeof(Fts5Storage) /* Fts5Storage object */
217680218381
+ pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */
217681218382
*pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
217682218383
if( !p ) return SQLITE_NOMEM;
217683218384
217684
- memset(p, 0, nByte);
218385
+ memset(p, 0, (size_t)nByte);
217685218386
p->aTotalSize = (i64*)&p[1];
217686218387
p->pConfig = pConfig;
217687218388
p->pIndex = pIndex;
217688218389
217689218390
if( bCreate ){
@@ -220589,11 +221290,11 @@
220589221290
int iTbl = 0;
220590221291
while( i<128 ){
220591221292
int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
220592221293
int n = (aFts5UnicodeData[iTbl] >> 5) + i;
220593221294
for(; i<128 && i<n; i++){
220594
- aAscii[i] = bToken;
221295
+ aAscii[i] = (u8)bToken;
220595221296
}
220596221297
iTbl++;
220597221298
}
220598221299
}
220599221300
@@ -222020,12 +222721,12 @@
222020222721
}
222021222722
#endif /* SQLITE_CORE */
222022222723
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
222023222724
222024222725
/************** End of stmt.c ************************************************/
222025
-#if __LINE__!=222025
222726
+#if __LINE__!=222726
222026222727
#undef SQLITE_SOURCE_ID
222027
-#define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07ealt2"
222728
+#define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2aalt2"
222028222729
#endif
222029222730
/* Return the source-id for this library */
222030222731
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
222031222732
/************************** End of sqlite3.c ******************************/
222032222733
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.28.0"
1166 #define SQLITE_VERSION_NUMBER 3028000
1167 #define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07e2f93"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -1226,10 +1226,13 @@
1226 ** [sqlite_compileoption_get()] and the [compile_options pragma].
1227 */
1228 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
1229 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
1230 SQLITE_API const char *sqlite3_compileoption_get(int N);
 
 
 
1231 #endif
1232
1233 /*
1234 ** CAPI3REF: Test To See If The Library Is Threadsafe
1235 **
@@ -3236,10 +3239,21 @@
3236 ** <li> The [PRAGMA writable_schema=ON] statement.
3237 ** <li> Writes to the [sqlite_dbpage] virtual table.
3238 ** <li> Direct writes to [shadow tables].
3239 ** </ul>
3240 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
3241 ** </dl>
3242 */
3243 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3244 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3245 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3249,11 +3263,12 @@
3249 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3250 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3251 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
3252 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
3253 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3254 #define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
 
3255
3256 /*
3257 ** CAPI3REF: Enable Or Disable Extended Result Codes
3258 ** METHOD: sqlite3
3259 **
@@ -6001,10 +6016,12 @@
6001 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
6002 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
6003 ** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
6004 ** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
6005 ** against a virtual table.
 
 
6006 ** </table></blockquote>
6007 **
6008 ** <b>Details:</b>
6009 **
6010 ** These routines extract type, size, and content information from
@@ -6061,10 +6078,15 @@
6061 ** was unchanging). ^Within an [xUpdate] method, any value for which
6062 ** sqlite3_value_nochange(X) is true will in all other respects appear
6063 ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
6064 ** than within an [xUpdate] method call for an UPDATE statement, then
6065 ** the return value is arbitrary and meaningless.
 
 
 
 
 
6066 **
6067 ** Please pay particular attention to the fact that the pointer returned
6068 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
6069 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
6070 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6107,10 +6129,11 @@
6107 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
6108 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
6109 SQLITE_API int sqlite3_value_type(sqlite3_value*);
6110 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
6111 SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
 
6112
6113 /*
6114 ** CAPI3REF: Finding The Subtype Of SQL Values
6115 ** METHOD: sqlite3_value
6116 **
@@ -11943,11 +11966,11 @@
11943 **
11944 ** Argument pIn must point to a buffer containing a changeset nIn bytes
11945 ** in size. This function allocates and populates a buffer with a copy
11946 ** of the changeset rebased rebased according to the configuration of the
11947 ** rebaser object passed as the first argument. If successful, (*ppOut)
11948 ** is set to point to the new buffer containing the rebased changset and
11949 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
11950 ** responsibility of the caller to eventually free the new buffer using
11951 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
11952 ** are set to zero and an SQLite error code returned.
11953 */
@@ -13534,96 +13557,100 @@
13534 #define TK_FOLLOWING 83
13535 #define TK_PARTITION 84
13536 #define TK_PRECEDING 85
13537 #define TK_RANGE 86
13538 #define TK_UNBOUNDED 87
13539 #define TK_REINDEX 88
13540 #define TK_RENAME 89
13541 #define TK_CTIME_KW 90
13542 #define TK_ANY 91
13543 #define TK_BITAND 92
13544 #define TK_BITOR 93
13545 #define TK_LSHIFT 94
13546 #define TK_RSHIFT 95
13547 #define TK_PLUS 96
13548 #define TK_MINUS 97
13549 #define TK_STAR 98
13550 #define TK_SLASH 99
13551 #define TK_REM 100
13552 #define TK_CONCAT 101
13553 #define TK_COLLATE 102
13554 #define TK_BITNOT 103
13555 #define TK_ON 104
13556 #define TK_INDEXED 105
13557 #define TK_STRING 106
13558 #define TK_JOIN_KW 107
13559 #define TK_CONSTRAINT 108
13560 #define TK_DEFAULT 109
13561 #define TK_NULL 110
13562 #define TK_PRIMARY 111
13563 #define TK_UNIQUE 112
13564 #define TK_CHECK 113
13565 #define TK_REFERENCES 114
13566 #define TK_AUTOINCR 115
13567 #define TK_INSERT 116
13568 #define TK_DELETE 117
13569 #define TK_UPDATE 118
13570 #define TK_SET 119
13571 #define TK_DEFERRABLE 120
13572 #define TK_FOREIGN 121
13573 #define TK_DROP 122
13574 #define TK_UNION 123
13575 #define TK_ALL 124
13576 #define TK_EXCEPT 125
13577 #define TK_INTERSECT 126
13578 #define TK_SELECT 127
13579 #define TK_VALUES 128
13580 #define TK_DISTINCT 129
13581 #define TK_DOT 130
13582 #define TK_FROM 131
13583 #define TK_JOIN 132
13584 #define TK_USING 133
13585 #define TK_ORDER 134
13586 #define TK_GROUP 135
13587 #define TK_HAVING 136
13588 #define TK_LIMIT 137
13589 #define TK_WHERE 138
13590 #define TK_INTO 139
13591 #define TK_NOTHING 140
13592 #define TK_FLOAT 141
13593 #define TK_BLOB 142
13594 #define TK_INTEGER 143
13595 #define TK_VARIABLE 144
13596 #define TK_CASE 145
13597 #define TK_WHEN 146
13598 #define TK_THEN 147
13599 #define TK_ELSE 148
13600 #define TK_INDEX 149
13601 #define TK_ALTER 150
13602 #define TK_ADD 151
13603 #define TK_WINDOW 152
13604 #define TK_OVER 153
13605 #define TK_FILTER 154
13606 #define TK_TRUEFALSE 155
13607 #define TK_ISNOT 156
13608 #define TK_FUNCTION 157
13609 #define TK_COLUMN 158
13610 #define TK_AGG_FUNCTION 159
13611 #define TK_AGG_COLUMN 160
13612 #define TK_UMINUS 161
13613 #define TK_UPLUS 162
13614 #define TK_TRUTH 163
13615 #define TK_REGISTER 164
13616 #define TK_VECTOR 165
13617 #define TK_SELECT_COLUMN 166
13618 #define TK_IF_NULL_ROW 167
13619 #define TK_ASTERISK 168
13620 #define TK_SPAN 169
13621 #define TK_END_OF_FILE 170
13622 #define TK_UNCLOSED_STRING 171
13623 #define TK_SPACE 172
13624 #define TK_ILLEGAL 173
 
 
 
 
13625
13626 /* The token codes above must all fit in 8 bits */
13627 #define TKFLG_MASK 0xff
13628
13629 /* Flags that can be added to a token code when it is not
@@ -14558,13 +14585,10 @@
14558 };
14559
14560 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
14561 int flags, int seekResult);
14562 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
14563 #ifndef SQLITE_OMIT_WINDOWFUNC
14564 SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor*);
14565 #endif
14566 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
14567 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
14568 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
14569 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
14570 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14918,29 +14942,29 @@
14918 #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14919 #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14920 #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */
14921 #define OP_Column 90 /* synopsis: r[P3]=PX */
14922 #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
14923 #define OP_BitAnd 92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14924 #define OP_BitOr 93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14925 #define OP_ShiftLeft 94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14926 #define OP_ShiftRight 95 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14927 #define OP_Add 96 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14928 #define OP_Subtract 97 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14929 #define OP_Multiply 98 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14930 #define OP_Divide 99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14931 #define OP_Remainder 100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14932 #define OP_Concat 101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14933 #define OP_MakeRecord 102 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14934 #define OP_BitNot 103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14935 #define OP_Count 104 /* synopsis: r[P2]=count() */
14936 #define OP_ReadCookie 105
14937 #define OP_String8 106 /* same as TK_STRING, synopsis: r[P2]='P4' */
14938 #define OP_SetCookie 107
14939 #define OP_ReopenIdx 108 /* synopsis: root=P2 iDb=P3 */
14940 #define OP_OpenRead 109 /* synopsis: root=P2 iDb=P3 */
14941 #define OP_OpenWrite 110 /* synopsis: root=P2 iDb=P3 */
14942 #define OP_OpenDup 111
14943 #define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */
14944 #define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */
14945 #define OP_SorterOpen 114
14946 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
@@ -14967,15 +14991,15 @@
14967 #define OP_Destroy 136
14968 #define OP_Clear 137
14969 #define OP_ResetSorter 138
14970 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14971 #define OP_SqlExec 140
14972 #define OP_Real 141 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
14973 #define OP_ParseSchema 142
14974 #define OP_LoadAnalysis 143
14975 #define OP_DropTable 144
14976 #define OP_DropIndex 145
14977 #define OP_DropTrigger 146
14978 #define OP_IntegrityCk 147
14979 #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
14980 #define OP_Param 149
14981 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
@@ -15022,18 +15046,18 @@
15022 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15023 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15024 /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15025 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15026 /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15027 /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x26, 0x26, 0x26, 0x26,\
15028 /* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
15029 /* 104 */ 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15030 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15031 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15032 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15033 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00,\
15034 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15035 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15036 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15037 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15038
15039 /* The sqlite3P2Values() routine is able to run faster if it knows
@@ -16479,11 +16503,11 @@
16479 ** Bits of the sqlite3.dbOptFlags field that are used by the
16480 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
16481 ** selectively disable various optimizations.
16482 */
16483 #define SQLITE_QueryFlattener 0x0001 /* Query flattening */
16484 /* 0x0002 available for reuse */
16485 #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */
16486 #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */
16487 #define SQLITE_DistinctOpt 0x0010 /* DISTINCT using indexes */
16488 #define SQLITE_CoverIdxScan 0x0020 /* Covering index scans */
16489 #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
@@ -16597,11 +16621,10 @@
16597 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
16598 ** single query - might change over time */
16599 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16600 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16601 #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
16602 #define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
16603 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
16604
16605 /*
16606 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16607 ** used to create the initializers for the FuncDef structures.
@@ -17403,16 +17426,20 @@
17403 } y;
17404 };
17405
17406 /*
17407 ** The following are the meanings of bits in the Expr.flags field.
 
 
 
 
17408 */
17409 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17410 #define EP_Agg 0x000002 /* Contains one or more aggregate functions */
17411 #define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17412 #define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17413 #define EP_Distinct 0x000010 /* Aggregate function with DISTINCT keyword */
17414 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17415 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17416 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17417 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17418 #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
@@ -17419,11 +17446,11 @@
17419 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17420 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17421 #define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */
17422 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17423 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17424 #define EP_Static 0x008000 /* Held in memory not obtained from malloc() */
17425 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17426 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17427 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17428 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17429 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
@@ -17431,10 +17458,11 @@
17431 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17432 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17433 #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17434 #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17435 #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
 
17436
17437 /*
17438 ** The EP_Propagate mask is a set of properties that automatically propagate
17439 ** upwards into parent nodes.
17440 */
@@ -17670,12 +17698,13 @@
17670
17671 /*
17672 ** Allowed values for the NameContext, ncFlags field.
17673 **
17674 ** Value constraints (all checked via assert()):
17675 ** NC_HasAgg == SF_HasAgg
17676 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
 
17677 **
17678 */
17679 #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
17680 #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */
17681 #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
@@ -17687,10 +17716,11 @@
17687 #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17688 #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17689 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17690 #define NC_Complex 0x2000 /* True if a function or subquery seen */
17691 #define NC_AllowWin 0x4000 /* Window functions are allowed here */
 
17692
17693 /*
17694 ** An instance of the following object describes a single ON CONFLICT
17695 ** clause in an upsert.
17696 **
@@ -18442,11 +18472,11 @@
18442 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
18443 };
18444 #endif /* SQLITE_DEBUG */
18445
18446 /*
18447 ** This object is used in varioius ways, all related to window functions
18448 **
18449 ** (1) A single instance of this structure is attached to the
18450 ** the Expr.pWin field for each window function in an expression tree.
18451 ** This object holds the information contained in the OVER clause,
18452 ** plus additional fields used during code generation.
@@ -18457,19 +18487,22 @@
18457 **
18458 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
18459 ** object on a linked list attached to Select.pWinDefn.
18460 **
18461 ** The uses (1) and (2) are really the same Window object that just happens
18462 ** to be accessible in two different ways. Use (3) is are separate objects.
18463 */
18464 struct Window {
18465 char *zName; /* Name of window (may be NULL) */
 
18466 ExprList *pPartition; /* PARTITION BY clause */
18467 ExprList *pOrderBy; /* ORDER BY clause */
18468 u8 eType; /* TK_RANGE or TK_ROWS */
18469 u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18470 u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
 
 
18471 Expr *pStart; /* Expression for "<expr> PRECEDING" */
18472 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18473 Window *pNextWin; /* Next window function belonging to this SELECT */
18474 Expr *pFilter; /* The FILTER expression */
18475 FuncDef *pFunc; /* The function */
@@ -18476,21 +18509,23 @@
18476 int iEphCsr; /* Partition buffer or Peer buffer */
18477 int regAccum;
18478 int regResult;
18479 int csrApp; /* Function cursor (used by min/max) */
18480 int regApp; /* Function register (also used by min/max) */
18481 int regPart; /* First in a set of registers holding PARTITION BY
18482 ** and ORDER BY values for the window */
18483 Expr *pOwner; /* Expression object this window is attached to */
18484 int nBufferCol; /* Number of columns in buffer table */
18485 int iArgCol; /* Offset of first argument for this function */
 
 
 
18486 };
18487
18488 #ifndef SQLITE_OMIT_WINDOWFUNC
18489 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18490 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18491 SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
18492 SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18493 SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
18494 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18495 SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18496 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
@@ -18497,10 +18532,12 @@
18497 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18498 SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
18499 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
18500 SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
18501 SQLITE_PRIVATE void sqlite3WindowFunctions(void);
 
 
18502 #else
18503 # define sqlite3WindowDelete(a,b)
18504 # define sqlite3WindowFunctions()
18505 # define sqlite3WindowAttach(a,b,c)
18506 #endif
@@ -20149,15 +20186,15 @@
20149 #define MEM_Str 0x0002 /* Value is a string */
20150 #define MEM_Int 0x0004 /* Value is an integer */
20151 #define MEM_Real 0x0008 /* Value is a real number */
20152 #define MEM_Blob 0x0010 /* Value is a BLOB */
20153 #define MEM_AffMask 0x001f /* Mask of affinity bits */
20154 /* Available 0x0020 */
20155 /* Available 0x0040 */
20156 #define MEM_Undefined 0x0080 /* Value is undefined */
20157 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
20158 #define MEM_TypeMask 0xc1ff /* Mask of type bits */
20159
20160
20161 /* Whenever Mem contains a valid string or blob representation, one of
20162 ** the following flags must be set to determine the memory management
20163 ** policy for Mem.z. The MEM_Term flag tells us whether or not the
@@ -28786,28 +28823,66 @@
28786 #ifndef SQLITE_OMIT_WINDOWFUNC
28787 /*
28788 ** Generate a human-readable explanation for a Window object
28789 */
28790 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){
 
 
 
 
 
 
28791 pView = sqlite3TreeViewPush(pView, more);
28792 if( pWin->zName ){
28793 sqlite3TreeViewLine(pView, "OVER %s", pWin->zName);
28794 }else{
28795 sqlite3TreeViewLine(pView, "OVER");
 
 
 
 
 
 
 
 
 
28796 }
28797 if( pWin->pPartition ){
28798 sqlite3TreeViewExprList(pView, pWin->pPartition, 1, "PARTITION-BY");
28799 }
28800 if( pWin->pOrderBy ){
28801 sqlite3TreeViewExprList(pView, pWin->pOrderBy, 1, "ORDER-BY");
28802 }
28803 if( pWin->eType ){
28804 sqlite3TreeViewItem(pView, pWin->eType==TK_RANGE ? "RANGE" : "ROWS", 0);
 
 
 
 
 
 
28805 sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
28806 sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
28807 sqlite3TreeViewPop(pView);
28808 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28809 sqlite3TreeViewPop(pView);
28810 }
28811 #endif /* SQLITE_OMIT_WINDOWFUNC */
28812
28813 #ifndef SQLITE_OMIT_WINDOWFUNC
@@ -32124,29 +32199,29 @@
32124 /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32125 /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32126 /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32127 /* 90 */ "Column" OpHelp("r[P3]=PX"),
32128 /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32129 /* 92 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32130 /* 93 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32131 /* 94 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32132 /* 95 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32133 /* 96 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32134 /* 97 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32135 /* 98 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32136 /* 99 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32137 /* 100 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32138 /* 101 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32139 /* 102 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32140 /* 103 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32141 /* 104 */ "Count" OpHelp("r[P2]=count()"),
32142 /* 105 */ "ReadCookie" OpHelp(""),
32143 /* 106 */ "String8" OpHelp("r[P2]='P4'"),
32144 /* 107 */ "SetCookie" OpHelp(""),
32145 /* 108 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32146 /* 109 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32147 /* 110 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32148 /* 111 */ "OpenDup" OpHelp(""),
32149 /* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32150 /* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32151 /* 114 */ "SorterOpen" OpHelp(""),
32152 /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
@@ -32173,15 +32248,15 @@
32173 /* 136 */ "Destroy" OpHelp(""),
32174 /* 137 */ "Clear" OpHelp(""),
32175 /* 138 */ "ResetSorter" OpHelp(""),
32176 /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32177 /* 140 */ "SqlExec" OpHelp(""),
32178 /* 141 */ "Real" OpHelp("r[P2]=P4"),
32179 /* 142 */ "ParseSchema" OpHelp(""),
32180 /* 143 */ "LoadAnalysis" OpHelp(""),
32181 /* 144 */ "DropTable" OpHelp(""),
32182 /* 145 */ "DropIndex" OpHelp(""),
32183 /* 146 */ "DropTrigger" OpHelp(""),
32184 /* 147 */ "IntegrityCk" OpHelp(""),
32185 /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32186 /* 149 */ "Param" OpHelp(""),
32187 /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
@@ -59204,10 +59279,11 @@
59204 static void walCleanupHash(Wal *pWal){
59205 WalHashLoc sLoc; /* Hash table location */
59206 int iLimit = 0; /* Zero values greater than this */
59207 int nByte; /* Number of bytes to zero in aPgno[] */
59208 int i; /* Used to iterate through aHash[] */
 
59209
59210 assert( pWal->writeLock );
59211 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
59212 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
59213 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -59214,15 +59290,16 @@
59214
59215 if( pWal->hdr.mxFrame==0 ) return;
59216
59217 /* Obtain pointers to the hash-table and page-number array containing
59218 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
59219 ** that the page said hash-table and array reside on is already mapped.
59220 */
59221 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
59222 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
59223 walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
 
59224
59225 /* Zero all hash-table entries that correspond to frame numbers greater
59226 ** than pWal->hdr.mxFrame.
59227 */
59228 iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -63922,18 +63999,22 @@
63922 ** at most one effective restoreCursorPosition() call after each
63923 ** saveCursorPosition().
63924 */
63925 static int btreeRestoreCursorPosition(BtCursor *pCur){
63926 int rc;
63927 int skipNext;
63928 assert( cursorOwnsBtShared(pCur) );
63929 assert( pCur->eState>=CURSOR_REQUIRESEEK );
63930 if( pCur->eState==CURSOR_FAULT ){
63931 return pCur->skipNext;
63932 }
63933 pCur->eState = CURSOR_INVALID;
63934 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
 
 
 
 
63935 if( rc==SQLITE_OK ){
63936 sqlite3_free(pCur->pKey);
63937 pCur->pKey = 0;
63938 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
63939 if( skipNext ) pCur->skipNext = skipNext;
@@ -64521,15 +64602,11 @@
64521 ** two (or one) blocks of cells using memmove() and add the required
64522 ** offsets to each pointer in the cell-pointer array than it is to
64523 ** reconstruct the entire page. */
64524 if( (int)data[hdr+7]<=nMaxFrag ){
64525 int iFree = get2byte(&data[hdr+1]);
64526
64527 /* If the initial freeblock offset were out of bounds, that would have
64528 ** been detected by btreeComputeFreeSpace() when it was computing the
64529 ** number of free bytes on the page. */
64530 assert( iFree<=usableSize-4 );
64531 if( iFree ){
64532 int iFree2 = get2byte(&data[iFree]);
64533 if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
64534 if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
64535 u8 *pEnd = &data[cellOffset + nCell*2];
@@ -64544,11 +64621,14 @@
64544 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
64545 sz2 = get2byte(&data[iFree2+2]);
64546 if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
64547 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
64548 sz += sz2;
 
 
64549 }
 
64550 cbrk = top+sz;
64551 assert( cbrk+(iFree-top) <= usableSize );
64552 memmove(&data[cbrk], &data[top], iFree-top);
64553 for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){
64554 pc = get2byte(pAddr);
@@ -65102,11 +65182,11 @@
65102 /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
65103 ** possible for a root page of a table that contains no rows) then the
65104 ** offset to the cell content area will equal the page size minus the
65105 ** bytes of reserved space. */
65106 assert( pPage->nCell>0
65107 || get2byteNotZero(&data[5])==pBt->usableSize
65108 || CORRUPT_DB );
65109 pPage->nFree = -1; /* Indicate that this value is yet uncomputed */
65110 pPage->isInit = 1;
65111 if( pBt->db->flags & SQLITE_CellSizeCk ){
65112 return btreeCellSizeCheck(pPage);
@@ -68359,27 +68439,10 @@
68359 rc = SQLITE_OK;
68360 }
68361 return rc;
68362 }
68363
68364 /*
68365 ** This function is a no-op if cursor pCur does not point to a valid row.
68366 ** Otherwise, if pCur is valid, configure it so that the next call to
68367 ** sqlite3BtreeNext() is a no-op.
68368 */
68369 #ifndef SQLITE_OMIT_WINDOWFUNC
68370 SQLITE_PRIVATE void sqlite3BtreeSkipNext(BtCursor *pCur){
68371 /* We believe that the cursor must always be in the valid state when
68372 ** this routine is called, but the proof is difficult, so we add an
68373 ** ALWaYS() test just in case we are wrong. */
68374 if( ALWAYS(pCur->eState==CURSOR_VALID) ){
68375 pCur->eState = CURSOR_SKIPNEXT;
68376 pCur->skipNext = 1;
68377 }
68378 }
68379 #endif /* SQLITE_OMIT_WINDOWFUNC */
68380
68381 /* Move the cursor to the last entry in the table. Return SQLITE_OK
68382 ** on success. Set *pRes to 0 if the cursor actually points to something
68383 ** or set *pRes to 1 if the table is empty.
68384 */
68385 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -69279,11 +69342,13 @@
69279
69280 assert( sqlite3_mutex_held(pBt->mutex) );
69281 assert( CORRUPT_DB || iPage>1 );
69282 assert( !pMemPage || pMemPage->pgno==iPage );
69283
69284 if( iPage<2 ) return SQLITE_CORRUPT_BKPT;
 
 
69285 if( pMemPage ){
69286 pPage = pMemPage;
69287 sqlite3PagerRef(pPage->pDbPage);
69288 }else{
69289 pPage = btreePageLookup(pBt, iPage);
@@ -70648,11 +70713,10 @@
70648 if( rc ){
70649 memset(apOld, 0, (i)*sizeof(MemPage*));
70650 goto balance_cleanup;
70651 }
70652 }
70653 nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
70654 if( (i--)==0 ) break;
70655
70656 if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
70657 apDiv[i] = pParent->apOvfl[0];
70658 pgno = get4byte(apDiv[i]);
@@ -70692,10 +70756,11 @@
70692 }
70693 }
70694
70695 /* Make nMaxCells a multiple of 4 in order to preserve 8-byte
70696 ** alignment */
 
70697 nMaxCells = (nMaxCells + 3)&~3;
70698
70699 /*
70700 ** Allocate space for memory structures
70701 */
@@ -70702,11 +70767,11 @@
70702 szScratch =
70703 nMaxCells*sizeof(u8*) /* b.apCell */
70704 + nMaxCells*sizeof(u16) /* b.szCell */
70705 + pBt->pageSize; /* aSpace1 */
70706
70707 assert( szScratch<=6*(int)pBt->pageSize );
70708 b.apCell = sqlite3StackAllocRaw(0, szScratch );
70709 if( b.apCell==0 ){
70710 rc = SQLITE_NOMEM_BKPT;
70711 goto balance_cleanup;
70712 }
@@ -71252,11 +71317,12 @@
71252 */
71253 assert( nNew==1 || CORRUPT_DB );
71254 rc = defragmentPage(apNew[0], -1);
71255 testcase( rc!=SQLITE_OK );
71256 assert( apNew[0]->nFree ==
71257 (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
 
71258 || rc!=SQLITE_OK
71259 );
71260 copyNodeContent(apNew[0], pParent, &rc);
71261 freePage(apNew[0], &rc);
71262 }else if( ISAUTOVACUUM && !leafCorrection ){
@@ -71917,13 +71983,16 @@
71917 assert( pBt->inTransaction==TRANS_WRITE );
71918 assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );
71919 assert( pCur->curFlags & BTCF_WriteFlag );
71920 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
71921 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
71922 assert( pCur->ix<pCur->pPage->nCell );
71923 assert( pCur->eState==CURSOR_VALID );
71924 assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
 
 
 
 
 
71925
71926 iCellDepth = pCur->iPage;
71927 iCellIdx = pCur->ix;
71928 pPage = pCur->pPage;
71929 pCell = findCell(pPage, iCellIdx);
@@ -74387,11 +74456,11 @@
74387 assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +
74388 ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +
74389 ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );
74390
74391 /* No other bits set */
74392 assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype
74393 |MEM_Dyn|MEM_Ephem|MEM_Static))==0 );
74394 }else{
74395 /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,
74396 ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */
74397 }
@@ -81474,10 +81543,15 @@
81474
81475 /* Return true if a parameter to xUpdate represents an unchanged column */
81476 SQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){
81477 return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero);
81478 }
 
 
 
 
 
81479
81480 /* Make a copy of an sqlite3_value object
81481 */
81482 SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){
81483 sqlite3_value *pNew;
@@ -83505,16 +83579,24 @@
83505 /*
83506 ** Invoke the VDBE coverage callback, if that callback is defined. This
83507 ** feature is used for test suite validation only and does not appear an
83508 ** production builds.
83509 **
83510 ** M is an integer between 2 and 4. 2 indicates a ordinary two-way
83511 ** branch (I=0 means fall through and I=1 means taken). 3 indicates
83512 ** a 3-way branch where the third way is when one of the operands is
83513 ** NULL. 4 indicates the OP_Jump instruction which has three destinations
83514 ** depending on whether the first operand is less than, equal to, or greater
83515 ** than the second.
 
 
 
 
 
 
 
 
83516 **
83517 ** iSrcLine is the source code line (from the __LINE__ macro) that
83518 ** generated the VDBE instruction combined with flag bits. The source
83519 ** code line number is in the lower 24 bits of iSrcLine and the upper
83520 ** 8 bytes are flags. The lower three bits of the flags indicate
@@ -83521,13 +83603,13 @@
83521 ** values for I that should never occur. For example, if the branch is
83522 ** always taken, the flags should be 0x05 since the fall-through and
83523 ** alternate branch are never taken. If a branch is never taken then
83524 ** flags should be 0x06 since only the fall-through approach is allowed.
83525 **
83526 ** Bit 0x04 of the flags indicates an OP_Jump opcode that is only
83527 ** interested in equal or not-equal. In other words, I==0 and I==2
83528 ** should be treated the same.
83529 **
83530 ** Since only a line number is retained, not the filename, this macro
83531 ** only works for amalgamation builds. But that is ok, since these macros
83532 ** should be no-ops except for special builds used to measure test coverage.
83533 */
@@ -83547,10 +83629,22 @@
83547 ** a branch really does go in one of those directions, assert right
83548 ** away. */
83549 mNever = iSrcLine >> 24;
83550 assert( (I & mNever)==0 );
83551 if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
 
 
 
 
 
 
 
 
 
 
 
 
83552 I |= mNever;
83553 if( M==2 ) I |= 0x04;
83554 if( M==4 ){
83555 I |= 0x08;
83556 if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/
@@ -84708,11 +84802,14 @@
84708 pVar = &p->aVar[pOp->p1 - 1];
84709 if( sqlite3VdbeMemTooBig(pVar) ){
84710 goto too_big;
84711 }
84712 pOut = &aMem[pOp->p2];
84713 sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
 
 
 
84714 UPDATE_MAX_BLOBSIZE(pOut);
84715 break;
84716 }
84717
84718 /* Opcode: Move P1 P2 P3 * *
@@ -85206,20 +85303,21 @@
85206 */
85207 case OP_MustBeInt: { /* jump, in1 */
85208 pIn1 = &aMem[pOp->p1];
85209 if( (pIn1->flags & MEM_Int)==0 ){
85210 applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
85211 VdbeBranchTaken((pIn1->flags&MEM_Int)==0, 2);
85212 if( (pIn1->flags & MEM_Int)==0 ){
 
85213 if( pOp->p2==0 ){
85214 rc = SQLITE_MISMATCH;
85215 goto abort_due_to_error;
85216 }else{
85217 goto jump_to_p2;
85218 }
85219 }
85220 }
 
85221 MemSetTypeFlag(pIn1, MEM_Int);
85222 break;
85223 }
85224
85225 #ifndef SQLITE_OMIT_FLOATING_POINT
@@ -85390,20 +85488,19 @@
85390 if( pOp->p5 & SQLITE_NULLEQ ){
85391 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
85392 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
85393 ** or not both operands are null.
85394 */
85395 assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
85396 assert( (flags1 & MEM_Cleared)==0 );
85397 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );
85398 testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );
85399 if( (flags1&flags3&MEM_Null)!=0
85400 && (flags3&MEM_Cleared)==0
85401 ){
85402 res = 0; /* Operands are equal */
85403 }else{
85404 res = 1; /* Operands are not equal */
85405 }
85406 }else{
85407 /* SQLITE_NULLEQ is clear and at least one operand is NULL,
85408 ** then the result is always NULL.
85409 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
@@ -85517,11 +85614,11 @@
85517 memAboutToChange(p, pOut);
85518 MemSetTypeFlag(pOut, MEM_Int);
85519 pOut->u.i = res2;
85520 REGISTER_TRACE(pOp->p2, pOut);
85521 }else{
85522 VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
85523 if( res2 ){
85524 goto jump_to_p2;
85525 }
85526 }
85527 break;
@@ -87078,10 +87175,11 @@
87078 pCx->nullRow = 1;
87079 pCx->isEphemeral = 1;
87080 pCx->pKeyInfo = pOrig->pKeyInfo;
87081 pCx->isTable = pOrig->isTable;
87082 pCx->pgnoRoot = pOrig->pgnoRoot;
 
87083 rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
87084 pCx->pKeyInfo, pCx->uc.pCursor);
87085 /* The sqlite3BtreeCursor() routine can only fail for the first cursor
87086 ** opened for a database. Since there is already an open cursor when this
87087 ** opcode is run, the sqlite3BtreeCursor() cannot fail */
@@ -88586,22 +88684,18 @@
88586 sqlite3_search_count--;
88587 #endif
88588 p->aCounter[SQLITE_STMTSTATUS_SORT]++;
88589 /* Fall through into OP_Rewind */
88590 }
88591 /* Opcode: Rewind P1 P2 * * P5
88592 **
88593 ** The next use of the Rowid or Column or Next instruction for P1
88594 ** will refer to the first entry in the database table or index.
88595 ** If the table or index is empty, jump immediately to P2.
88596 ** If the table or index is not empty, fall through to the following
88597 ** instruction.
88598 **
88599 ** If P5 is non-zero and the table is not empty, then the "skip-next"
88600 ** flag is set on the cursor so that the next OP_Next instruction
88601 ** executed on it is a no-op.
88602 **
88603 ** This opcode leaves the cursor configured to move in forward order,
88604 ** from the beginning toward the end. In other words, the cursor is
88605 ** configured to use Next, not Prev.
88606 */
88607 case OP_Rewind: { /* jump */
@@ -88608,10 +88702,11 @@
88608 VdbeCursor *pC;
88609 BtCursor *pCrsr;
88610 int res;
88611
88612 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
 
88613 pC = p->apCsr[pOp->p1];
88614 assert( pC!=0 );
88615 assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );
88616 res = 1;
88617 #ifdef SQLITE_DEBUG
@@ -88622,13 +88717,10 @@
88622 }else{
88623 assert( pC->eCurType==CURTYPE_BTREE );
88624 pCrsr = pC->uc.pCursor;
88625 assert( pCrsr );
88626 rc = sqlite3BtreeFirst(pCrsr, &res);
88627 #ifndef SQLITE_OMIT_WINDOWFUNC
88628 if( pOp->p5 ) sqlite3BtreeSkipNext(pCrsr);
88629 #endif
88630 pC->deferredMoveto = 0;
88631 pC->cacheStatus = CACHE_STALE;
88632 }
88633 if( rc ) goto abort_due_to_error;
88634 pC->nullRow = (u8)res;
@@ -90006,10 +90098,11 @@
90006 assert( pOp->p3==0 || pOp->opcode==OP_AggValue );
90007 pMem = &aMem[pOp->p1];
90008 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
90009 #ifndef SQLITE_OMIT_WINDOWFUNC
90010 if( pOp->p3 ){
 
90011 rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
90012 pMem = &aMem[pOp->p3];
90013 }else
90014 #endif
90015 {
@@ -95424,10 +95517,14 @@
95424 assert( pExpr->x.pSelect==0 );
95425 pOrig = pEList->a[j].pExpr;
95426 if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){
95427 sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs);
95428 return WRC_Abort;
 
 
 
 
95429 }
95430 if( sqlite3ExprVectorSize(pOrig)!=1 ){
95431 sqlite3ErrorMsg(pParse, "row value misused");
95432 return WRC_Abort;
95433 }
@@ -95715,10 +95812,11 @@
95715 int is_agg = 0; /* True if is an aggregate function */
95716 int nId; /* Number of characters in function name */
95717 const char *zId; /* The function name. */
95718 FuncDef *pDef; /* Information about the function */
95719 u8 enc = ENC(pParse->db); /* The database encoding */
 
95720
95721 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
95722 zId = pExpr->u.zToken;
95723 nId = sqlite3Strlen30(zId);
95724 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
@@ -95836,12 +95934,15 @@
95836 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
95837 nId, zId);
95838 pNC->nErr++;
95839 }
95840 if( is_agg ){
 
 
 
95841 #ifndef SQLITE_OMIT_WINDOWFUNC
95842 pNC->ncFlags &= ~(pExpr->y.pWin ? NC_AllowWin : NC_AllowAgg);
95843 #else
95844 pNC->ncFlags &= ~NC_AllowAgg;
95845 #endif
95846 }
95847 }
@@ -95858,11 +95959,11 @@
95858 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
95859 ){
95860 pExpr->y.pWin->pNextWin = pSel->pWin;
95861 pSel->pWin = pExpr->y.pWin;
95862 }
95863 pNC->ncFlags |= NC_AllowWin;
95864 }else
95865 #endif /* SQLITE_OMIT_WINDOWFUNC */
95866 {
95867 NameContext *pNC2 = pNC;
95868 pExpr->op = TK_AGG_FUNCTION;
@@ -95876,12 +95977,12 @@
95876 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
95877 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
95878 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
95879
95880 }
95881 pNC->ncFlags |= NC_AllowAgg;
95882 }
 
95883 }
95884 /* FIX ME: Compute pExpr->affinity based on the expected return
95885 ** type of the function
95886 */
95887 return WRC_Prune;
@@ -96414,11 +96515,11 @@
96414
96415 /* Recursively resolve names in all subqueries
96416 */
96417 for(i=0; i<p->pSrc->nSrc; i++){
96418 struct SrcList_item *pItem = &p->pSrc->a[i];
96419 if( pItem->pSelect ){
96420 NameContext *pNC; /* Used to iterate name contexts */
96421 int nRef = 0; /* Refcount for pOuterNC and outer contexts */
96422 const char *zSavedContext = pParse->zAuthContext;
96423
96424 /* Count the total number of references to pOuterNC and all of its
@@ -96638,12 +96739,12 @@
96638 ){
96639 u16 savedHasAgg;
96640 Walker w;
96641
96642 if( pExpr==0 ) return SQLITE_OK;
96643 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg);
96644 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg);
96645 w.pParse = pNC->pParse;
96646 w.xExprCallback = resolveExprStep;
96647 w.xSelectCallback = resolveSelectStep;
96648 w.xSelectCallback2 = 0;
96649 w.u.pNC = pNC;
@@ -96655,13 +96756,15 @@
96655 #endif
96656 sqlite3WalkExpr(&w, pExpr);
96657 #if SQLITE_MAX_EXPR_DEPTH>0
96658 w.pParse->nHeight -= pExpr->nHeight;
96659 #endif
96660 if( pNC->ncFlags & NC_HasAgg ){
96661 ExprSetProperty(pExpr, EP_Agg);
96662 }
 
 
96663 pNC->ncFlags |= savedHasAgg;
96664 return pNC->nErr>0 || w.pParse->nErr>0;
96665 }
96666
96667 /*
@@ -101788,10 +101891,21 @@
101788 ** be non-NULL, then the LEFT JOIN can be safely converted into an
101789 ** ordinary join.
101790 */
101791 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
101792 Walker w;
 
 
 
 
 
 
 
 
 
 
 
101793 w.xExprCallback = impliesNotNullRow;
101794 w.xSelectCallback = 0;
101795 w.xSelectCallback2 = 0;
101796 w.eCode = 0;
101797 w.u.iCur = iTab;
@@ -106961,10 +107075,11 @@
106961 if( zSql==0 ){
106962 /* This can result either from an OOM or because the formatted string
106963 ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set
106964 ** an error */
106965 if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG;
 
106966 return;
106967 }
106968 pParse->nested++;
106969 memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
106970 memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
@@ -108101,11 +108216,12 @@
108101 && pCol
108102 && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
108103 && sortOrder!=SQLITE_SO_DESC
108104 ){
108105 if( IN_RENAME_OBJECT && pList ){
108106 sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);
 
108107 }
108108 pTab->iPKey = iCol;
108109 pTab->keyConf = (u8)onError;
108110 assert( autoInc==0 || autoInc==1 );
108111 pTab->tabFlags |= autoInc*TF_Autoincrement;
@@ -109850,17 +109966,17 @@
109850
109851 assert( pTab!=0 );
109852 assert( pParse->nErr==0 );
109853 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
109854 && db->init.busy==0
 
109855 #if SQLITE_USER_AUTHENTICATION
109856 && sqlite3UserAuthTable(pTab->zName)==0
109857 #endif
109858 #ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX
109859 && sqlite3StrICmp(&pTab->zName[7],"master")!=0
109860 #endif
109861 && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0
109862 ){
109863 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
109864 goto exit_create_index;
109865 }
109866 #ifndef SQLITE_OMIT_VIEW
@@ -109960,10 +110076,11 @@
109960 if( pList==0 ) goto exit_create_index;
109961 assert( pList->nExpr==1 );
109962 sqlite3ExprListSetSortOrder(pList, sortOrder);
109963 }else{
109964 sqlite3ExprListCheckLength(pParse, pList, "index");
 
109965 }
109966
109967 /* Figure out how many bytes of space are required to store explicitly
109968 ** specified collation sequence names.
109969 */
@@ -109978,10 +110095,11 @@
109978 /*
109979 ** Allocate the index structure.
109980 */
109981 nName = sqlite3Strlen30(zName);
109982 nExtraCol = pPk ? pPk->nKeyCol : 1;
 
109983 pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,
109984 nName + nExtra + 1, &zExtra);
109985 if( db->mallocFailed ){
109986 goto exit_create_index;
109987 }
@@ -119232,10 +119350,13 @@
119232 void (*xValue)(sqlite3_context*),
119233 void (*xInv)(sqlite3_context*,int,sqlite3_value**),
119234 void(*xDestroy)(void*));
119235 /* Version 3.26.0 and later */
119236 const char *(*normalized_sql)(sqlite3_stmt*);
 
 
 
119237 };
119238
119239 /*
119240 ** This is the function signature used for all extension entry points. It
119241 ** is also defined in the file "loadext.c".
@@ -119521,10 +119642,13 @@
119521 #define sqlite3_str_value sqlite3_api->str_value
119522 /* Version 3.25.0 and later */
119523 #define sqlite3_create_window_function sqlite3_api->create_window_function
119524 /* Version 3.26.0 and later */
119525 #define sqlite3_normalized_sql sqlite3_api->normalized_sql
 
 
 
119526 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
119527
119528 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
119529 /* This case when the file really is being compiled as a loadable
119530 ** extension */
@@ -133859,19 +133983,20 @@
133859 */
133860 SQLITE_PRIVATE int sqlite3RunVacuum(
133861 char **pzErrMsg, /* Write error message here */
133862 sqlite3 *db, /* Database connection */
133863 int iDb, /* Which attached DB to vacuum */
133864 sqlite3_value *pOut /* Write results here, if not NULL */
133865 ){
133866 int rc = SQLITE_OK; /* Return code from service routines */
133867 Btree *pMain; /* The database being vacuumed */
133868 Btree *pTemp; /* The temporary database we vacuum into */
133869 u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
133870 u64 saved_flags; /* Saved value of db->flags */
133871 int saved_nChange; /* Saved value of db->nChange */
133872 int saved_nTotalChange; /* Saved value of db->nTotalChange */
 
133873 u8 saved_mTrace; /* Saved trace settings */
133874 Db *pDb = 0; /* Database to detach at end of vacuum */
133875 int isMemDb; /* True if vacuuming a :memory: database */
133876 int nRes; /* Bytes of reserved space at the end of each page */
133877 int nDb; /* Number of attached databases */
@@ -133884,16 +134009,19 @@
133884 }
133885 if( db->nVdbeActive>1 ){
133886 sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
133887 return SQLITE_ERROR;
133888 }
 
133889 if( pOut ){
133890 if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
133891 sqlite3SetString(pzErrMsg, db, "non-text filename");
133892 return SQLITE_ERROR;
133893 }
133894 zOut = (const char*)sqlite3_value_text(pOut);
 
 
133895 }else{
133896 zOut = "";
133897 }
133898
133899 /* Save the current value of the database flags so that it can be
@@ -133928,10 +134056,11 @@
133928 ** time to parse and run the PRAGMA to turn journalling off than it does
133929 ** to write the journal header file.
133930 */
133931 nDb = db->nDb;
133932 rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
 
133933 if( rc!=SQLITE_OK ) goto end_of_vacuum;
133934 assert( (db->nDb-1)==nDb );
133935 pDb = &db->aDb[nDb];
133936 assert( strcmp(pDb->zDbSName,"vacuum_db")==0 );
133937 pTemp = pDb->pBt;
@@ -138164,12 +138293,13 @@
138164 continue;
138165 #else
138166 u32 x = pLevel->iLikeRepCntr;
138167 if( x>0 ){
138168 skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1));
 
 
138169 }
138170 VdbeCoverage(v);
138171 #endif
138172 }
138173 #ifdef WHERETRACE_ENABLED /* 0xffff */
138174 if( sqlite3WhereTrace ){
138175 VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
@@ -143189,15 +143319,15 @@
143189 WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
143190 WHERETRACE(0x40, (" VirtualOne: all usable\n"));
143191 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
143192
143193 /* If the call to xBestIndex() with all terms enabled produced a plan
143194 ** that does not require any source tables (IOW: a plan with mBest==0),
143195 ** then there is no point in making any further calls to xBestIndex()
143196 ** since they will all return the same result (if the xBestIndex()
143197 ** implementation is sane). */
143198 if( rc==SQLITE_OK && (mBest = (pNew->prereq & ~mPrereq))!=0 ){
143199 int seenZero = 0; /* True if a plan with no prereqs seen */
143200 int seenZeroNoIN = 0; /* Plan with no prereqs and no IN(...) seen */
143201 Bitmask mPrev = 0;
143202 Bitmask mBestNoIn = 0;
143203
@@ -145426,10 +145556,100 @@
145426 }
145427 sqlite3_result_int64(pCtx, p->nValue);
145428 }
145429 }
145430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145431 /*
145432 ** Implementation of built-in window function rank(). Assumes that
145433 ** the window frame has been set to:
145434 **
145435 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
@@ -145461,75 +145681,90 @@
145461
145462 /*
145463 ** Implementation of built-in window function percent_rank(). Assumes that
145464 ** the window frame has been set to:
145465 **
145466 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
145467 */
145468 static void percent_rankStepFunc(
145469 sqlite3_context *pCtx,
145470 int nArg,
145471 sqlite3_value **apArg
145472 ){
145473 struct CallCount *p;
145474 UNUSED_PARAMETER(nArg); assert( nArg==1 );
145475
 
 
 
 
 
 
 
 
 
 
 
 
 
145476 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145477 if( p ){
145478 if( p->nTotal==0 ){
145479 p->nTotal = sqlite3_value_int64(apArg[0]);
145480 }
145481 p->nStep++;
145482 if( p->nValue==0 ){
145483 p->nValue = p->nStep;
145484 }
145485 }
145486 }
145487 static void percent_rankValueFunc(sqlite3_context *pCtx){
145488 struct CallCount *p;
145489 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145490 if( p ){
 
145491 if( p->nTotal>1 ){
145492 double r = (double)(p->nValue-1) / (double)(p->nTotal-1);
145493 sqlite3_result_double(pCtx, r);
145494 }else{
145495 sqlite3_result_double(pCtx, 0.0);
145496 }
145497 p->nValue = 0;
145498 }
145499 }
 
145500
145501 /*
145502 ** Implementation of built-in window function cume_dist(). Assumes that
145503 ** the window frame has been set to:
145504 **
145505 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
145506 */
145507 static void cume_distStepFunc(
145508 sqlite3_context *pCtx,
145509 int nArg,
145510 sqlite3_value **apArg
145511 ){
145512 struct CallCount *p;
145513 assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145514
 
 
 
 
 
 
 
 
 
 
 
 
 
145515 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145516 if( p ){
145517 if( p->nTotal==0 ){
145518 p->nTotal = sqlite3_value_int64(apArg[0]);
145519 }
145520 p->nStep++;
145521 }
145522 }
145523 static void cume_distValueFunc(sqlite3_context *pCtx){
145524 struct CallCount *p;
145525 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145526 if( p && p->nTotal ){
145527 double r = (double)(p->nStep) / (double)(p->nTotal);
145528 sqlite3_result_double(pCtx, r);
145529 }
145530 }
 
145531
145532 /*
145533 ** Context object for ntile() window function.
145534 */
145535 struct NtileCtx {
@@ -145540,44 +145775,54 @@
145540
145541 /*
145542 ** Implementation of ntile(). This assumes that the window frame has
145543 ** been coerced to:
145544 **
145545 ** ROWS UNBOUNDED PRECEDING AND CURRENT ROW
145546 */
145547 static void ntileStepFunc(
145548 sqlite3_context *pCtx,
145549 int nArg,
145550 sqlite3_value **apArg
145551 ){
145552 struct NtileCtx *p;
145553 assert( nArg==2 ); UNUSED_PARAMETER(nArg);
145554 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145555 if( p ){
145556 if( p->nTotal==0 ){
145557 p->nParam = sqlite3_value_int64(apArg[0]);
145558 p->nTotal = sqlite3_value_int64(apArg[1]);
145559 if( p->nParam<=0 ){
145560 sqlite3_result_error(
145561 pCtx, "argument of ntile must be a positive integer", -1
145562 );
145563 }
145564 }
145565 p->iRow++;
145566 }
 
 
 
 
 
 
 
 
 
 
 
145567 }
145568 static void ntileValueFunc(sqlite3_context *pCtx){
145569 struct NtileCtx *p;
145570 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145571 if( p && p->nParam>0 ){
145572 int nSize = (p->nTotal / p->nParam);
145573 if( nSize==0 ){
145574 sqlite3_result_int64(pCtx, p->iRow);
145575 }else{
145576 i64 nLarge = p->nTotal - p->nParam*nSize;
145577 i64 iSmall = nLarge*(nSize+1);
145578 i64 iRow = p->iRow-1;
145579
145580 assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );
145581
145582 if( iRow<iSmall ){
145583 sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
@@ -145585,10 +145830,11 @@
145585 sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
145586 }
145587 }
145588 }
145589 }
 
145590
145591 /*
145592 ** Context object for last_value() window function.
145593 */
145594 struct LastValueCtx {
@@ -145634,11 +145880,11 @@
145634 }
145635 }
145636 }
145637 static void last_valueValueFunc(sqlite3_context *pCtx){
145638 struct LastValueCtx *p;
145639 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145640 if( p && p->pVal ){
145641 sqlite3_result_value(pCtx, p->pVal);
145642 }
145643 }
145644 static void last_valueFinalizeFunc(sqlite3_context *pCtx){
@@ -145724,25 +145970,36 @@
145724 SQLITE_PRIVATE void sqlite3WindowFunctions(void){
145725 static FuncDef aWindowFuncs[] = {
145726 WINDOWFUNCX(row_number, 0, 0),
145727 WINDOWFUNCX(dense_rank, 0, 0),
145728 WINDOWFUNCX(rank, 0, 0),
145729 WINDOWFUNCX(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),
145730 WINDOWFUNCX(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),
145731 WINDOWFUNCX(ntile, 1, SQLITE_FUNC_WINDOW_SIZE),
145732 WINDOWFUNCALL(last_value, 1, 0),
145733 WINDOWFUNCNOOP(nth_value, 2, 0),
145734 WINDOWFUNCNOOP(first_value, 1, 0),
145735 WINDOWFUNCNOOP(lead, 1, 0),
145736 WINDOWFUNCNOOP(lead, 2, 0),
145737 WINDOWFUNCNOOP(lead, 3, 0),
145738 WINDOWFUNCNOOP(lag, 1, 0),
145739 WINDOWFUNCNOOP(lag, 2, 0),
145740 WINDOWFUNCNOOP(lag, 3, 0),
145741 };
145742 sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
145743 }
 
 
 
 
 
 
 
 
 
 
 
145744
145745 /*
145746 ** This function is called immediately after resolving the function name
145747 ** for a window function within a SELECT statement. Argument pList is a
145748 ** linked list of WINDOW definitions for the current SELECT statement.
@@ -145763,52 +146020,70 @@
145763 Parse *pParse,
145764 Window *pList, /* List of named windows for this SELECT */
145765 Window *pWin, /* Window frame to update */
145766 FuncDef *pFunc /* Window function definition */
145767 ){
145768 if( pWin->zName && pWin->eType==0 ){
145769 Window *p;
145770 for(p=pList; p; p=p->pNextWin){
145771 if( sqlite3StrICmp(p->zName, pWin->zName)==0 ) break;
145772 }
145773 if( p==0 ){
145774 sqlite3ErrorMsg(pParse, "no such window: %s", pWin->zName);
145775 return;
145776 }
145777 pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
145778 pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
145779 pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
145780 pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
145781 pWin->eStart = p->eStart;
145782 pWin->eEnd = p->eEnd;
145783 pWin->eType = p->eType;
 
 
 
145784 }
 
 
 
 
 
 
 
 
145785 if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
145786 sqlite3 *db = pParse->db;
145787 if( pWin->pFilter ){
145788 sqlite3ErrorMsg(pParse,
145789 "FILTER clause may only be used with aggregate window functions"
145790 );
145791 }else
145792 if( pFunc->zName==row_numberName || pFunc->zName==ntileName ){
145793 sqlite3ExprDelete(db, pWin->pStart);
145794 sqlite3ExprDelete(db, pWin->pEnd);
145795 pWin->pStart = pWin->pEnd = 0;
145796 pWin->eType = TK_ROWS;
145797 pWin->eStart = TK_UNBOUNDED;
145798 pWin->eEnd = TK_CURRENT;
145799 }else
145800
145801 if( pFunc->zName==dense_rankName || pFunc->zName==rankName
145802 || pFunc->zName==percent_rankName || pFunc->zName==cume_distName
145803 ){
145804 sqlite3ExprDelete(db, pWin->pStart);
145805 sqlite3ExprDelete(db, pWin->pEnd);
145806 pWin->pStart = pWin->pEnd = 0;
145807 pWin->eType = TK_RANGE;
145808 pWin->eStart = TK_UNBOUNDED;
145809 pWin->eEnd = TK_CURRENT;
 
 
 
 
 
 
 
 
 
 
 
 
 
145810 }
145811 }
145812 pWin->pFunc = pFunc;
145813 }
145814
@@ -146009,10 +146284,11 @@
146009
146010 /* Assign a cursor number for the ephemeral table used to buffer rows.
146011 ** The OpenEphemeral instruction is coded later, after it is known how
146012 ** many columns the table will have. */
146013 pMWin->iEphCsr = pParse->nTab++;
 
146014
146015 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);
146016 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);
146017 pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);
146018
@@ -146064,10 +146340,13 @@
146064 p->selFlags &= ~SF_Aggregate;
146065 sqlite3SelectPrep(pParse, pSub, 0);
146066 }
146067
146068 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
 
 
 
146069 }else{
146070 sqlite3SelectDelete(db, pSub);
146071 }
146072 if( db->mallocFailed ) rc = SQLITE_NOMEM;
146073 }
@@ -146084,10 +146363,11 @@
146084 sqlite3ExprListDelete(db, p->pPartition);
146085 sqlite3ExprListDelete(db, p->pOrderBy);
146086 sqlite3ExprDelete(db, p->pEnd);
146087 sqlite3ExprDelete(db, p->pStart);
146088 sqlite3DbFree(db, p->zName);
 
146089 sqlite3DbFree(db, p);
146090 }
146091 }
146092
146093 /*
@@ -146120,34 +146400,32 @@
146120 /*
146121 ** Allocate and return a new Window object describing a Window Definition.
146122 */
146123 SQLITE_PRIVATE Window *sqlite3WindowAlloc(
146124 Parse *pParse, /* Parsing context */
146125 int eType, /* Frame type. TK_RANGE or TK_ROWS */
146126 int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
146127 Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
146128 int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
146129 Expr *pEnd /* End window size if TK_FOLLOWING or PRECEDING */
 
146130 ){
146131 Window *pWin = 0;
 
146132
146133 /* Parser assures the following: */
146134 assert( eType==TK_RANGE || eType==TK_ROWS );
146135 assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
146136 || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
146137 assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
146138 || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
146139 assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
146140 assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );
146141
146142
146143 /* If a frame is declared "RANGE" (not "ROWS"), then it may not use
146144 ** either "<expr> PRECEDING" or "<expr> FOLLOWING".
146145 */
146146 if( eType==TK_RANGE && (pStart!=0 || pEnd!=0) ){
146147 sqlite3ErrorMsg(pParse, "RANGE must use only UNBOUNDED or CURRENT ROW");
146148 goto windowAllocErr;
146149 }
146150
146151 /* Additionally, the
146152 ** starting boundary type may not occur earlier in the following list than
146153 ** the ending boundary type:
@@ -146163,28 +146441,96 @@
146163 ** frame boundary.
146164 */
146165 if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
146166 || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
146167 ){
146168 sqlite3ErrorMsg(pParse, "unsupported frame delimiter for ROWS");
146169 goto windowAllocErr;
146170 }
146171
146172 pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
146173 if( pWin==0 ) goto windowAllocErr;
146174 pWin->eType = eType;
146175 pWin->eStart = eStart;
146176 pWin->eEnd = eEnd;
 
 
 
 
 
146177 pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
146178 pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
146179 return pWin;
146180
146181 windowAllocErr:
146182 sqlite3ExprDelete(pParse->db, pEnd);
146183 sqlite3ExprDelete(pParse->db, pStart);
146184 return 0;
146185 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146186
146187 /*
146188 ** Attach window object pWin to expression p.
146189 */
146190 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
@@ -146210,13 +146556,14 @@
146210 /*
146211 ** Return 0 if the two window objects are identical, or non-zero otherwise.
146212 ** Identical window objects can be processed in a single scan.
146213 */
146214 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
146215 if( p1->eType!=p2->eType ) return 1;
146216 if( p1->eStart!=p2->eStart ) return 1;
146217 if( p1->eEnd!=p2->eEnd ) return 1;
 
146218 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
146219 if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
146220 if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
146221 if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
146222 return 0;
@@ -146229,16 +146576,31 @@
146229 ** and initialize registers and cursors used by sqlite3WindowCodeStep().
146230 */
146231 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
146232 Window *pWin;
146233 Vdbe *v = sqlite3GetVdbe(pParse);
146234 int nPart = (pMWin->pPartition ? pMWin->pPartition->nExpr : 0);
146235 nPart += (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
146236 if( nPart ){
 
 
146237 pMWin->regPart = pParse->nMem+1;
146238 pParse->nMem += nPart;
146239 sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nPart-1);
 
 
 
 
 
 
 
 
 
 
 
 
 
146240 }
146241
146242 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146243 FuncDef *p = pWin->pFunc;
146244 if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
@@ -146263,50 +146625,71 @@
146263 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146264 }
146265 else if( p->zName==nth_valueName || p->zName==first_valueName ){
146266 /* Allocate two registers at pWin->regApp. These will be used to
146267 ** store the start and end index of the current frame. */
146268 assert( pMWin->iEphCsr );
146269 pWin->regApp = pParse->nMem+1;
146270 pWin->csrApp = pParse->nTab++;
146271 pParse->nMem += 2;
146272 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146273 }
146274 else if( p->zName==leadName || p->zName==lagName ){
146275 assert( pMWin->iEphCsr );
146276 pWin->csrApp = pParse->nTab++;
146277 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146278 }
146279 }
146280 }
 
 
 
 
 
 
146281
146282 /*
146283 ** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
146284 ** value of the second argument to nth_value() (eCond==2) has just been
146285 ** evaluated and the result left in register reg. This function generates VM
146286 ** code to check that the value is a non-negative integer and throws an
146287 ** exception if it is not.
146288 */
146289 static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
146290 static const char *azErr[] = {
146291 "frame starting offset must be a non-negative integer",
146292 "frame ending offset must be a non-negative integer",
146293 "second argument to nth_value must be a positive integer"
 
 
146294 };
146295 static int aOp[] = { OP_Ge, OP_Ge, OP_Gt };
146296 Vdbe *v = sqlite3GetVdbe(pParse);
146297 int regZero = sqlite3GetTempReg(pParse);
146298 assert( eCond==0 || eCond==1 || eCond==2 );
146299 sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
146300 sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
146301 VdbeCoverageIf(v, eCond==0);
146302 VdbeCoverageIf(v, eCond==1);
146303 VdbeCoverageIf(v, eCond==2);
 
 
 
 
 
 
 
 
 
 
 
 
 
146304 sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
146305 VdbeCoverageNeverNullIf(v, eCond==0);
146306 VdbeCoverageNeverNullIf(v, eCond==1);
146307 VdbeCoverageNeverNullIf(v, eCond==2);
 
 
146308 sqlite3MayAbort(pParse);
146309 sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
146310 sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
146311 sqlite3ReleaseTempReg(pParse, regZero);
146312 }
@@ -146342,41 +146725,32 @@
146342 static void windowAggStep(
146343 Parse *pParse,
146344 Window *pMWin, /* Linked list of window functions */
146345 int csr, /* Read arguments from this cursor */
146346 int bInverse, /* True to invoke xInverse instead of xStep */
146347 int reg, /* Array of registers */
146348 int regPartSize /* Register containing size of partition */
146349 ){
146350 Vdbe *v = sqlite3GetVdbe(pParse);
146351 Window *pWin;
146352 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146353 int flags = pWin->pFunc->funcFlags;
146354 int regArg;
146355 int nArg = windowArgCount(pWin);
 
146356
146357 if( csr>=0 ){
146358 int i;
146359 for(i=0; i<nArg; i++){
146360 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
146361 }
146362 regArg = reg;
146363 if( flags & SQLITE_FUNC_WINDOW_SIZE ){
146364 if( nArg==0 ){
146365 regArg = regPartSize;
146366 }else{
146367 sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
146368 }
146369 nArg++;
146370 }
146371 }else{
146372 assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
146373 regArg = reg + pWin->iArgCol;
146374 }
146375
146376 if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146377 && pWin->eStart!=TK_UNBOUNDED
146378 ){
146379 int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
146380 VdbeCoverage(v);
146381 if( bInverse==0 ){
146382 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
@@ -146389,151 +146763,223 @@
146389 sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
146390 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
146391 }
146392 sqlite3VdbeJumpHere(v, addrIsNull);
146393 }else if( pWin->regApp ){
146394 assert( pWin->pFunc->zName==nth_valueName
146395 || pWin->pFunc->zName==first_valueName
146396 );
146397 assert( bInverse==0 || bInverse==1 );
146398 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
146399 }else if( pWin->pFunc->zName==leadName
146400 || pWin->pFunc->zName==lagName
146401 ){
146402 /* no-op */
146403 }else{
146404 int addrIf = 0;
146405 if( pWin->pFilter ){
146406 int regTmp;
146407 assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
146408 assert( nArg || pWin->pOwner->x.pList==0 );
146409 if( csr>0 ){
146410 regTmp = sqlite3GetTempReg(pParse);
146411 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
146412 }else{
146413 regTmp = regArg + nArg;
146414 }
146415 addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
146416 VdbeCoverage(v);
146417 if( csr>0 ){
146418 sqlite3ReleaseTempReg(pParse, regTmp);
146419 }
146420 }
146421 if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
146422 CollSeq *pColl;
146423 assert( nArg>0 );
146424 pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
146425 sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
146426 }
146427 sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
146428 bInverse, regArg, pWin->regAccum);
146429 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146430 sqlite3VdbeChangeP5(v, (u8)nArg);
146431 if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
146432 }
146433 }
146434 }
146435
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146436 /*
146437 ** Generate VM code to invoke either xValue() (bFinal==0) or xFinalize()
146438 ** (bFinal==1) for each window function in the linked list starting at
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146439 ** pMWin. Or, for built-in window-functions that do not use the standard
146440 ** API, generate the equivalent VM code.
146441 */
146442 static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
 
 
146443 Vdbe *v = sqlite3GetVdbe(pParse);
146444 Window *pWin;
146445
146446 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146447 if( (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146448 && pWin->eStart!=TK_UNBOUNDED
 
146449 ){
146450 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146451 sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
146452 VdbeCoverage(v);
146453 sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
146454 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
146455 if( bFinal ){
146456 sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
146457 }
146458 }else if( pWin->regApp ){
 
146459 }else{
146460 if( bFinal ){
146461 sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, windowArgCount(pWin));
 
146462 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146463 sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
146464 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146465 }else{
146466 sqlite3VdbeAddOp3(v, OP_AggValue, pWin->regAccum, windowArgCount(pWin),
146467 pWin->regResult);
146468 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146469 }
146470 }
146471 }
146472 }
146473
146474 /*
146475 ** This function generates VM code to invoke the sub-routine at address
146476 ** lblFlushPart once for each partition with the entire partition cached in
146477 ** the Window.iEphCsr temp table.
 
146478 */
146479 static void windowPartitionCache(
146480 Parse *pParse,
146481 Select *p, /* The rewritten SELECT statement */
146482 WhereInfo *pWInfo, /* WhereInfo to call WhereEnd() on */
146483 int regFlushPart, /* Register to use with Gosub lblFlushPart */
146484 int lblFlushPart, /* Subroutine to Gosub to */
146485 int *pRegSize /* OUT: Register containing partition size */
146486 ){
146487 Window *pMWin = p->pWin;
146488 Vdbe *v = sqlite3GetVdbe(pParse);
146489 int iSubCsr = p->pSrc->a[0].iCursor;
146490 int nSub = p->pSrc->a[0].pTab->nCol;
146491 int k;
146492
146493 int reg = pParse->nMem+1;
146494 int regRecord = reg+nSub;
146495 int regRowid = regRecord+1;
146496
146497 *pRegSize = regRowid;
146498 pParse->nMem += nSub + 2;
146499
146500 /* Load the column values for the row returned by the sub-select
146501 ** into an array of registers starting at reg. */
146502 for(k=0; k<nSub; k++){
146503 sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
146504 }
146505 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, nSub, regRecord);
146506
146507 /* Check if this is the start of a new partition. If so, call the
146508 ** flush_partition sub-routine. */
146509 if( pMWin->pPartition ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146510 int addr;
146511 ExprList *pPart = pMWin->pPartition;
146512 int nPart = pPart->nExpr;
146513 int regNewPart = reg + pMWin->nBufferCol;
146514 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
146515
146516 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
146517 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
146518 sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
146519 VdbeCoverageEqNe(v);
146520 sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
146521 sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
146522 VdbeComment((v, "call flush_partition"));
146523 }
146524
146525 /* Buffer the current row in the ephemeral table. */
146526 sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
146527 sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
146528
146529 /* End of the input loop */
146530 sqlite3WhereEnd(pWInfo);
146531
146532 /* Invoke "flush_partition" to deal with the final (or only) partition */
146533 sqlite3VdbeAddOp2(v, OP_Gosub, regFlushPart, lblFlushPart);
146534 VdbeComment((v, "call flush_partition"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146535 }
146536
146537 /*
146538 ** Invoke the sub-routine at regGosub (generated by code in select.c) to
146539 ** return the current row of Window.iEphCsr. If all window functions are
@@ -146545,114 +146991,78 @@
146545 ** nth_value()
146546 ** first_value()
146547 ** lag()
146548 ** lead()
146549 */
146550 static void windowReturnOneRow(
146551 Parse *pParse,
146552 Window *pMWin,
146553 int regGosub,
146554 int addrGosub
146555 ){
146556 Vdbe *v = sqlite3GetVdbe(pParse);
146557 Window *pWin;
146558 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146559 FuncDef *pFunc = pWin->pFunc;
146560 if( pFunc->zName==nth_valueName
146561 || pFunc->zName==first_valueName
146562 ){
146563 int csr = pWin->csrApp;
146564 int lbl = sqlite3VdbeMakeLabel(pParse);
146565 int tmpReg = sqlite3GetTempReg(pParse);
146566 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146567
146568 if( pFunc->zName==nth_valueName ){
146569 sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+1,tmpReg);
146570 windowCheckIntValue(pParse, tmpReg, 2);
146571 }else{
146572 sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
146573 }
146574 sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
146575 sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
146576 VdbeCoverageNeverNull(v);
146577 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
146578 VdbeCoverageNeverTaken(v);
146579 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
146580 sqlite3VdbeResolveLabel(v, lbl);
146581 sqlite3ReleaseTempReg(pParse, tmpReg);
146582 }
146583 else if( pFunc->zName==leadName || pFunc->zName==lagName ){
146584 int nArg = pWin->pOwner->x.pList->nExpr;
146585 int iEph = pMWin->iEphCsr;
146586 int csr = pWin->csrApp;
146587 int lbl = sqlite3VdbeMakeLabel(pParse);
146588 int tmpReg = sqlite3GetTempReg(pParse);
146589
146590 if( nArg<3 ){
146591 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146592 }else{
146593 sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);
146594 }
146595 sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
146596 if( nArg<2 ){
146597 int val = (pFunc->zName==leadName ? 1 : -1);
146598 sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
146599 }else{
146600 int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
146601 int tmpReg2 = sqlite3GetTempReg(pParse);
146602 sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
146603 sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
146604 sqlite3ReleaseTempReg(pParse, tmpReg2);
146605 }
146606
146607 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
146608 VdbeCoverage(v);
146609 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
146610 sqlite3VdbeResolveLabel(v, lbl);
146611 sqlite3ReleaseTempReg(pParse, tmpReg);
146612 }
146613 }
146614 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
146615 }
146616
146617 /*
146618 ** Invoke the code generated by windowReturnOneRow() and, optionally, the
146619 ** xInverse() function for each window function, for one or more rows
146620 ** from the Window.iEphCsr temp table. This routine generates VM code
146621 ** similar to:
146622 **
146623 ** while( regCtr>0 ){
146624 ** regCtr--;
146625 ** windowReturnOneRow()
146626 ** if( bInverse ){
146627 ** AggInverse
146628 ** }
146629 ** Next (Window.iEphCsr)
146630 ** }
146631 */
146632 static void windowReturnRows(
146633 Parse *pParse,
146634 Window *pMWin, /* List of window functions */
146635 int regCtr, /* Register containing number of rows */
146636 int regGosub, /* Register for Gosub addrGosub */
146637 int addrGosub, /* Address of sub-routine for ReturnOneRow */
146638 int regInvArg, /* Array of registers for xInverse args */
146639 int regInvSize /* Register containing size of partition */
146640 ){
146641 int addr;
146642 Vdbe *v = sqlite3GetVdbe(pParse);
146643 windowAggFinal(pParse, pMWin, 0);
146644 addr = sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 ,1);
146645 VdbeCoverage(v);
146646 sqlite3VdbeAddOp2(v, OP_Goto, 0, 0);
146647 windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
146648 if( regInvArg ){
146649 windowAggStep(pParse, pMWin, pMWin->iEphCsr, 1, regInvArg, regInvSize);
146650 }
146651 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, addr);
146652 VdbeCoverage(v);
146653 sqlite3VdbeJumpHere(v, addr+1); /* The OP_Goto */
146654 }
146655
146656 /*
146657 ** Generate code to set the accumulator register for each window function
146658 ** in the linked list passed as the second argument to NULL. And perform
@@ -146666,693 +147076,269 @@
146666 Window *pWin;
146667 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146668 FuncDef *pFunc = pWin->pFunc;
146669 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146670 nArg = MAX(nArg, windowArgCount(pWin));
146671 if( pFunc->zName==nth_valueName
146672 || pFunc->zName==first_valueName
146673 ){
146674 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
146675 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146676 }
146677
146678 if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
146679 assert( pWin->eStart!=TK_UNBOUNDED );
146680 sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
146681 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146682 }
146683 }
146684 regArg = pParse->nMem+1;
146685 pParse->nMem += nArg;
146686 return regArg;
146687 }
146688
146689
146690 /*
146691 ** This function does the work of sqlite3WindowCodeStep() for all "ROWS"
146692 ** window frame types except for "BETWEEN UNBOUNDED PRECEDING AND CURRENT
146693 ** ROW". Pseudo-code for each follows.
146694 **
146695 ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
146696 **
146697 ** ...
146698 ** if( new partition ){
146699 ** Gosub flush_partition
146700 ** }
146701 ** Insert (record in eph-table)
146702 ** sqlite3WhereEnd()
146703 ** Gosub flush_partition
146704 **
146705 ** flush_partition:
146706 ** Once {
146707 ** OpenDup (iEphCsr -> csrStart)
146708 ** OpenDup (iEphCsr -> csrEnd)
146709 ** }
146710 ** regStart = <expr1> // PRECEDING expression
146711 ** regEnd = <expr2> // FOLLOWING expression
146712 ** if( regStart<0 || regEnd<0 ){ error! }
146713 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146714 ** Next(csrEnd) // if EOF skip Aggstep
146715 ** Aggstep (csrEnd)
146716 ** if( (regEnd--)<=0 ){
146717 ** AggFinal (xValue)
146718 ** Gosub addrGosub
146719 ** Next(csr) // if EOF goto flush_partition_done
146720 ** if( (regStart--)<=0 ){
146721 ** AggInverse (csrStart)
146722 ** Next(csrStart)
146723 ** }
146724 ** }
146725 ** flush_partition_done:
146726 ** ResetSorter (csr)
146727 ** Return
146728 **
146729 ** ROWS BETWEEN <expr> PRECEDING AND CURRENT ROW
146730 ** ROWS BETWEEN CURRENT ROW AND <expr> FOLLOWING
146731 ** ROWS BETWEEN UNBOUNDED PRECEDING AND <expr> FOLLOWING
146732 **
146733 ** These are similar to the above. For "CURRENT ROW", intialize the
146734 ** register to 0. For "UNBOUNDED PRECEDING" to infinity.
146735 **
146736 ** ROWS BETWEEN <expr> PRECEDING AND UNBOUNDED FOLLOWING
146737 ** ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
146738 **
146739 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146740 ** while( 1 ){
146741 ** Next(csrEnd) // Exit while(1) at EOF
146742 ** Aggstep (csrEnd)
146743 ** }
146744 ** while( 1 ){
146745 ** AggFinal (xValue)
146746 ** Gosub addrGosub
146747 ** Next(csr) // if EOF goto flush_partition_done
146748 ** if( (regStart--)<=0 ){
146749 ** AggInverse (csrStart)
146750 ** Next(csrStart)
146751 ** }
146752 ** }
146753 **
146754 ** For the "CURRENT ROW AND UNBOUNDED FOLLOWING" case, the final if()
146755 ** condition is always true (as if regStart were initialized to 0).
146756 **
146757 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
146758 **
146759 ** This is the only RANGE case handled by this routine. It modifies the
146760 ** second while( 1 ) loop in "ROWS BETWEEN CURRENT ... UNBOUNDED..." to
146761 ** be:
146762 **
146763 ** while( 1 ){
146764 ** AggFinal (xValue)
146765 ** while( 1 ){
146766 ** regPeer++
146767 ** Gosub addrGosub
146768 ** Next(csr) // if EOF goto flush_partition_done
146769 ** if( new peer ) break;
146770 ** }
146771 ** while( (regPeer--)>0 ){
146772 ** AggInverse (csrStart)
146773 ** Next(csrStart)
146774 ** }
146775 ** }
146776 **
146777 ** ROWS BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING
146778 **
146779 ** regEnd = regEnd - regStart
146780 ** Rewind (csr,csrStart,csrEnd) // if EOF goto flush_partition_done
146781 ** Aggstep (csrEnd)
146782 ** Next(csrEnd) // if EOF fall-through
146783 ** if( (regEnd--)<=0 ){
146784 ** if( (regStart--)<=0 ){
146785 ** AggFinal (xValue)
146786 ** Gosub addrGosub
146787 ** Next(csr) // if EOF goto flush_partition_done
146788 ** }
146789 ** AggInverse (csrStart)
146790 ** Next (csrStart)
146791 ** }
146792 **
146793 ** ROWS BETWEEN <expr> PRECEDING AND <expr> PRECEDING
146794 **
146795 ** Replace the bit after "Rewind" in the above with:
146796 **
146797 ** if( (regEnd--)<=0 ){
146798 ** AggStep (csrEnd)
146799 ** Next (csrEnd)
146800 ** }
146801 ** AggFinal (xValue)
146802 ** Gosub addrGosub
146803 ** Next(csr) // if EOF goto flush_partition_done
146804 ** if( (regStart--)<=0 ){
146805 ** AggInverse (csr2)
146806 ** Next (csr2)
146807 ** }
146808 **
146809 */
146810 static void windowCodeRowExprStep(
146811 Parse *pParse,
146812 Select *p,
146813 WhereInfo *pWInfo,
146814 int regGosub,
146815 int addrGosub
146816 ){
146817 Window *pMWin = p->pWin;
146818 Vdbe *v = sqlite3GetVdbe(pParse);
146819 int regFlushPart; /* Register for "Gosub flush_partition" */
146820 int lblFlushPart; /* Label for "Gosub flush_partition" */
146821 int lblFlushDone; /* Label for "Gosub flush_partition_done" */
146822
146823 int regArg;
146824 int addr;
146825 int csrStart = pParse->nTab++;
146826 int csrEnd = pParse->nTab++;
146827 int regStart; /* Value of <expr> PRECEDING */
146828 int regEnd; /* Value of <expr> FOLLOWING */
146829 int addrGoto;
146830 int addrTop;
146831 int addrIfPos1 = 0;
146832 int addrIfPos2 = 0;
146833 int regSize = 0;
146834
146835 assert( pMWin->eStart==TK_PRECEDING
146836 || pMWin->eStart==TK_CURRENT
146837 || pMWin->eStart==TK_FOLLOWING
146838 || pMWin->eStart==TK_UNBOUNDED
146839 );
146840 assert( pMWin->eEnd==TK_FOLLOWING
146841 || pMWin->eEnd==TK_CURRENT
146842 || pMWin->eEnd==TK_UNBOUNDED
146843 || pMWin->eEnd==TK_PRECEDING
146844 );
146845
146846 /* Allocate register and label for the "flush_partition" sub-routine. */
146847 regFlushPart = ++pParse->nMem;
146848 lblFlushPart = sqlite3VdbeMakeLabel(pParse);
146849 lblFlushDone = sqlite3VdbeMakeLabel(pParse);
146850
146851 regStart = ++pParse->nMem;
146852 regEnd = ++pParse->nMem;
146853
146854 windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
146855
146856 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
146857
146858 /* Start of "flush_partition" */
146859 sqlite3VdbeResolveLabel(v, lblFlushPart);
146860 sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
146861 VdbeCoverage(v);
146862 VdbeComment((v, "Flush_partition subroutine"));
146863 sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
146864 sqlite3VdbeAddOp2(v, OP_OpenDup, csrEnd, pMWin->iEphCsr);
146865
146866 /* If either regStart or regEnd are not non-negative integers, throw
146867 ** an exception. */
146868 if( pMWin->pStart ){
146869 sqlite3ExprCode(pParse, pMWin->pStart, regStart);
146870 windowCheckIntValue(pParse, regStart, 0);
146871 }
146872 if( pMWin->pEnd ){
146873 sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
146874 windowCheckIntValue(pParse, regEnd, 1);
146875 }
146876
146877 /* If this is "ROWS <expr1> FOLLOWING AND ROWS <expr2> FOLLOWING", do:
146878 **
146879 ** if( regEnd<regStart ){
146880 ** // The frame always consists of 0 rows
146881 ** regStart = regSize;
146882 ** }
146883 ** regEnd = regEnd - regStart;
146884 */
146885 if( pMWin->pEnd && pMWin->eStart==TK_FOLLOWING ){
146886 assert( pMWin->pStart!=0 );
146887 assert( pMWin->eEnd==TK_FOLLOWING );
146888 sqlite3VdbeAddOp3(v, OP_Ge, regStart, sqlite3VdbeCurrentAddr(v)+2, regEnd);
146889 VdbeCoverageNeverNull(v);
146890 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
146891 sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
146892 }
146893
146894 if( pMWin->pStart && pMWin->eEnd==TK_PRECEDING ){
146895 assert( pMWin->pEnd!=0 );
146896 assert( pMWin->eStart==TK_PRECEDING );
146897 sqlite3VdbeAddOp3(v, OP_Le, regStart, sqlite3VdbeCurrentAddr(v)+3, regEnd);
146898 VdbeCoverageNeverNull(v);
146899 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regStart);
146900 sqlite3VdbeAddOp2(v, OP_Copy, regSize, regEnd);
146901 }
146902
146903 /* Initialize the accumulator register for each window function to NULL */
146904 regArg = windowInitAccum(pParse, pMWin);
146905
146906 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
146907 VdbeCoverage(v);
146908 sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
146909 VdbeCoverageNeverTaken(v);
146910 sqlite3VdbeChangeP5(v, 1);
146911 sqlite3VdbeAddOp2(v, OP_Rewind, csrEnd, lblFlushDone);
146912 VdbeCoverageNeverTaken(v);
146913 sqlite3VdbeChangeP5(v, 1);
146914
146915 /* Invoke AggStep function for each window function using the row that
146916 ** csrEnd currently points to. Or, if csrEnd is already at EOF,
146917 ** do nothing. */
146918 addrTop = sqlite3VdbeCurrentAddr(v);
146919 if( pMWin->eEnd==TK_PRECEDING ){
146920 addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
146921 VdbeCoverage(v);
146922 }
146923 sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
146924 VdbeCoverage(v);
146925 addr = sqlite3VdbeAddOp0(v, OP_Goto);
146926 windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
146927 if( pMWin->eEnd==TK_UNBOUNDED ){
146928 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
146929 sqlite3VdbeJumpHere(v, addr);
146930 addrTop = sqlite3VdbeCurrentAddr(v);
146931 }else{
146932 sqlite3VdbeJumpHere(v, addr);
146933 if( pMWin->eEnd==TK_PRECEDING ){
146934 sqlite3VdbeJumpHere(v, addrIfPos1);
146935 }
146936 }
146937
146938 if( pMWin->eEnd==TK_FOLLOWING ){
146939 addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
146940 VdbeCoverage(v);
146941 }
146942 if( pMWin->eStart==TK_FOLLOWING ){
146943 addrIfPos2 = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
146944 VdbeCoverage(v);
146945 }
146946 windowAggFinal(pParse, pMWin, 0);
146947 windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
146948 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)+2);
146949 VdbeCoverage(v);
146950 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblFlushDone);
146951 if( pMWin->eStart==TK_FOLLOWING ){
146952 sqlite3VdbeJumpHere(v, addrIfPos2);
146953 }
146954
146955 if( pMWin->eStart==TK_CURRENT
146956 || pMWin->eStart==TK_PRECEDING
146957 || pMWin->eStart==TK_FOLLOWING
146958 ){
146959 int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;
146960 if( pMWin->eStart==TK_PRECEDING ){
146961 sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
146962 VdbeCoverage(v);
146963 }
146964 if( pMWin->eStart==TK_FOLLOWING ){
146965 sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+2);
146966 VdbeCoverage(v);
146967 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblSkipInverse);
146968 }else{
146969 sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
146970 VdbeCoverageAlwaysTaken(v);
146971 }
146972 windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
146973 sqlite3VdbeResolveLabel(v, lblSkipInverse);
146974 }
146975 if( pMWin->eEnd==TK_FOLLOWING ){
146976 sqlite3VdbeJumpHere(v, addrIfPos1);
146977 }
146978 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
146979
146980 /* flush_partition_done: */
146981 sqlite3VdbeResolveLabel(v, lblFlushDone);
146982 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
146983 sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
146984 VdbeComment((v, "end flush_partition subroutine"));
146985
146986 /* Jump to here to skip over flush_partition */
146987 sqlite3VdbeJumpHere(v, addrGoto);
146988 }
146989
146990 /*
146991 ** This function does the work of sqlite3WindowCodeStep() for cases that
146992 ** would normally be handled by windowCodeDefaultStep() when there are
146993 ** one or more built-in window-functions that require the entire partition
146994 ** to be cached in a temp table before any rows can be returned. Additionally.
146995 ** "RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" is always handled by
146996 ** this function.
146997 **
146998 ** Pseudo-code corresponding to the VM code generated by this function
146999 ** for each type of window follows.
147000 **
147001 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147002 **
147003 ** flush_partition:
147004 ** Once {
147005 ** OpenDup (iEphCsr -> csrLead)
147006 ** }
147007 ** Integer ctr 0
147008 ** foreach row (csrLead){
147009 ** if( new peer ){
147010 ** AggFinal (xValue)
147011 ** for(i=0; i<ctr; i++){
147012 ** Gosub addrGosub
147013 ** Next iEphCsr
147014 ** }
147015 ** Integer ctr 0
147016 ** }
147017 ** AggStep (csrLead)
147018 ** Incr ctr
147019 ** }
147020 **
147021 ** AggFinal (xFinalize)
147022 ** for(i=0; i<ctr; i++){
147023 ** Gosub addrGosub
147024 ** Next iEphCsr
147025 ** }
147026 **
147027 ** ResetSorter (csr)
147028 ** Return
147029 **
147030 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147031 **
147032 ** As above, except that the "if( new peer )" branch is always taken.
147033 **
147034 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147035 **
147036 ** As above, except that each of the for() loops becomes:
147037 **
147038 ** for(i=0; i<ctr; i++){
147039 ** Gosub addrGosub
147040 ** AggInverse (iEphCsr)
147041 ** Next iEphCsr
147042 ** }
147043 **
147044 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147045 **
147046 ** flush_partition:
147047 ** Once {
147048 ** OpenDup (iEphCsr -> csrLead)
147049 ** }
147050 ** foreach row (csrLead) {
147051 ** AggStep (csrLead)
147052 ** }
147053 ** foreach row (iEphCsr) {
147054 ** Gosub addrGosub
147055 ** }
147056 **
147057 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
147058 **
147059 ** flush_partition:
147060 ** Once {
147061 ** OpenDup (iEphCsr -> csrLead)
147062 ** }
147063 ** foreach row (csrLead){
147064 ** AggStep (csrLead)
147065 ** }
147066 ** Rewind (csrLead)
147067 ** Integer ctr 0
147068 ** foreach row (csrLead){
147069 ** if( new peer ){
147070 ** AggFinal (xValue)
147071 ** for(i=0; i<ctr; i++){
147072 ** Gosub addrGosub
147073 ** AggInverse (iEphCsr)
147074 ** Next iEphCsr
147075 ** }
147076 ** Integer ctr 0
147077 ** }
147078 ** Incr ctr
147079 ** }
147080 **
147081 ** AggFinal (xFinalize)
147082 ** for(i=0; i<ctr; i++){
147083 ** Gosub addrGosub
147084 ** Next iEphCsr
147085 ** }
147086 **
147087 ** ResetSorter (csr)
147088 ** Return
147089 */
147090 static void windowCodeCacheStep(
147091 Parse *pParse,
147092 Select *p,
147093 WhereInfo *pWInfo,
147094 int regGosub,
147095 int addrGosub
147096 ){
147097 Window *pMWin = p->pWin;
147098 Vdbe *v = sqlite3GetVdbe(pParse);
147099 int k;
147100 int addr;
147101 ExprList *pPart = pMWin->pPartition;
147102 ExprList *pOrderBy = pMWin->pOrderBy;
147103 int nPeer = pOrderBy ? pOrderBy->nExpr : 0;
147104 int regNewPeer;
147105
147106 int addrGoto; /* Address of Goto used to jump flush_par.. */
147107 int addrNext; /* Jump here for next iteration of loop */
147108 int regFlushPart;
147109 int lblFlushPart;
147110 int csrLead;
147111 int regCtr;
147112 int regArg; /* Register array to martial function args */
147113 int regSize;
147114 int lblEmpty;
147115 int bReverse = pMWin->pOrderBy && pMWin->eStart==TK_CURRENT
147116 && pMWin->eEnd==TK_UNBOUNDED;
147117
147118 assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147119 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
147120 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
147121 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
147122 );
147123
147124 lblEmpty = sqlite3VdbeMakeLabel(pParse);
147125 regNewPeer = pParse->nMem+1;
147126 pParse->nMem += nPeer;
147127
147128 /* Allocate register and label for the "flush_partition" sub-routine. */
147129 regFlushPart = ++pParse->nMem;
147130 lblFlushPart = sqlite3VdbeMakeLabel(pParse);
147131
147132 csrLead = pParse->nTab++;
147133 regCtr = ++pParse->nMem;
147134
147135 windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
147136 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147137
147138 /* Start of "flush_partition" */
147139 sqlite3VdbeResolveLabel(v, lblFlushPart);
147140 sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
147141 VdbeCoverage(v);
147142 sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);
147143
147144 /* Initialize the accumulator register for each window function to NULL */
147145 regArg = windowInitAccum(pParse, pMWin);
147146
147147 sqlite3VdbeAddOp2(v, OP_Integer, 0, regCtr);
147148 sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
147149 VdbeCoverage(v);
147150 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblEmpty);
147151 VdbeCoverageNeverTaken(v);
147152
147153 if( bReverse ){
147154 int addr2 = sqlite3VdbeCurrentAddr(v);
147155 windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
147156 sqlite3VdbeAddOp2(v, OP_Next, csrLead, addr2);
147157 VdbeCoverage(v);
147158 sqlite3VdbeAddOp2(v, OP_Rewind, csrLead, lblEmpty);
147159 VdbeCoverageNeverTaken(v);
147160 }
147161 addrNext = sqlite3VdbeCurrentAddr(v);
147162
147163 if( pOrderBy && (pMWin->eEnd==TK_CURRENT || pMWin->eStart==TK_CURRENT) ){
147164 int bCurrent = (pMWin->eStart==TK_CURRENT);
147165 int addrJump = 0; /* Address of OP_Jump below */
147166 if( pMWin->eType==TK_RANGE ){
147167 int iOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
147168 int regPeer = pMWin->regPart + (pPart ? pPart->nExpr : 0);
147169 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147170 for(k=0; k<nPeer; k++){
147171 sqlite3VdbeAddOp3(v, OP_Column, csrLead, iOff+k, regNewPeer+k);
147172 }
147173 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
147174 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147175 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147176 VdbeCoverage(v);
147177 sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, nPeer-1);
147178 }
147179
147180 windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub,
147181 (bCurrent ? regArg : 0), (bCurrent ? regSize : 0)
147182 );
147183 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147184 }
147185
147186 if( bReverse==0 ){
147187 windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
147188 }
147189 sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);
147190 sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrNext);
147191 VdbeCoverage(v);
147192
147193 windowReturnRows(pParse, pMWin, regCtr, regGosub, addrGosub, 0, 0);
147194
147195 sqlite3VdbeResolveLabel(v, lblEmpty);
147196 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
147197 sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
147198
147199 /* Jump to here to skip over flush_partition */
147200 sqlite3VdbeJumpHere(v, addrGoto);
147201 }
147202
147203
147204 /*
147205 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147206 **
147207 ** ...
147208 ** if( new partition ){
147209 ** AggFinal (xFinalize)
147210 ** Gosub addrGosub
147211 ** ResetSorter eph-table
147212 ** }
147213 ** else if( new peer ){
147214 ** AggFinal (xValue)
147215 ** Gosub addrGosub
147216 ** ResetSorter eph-table
147217 ** }
147218 ** AggStep
147219 ** Insert (record into eph-table)
147220 ** sqlite3WhereEnd()
147221 ** AggFinal (xFinalize)
147222 ** Gosub addrGosub
147223 **
147224 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147225 **
147226 ** As above, except take no action for a "new peer". Invoke
147227 ** the sub-routine once only for each partition.
147228 **
147229 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147230 **
147231 ** As above, except that the "new peer" condition is handled in the
147232 ** same way as "new partition" (so there is no "else if" block).
147233 **
147234 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147235 **
147236 ** As above, except assume every row is a "new peer".
147237 */
147238 static void windowCodeDefaultStep(
147239 Parse *pParse,
147240 Select *p,
147241 WhereInfo *pWInfo,
147242 int regGosub,
147243 int addrGosub
147244 ){
147245 Window *pMWin = p->pWin;
147246 Vdbe *v = sqlite3GetVdbe(pParse);
147247 int k;
147248 int iSubCsr = p->pSrc->a[0].iCursor;
147249 int nSub = p->pSrc->a[0].pTab->nCol;
147250 int reg = pParse->nMem+1;
147251 int regRecord = reg+nSub;
147252 int regRowid = regRecord+1;
147253 int addr;
147254 ExprList *pPart = pMWin->pPartition;
147255 ExprList *pOrderBy = pMWin->pOrderBy;
147256
147257 assert( pMWin->eType==TK_RANGE
147258 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147259 );
147260
147261 assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT)
147262 || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED)
147263 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT)
147264 || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED && !pOrderBy)
147265 );
147266
147267 if( pMWin->eEnd==TK_UNBOUNDED ){
147268 pOrderBy = 0;
147269 }
147270
147271 pParse->nMem += nSub + 2;
147272
147273 /* Load the individual column values of the row returned by
147274 ** the sub-select into an array of registers. */
147275 for(k=0; k<nSub; k++){
147276 sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
147277 }
147278
147279 /* Check if this is the start of a new partition or peer group. */
147280 if( pPart || pOrderBy ){
147281 int nPart = (pPart ? pPart->nExpr : 0);
147282 int addrGoto = 0;
147283 int addrJump = 0;
147284 int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
147285
147286 if( pPart ){
147287 int regNewPart = reg + pMWin->nBufferCol;
147288 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
147289 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart,nPart);
147290 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147291 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147292 VdbeCoverageEqNe(v);
147293 windowAggFinal(pParse, pMWin, 1);
147294 if( pOrderBy ){
147295 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147296 }
147297 }
147298
147299 if( pOrderBy ){
147300 int regNewPeer = reg + pMWin->nBufferCol + nPart;
147301 int regPeer = pMWin->regPart + nPart;
147302
147303 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147304 if( pMWin->eType==TK_RANGE ){
147305 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147306 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPeer, regPeer, nPeer);
147307 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147308 addrJump = sqlite3VdbeAddOp3(v, OP_Jump, addr+2, 0, addr+2);
147309 VdbeCoverage(v);
147310 }else{
147311 addrJump = 0;
147312 }
147313 windowAggFinal(pParse, pMWin, pMWin->eStart==TK_CURRENT);
147314 if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
147315 }
147316
147317 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
147318 VdbeCoverage(v);
147319 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
147320 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
147321 VdbeCoverage(v);
147322
147323 sqlite3VdbeAddOp1(v, OP_ResetSorter, pMWin->iEphCsr);
147324 sqlite3VdbeAddOp3(
147325 v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
147326 );
147327
147328 if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
147329 }
147330
147331 /* Invoke step function for window functions */
147332 windowAggStep(pParse, pMWin, -1, 0, reg, 0);
147333
147334 /* Buffer the current row in the ephemeral table. */
147335 if( pMWin->nBufferCol>0 ){
147336 sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
147337 }else{
147338 sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
147339 sqlite3VdbeAppendP4(v, (void*)"", 0);
147340 }
147341 sqlite3VdbeAddOp2(v, OP_NewRowid, pMWin->iEphCsr, regRowid);
147342 sqlite3VdbeAddOp3(v, OP_Insert, pMWin->iEphCsr, regRecord, regRowid);
147343
147344 /* End the database scan loop. */
147345 sqlite3WhereEnd(pWInfo);
147346
147347 windowAggFinal(pParse, pMWin, 1);
147348 sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr,sqlite3VdbeCurrentAddr(v)+3);
147349 VdbeCoverage(v);
147350 sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
147351 sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-1);
147352 VdbeCoverage(v);
147353 }
147354
147355 /*
147356 ** Allocate and return a duplicate of the Window object indicated by the
147357 ** third argument. Set the Window.pOwner field of the new object to
147358 ** pOwner.
@@ -147365,13 +147351,14 @@
147365 pNew->zName = sqlite3DbStrDup(db, p->zName);
147366 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
147367 pNew->pFunc = p->pFunc;
147368 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
147369 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
147370 pNew->eType = p->eType;
147371 pNew->eEnd = p->eEnd;
147372 pNew->eStart = p->eStart;
 
147373 pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
147374 pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
147375 pNew->pOwner = pOwner;
147376 }
147377 }
@@ -147393,95 +147380,689 @@
147393 pp = &((*pp)->pNextWin);
147394 }
147395
147396 return pRet;
147397 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147398
147399 /*
147400 ** sqlite3WhereBegin() has already been called for the SELECT statement
147401 ** passed as the second argument when this function is invoked. It generates
147402 ** code to populate the Window.regResult register for each window function and
147403 ** invoke the sub-routine at instruction addrGosub once for each row.
147404 ** This function calls sqlite3WhereEnd() before returning.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147405 */
147406 SQLITE_PRIVATE void sqlite3WindowCodeStep(
147407 Parse *pParse, /* Parse context */
147408 Select *p, /* Rewritten SELECT statement */
147409 WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */
147410 int regGosub, /* Register for OP_Gosub */
147411 int addrGosub /* OP_Gosub here to return each row */
147412 ){
147413 Window *pMWin = p->pWin;
147414
147415 /* There are three different functions that may be used to do the work
147416 ** of this one, depending on the window frame and the specific built-in
147417 ** window functions used (if any).
147418 **
147419 ** windowCodeRowExprStep() handles all "ROWS" window frames, except for:
147420 **
147421 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147422 **
147423 ** The exception is because windowCodeRowExprStep() implements all window
147424 ** frame types by caching the entire partition in a temp table, and
147425 ** "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" is easy enough to
147426 ** implement without such a cache.
147427 **
147428 ** windowCodeCacheStep() is used for:
147429 **
147430 ** RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
147431 **
147432 ** It is also used for anything not handled by windowCodeRowExprStep()
147433 ** that invokes a built-in window function that requires the entire
147434 ** partition to be cached in a temp table before any rows are returned
147435 ** (e.g. nth_value() or percent_rank()).
147436 **
147437 ** Finally, assuming there is no built-in window function that requires
147438 ** the partition to be cached, windowCodeDefaultStep() is used for:
147439 **
147440 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147441 ** RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
147442 ** RANGE BETWEEN CURRENT ROW AND CURRENT ROW
147443 ** ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
147444 **
147445 ** windowCodeDefaultStep() is the only one of the three functions that
147446 ** does not cache each partition in a temp table before beginning to
147447 ** return rows.
147448 */
147449 if( pMWin->eType==TK_ROWS
147450 && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy)
147451 ){
147452 VdbeModuleComment((pParse->pVdbe, "Begin RowExprStep()"));
147453 windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
147454 }else{
147455 Window *pWin;
147456 int bCache = 0; /* True to use CacheStep() */
147457
147458 if( pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED ){
147459 bCache = 1;
147460 }else{
147461 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147462 FuncDef *pFunc = pWin->pFunc;
147463 if( (pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE)
147464 || (pFunc->zName==nth_valueName)
147465 || (pFunc->zName==first_valueName)
147466 || (pFunc->zName==leadName)
147467 || (pFunc->zName==lagName)
147468 ){
147469 bCache = 1;
147470 break;
147471 }
147472 }
147473 }
147474
147475 /* Otherwise, call windowCodeDefaultStep(). */
147476 if( bCache ){
147477 VdbeModuleComment((pParse->pVdbe, "Begin CacheStep()"));
147478 windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
147479 }else{
147480 VdbeModuleComment((pParse->pVdbe, "Begin DefaultStep()"));
147481 windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
147482 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147483 }
147484 }
147485
147486 #endif /* SQLITE_OMIT_WINDOWFUNC */
147487
@@ -147729,31 +148310,32 @@
147729 #ifndef INTERFACE
147730 # define INTERFACE 1
147731 #endif
147732 /************* Begin control #defines *****************************************/
147733 #define YYCODETYPE unsigned short int
147734 #define YYNOCODE 278
147735 #define YYACTIONTYPE unsigned short int
147736 #define YYWILDCARD 91
147737 #define sqlite3ParserTOKENTYPE Token
147738 typedef union {
147739 int yyinit;
147740 sqlite3ParserTOKENTYPE yy0;
147741 ExprList* yy42;
147742 int yy96;
147743 TriggerStep* yy119;
147744 Window* yy147;
147745 SrcList* yy167;
147746 Upsert* yy266;
147747 struct FrameBound yy317;
147748 IdList* yy336;
147749 struct TrigEvent yy350;
147750 struct {int value; int mask;} yy367;
147751 Select* yy423;
147752 const char* yy464;
147753 Expr* yy490;
147754 With* yy499;
 
147755 } YYMINORTYPE;
147756 #ifndef YYSTACKDEPTH
147757 #define YYSTACKDEPTH 100
147758 #endif
147759 #define sqlite3ParserARG_SDECL
@@ -147765,21 +148347,21 @@
147765 #define sqlite3ParserCTX_PDECL ,Parse *pParse
147766 #define sqlite3ParserCTX_PARAM ,pParse
147767 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
147768 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
147769 #define YYFALLBACK 1
147770 #define YYNSTATE 524
147771 #define YYNRULE 369
147772 #define YYNTOKEN 155
147773 #define YY_MAX_SHIFT 523
147774 #define YY_MIN_SHIFTREDUCE 760
147775 #define YY_MAX_SHIFTREDUCE 1128
147776 #define YY_ERROR_ACTION 1129
147777 #define YY_ACCEPT_ACTION 1130
147778 #define YY_NO_ACTION 1131
147779 #define YY_MIN_REDUCE 1132
147780 #define YY_MAX_REDUCE 1500
147781 /************* End control #defines *******************************************/
147782 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
147783
147784 /* Define the yytestcase() macro to be a no-op if is not already defined
147785 ** otherwise.
@@ -147842,573 +148424,606 @@
147842 ** yy_reduce_ofst[] For each state, the offset into yy_action for
147843 ** shifting non-terminals after a reduce.
147844 ** yy_default[] Default action for each state.
147845 **
147846 *********** Begin parsing tables **********************************************/
147847 #define YY_ACTTAB_COUNT (2009)
147848 static const YYACTIONTYPE yy_action[] = {
147849 /* 0 */ 377, 518, 371, 107, 104, 200, 1293, 518, 1130, 1,
147850 /* 10 */ 1, 523, 2, 1134, 518, 1203, 1203, 1262, 277, 373,
147851 /* 20 */ 129, 495, 37, 37, 1397, 1201, 1201, 1211, 65, 65,
147852 /* 30 */ 480, 891, 107, 104, 200, 37, 37, 1043, 1494, 892,
147853 /* 40 */ 346, 1494, 342, 114, 115, 105, 1106, 1106, 957, 960,
147854 /* 50 */ 950, 950, 112, 112, 113, 113, 113, 113, 285, 254,
147855 /* 60 */ 254, 518, 254, 254, 500, 518, 495, 518, 107, 104,
147856 /* 70 */ 200, 1085, 515, 481, 386, 515, 1464, 442, 501, 230,
147857 /* 80 */ 197, 439, 37, 37, 1172, 210, 65, 65, 65, 65,
147858 /* 90 */ 254, 254, 111, 111, 111, 111, 110, 110, 109, 109,
147859 /* 100 */ 109, 108, 404, 515, 404, 155, 1041, 431, 401, 400,
147860 /* 110 */ 254, 254, 373, 1431, 1427, 408, 1110, 1085, 1086, 1087,
147861 /* 120 */ 284, 1112, 500, 515, 500, 368, 1433, 1421, 1428, 1111,
147862 /* 130 */ 1261, 499, 373, 502, 108, 404, 114, 115, 105, 1106,
147863 /* 140 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147864 /* 150 */ 113, 276, 509, 1113, 369, 1113, 114, 115, 105, 1106,
147865 /* 160 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147866 /* 170 */ 113, 496, 1420, 1431, 493, 1468, 1065, 260, 1063, 433,
147867 /* 180 */ 74, 107, 104, 200, 498, 111, 111, 111, 111, 110,
147868 /* 190 */ 110, 109, 109, 109, 108, 404, 373, 113, 113, 113,
147869 /* 200 */ 113, 106, 131, 91, 1361, 111, 111, 111, 111, 110,
147870 /* 210 */ 110, 109, 109, 109, 108, 404, 113, 113, 113, 113,
147871 /* 220 */ 114, 115, 105, 1106, 1106, 957, 960, 950, 950, 112,
147872 /* 230 */ 112, 113, 113, 113, 113, 111, 111, 111, 111, 110,
147873 /* 240 */ 110, 109, 109, 109, 108, 404, 116, 110, 110, 109,
147874 /* 250 */ 109, 109, 108, 404, 111, 111, 111, 111, 110, 110,
147875 /* 260 */ 109, 109, 109, 108, 404, 917, 512, 512, 512, 111,
147876 /* 270 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147877 /* 280 */ 517, 1198, 1177, 181, 109, 109, 109, 108, 404, 373,
147878 /* 290 */ 1198, 402, 402, 402, 75, 360, 111, 111, 111, 111,
147879 /* 300 */ 110, 110, 109, 109, 109, 108, 404, 382, 299, 419,
147880 /* 310 */ 287, 170, 518, 114, 115, 105, 1106, 1106, 957, 960,
147881 /* 320 */ 950, 950, 112, 112, 113, 113, 113, 113, 1444, 523,
147882 /* 330 */ 2, 1134, 518, 13, 13, 337, 277, 1085, 129, 226,
147883 /* 340 */ 937, 1058, 1000, 471, 917, 1211, 453, 384, 1085, 395,
147884 /* 350 */ 162, 1057, 155, 45, 45, 416, 928, 401, 400, 479,
147885 /* 360 */ 927, 12, 111, 111, 111, 111, 110, 110, 109, 109,
147886 /* 370 */ 109, 108, 404, 226, 286, 254, 254, 254, 254, 518,
147887 /* 380 */ 16, 16, 373, 1085, 1086, 1087, 314, 299, 515, 472,
147888 /* 390 */ 515, 927, 927, 929, 1085, 1086, 1087, 378, 276, 509,
147889 /* 400 */ 65, 65, 1113, 210, 1113, 1085, 114, 115, 105, 1106,
147890 /* 410 */ 1106, 957, 960, 950, 950, 112, 112, 113, 113, 113,
147891 /* 420 */ 113, 1448, 222, 1134, 1089, 461, 458, 457, 277, 180,
147892 /* 430 */ 129, 378, 392, 408, 423, 456, 500, 1211, 240, 257,
147893 /* 440 */ 324, 464, 319, 463, 227, 470, 12, 317, 424, 300,
147894 /* 450 */ 317, 1085, 1086, 1087, 485, 111, 111, 111, 111, 110,
147895 /* 460 */ 110, 109, 109, 109, 108, 404, 181, 118, 1085, 254,
147896 /* 470 */ 254, 1089, 518, 90, 351, 373, 518, 1181, 365, 798,
147897 /* 480 */ 1440, 339, 515, 248, 248, 77, 325, 133, 1085, 249,
147898 /* 490 */ 424, 300, 794, 49, 49, 210, 515, 65, 65, 114,
147899 /* 500 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147900 /* 510 */ 113, 113, 113, 113, 1085, 1086, 1087, 222, 1085, 438,
147901 /* 520 */ 461, 458, 457, 937, 787, 408, 171, 857, 362, 1021,
147902 /* 530 */ 456, 136, 198, 486, 1085, 1086, 1087, 448, 794, 928,
147903 /* 540 */ 5, 193, 192, 927, 1022, 107, 104, 200, 111, 111,
147904 /* 550 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 1023,
147905 /* 560 */ 254, 254, 803, 1085, 1085, 1086, 1087, 437, 373, 1085,
147906 /* 570 */ 344, 787, 791, 515, 927, 927, 929, 1085, 1408, 1396,
147907 /* 580 */ 832, 1085, 176, 3, 852, 1085, 518, 1439, 429, 851,
147908 /* 590 */ 833, 518, 114, 115, 105, 1106, 1106, 957, 960, 950,
147909 /* 600 */ 950, 112, 112, 113, 113, 113, 113, 13, 13, 1085,
147910 /* 610 */ 1086, 1087, 13, 13, 518, 1085, 1086, 1087, 1496, 358,
147911 /* 620 */ 1085, 389, 1234, 1085, 1086, 1087, 391, 1085, 1086, 1087,
147912 /* 630 */ 448, 1085, 1086, 1087, 518, 65, 65, 947, 947, 958,
147913 /* 640 */ 961, 111, 111, 111, 111, 110, 110, 109, 109, 109,
147914 /* 650 */ 108, 404, 518, 382, 878, 13, 13, 518, 877, 518,
147915 /* 660 */ 263, 373, 518, 431, 448, 1070, 1085, 1086, 1087, 267,
147916 /* 670 */ 448, 488, 1360, 64, 64, 431, 812, 155, 50, 50,
147917 /* 680 */ 65, 65, 518, 65, 65, 114, 115, 105, 1106, 1106,
147918 /* 690 */ 957, 960, 950, 950, 112, 112, 113, 113, 113, 113,
147919 /* 700 */ 518, 951, 382, 13, 13, 415, 411, 462, 414, 1085,
147920 /* 710 */ 1366, 777, 1210, 292, 297, 813, 399, 497, 181, 403,
147921 /* 720 */ 261, 15, 15, 276, 509, 414, 413, 1366, 1368, 410,
147922 /* 730 */ 372, 345, 1209, 264, 111, 111, 111, 111, 110, 110,
147923 /* 740 */ 109, 109, 109, 108, 404, 265, 254, 254, 229, 1405,
147924 /* 750 */ 268, 1215, 268, 1103, 373, 1085, 1086, 1087, 938, 515,
147925 /* 760 */ 393, 409, 876, 515, 254, 254, 1152, 482, 473, 262,
147926 /* 770 */ 422, 476, 325, 503, 289, 518, 291, 515, 114, 115,
147927 /* 780 */ 105, 1106, 1106, 957, 960, 950, 950, 112, 112, 113,
147928 /* 790 */ 113, 113, 113, 414, 1021, 1366, 39, 39, 254, 254,
147929 /* 800 */ 254, 254, 980, 254, 254, 254, 254, 255, 255, 1022,
147930 /* 810 */ 279, 515, 516, 515, 846, 846, 515, 138, 515, 518,
147931 /* 820 */ 515, 1043, 1495, 251, 1023, 1495, 876, 111, 111, 111,
147932 /* 830 */ 111, 110, 110, 109, 109, 109, 108, 404, 518, 1353,
147933 /* 840 */ 51, 51, 518, 199, 518, 506, 290, 373, 518, 276,
147934 /* 850 */ 509, 922, 9, 483, 233, 1005, 1005, 445, 189, 52,
147935 /* 860 */ 52, 325, 280, 53, 53, 54, 54, 373, 876, 55,
147936 /* 870 */ 55, 114, 115, 105, 1106, 1106, 957, 960, 950, 950,
147937 /* 880 */ 112, 112, 113, 113, 113, 113, 97, 518, 95, 1104,
147938 /* 890 */ 1041, 114, 115, 105, 1106, 1106, 957, 960, 950, 950,
147939 /* 900 */ 112, 112, 113, 113, 113, 113, 135, 199, 56, 56,
147940 /* 910 */ 765, 766, 767, 225, 224, 223, 518, 283, 437, 233,
147941 /* 920 */ 111, 111, 111, 111, 110, 110, 109, 109, 109, 108,
147942 /* 930 */ 404, 1002, 876, 326, 518, 1002, 1104, 40, 40, 518,
147943 /* 940 */ 111, 111, 111, 111, 110, 110, 109, 109, 109, 108,
147944 /* 950 */ 404, 518, 448, 518, 1104, 41, 41, 518, 17, 518,
147945 /* 960 */ 43, 43, 1155, 379, 518, 448, 518, 443, 518, 390,
147946 /* 970 */ 518, 194, 44, 44, 57, 57, 1247, 518, 58, 58,
147947 /* 980 */ 59, 59, 518, 466, 326, 14, 14, 60, 60, 120,
147948 /* 990 */ 120, 61, 61, 449, 1206, 93, 518, 425, 46, 46,
147949 /* 1000 */ 518, 1104, 518, 62, 62, 518, 437, 305, 518, 852,
147950 /* 1010 */ 518, 298, 518, 1246, 851, 373, 518, 63, 63, 1293,
147951 /* 1020 */ 397, 47, 47, 142, 142, 1467, 143, 143, 821, 70,
147952 /* 1030 */ 70, 48, 48, 66, 66, 373, 518, 121, 121, 114,
147953 /* 1040 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147954 /* 1050 */ 113, 113, 113, 113, 518, 418, 518, 67, 67, 114,
147955 /* 1060 */ 115, 105, 1106, 1106, 957, 960, 950, 950, 112, 112,
147956 /* 1070 */ 113, 113, 113, 113, 312, 122, 122, 123, 123, 1293,
147957 /* 1080 */ 518, 357, 1126, 88, 518, 435, 325, 387, 111, 111,
147958 /* 1090 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 266,
147959 /* 1100 */ 518, 119, 119, 518, 1293, 141, 141, 518, 111, 111,
147960 /* 1110 */ 111, 111, 110, 110, 109, 109, 109, 108, 404, 518,
147961 /* 1120 */ 801, 140, 140, 518, 127, 127, 511, 379, 126, 126,
147962 /* 1130 */ 518, 137, 518, 1308, 518, 307, 518, 310, 518, 203,
147963 /* 1140 */ 124, 124, 1307, 96, 125, 125, 207, 388, 1441, 468,
147964 /* 1150 */ 1127, 69, 69, 71, 71, 68, 68, 38, 38, 42,
147965 /* 1160 */ 42, 357, 1042, 373, 1293, 276, 509, 801, 185, 469,
147966 /* 1170 */ 494, 436, 444, 6, 380, 156, 253, 197, 469, 134,
147967 /* 1180 */ 426, 33, 1038, 373, 1121, 359, 1411, 114, 115, 105,
147968 /* 1190 */ 1106, 1106, 957, 960, 950, 950, 112, 112, 113, 113,
147969 /* 1200 */ 113, 113, 914, 296, 27, 293, 90, 114, 103, 105,
147970 /* 1210 */ 1106, 1106, 957, 960, 950, 950, 112, 112, 113, 113,
147971 /* 1220 */ 113, 113, 919, 275, 430, 232, 891, 232, 432, 256,
147972 /* 1230 */ 1127, 232, 398, 370, 892, 28, 111, 111, 111, 111,
147973 /* 1240 */ 110, 110, 109, 109, 109, 108, 404, 301, 454, 1385,
147974 /* 1250 */ 90, 228, 209, 987, 811, 810, 111, 111, 111, 111,
147975 /* 1260 */ 110, 110, 109, 109, 109, 108, 404, 315, 818, 819,
147976 /* 1270 */ 90, 323, 983, 931, 885, 228, 373, 232, 999, 849,
147977 /* 1280 */ 999, 322, 102, 998, 1384, 998, 785, 850, 440, 132,
147978 /* 1290 */ 102, 302, 1243, 306, 309, 311, 373, 313, 1194, 1180,
147979 /* 1300 */ 987, 115, 105, 1106, 1106, 957, 960, 950, 950, 112,
147980 /* 1310 */ 112, 113, 113, 113, 113, 1178, 1179, 318, 327, 328,
147981 /* 1320 */ 931, 1255, 105, 1106, 1106, 957, 960, 950, 950, 112,
147982 /* 1330 */ 112, 113, 113, 113, 113, 1292, 1230, 1457, 273, 1241,
147983 /* 1340 */ 504, 505, 1298, 100, 510, 246, 4, 1161, 1154, 111,
147984 /* 1350 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147985 /* 1360 */ 513, 1143, 187, 1142, 202, 1144, 1451, 356, 1227, 111,
147986 /* 1370 */ 111, 111, 111, 110, 110, 109, 109, 109, 108, 404,
147987 /* 1380 */ 11, 1277, 330, 405, 332, 334, 191, 1285, 364, 195,
147988 /* 1390 */ 295, 417, 288, 100, 510, 507, 4, 434, 459, 321,
147989 /* 1400 */ 1177, 349, 1357, 1356, 336, 155, 190, 1454, 1121, 158,
147990 /* 1410 */ 513, 508, 235, 1404, 937, 1402, 1118, 381, 77, 428,
147991 /* 1420 */ 98, 98, 8, 1282, 168, 30, 152, 99, 160, 405,
147992 /* 1430 */ 520, 519, 88, 405, 927, 1362, 1274, 420, 163, 73,
147993 /* 1440 */ 164, 76, 165, 166, 421, 507, 452, 212, 361, 363,
147994 /* 1450 */ 427, 276, 509, 31, 1288, 172, 491, 441, 216, 1351,
147995 /* 1460 */ 82, 490, 447, 1373, 937, 927, 927, 929, 930, 24,
147996 /* 1470 */ 98, 98, 304, 247, 218, 177, 308, 99, 219, 405,
147997 /* 1480 */ 520, 519, 450, 1145, 927, 220, 366, 1197, 100, 510,
147998 /* 1490 */ 465, 4, 1188, 1196, 1195, 394, 803, 1169, 1187, 367,
147999 /* 1500 */ 1168, 396, 484, 320, 1167, 513, 1466, 87, 475, 100,
148000 /* 1510 */ 510, 271, 4, 272, 478, 927, 927, 929, 930, 24,
148001 /* 1520 */ 1443, 1074, 407, 1238, 1239, 258, 513, 329, 405, 331,
148002 /* 1530 */ 355, 355, 354, 243, 352, 234, 489, 774, 498, 184,
148003 /* 1540 */ 507, 338, 1422, 339, 117, 1220, 10, 341, 333, 405,
148004 /* 1550 */ 204, 491, 282, 1219, 1237, 1236, 492, 335, 343, 937,
148005 /* 1560 */ 281, 507, 94, 1337, 186, 98, 98, 347, 89, 487,
148006 /* 1570 */ 348, 241, 99, 29, 405, 520, 519, 274, 1151, 927,
148007 /* 1580 */ 937, 521, 1080, 245, 242, 244, 98, 98, 856, 522,
148008 /* 1590 */ 206, 1140, 1135, 99, 144, 405, 520, 519, 147, 375,
148009 /* 1600 */ 927, 149, 376, 157, 1389, 1390, 1388, 1387, 205, 145,
148010 /* 1610 */ 927, 927, 929, 930, 24, 146, 130, 761, 1165, 1164,
148011 /* 1620 */ 72, 100, 510, 1162, 4, 269, 406, 188, 278, 201,
148012 /* 1630 */ 259, 927, 927, 929, 930, 24, 128, 911, 513, 997,
148013 /* 1640 */ 995, 159, 374, 208, 148, 161, 835, 276, 509, 211,
148014 /* 1650 */ 294, 1011, 915, 167, 150, 383, 169, 78, 385, 79,
148015 /* 1660 */ 80, 405, 81, 151, 1014, 213, 214, 1010, 139, 18,
148016 /* 1670 */ 412, 215, 303, 507, 232, 1115, 1003, 446, 173, 217,
148017 /* 1680 */ 174, 32, 776, 451, 491, 322, 221, 175, 814, 490,
148018 /* 1690 */ 83, 455, 937, 19, 460, 316, 20, 84, 98, 98,
148019 /* 1700 */ 270, 182, 85, 467, 153, 99, 154, 405, 520, 519,
148020 /* 1710 */ 1074, 407, 927, 183, 258, 963, 1046, 86, 34, 355,
148021 /* 1720 */ 355, 354, 243, 352, 474, 1047, 774, 35, 477, 196,
148022 /* 1730 */ 250, 100, 510, 252, 4, 884, 178, 231, 1060, 204,
148023 /* 1740 */ 21, 282, 102, 927, 927, 929, 930, 24, 513, 281,
148024 /* 1750 */ 879, 22, 1064, 1062, 1051, 7, 340, 23, 978, 179,
148025 /* 1760 */ 90, 92, 510, 964, 4, 236, 962, 966, 1020, 1019,
148026 /* 1770 */ 237, 405, 967, 25, 36, 514, 932, 786, 513, 206,
148027 /* 1780 */ 101, 26, 845, 507, 238, 239, 1459, 147, 350, 1458,
148028 /* 1790 */ 149, 353, 1075, 1131, 1131, 1131, 1131, 205, 1131, 1131,
148029 /* 1800 */ 1131, 405, 937, 1131, 1131, 1131, 1131, 1131, 98, 98,
148030 /* 1810 */ 1131, 1131, 1131, 507, 1131, 99, 1131, 405, 520, 519,
148031 /* 1820 */ 1131, 1131, 927, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148032 /* 1830 */ 1131, 374, 937, 1131, 1131, 1131, 276, 509, 98, 98,
148033 /* 1840 */ 1131, 1131, 1131, 1131, 1131, 99, 1131, 405, 520, 519,
148034 /* 1850 */ 1131, 1131, 927, 927, 927, 929, 930, 24, 1131, 412,
148035 /* 1860 */ 1131, 1131, 1131, 258, 1131, 1131, 1131, 1131, 355, 355,
148036 /* 1870 */ 354, 243, 352, 1131, 1131, 774, 1131, 1131, 1131, 1131,
148037 /* 1880 */ 1131, 1131, 1131, 927, 927, 929, 930, 24, 204, 1131,
148038 /* 1890 */ 282, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 281, 1131,
148039 /* 1900 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148040 /* 1910 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148041 /* 1920 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 206, 1131,
148042 /* 1930 */ 1131, 1131, 1131, 1131, 1131, 1131, 147, 1131, 1131, 149,
148043 /* 1940 */ 1131, 1131, 1131, 1131, 1131, 1131, 205, 1131, 1131, 1131,
148044 /* 1950 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148045 /* 1960 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148046 /* 1970 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148047 /* 1980 */ 374, 1131, 1131, 1131, 1131, 276, 509, 1131, 1131, 1131,
148048 /* 1990 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
148049 /* 2000 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 412,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148050 };
148051 static const YYCODETYPE yy_lookahead[] = {
148052 /* 0 */ 168, 163, 184, 238, 239, 240, 163, 163, 155, 156,
148053 /* 10 */ 157, 158, 159, 160, 163, 202, 203, 187, 165, 19,
148054 /* 20 */ 167, 163, 184, 185, 259, 202, 203, 174, 184, 185,
148055 /* 30 */ 174, 31, 238, 239, 240, 184, 185, 22, 23, 39,
148056 /* 40 */ 216, 26, 218, 43, 44, 45, 46, 47, 48, 49,
148057 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 206,
148058 /* 60 */ 207, 163, 206, 207, 220, 163, 163, 163, 238, 239,
148059 /* 70 */ 240, 59, 219, 229, 231, 219, 183, 245, 174, 223,
148060 /* 80 */ 224, 249, 184, 185, 191, 232, 184, 185, 184, 185,
148061 /* 90 */ 206, 207, 92, 93, 94, 95, 96, 97, 98, 99,
148062 /* 100 */ 100, 101, 102, 219, 102, 81, 91, 163, 96, 97,
148063 /* 110 */ 206, 207, 19, 275, 276, 262, 104, 105, 106, 107,
148064 /* 120 */ 163, 109, 220, 219, 220, 184, 275, 269, 277, 117,
148065 /* 130 */ 187, 229, 19, 229, 101, 102, 43, 44, 45, 46,
148066 /* 140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148067 /* 150 */ 57, 127, 128, 141, 184, 143, 43, 44, 45, 46,
148068 /* 160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148069 /* 170 */ 57, 268, 269, 275, 276, 197, 83, 233, 85, 163,
148070 /* 180 */ 67, 238, 239, 240, 134, 92, 93, 94, 95, 96,
148071 /* 190 */ 97, 98, 99, 100, 101, 102, 19, 54, 55, 56,
148072 /* 200 */ 57, 58, 152, 26, 247, 92, 93, 94, 95, 96,
148073 /* 210 */ 97, 98, 99, 100, 101, 102, 54, 55, 56, 57,
148074 /* 220 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148075 /* 230 */ 53, 54, 55, 56, 57, 92, 93, 94, 95, 96,
148076 /* 240 */ 97, 98, 99, 100, 101, 102, 69, 96, 97, 98,
148077 /* 250 */ 99, 100, 101, 102, 92, 93, 94, 95, 96, 97,
148078 /* 260 */ 98, 99, 100, 101, 102, 73, 179, 180, 181, 92,
148079 /* 270 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148080 /* 280 */ 163, 191, 192, 163, 98, 99, 100, 101, 102, 19,
148081 /* 290 */ 200, 179, 180, 181, 24, 175, 92, 93, 94, 95,
148082 /* 300 */ 96, 97, 98, 99, 100, 101, 102, 163, 116, 117,
148083 /* 310 */ 118, 22, 163, 43, 44, 45, 46, 47, 48, 49,
148084 /* 320 */ 50, 51, 52, 53, 54, 55, 56, 57, 157, 158,
148085 /* 330 */ 159, 160, 163, 184, 185, 163, 165, 59, 167, 46,
148086 /* 340 */ 90, 76, 11, 174, 73, 174, 19, 198, 59, 19,
148087 /* 350 */ 72, 86, 81, 184, 185, 234, 106, 96, 97, 163,
148088 /* 360 */ 110, 182, 92, 93, 94, 95, 96, 97, 98, 99,
148089 /* 370 */ 100, 101, 102, 46, 230, 206, 207, 206, 207, 163,
148090 /* 380 */ 184, 185, 19, 105, 106, 107, 23, 116, 219, 220,
148091 /* 390 */ 219, 141, 142, 143, 105, 106, 107, 104, 127, 128,
148092 /* 400 */ 184, 185, 141, 232, 143, 59, 43, 44, 45, 46,
148093 /* 410 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148094 /* 420 */ 57, 158, 108, 160, 59, 111, 112, 113, 165, 250,
148095 /* 430 */ 167, 104, 102, 262, 255, 121, 220, 174, 108, 109,
148096 /* 440 */ 110, 111, 112, 113, 114, 229, 182, 120, 117, 118,
148097 /* 450 */ 120, 105, 106, 107, 163, 92, 93, 94, 95, 96,
148098 /* 460 */ 97, 98, 99, 100, 101, 102, 163, 22, 59, 206,
148099 /* 470 */ 207, 106, 163, 26, 171, 19, 163, 193, 175, 23,
148100 /* 480 */ 163, 22, 219, 206, 207, 139, 163, 22, 59, 182,
148101 /* 490 */ 117, 118, 59, 184, 185, 232, 219, 184, 185, 43,
148102 /* 500 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148103 /* 510 */ 54, 55, 56, 57, 105, 106, 107, 108, 59, 255,
148104 /* 520 */ 111, 112, 113, 90, 59, 262, 22, 98, 174, 12,
148105 /* 530 */ 121, 208, 163, 220, 105, 106, 107, 163, 105, 106,
148106 /* 540 */ 22, 96, 97, 110, 27, 238, 239, 240, 92, 93,
148107 /* 550 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 42,
148108 /* 560 */ 206, 207, 115, 59, 105, 106, 107, 163, 19, 59,
148109 /* 570 */ 163, 106, 23, 219, 141, 142, 143, 59, 163, 205,
148110 /* 580 */ 63, 59, 72, 22, 124, 59, 163, 270, 234, 129,
148111 /* 590 */ 73, 163, 43, 44, 45, 46, 47, 48, 49, 50,
148112 /* 600 */ 51, 52, 53, 54, 55, 56, 57, 184, 185, 105,
148113 /* 610 */ 106, 107, 184, 185, 163, 105, 106, 107, 265, 266,
148114 /* 620 */ 59, 198, 225, 105, 106, 107, 198, 105, 106, 107,
148115 /* 630 */ 163, 105, 106, 107, 163, 184, 185, 46, 47, 48,
148116 /* 640 */ 49, 92, 93, 94, 95, 96, 97, 98, 99, 100,
148117 /* 650 */ 101, 102, 163, 163, 132, 184, 185, 163, 132, 163,
148118 /* 660 */ 256, 19, 163, 163, 163, 23, 105, 106, 107, 198,
148119 /* 670 */ 163, 220, 205, 184, 185, 163, 35, 81, 184, 185,
148120 /* 680 */ 184, 185, 163, 184, 185, 43, 44, 45, 46, 47,
148121 /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
148122 /* 700 */ 163, 110, 163, 184, 185, 109, 205, 66, 163, 59,
148123 /* 710 */ 163, 21, 205, 16, 174, 74, 220, 198, 163, 220,
148124 /* 720 */ 230, 184, 185, 127, 128, 180, 181, 180, 181, 163,
148125 /* 730 */ 175, 242, 174, 233, 92, 93, 94, 95, 96, 97,
148126 /* 740 */ 98, 99, 100, 101, 102, 233, 206, 207, 26, 163,
148127 /* 750 */ 195, 207, 197, 26, 19, 105, 106, 107, 23, 219,
148128 /* 760 */ 119, 260, 26, 219, 206, 207, 174, 19, 174, 230,
148129 /* 770 */ 80, 174, 163, 174, 77, 163, 79, 219, 43, 44,
148130 /* 780 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148131 /* 790 */ 55, 56, 57, 248, 12, 248, 184, 185, 206, 207,
148132 /* 800 */ 206, 207, 112, 206, 207, 206, 207, 206, 207, 27,
148133 /* 810 */ 163, 219, 123, 219, 125, 126, 219, 208, 219, 163,
148134 /* 820 */ 219, 22, 23, 23, 42, 26, 26, 92, 93, 94,
148135 /* 830 */ 95, 96, 97, 98, 99, 100, 101, 102, 163, 149,
148136 /* 840 */ 184, 185, 163, 107, 163, 63, 149, 19, 163, 127,
148137 /* 850 */ 128, 23, 22, 105, 24, 116, 117, 118, 131, 184,
148138 /* 860 */ 185, 163, 163, 184, 185, 184, 185, 19, 132, 184,
148139 /* 870 */ 185, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148140 /* 880 */ 52, 53, 54, 55, 56, 57, 146, 163, 148, 59,
148141 /* 890 */ 91, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148142 /* 900 */ 52, 53, 54, 55, 56, 57, 208, 107, 184, 185,
148143 /* 910 */ 7, 8, 9, 116, 117, 118, 163, 163, 163, 24,
148144 /* 920 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
148145 /* 930 */ 102, 29, 132, 163, 163, 33, 106, 184, 185, 163,
148146 /* 940 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
148147 /* 950 */ 102, 163, 163, 163, 59, 184, 185, 163, 22, 163,
148148 /* 960 */ 184, 185, 177, 178, 163, 163, 163, 65, 163, 199,
148149 /* 970 */ 163, 26, 184, 185, 184, 185, 163, 163, 184, 185,
148150 /* 980 */ 184, 185, 163, 98, 163, 184, 185, 184, 185, 184,
148151 /* 990 */ 185, 184, 185, 252, 205, 147, 163, 61, 184, 185,
148152 /* 1000 */ 163, 106, 163, 184, 185, 163, 163, 205, 163, 124,
148153 /* 1010 */ 163, 256, 163, 163, 129, 19, 163, 184, 185, 163,
148154 /* 1020 */ 199, 184, 185, 184, 185, 23, 184, 185, 26, 184,
148155 /* 1030 */ 185, 184, 185, 184, 185, 19, 163, 184, 185, 43,
148156 /* 1040 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148157 /* 1050 */ 54, 55, 56, 57, 163, 163, 163, 184, 185, 43,
148158 /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148159 /* 1070 */ 54, 55, 56, 57, 16, 184, 185, 184, 185, 163,
148160 /* 1080 */ 163, 22, 23, 138, 163, 19, 163, 231, 92, 93,
148161 /* 1090 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 256,
148162 /* 1100 */ 163, 184, 185, 163, 163, 184, 185, 163, 92, 93,
148163 /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 163,
148164 /* 1120 */ 59, 184, 185, 163, 184, 185, 177, 178, 184, 185,
148165 /* 1130 */ 163, 208, 163, 237, 163, 77, 163, 79, 163, 15,
148166 /* 1140 */ 184, 185, 237, 147, 184, 185, 24, 231, 153, 154,
148167 /* 1150 */ 91, 184, 185, 184, 185, 184, 185, 184, 185, 184,
148168 /* 1160 */ 185, 22, 23, 19, 163, 127, 128, 106, 24, 273,
148169 /* 1170 */ 271, 105, 231, 274, 263, 264, 223, 224, 273, 22,
148170 /* 1180 */ 118, 24, 23, 19, 60, 26, 163, 43, 44, 45,
148171 /* 1190 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148172 /* 1200 */ 56, 57, 140, 23, 22, 163, 26, 43, 44, 45,
148173 /* 1210 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148174 /* 1220 */ 56, 57, 23, 211, 23, 26, 31, 26, 23, 22,
148175 /* 1230 */ 91, 26, 231, 221, 39, 53, 92, 93, 94, 95,
148176 /* 1240 */ 96, 97, 98, 99, 100, 101, 102, 23, 23, 163,
148177 /* 1250 */ 26, 26, 130, 59, 109, 110, 92, 93, 94, 95,
148178 /* 1260 */ 96, 97, 98, 99, 100, 101, 102, 23, 7, 8,
148179 /* 1270 */ 26, 110, 23, 59, 23, 26, 19, 26, 141, 23,
148180 /* 1280 */ 143, 120, 26, 141, 163, 143, 23, 23, 163, 26,
148181 /* 1290 */ 26, 163, 163, 163, 163, 163, 19, 163, 163, 193,
148182 /* 1300 */ 106, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148183 /* 1310 */ 53, 54, 55, 56, 57, 163, 193, 163, 163, 163,
148184 /* 1320 */ 106, 163, 45, 46, 47, 48, 49, 50, 51, 52,
148185 /* 1330 */ 53, 54, 55, 56, 57, 163, 163, 130, 222, 163,
148186 /* 1340 */ 163, 203, 163, 19, 20, 251, 22, 163, 163, 92,
148187 /* 1350 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148188 /* 1360 */ 36, 163, 209, 163, 261, 163, 163, 161, 222, 92,
148189 /* 1370 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
148190 /* 1380 */ 210, 213, 222, 59, 222, 222, 182, 213, 213, 196,
148191 /* 1390 */ 257, 226, 226, 19, 20, 71, 22, 257, 188, 187,
148192 /* 1400 */ 192, 212, 187, 187, 226, 81, 210, 166, 60, 261,
148193 /* 1410 */ 36, 244, 130, 170, 90, 170, 38, 170, 139, 104,
148194 /* 1420 */ 96, 97, 48, 236, 22, 235, 43, 103, 201, 105,
148195 /* 1430 */ 106, 107, 138, 59, 110, 247, 213, 18, 204, 258,
148196 /* 1440 */ 204, 258, 204, 204, 170, 71, 18, 169, 213, 236,
148197 /* 1450 */ 213, 127, 128, 235, 201, 201, 82, 170, 169, 213,
148198 /* 1460 */ 146, 87, 62, 254, 90, 141, 142, 143, 144, 145,
148199 /* 1470 */ 96, 97, 253, 170, 169, 22, 170, 103, 169, 105,
148200 /* 1480 */ 106, 107, 189, 170, 110, 169, 189, 186, 19, 20,
148201 /* 1490 */ 104, 22, 194, 186, 186, 64, 115, 186, 194, 189,
148202 /* 1500 */ 188, 102, 133, 186, 186, 36, 186, 104, 189, 19,
148203 /* 1510 */ 20, 246, 22, 246, 189, 141, 142, 143, 144, 145,
148204 /* 1520 */ 0, 1, 2, 228, 228, 5, 36, 227, 59, 227,
148205 /* 1530 */ 10, 11, 12, 13, 14, 170, 84, 17, 134, 216,
148206 /* 1540 */ 71, 272, 270, 22, 137, 217, 22, 216, 227, 59,
148207 /* 1550 */ 30, 82, 32, 217, 228, 228, 87, 227, 170, 90,
148208 /* 1560 */ 40, 71, 146, 241, 215, 96, 97, 214, 136, 135,
148209 /* 1570 */ 213, 25, 103, 26, 105, 106, 107, 243, 173, 110,
148210 /* 1580 */ 90, 172, 13, 6, 164, 164, 96, 97, 98, 162,
148211 /* 1590 */ 70, 162, 162, 103, 176, 105, 106, 107, 78, 267,
148212 /* 1600 */ 110, 81, 267, 264, 182, 182, 182, 182, 88, 176,
148213 /* 1610 */ 141, 142, 143, 144, 145, 176, 190, 4, 182, 182,
148214 /* 1620 */ 182, 19, 20, 182, 22, 190, 3, 22, 151, 15,
148215 /* 1630 */ 89, 141, 142, 143, 144, 145, 16, 128, 36, 23,
148216 /* 1640 */ 23, 139, 122, 24, 119, 131, 20, 127, 128, 133,
148217 /* 1650 */ 16, 1, 140, 131, 119, 61, 139, 53, 37, 53,
148218 /* 1660 */ 53, 59, 53, 119, 105, 34, 130, 1, 5, 22,
148219 /* 1670 */ 150, 104, 149, 71, 26, 75, 68, 41, 68, 130,
148220 /* 1680 */ 104, 24, 20, 19, 82, 120, 114, 22, 28, 87,
148221 /* 1690 */ 22, 67, 90, 22, 67, 23, 22, 22, 96, 97,
148222 /* 1700 */ 67, 23, 138, 22, 37, 103, 153, 105, 106, 107,
148223 /* 1710 */ 1, 2, 110, 23, 5, 23, 23, 26, 22, 10,
148224 /* 1720 */ 11, 12, 13, 14, 24, 23, 17, 22, 24, 130,
148225 /* 1730 */ 23, 19, 20, 23, 22, 105, 22, 34, 85, 30,
148226 /* 1740 */ 34, 32, 26, 141, 142, 143, 144, 145, 36, 40,
148227 /* 1750 */ 132, 34, 75, 83, 23, 44, 24, 34, 23, 26,
148228 /* 1760 */ 26, 19, 20, 23, 22, 26, 23, 23, 23, 23,
148229 /* 1770 */ 22, 59, 11, 22, 22, 26, 23, 23, 36, 70,
148230 /* 1780 */ 22, 22, 124, 71, 130, 130, 130, 78, 23, 130,
148231 /* 1790 */ 81, 15, 1, 278, 278, 278, 278, 88, 278, 278,
148232 /* 1800 */ 278, 59, 90, 278, 278, 278, 278, 278, 96, 97,
148233 /* 1810 */ 278, 278, 278, 71, 278, 103, 278, 105, 106, 107,
148234 /* 1820 */ 278, 278, 110, 278, 278, 278, 278, 278, 278, 278,
148235 /* 1830 */ 278, 122, 90, 278, 278, 278, 127, 128, 96, 97,
148236 /* 1840 */ 278, 278, 278, 278, 278, 103, 278, 105, 106, 107,
148237 /* 1850 */ 278, 278, 110, 141, 142, 143, 144, 145, 278, 150,
148238 /* 1860 */ 278, 278, 278, 5, 278, 278, 278, 278, 10, 11,
148239 /* 1870 */ 12, 13, 14, 278, 278, 17, 278, 278, 278, 278,
148240 /* 1880 */ 278, 278, 278, 141, 142, 143, 144, 145, 30, 278,
148241 /* 1890 */ 32, 278, 278, 278, 278, 278, 278, 278, 40, 278,
148242 /* 1900 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148243 /* 1910 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148244 /* 1920 */ 278, 278, 278, 278, 278, 278, 278, 278, 70, 278,
148245 /* 1930 */ 278, 278, 278, 278, 278, 278, 78, 278, 278, 81,
148246 /* 1940 */ 278, 278, 278, 278, 278, 278, 88, 278, 278, 278,
148247 /* 1950 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148248 /* 1960 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148249 /* 1970 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148250 /* 1980 */ 122, 278, 278, 278, 278, 127, 128, 278, 278, 278,
148251 /* 1990 */ 278, 278, 278, 278, 278, 278, 278, 278, 278, 278,
148252 /* 2000 */ 278, 278, 278, 278, 278, 278, 278, 278, 150, 278,
148253 /* 2010 */ 278, 278, 278, 278, 278, 278, 278, 278, 278,
148254 };
148255 #define YY_SHIFT_COUNT (523)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148256 #define YY_SHIFT_MIN (0)
148257 #define YY_SHIFT_MAX (1858)
148258 static const unsigned short int yy_shift_ofst[] = {
148259 /* 0 */ 1709, 1520, 1858, 1324, 1324, 24, 1374, 1469, 1602, 1712,
148260 /* 10 */ 1712, 1712, 271, 0, 0, 113, 1016, 1712, 1712, 1712,
148261 /* 20 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 12, 12, 409,
148262 /* 30 */ 596, 24, 24, 24, 24, 24, 24, 93, 177, 270,
148263 /* 40 */ 363, 456, 549, 642, 735, 828, 848, 996, 1144, 1016,
148264 /* 50 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016,
148265 /* 60 */ 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1164, 1016, 1257,
148266 /* 70 */ 1277, 1277, 1490, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148267 /* 80 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148268 /* 90 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712,
148269 /* 100 */ 1712, 1712, 1712, 1712, 1712, 1742, 1712, 1712, 1712, 1712,
148270 /* 110 */ 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 143,
148271 /* 120 */ 162, 162, 162, 162, 162, 204, 151, 186, 650, 690,
148272 /* 130 */ 327, 650, 261, 261, 650, 722, 722, 722, 722, 373,
148273 /* 140 */ 33, 2, 2009, 2009, 330, 330, 330, 346, 289, 278,
148274 /* 150 */ 289, 289, 517, 517, 459, 510, 15, 799, 650, 650,
148275 /* 160 */ 650, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148276 /* 170 */ 650, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148277 /* 180 */ 331, 365, 995, 995, 265, 365, 50, 1038, 2009, 2009,
148278 /* 190 */ 2009, 433, 250, 250, 504, 314, 429, 518, 522, 526,
148279 /* 200 */ 561, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148280 /* 210 */ 192, 650, 650, 650, 650, 650, 650, 650, 650, 650,
148281 /* 220 */ 650, 650, 650, 641, 641, 641, 650, 650, 650, 650,
148282 /* 230 */ 800, 650, 650, 650, 830, 650, 650, 782, 650, 650,
148283 /* 240 */ 650, 650, 650, 650, 650, 650, 739, 902, 689, 895,
148284 /* 250 */ 895, 895, 895, 736, 689, 689, 885, 445, 903, 1124,
148285 /* 260 */ 945, 748, 748, 1066, 945, 945, 1066, 447, 1002, 293,
148286 /* 270 */ 1195, 1195, 1195, 748, 740, 727, 460, 1157, 1348, 1282,
148287 /* 280 */ 1282, 1378, 1378, 1282, 1279, 1315, 1402, 1383, 1294, 1419,
148288 /* 290 */ 1419, 1419, 1419, 1282, 1428, 1294, 1294, 1315, 1402, 1383,
148289 /* 300 */ 1383, 1294, 1282, 1428, 1314, 1400, 1282, 1428, 1453, 1282,
148290 /* 310 */ 1428, 1282, 1428, 1453, 1386, 1386, 1386, 1431, 1453, 1386,
148291 /* 320 */ 1381, 1386, 1431, 1386, 1386, 1453, 1399, 1399, 1453, 1369,
148292 /* 330 */ 1403, 1369, 1403, 1369, 1403, 1369, 1403, 1282, 1404, 1452,
148293 /* 340 */ 1521, 1407, 1404, 1524, 1282, 1416, 1407, 1432, 1434, 1294,
148294 /* 350 */ 1546, 1547, 1569, 1569, 1577, 1577, 1577, 2009, 2009, 2009,
148295 /* 360 */ 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
148296 /* 370 */ 2009, 2009, 2009, 591, 697, 1059, 1139, 1058, 797, 465,
148297 /* 380 */ 1159, 1182, 1122, 1062, 1180, 936, 1199, 1201, 1205, 1224,
148298 /* 390 */ 1225, 1244, 1061, 1145, 1261, 1161, 1194, 1249, 1251, 1256,
148299 /* 400 */ 1137, 1142, 1263, 1264, 1214, 1207, 1613, 1623, 1605, 1477,
148300 /* 410 */ 1614, 1541, 1620, 1616, 1617, 1509, 1502, 1525, 1619, 1514,
148301 /* 420 */ 1626, 1516, 1634, 1650, 1522, 1512, 1535, 1594, 1621, 1517,
148302 /* 430 */ 1604, 1606, 1607, 1609, 1544, 1559, 1631, 1536, 1666, 1663,
148303 /* 440 */ 1647, 1567, 1523, 1608, 1648, 1610, 1600, 1636, 1549, 1576,
148304 /* 450 */ 1657, 1662, 1664, 1565, 1572, 1665, 1624, 1668, 1671, 1672,
148305 /* 460 */ 1674, 1627, 1660, 1675, 1633, 1667, 1678, 1564, 1681, 1553,
148306 /* 470 */ 1690, 1692, 1691, 1693, 1696, 1700, 1702, 1705, 1704, 1599,
148307 /* 480 */ 1707, 1710, 1630, 1703, 1714, 1618, 1716, 1706, 1716, 1717,
148308 /* 490 */ 1653, 1677, 1670, 1711, 1731, 1732, 1733, 1734, 1723, 1735,
148309 /* 500 */ 1716, 1740, 1743, 1744, 1745, 1739, 1746, 1748, 1761, 1751,
148310 /* 510 */ 1752, 1753, 1754, 1758, 1759, 1749, 1658, 1654, 1655, 1656,
148311 /* 520 */ 1659, 1765, 1776, 1791,
148312 };
148313 #define YY_REDUCE_COUNT (372)
148314 #define YY_REDUCE_MIN (-235)
148315 #define YY_REDUCE_MAX (1441)
 
 
148316 static const short yy_reduce_ofst[] = {
148317 /* 0 */ -147, 171, 263, -96, 169, -144, -162, -149, -102, -156,
148318 /* 10 */ -98, 216, 354, -170, -57, -235, 307, 149, 423, 428,
148319 /* 20 */ 471, 313, 451, 519, 489, 496, 499, 545, 547, 555,
148320 /* 30 */ -116, 540, 558, 592, 594, 597, 599, -206, -206, -206,
148321 /* 40 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148322 /* 50 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148323 /* 60 */ -206, -206, -206, -206, -206, -206, -206, -206, -206, -206,
148324 /* 70 */ -206, -206, 196, 309, 494, 537, 612, 656, 675, 679,
148325 /* 80 */ 681, 685, 724, 753, 771, 776, 788, 790, 794, 796,
148326 /* 90 */ 801, 803, 805, 807, 814, 819, 833, 837, 839, 842,
148327 /* 100 */ 845, 847, 849, 853, 873, 891, 893, 917, 921, 937,
148328 /* 110 */ 940, 944, 956, 960, 967, 969, 971, 973, 975, -206,
148329 /* 120 */ -206, -206, -206, -206, -206, -206, -206, -206, 501, -168,
148330 /* 130 */ 90, -97, 87, 112, 303, 277, 601, 277, 601, 179,
148331 /* 140 */ -206, -206, -206, -206, -107, -107, -107, -43, -56, 323,
148332 /* 150 */ 500, 512, -187, -177, 317, 609, 353, 353, 120, 144,
148333 /* 160 */ 490, 539, 698, 374, 467, 507, 789, 404, -157, 755,
148334 /* 170 */ 856, 916, 843, 941, 802, 770, 923, 821, 1001, -142,
148335 /* 180 */ 264, 785, 896, 905, 899, 949, -176, 544, 911, 953,
148336 /* 190 */ 1012, -182, -59, -30, 16, -22, 117, 172, 291, 369,
148337 /* 200 */ 407, 415, 566, 586, 647, 699, 754, 813, 850, 892,
148338 /* 210 */ 121, 1023, 1042, 1086, 1121, 1125, 1128, 1129, 1130, 1131,
148339 /* 220 */ 1132, 1134, 1135, 284, 1106, 1123, 1152, 1154, 1155, 1156,
148340 /* 230 */ 397, 1158, 1172, 1173, 1116, 1176, 1177, 1138, 1179, 117,
148341 /* 240 */ 1184, 1185, 1198, 1200, 1202, 1203, 741, 1094, 1153, 1146,
148342 /* 250 */ 1160, 1162, 1163, 397, 1153, 1153, 1170, 1204, 1206, 1103,
148343 /* 260 */ 1168, 1165, 1166, 1133, 1174, 1175, 1140, 1210, 1193, 1208,
148344 /* 270 */ 1212, 1215, 1216, 1178, 1167, 1189, 1196, 1241, 1148, 1243,
148345 /* 280 */ 1245, 1181, 1183, 1247, 1188, 1187, 1190, 1227, 1223, 1234,
148346 /* 290 */ 1236, 1238, 1239, 1274, 1278, 1235, 1237, 1213, 1218, 1253,
148347 /* 300 */ 1254, 1246, 1287, 1289, 1209, 1219, 1303, 1305, 1293, 1306,
148348 /* 310 */ 1309, 1313, 1316, 1297, 1301, 1307, 1308, 1298, 1310, 1311,
148349 /* 320 */ 1312, 1317, 1304, 1318, 1320, 1319, 1265, 1267, 1325, 1295,
148350 /* 330 */ 1300, 1296, 1302, 1326, 1321, 1327, 1330, 1365, 1323, 1269,
148351 /* 340 */ 1272, 1328, 1331, 1322, 1388, 1334, 1336, 1349, 1353, 1357,
148352 /* 350 */ 1405, 1409, 1420, 1421, 1427, 1429, 1430, 1332, 1335, 1339,
148353 /* 360 */ 1418, 1422, 1423, 1424, 1425, 1433, 1426, 1435, 1436, 1437,
148354 /* 370 */ 1438, 1441, 1439,
 
148355 };
148356 static const YYACTIONTYPE yy_default[] = {
148357 /* 0 */ 1500, 1500, 1500, 1346, 1129, 1235, 1129, 1129, 1129, 1346,
148358 /* 10 */ 1346, 1346, 1129, 1265, 1265, 1399, 1160, 1129, 1129, 1129,
148359 /* 20 */ 1129, 1129, 1129, 1129, 1345, 1129, 1129, 1129, 1129, 1129,
148360 /* 30 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1271, 1129,
148361 /* 40 */ 1129, 1129, 1129, 1129, 1347, 1348, 1129, 1129, 1129, 1398,
148362 /* 50 */ 1400, 1363, 1281, 1280, 1279, 1278, 1381, 1252, 1276, 1269,
148363 /* 60 */ 1273, 1341, 1342, 1340, 1344, 1348, 1347, 1129, 1272, 1312,
148364 /* 70 */ 1326, 1311, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148365 /* 80 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148366 /* 90 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148367 /* 100 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148368 /* 110 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1320,
148369 /* 120 */ 1325, 1331, 1324, 1321, 1314, 1313, 1315, 1316, 1129, 1150,
148370 /* 130 */ 1199, 1129, 1129, 1129, 1129, 1417, 1416, 1129, 1129, 1160,
148371 /* 140 */ 1317, 1318, 1328, 1327, 1406, 1456, 1455, 1364, 1129, 1129,
148372 /* 150 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148373 /* 160 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148374 /* 170 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148375 /* 180 */ 1160, 1156, 1306, 1305, 1426, 1156, 1259, 1129, 1412, 1235,
148376 /* 190 */ 1226, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148377 /* 200 */ 1129, 1129, 1129, 1129, 1403, 1401, 1129, 1129, 1129, 1129,
148378 /* 210 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148379 /* 220 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148380 /* 230 */ 1129, 1129, 1129, 1129, 1231, 1129, 1129, 1129, 1129, 1129,
148381 /* 240 */ 1129, 1129, 1129, 1129, 1129, 1450, 1129, 1376, 1213, 1231,
148382 /* 250 */ 1231, 1231, 1231, 1233, 1214, 1212, 1225, 1160, 1136, 1492,
148383 /* 260 */ 1275, 1254, 1254, 1489, 1275, 1275, 1489, 1174, 1470, 1171,
148384 /* 270 */ 1265, 1265, 1265, 1254, 1343, 1232, 1225, 1129, 1492, 1240,
148385 /* 280 */ 1240, 1491, 1491, 1240, 1364, 1284, 1290, 1202, 1275, 1208,
148386 /* 290 */ 1208, 1208, 1208, 1240, 1147, 1275, 1275, 1284, 1290, 1202,
148387 /* 300 */ 1202, 1275, 1240, 1147, 1380, 1486, 1240, 1147, 1354, 1240,
148388 /* 310 */ 1147, 1240, 1147, 1354, 1200, 1200, 1200, 1189, 1354, 1200,
148389 /* 320 */ 1174, 1200, 1189, 1200, 1200, 1354, 1358, 1358, 1354, 1258,
148390 /* 330 */ 1253, 1258, 1253, 1258, 1253, 1258, 1253, 1240, 1259, 1425,
148391 /* 340 */ 1129, 1270, 1259, 1349, 1240, 1129, 1270, 1268, 1266, 1275,
148392 /* 350 */ 1153, 1192, 1453, 1453, 1449, 1449, 1449, 1497, 1497, 1412,
148393 /* 360 */ 1465, 1160, 1160, 1160, 1160, 1465, 1176, 1176, 1160, 1160,
148394 /* 370 */ 1160, 1160, 1465, 1129, 1129, 1129, 1129, 1129, 1129, 1460,
148395 /* 380 */ 1129, 1365, 1244, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148396 /* 390 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148397 /* 400 */ 1129, 1129, 1129, 1129, 1129, 1295, 1129, 1132, 1409, 1129,
148398 /* 410 */ 1129, 1407, 1129, 1129, 1129, 1129, 1129, 1129, 1245, 1129,
148399 /* 420 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148400 /* 430 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1488, 1129, 1129,
148401 /* 440 */ 1129, 1129, 1129, 1129, 1379, 1378, 1129, 1129, 1242, 1129,
148402 /* 450 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148403 /* 460 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148404 /* 470 */ 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148405 /* 480 */ 1129, 1129, 1129, 1129, 1129, 1129, 1267, 1129, 1424, 1129,
148406 /* 490 */ 1129, 1129, 1129, 1129, 1129, 1129, 1438, 1260, 1129, 1129,
148407 /* 500 */ 1479, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129, 1129,
148408 /* 510 */ 1129, 1129, 1129, 1129, 1129, 1474, 1216, 1297, 1129, 1296,
148409 /* 520 */ 1300, 1129, 1141, 1129,
 
 
148410 };
148411 /********** End of lemon-generated parsing tables *****************************/
148412
148413 /* The next table maps tokens (terminal symbols) into fallback tokens.
148414 ** If a construct like the following:
@@ -148512,10 +149127,14 @@
148512 59, /* FOLLOWING => ID */
148513 59, /* PARTITION => ID */
148514 59, /* PRECEDING => ID */
148515 59, /* RANGE => ID */
148516 59, /* UNBOUNDED => ID */
 
 
 
 
148517 59, /* REINDEX => ID */
148518 59, /* RENAME => ID */
148519 59, /* CTIME_KW => ID */
148520 };
148521 #endif /* YYFALLBACK */
@@ -148690,200 +149309,206 @@
148690 /* 83 */ "FOLLOWING",
148691 /* 84 */ "PARTITION",
148692 /* 85 */ "PRECEDING",
148693 /* 86 */ "RANGE",
148694 /* 87 */ "UNBOUNDED",
148695 /* 88 */ "REINDEX",
148696 /* 89 */ "RENAME",
148697 /* 90 */ "CTIME_KW",
148698 /* 91 */ "ANY",
148699 /* 92 */ "BITAND",
148700 /* 93 */ "BITOR",
148701 /* 94 */ "LSHIFT",
148702 /* 95 */ "RSHIFT",
148703 /* 96 */ "PLUS",
148704 /* 97 */ "MINUS",
148705 /* 98 */ "STAR",
148706 /* 99 */ "SLASH",
148707 /* 100 */ "REM",
148708 /* 101 */ "CONCAT",
148709 /* 102 */ "COLLATE",
148710 /* 103 */ "BITNOT",
148711 /* 104 */ "ON",
148712 /* 105 */ "INDEXED",
148713 /* 106 */ "STRING",
148714 /* 107 */ "JOIN_KW",
148715 /* 108 */ "CONSTRAINT",
148716 /* 109 */ "DEFAULT",
148717 /* 110 */ "NULL",
148718 /* 111 */ "PRIMARY",
148719 /* 112 */ "UNIQUE",
148720 /* 113 */ "CHECK",
148721 /* 114 */ "REFERENCES",
148722 /* 115 */ "AUTOINCR",
148723 /* 116 */ "INSERT",
148724 /* 117 */ "DELETE",
148725 /* 118 */ "UPDATE",
148726 /* 119 */ "SET",
148727 /* 120 */ "DEFERRABLE",
148728 /* 121 */ "FOREIGN",
148729 /* 122 */ "DROP",
148730 /* 123 */ "UNION",
148731 /* 124 */ "ALL",
148732 /* 125 */ "EXCEPT",
148733 /* 126 */ "INTERSECT",
148734 /* 127 */ "SELECT",
148735 /* 128 */ "VALUES",
148736 /* 129 */ "DISTINCT",
148737 /* 130 */ "DOT",
148738 /* 131 */ "FROM",
148739 /* 132 */ "JOIN",
148740 /* 133 */ "USING",
148741 /* 134 */ "ORDER",
148742 /* 135 */ "GROUP",
148743 /* 136 */ "HAVING",
148744 /* 137 */ "LIMIT",
148745 /* 138 */ "WHERE",
148746 /* 139 */ "INTO",
148747 /* 140 */ "NOTHING",
148748 /* 141 */ "FLOAT",
148749 /* 142 */ "BLOB",
148750 /* 143 */ "INTEGER",
148751 /* 144 */ "VARIABLE",
148752 /* 145 */ "CASE",
148753 /* 146 */ "WHEN",
148754 /* 147 */ "THEN",
148755 /* 148 */ "ELSE",
148756 /* 149 */ "INDEX",
148757 /* 150 */ "ALTER",
148758 /* 151 */ "ADD",
148759 /* 152 */ "WINDOW",
148760 /* 153 */ "OVER",
148761 /* 154 */ "FILTER",
148762 /* 155 */ "input",
148763 /* 156 */ "cmdlist",
148764 /* 157 */ "ecmd",
148765 /* 158 */ "cmdx",
148766 /* 159 */ "explain",
148767 /* 160 */ "cmd",
148768 /* 161 */ "transtype",
148769 /* 162 */ "trans_opt",
148770 /* 163 */ "nm",
148771 /* 164 */ "savepoint_opt",
148772 /* 165 */ "create_table",
148773 /* 166 */ "create_table_args",
148774 /* 167 */ "createkw",
148775 /* 168 */ "temp",
148776 /* 169 */ "ifnotexists",
148777 /* 170 */ "dbnm",
148778 /* 171 */ "columnlist",
148779 /* 172 */ "conslist_opt",
148780 /* 173 */ "table_options",
148781 /* 174 */ "select",
148782 /* 175 */ "columnname",
148783 /* 176 */ "carglist",
148784 /* 177 */ "typetoken",
148785 /* 178 */ "typename",
148786 /* 179 */ "signed",
148787 /* 180 */ "plus_num",
148788 /* 181 */ "minus_num",
148789 /* 182 */ "scanpt",
148790 /* 183 */ "ccons",
148791 /* 184 */ "term",
148792 /* 185 */ "expr",
148793 /* 186 */ "onconf",
148794 /* 187 */ "sortorder",
148795 /* 188 */ "autoinc",
148796 /* 189 */ "eidlist_opt",
148797 /* 190 */ "refargs",
148798 /* 191 */ "defer_subclause",
148799 /* 192 */ "refarg",
148800 /* 193 */ "refact",
148801 /* 194 */ "init_deferred_pred_opt",
148802 /* 195 */ "conslist",
148803 /* 196 */ "tconscomma",
148804 /* 197 */ "tcons",
148805 /* 198 */ "sortlist",
148806 /* 199 */ "eidlist",
148807 /* 200 */ "defer_subclause_opt",
148808 /* 201 */ "orconf",
148809 /* 202 */ "resolvetype",
148810 /* 203 */ "raisetype",
148811 /* 204 */ "ifexists",
148812 /* 205 */ "fullname",
148813 /* 206 */ "selectnowith",
148814 /* 207 */ "oneselect",
148815 /* 208 */ "wqlist",
148816 /* 209 */ "multiselect_op",
148817 /* 210 */ "distinct",
148818 /* 211 */ "selcollist",
148819 /* 212 */ "from",
148820 /* 213 */ "where_opt",
148821 /* 214 */ "groupby_opt",
148822 /* 215 */ "having_opt",
148823 /* 216 */ "orderby_opt",
148824 /* 217 */ "limit_opt",
148825 /* 218 */ "window_clause",
148826 /* 219 */ "values",
148827 /* 220 */ "nexprlist",
148828 /* 221 */ "sclp",
148829 /* 222 */ "as",
148830 /* 223 */ "seltablist",
148831 /* 224 */ "stl_prefix",
148832 /* 225 */ "joinop",
148833 /* 226 */ "indexed_opt",
148834 /* 227 */ "on_opt",
148835 /* 228 */ "using_opt",
148836 /* 229 */ "exprlist",
148837 /* 230 */ "xfullname",
148838 /* 231 */ "idlist",
148839 /* 232 */ "with",
148840 /* 233 */ "setlist",
148841 /* 234 */ "insert_cmd",
148842 /* 235 */ "idlist_opt",
148843 /* 236 */ "upsert",
148844 /* 237 */ "over_clause",
148845 /* 238 */ "likeop",
148846 /* 239 */ "between_op",
148847 /* 240 */ "in_op",
148848 /* 241 */ "paren_exprlist",
148849 /* 242 */ "case_operand",
148850 /* 243 */ "case_exprlist",
148851 /* 244 */ "case_else",
148852 /* 245 */ "uniqueflag",
148853 /* 246 */ "collate",
148854 /* 247 */ "vinto",
148855 /* 248 */ "nmnum",
148856 /* 249 */ "trigger_decl",
148857 /* 250 */ "trigger_cmd_list",
148858 /* 251 */ "trigger_time",
148859 /* 252 */ "trigger_event",
148860 /* 253 */ "foreach_clause",
148861 /* 254 */ "when_clause",
148862 /* 255 */ "trigger_cmd",
148863 /* 256 */ "trnm",
148864 /* 257 */ "tridxby",
148865 /* 258 */ "database_kw_opt",
148866 /* 259 */ "key_opt",
148867 /* 260 */ "add_column_fullname",
148868 /* 261 */ "kwcolumn_opt",
148869 /* 262 */ "create_vtab",
148870 /* 263 */ "vtabarglist",
148871 /* 264 */ "vtabarg",
148872 /* 265 */ "vtabargtoken",
148873 /* 266 */ "lp",
148874 /* 267 */ "anylist",
148875 /* 268 */ "windowdefn_list",
148876 /* 269 */ "windowdefn",
148877 /* 270 */ "window",
148878 /* 271 */ "frame_opt",
148879 /* 272 */ "part_opt",
148880 /* 273 */ "filter_opt",
148881 /* 274 */ "range_or_rows",
148882 /* 275 */ "frame_bound",
148883 /* 276 */ "frame_bound_s",
148884 /* 277 */ "frame_bound_e",
 
 
 
 
 
 
148885 };
148886 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
148887
148888 #ifndef NDEBUG
148889 /* For tracing reduce actions, the names of all rules are required.
@@ -149177,89 +149802,95 @@
149177 /* 285 */ "with ::= WITH RECURSIVE wqlist",
149178 /* 286 */ "wqlist ::= nm eidlist_opt AS LP select RP",
149179 /* 287 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
149180 /* 288 */ "windowdefn_list ::= windowdefn",
149181 /* 289 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
149182 /* 290 */ "windowdefn ::= nm AS window",
149183 /* 291 */ "window ::= LP part_opt orderby_opt frame_opt RP",
149184 /* 292 */ "part_opt ::= PARTITION BY nexprlist",
149185 /* 293 */ "part_opt ::=",
149186 /* 294 */ "frame_opt ::=",
149187 /* 295 */ "frame_opt ::= range_or_rows frame_bound_s",
149188 /* 296 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e",
149189 /* 297 */ "range_or_rows ::= RANGE",
149190 /* 298 */ "range_or_rows ::= ROWS",
149191 /* 299 */ "frame_bound_s ::= frame_bound",
149192 /* 300 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
149193 /* 301 */ "frame_bound_e ::= frame_bound",
149194 /* 302 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
149195 /* 303 */ "frame_bound ::= expr PRECEDING",
149196 /* 304 */ "frame_bound ::= CURRENT ROW",
149197 /* 305 */ "frame_bound ::= expr FOLLOWING",
149198 /* 306 */ "window_clause ::= WINDOW windowdefn_list",
149199 /* 307 */ "over_clause ::= filter_opt OVER window",
149200 /* 308 */ "over_clause ::= filter_opt OVER nm",
149201 /* 309 */ "filter_opt ::=",
149202 /* 310 */ "filter_opt ::= FILTER LP WHERE expr RP",
149203 /* 311 */ "input ::= cmdlist",
149204 /* 312 */ "cmdlist ::= cmdlist ecmd",
149205 /* 313 */ "cmdlist ::= ecmd",
149206 /* 314 */ "ecmd ::= SEMI",
149207 /* 315 */ "ecmd ::= cmdx SEMI",
149208 /* 316 */ "ecmd ::= explain cmdx",
149209 /* 317 */ "trans_opt ::=",
149210 /* 318 */ "trans_opt ::= TRANSACTION",
149211 /* 319 */ "trans_opt ::= TRANSACTION nm",
149212 /* 320 */ "savepoint_opt ::= SAVEPOINT",
149213 /* 321 */ "savepoint_opt ::=",
149214 /* 322 */ "cmd ::= create_table create_table_args",
149215 /* 323 */ "columnlist ::= columnlist COMMA columnname carglist",
149216 /* 324 */ "columnlist ::= columnname carglist",
149217 /* 325 */ "nm ::= ID|INDEXED",
149218 /* 326 */ "nm ::= STRING",
149219 /* 327 */ "nm ::= JOIN_KW",
149220 /* 328 */ "typetoken ::= typename",
149221 /* 329 */ "typename ::= ID|STRING",
149222 /* 330 */ "signed ::= plus_num",
149223 /* 331 */ "signed ::= minus_num",
149224 /* 332 */ "carglist ::= carglist ccons",
149225 /* 333 */ "carglist ::=",
149226 /* 334 */ "ccons ::= NULL onconf",
149227 /* 335 */ "conslist_opt ::= COMMA conslist",
149228 /* 336 */ "conslist ::= conslist tconscomma tcons",
149229 /* 337 */ "conslist ::= tcons",
149230 /* 338 */ "tconscomma ::=",
149231 /* 339 */ "defer_subclause_opt ::= defer_subclause",
149232 /* 340 */ "resolvetype ::= raisetype",
149233 /* 341 */ "selectnowith ::= oneselect",
149234 /* 342 */ "oneselect ::= values",
149235 /* 343 */ "sclp ::= selcollist COMMA",
149236 /* 344 */ "as ::= ID|STRING",
149237 /* 345 */ "expr ::= term",
149238 /* 346 */ "likeop ::= LIKE_KW|MATCH",
149239 /* 347 */ "exprlist ::= nexprlist",
149240 /* 348 */ "nmnum ::= plus_num",
149241 /* 349 */ "nmnum ::= nm",
149242 /* 350 */ "nmnum ::= ON",
149243 /* 351 */ "nmnum ::= DELETE",
149244 /* 352 */ "nmnum ::= DEFAULT",
149245 /* 353 */ "plus_num ::= INTEGER|FLOAT",
149246 /* 354 */ "foreach_clause ::=",
149247 /* 355 */ "foreach_clause ::= FOR EACH ROW",
149248 /* 356 */ "trnm ::= nm",
149249 /* 357 */ "tridxby ::=",
149250 /* 358 */ "database_kw_opt ::= DATABASE",
149251 /* 359 */ "database_kw_opt ::=",
149252 /* 360 */ "kwcolumn_opt ::=",
149253 /* 361 */ "kwcolumn_opt ::= COLUMNKW",
149254 /* 362 */ "vtabarglist ::= vtabarg",
149255 /* 363 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
149256 /* 364 */ "vtabarg ::= vtabarg vtabargtoken",
149257 /* 365 */ "anylist ::=",
149258 /* 366 */ "anylist ::= anylist LP anylist RP",
149259 /* 367 */ "anylist ::= anylist ANY",
149260 /* 368 */ "with ::=",
 
 
 
 
 
 
149261 };
149262 #endif /* NDEBUG */
149263
149264
149265 #if YYSTACKDEPTH<=0
@@ -149381,101 +150012,101 @@
149381 ** Note: during a reduce, the only symbols destroyed are those
149382 ** which appear on the RHS of the rule, but which are *not* used
149383 ** inside the C code.
149384 */
149385 /********* Begin destructor definitions ***************************************/
149386 case 174: /* select */
149387 case 206: /* selectnowith */
149388 case 207: /* oneselect */
149389 case 219: /* values */
149390 {
149391 sqlite3SelectDelete(pParse->db, (yypminor->yy423));
149392 }
149393 break;
149394 case 184: /* term */
149395 case 185: /* expr */
149396 case 213: /* where_opt */
149397 case 215: /* having_opt */
149398 case 227: /* on_opt */
149399 case 242: /* case_operand */
149400 case 244: /* case_else */
149401 case 247: /* vinto */
149402 case 254: /* when_clause */
149403 case 259: /* key_opt */
149404 case 273: /* filter_opt */
149405 {
149406 sqlite3ExprDelete(pParse->db, (yypminor->yy490));
149407 }
149408 break;
149409 case 189: /* eidlist_opt */
149410 case 198: /* sortlist */
149411 case 199: /* eidlist */
149412 case 211: /* selcollist */
149413 case 214: /* groupby_opt */
149414 case 216: /* orderby_opt */
149415 case 220: /* nexprlist */
149416 case 221: /* sclp */
149417 case 229: /* exprlist */
149418 case 233: /* setlist */
149419 case 241: /* paren_exprlist */
149420 case 243: /* case_exprlist */
149421 case 272: /* part_opt */
149422 {
149423 sqlite3ExprListDelete(pParse->db, (yypminor->yy42));
149424 }
149425 break;
149426 case 205: /* fullname */
149427 case 212: /* from */
149428 case 223: /* seltablist */
149429 case 224: /* stl_prefix */
149430 case 230: /* xfullname */
149431 {
149432 sqlite3SrcListDelete(pParse->db, (yypminor->yy167));
149433 }
149434 break;
149435 case 208: /* wqlist */
149436 {
149437 sqlite3WithDelete(pParse->db, (yypminor->yy499));
149438 }
149439 break;
149440 case 218: /* window_clause */
149441 case 268: /* windowdefn_list */
149442 {
149443 sqlite3WindowListDelete(pParse->db, (yypminor->yy147));
149444 }
149445 break;
149446 case 228: /* using_opt */
149447 case 231: /* idlist */
149448 case 235: /* idlist_opt */
149449 {
149450 sqlite3IdListDelete(pParse->db, (yypminor->yy336));
149451 }
149452 break;
149453 case 237: /* over_clause */
149454 case 269: /* windowdefn */
149455 case 270: /* window */
149456 case 271: /* frame_opt */
149457 {
149458 sqlite3WindowDelete(pParse->db, (yypminor->yy147));
149459 }
149460 break;
149461 case 250: /* trigger_cmd_list */
149462 case 255: /* trigger_cmd */
149463 {
149464 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy119));
149465 }
149466 break;
149467 case 252: /* trigger_event */
149468 {
149469 sqlite3IdListDelete(pParse->db, (yypminor->yy350).b);
149470 }
149471 break;
149472 case 275: /* frame_bound */
149473 case 276: /* frame_bound_s */
149474 case 277: /* frame_bound_e */
149475 {
149476 sqlite3ExprDelete(pParse->db, (yypminor->yy317).pExpr);
149477 }
149478 break;
149479 /********* End destructor definitions *****************************************/
149480 default: break; /* If no destructor action specified: do nothing */
149481 }
@@ -149766,379 +150397,385 @@
149766 }
149767
149768 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
149769 ** of that rule */
149770 static const YYCODETYPE yyRuleInfoLhs[] = {
149771 159, /* (0) explain ::= EXPLAIN */
149772 159, /* (1) explain ::= EXPLAIN QUERY PLAN */
149773 158, /* (2) cmdx ::= cmd */
149774 160, /* (3) cmd ::= BEGIN transtype trans_opt */
149775 161, /* (4) transtype ::= */
149776 161, /* (5) transtype ::= DEFERRED */
149777 161, /* (6) transtype ::= IMMEDIATE */
149778 161, /* (7) transtype ::= EXCLUSIVE */
149779 160, /* (8) cmd ::= COMMIT|END trans_opt */
149780 160, /* (9) cmd ::= ROLLBACK trans_opt */
149781 160, /* (10) cmd ::= SAVEPOINT nm */
149782 160, /* (11) cmd ::= RELEASE savepoint_opt nm */
149783 160, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
149784 165, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
149785 167, /* (14) createkw ::= CREATE */
149786 169, /* (15) ifnotexists ::= */
149787 169, /* (16) ifnotexists ::= IF NOT EXISTS */
149788 168, /* (17) temp ::= TEMP */
149789 168, /* (18) temp ::= */
149790 166, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
149791 166, /* (20) create_table_args ::= AS select */
149792 173, /* (21) table_options ::= */
149793 173, /* (22) table_options ::= WITHOUT nm */
149794 175, /* (23) columnname ::= nm typetoken */
149795 177, /* (24) typetoken ::= */
149796 177, /* (25) typetoken ::= typename LP signed RP */
149797 177, /* (26) typetoken ::= typename LP signed COMMA signed RP */
149798 178, /* (27) typename ::= typename ID|STRING */
149799 182, /* (28) scanpt ::= */
149800 183, /* (29) ccons ::= CONSTRAINT nm */
149801 183, /* (30) ccons ::= DEFAULT scanpt term scanpt */
149802 183, /* (31) ccons ::= DEFAULT LP expr RP */
149803 183, /* (32) ccons ::= DEFAULT PLUS term scanpt */
149804 183, /* (33) ccons ::= DEFAULT MINUS term scanpt */
149805 183, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
149806 183, /* (35) ccons ::= NOT NULL onconf */
149807 183, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
149808 183, /* (37) ccons ::= UNIQUE onconf */
149809 183, /* (38) ccons ::= CHECK LP expr RP */
149810 183, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
149811 183, /* (40) ccons ::= defer_subclause */
149812 183, /* (41) ccons ::= COLLATE ID|STRING */
149813 188, /* (42) autoinc ::= */
149814 188, /* (43) autoinc ::= AUTOINCR */
149815 190, /* (44) refargs ::= */
149816 190, /* (45) refargs ::= refargs refarg */
149817 192, /* (46) refarg ::= MATCH nm */
149818 192, /* (47) refarg ::= ON INSERT refact */
149819 192, /* (48) refarg ::= ON DELETE refact */
149820 192, /* (49) refarg ::= ON UPDATE refact */
149821 193, /* (50) refact ::= SET NULL */
149822 193, /* (51) refact ::= SET DEFAULT */
149823 193, /* (52) refact ::= CASCADE */
149824 193, /* (53) refact ::= RESTRICT */
149825 193, /* (54) refact ::= NO ACTION */
149826 191, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
149827 191, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
149828 194, /* (57) init_deferred_pred_opt ::= */
149829 194, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
149830 194, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
149831 172, /* (60) conslist_opt ::= */
149832 196, /* (61) tconscomma ::= COMMA */
149833 197, /* (62) tcons ::= CONSTRAINT nm */
149834 197, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
149835 197, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
149836 197, /* (65) tcons ::= CHECK LP expr RP onconf */
149837 197, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
149838 200, /* (67) defer_subclause_opt ::= */
149839 186, /* (68) onconf ::= */
149840 186, /* (69) onconf ::= ON CONFLICT resolvetype */
149841 201, /* (70) orconf ::= */
149842 201, /* (71) orconf ::= OR resolvetype */
149843 202, /* (72) resolvetype ::= IGNORE */
149844 202, /* (73) resolvetype ::= REPLACE */
149845 160, /* (74) cmd ::= DROP TABLE ifexists fullname */
149846 204, /* (75) ifexists ::= IF EXISTS */
149847 204, /* (76) ifexists ::= */
149848 160, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
149849 160, /* (78) cmd ::= DROP VIEW ifexists fullname */
149850 160, /* (79) cmd ::= select */
149851 174, /* (80) select ::= WITH wqlist selectnowith */
149852 174, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
149853 174, /* (82) select ::= selectnowith */
149854 206, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
149855 209, /* (84) multiselect_op ::= UNION */
149856 209, /* (85) multiselect_op ::= UNION ALL */
149857 209, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
149858 207, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
149859 207, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
149860 219, /* (89) values ::= VALUES LP nexprlist RP */
149861 219, /* (90) values ::= values COMMA LP nexprlist RP */
149862 210, /* (91) distinct ::= DISTINCT */
149863 210, /* (92) distinct ::= ALL */
149864 210, /* (93) distinct ::= */
149865 221, /* (94) sclp ::= */
149866 211, /* (95) selcollist ::= sclp scanpt expr scanpt as */
149867 211, /* (96) selcollist ::= sclp scanpt STAR */
149868 211, /* (97) selcollist ::= sclp scanpt nm DOT STAR */
149869 222, /* (98) as ::= AS nm */
149870 222, /* (99) as ::= */
149871 212, /* (100) from ::= */
149872 212, /* (101) from ::= FROM seltablist */
149873 224, /* (102) stl_prefix ::= seltablist joinop */
149874 224, /* (103) stl_prefix ::= */
149875 223, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
149876 223, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
149877 223, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
149878 223, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
149879 170, /* (108) dbnm ::= */
149880 170, /* (109) dbnm ::= DOT nm */
149881 205, /* (110) fullname ::= nm */
149882 205, /* (111) fullname ::= nm DOT nm */
149883 230, /* (112) xfullname ::= nm */
149884 230, /* (113) xfullname ::= nm DOT nm */
149885 230, /* (114) xfullname ::= nm DOT nm AS nm */
149886 230, /* (115) xfullname ::= nm AS nm */
149887 225, /* (116) joinop ::= COMMA|JOIN */
149888 225, /* (117) joinop ::= JOIN_KW JOIN */
149889 225, /* (118) joinop ::= JOIN_KW nm JOIN */
149890 225, /* (119) joinop ::= JOIN_KW nm nm JOIN */
149891 227, /* (120) on_opt ::= ON expr */
149892 227, /* (121) on_opt ::= */
149893 226, /* (122) indexed_opt ::= */
149894 226, /* (123) indexed_opt ::= INDEXED BY nm */
149895 226, /* (124) indexed_opt ::= NOT INDEXED */
149896 228, /* (125) using_opt ::= USING LP idlist RP */
149897 228, /* (126) using_opt ::= */
149898 216, /* (127) orderby_opt ::= */
149899 216, /* (128) orderby_opt ::= ORDER BY sortlist */
149900 198, /* (129) sortlist ::= sortlist COMMA expr sortorder */
149901 198, /* (130) sortlist ::= expr sortorder */
149902 187, /* (131) sortorder ::= ASC */
149903 187, /* (132) sortorder ::= DESC */
149904 187, /* (133) sortorder ::= */
149905 214, /* (134) groupby_opt ::= */
149906 214, /* (135) groupby_opt ::= GROUP BY nexprlist */
149907 215, /* (136) having_opt ::= */
149908 215, /* (137) having_opt ::= HAVING expr */
149909 217, /* (138) limit_opt ::= */
149910 217, /* (139) limit_opt ::= LIMIT expr */
149911 217, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
149912 217, /* (141) limit_opt ::= LIMIT expr COMMA expr */
149913 160, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
149914 213, /* (143) where_opt ::= */
149915 213, /* (144) where_opt ::= WHERE expr */
149916 160, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
149917 233, /* (146) setlist ::= setlist COMMA nm EQ expr */
149918 233, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
149919 233, /* (148) setlist ::= nm EQ expr */
149920 233, /* (149) setlist ::= LP idlist RP EQ expr */
149921 160, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
149922 160, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
149923 236, /* (152) upsert ::= */
149924 236, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
149925 236, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
149926 236, /* (155) upsert ::= ON CONFLICT DO NOTHING */
149927 234, /* (156) insert_cmd ::= INSERT orconf */
149928 234, /* (157) insert_cmd ::= REPLACE */
149929 235, /* (158) idlist_opt ::= */
149930 235, /* (159) idlist_opt ::= LP idlist RP */
149931 231, /* (160) idlist ::= idlist COMMA nm */
149932 231, /* (161) idlist ::= nm */
149933 185, /* (162) expr ::= LP expr RP */
149934 185, /* (163) expr ::= ID|INDEXED */
149935 185, /* (164) expr ::= JOIN_KW */
149936 185, /* (165) expr ::= nm DOT nm */
149937 185, /* (166) expr ::= nm DOT nm DOT nm */
149938 184, /* (167) term ::= NULL|FLOAT|BLOB */
149939 184, /* (168) term ::= STRING */
149940 184, /* (169) term ::= INTEGER */
149941 185, /* (170) expr ::= VARIABLE */
149942 185, /* (171) expr ::= expr COLLATE ID|STRING */
149943 185, /* (172) expr ::= CAST LP expr AS typetoken RP */
149944 185, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */
149945 185, /* (174) expr ::= ID|INDEXED LP STAR RP */
149946 185, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
149947 185, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */
149948 184, /* (177) term ::= CTIME_KW */
149949 185, /* (178) expr ::= LP nexprlist COMMA expr RP */
149950 185, /* (179) expr ::= expr AND expr */
149951 185, /* (180) expr ::= expr OR expr */
149952 185, /* (181) expr ::= expr LT|GT|GE|LE expr */
149953 185, /* (182) expr ::= expr EQ|NE expr */
149954 185, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
149955 185, /* (184) expr ::= expr PLUS|MINUS expr */
149956 185, /* (185) expr ::= expr STAR|SLASH|REM expr */
149957 185, /* (186) expr ::= expr CONCAT expr */
149958 238, /* (187) likeop ::= NOT LIKE_KW|MATCH */
149959 185, /* (188) expr ::= expr likeop expr */
149960 185, /* (189) expr ::= expr likeop expr ESCAPE expr */
149961 185, /* (190) expr ::= expr ISNULL|NOTNULL */
149962 185, /* (191) expr ::= expr NOT NULL */
149963 185, /* (192) expr ::= expr IS expr */
149964 185, /* (193) expr ::= expr IS NOT expr */
149965 185, /* (194) expr ::= NOT expr */
149966 185, /* (195) expr ::= BITNOT expr */
149967 185, /* (196) expr ::= PLUS|MINUS expr */
149968 239, /* (197) between_op ::= BETWEEN */
149969 239, /* (198) between_op ::= NOT BETWEEN */
149970 185, /* (199) expr ::= expr between_op expr AND expr */
149971 240, /* (200) in_op ::= IN */
149972 240, /* (201) in_op ::= NOT IN */
149973 185, /* (202) expr ::= expr in_op LP exprlist RP */
149974 185, /* (203) expr ::= LP select RP */
149975 185, /* (204) expr ::= expr in_op LP select RP */
149976 185, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */
149977 185, /* (206) expr ::= EXISTS LP select RP */
149978 185, /* (207) expr ::= CASE case_operand case_exprlist case_else END */
149979 243, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */
149980 243, /* (209) case_exprlist ::= WHEN expr THEN expr */
149981 244, /* (210) case_else ::= ELSE expr */
149982 244, /* (211) case_else ::= */
149983 242, /* (212) case_operand ::= expr */
149984 242, /* (213) case_operand ::= */
149985 229, /* (214) exprlist ::= */
149986 220, /* (215) nexprlist ::= nexprlist COMMA expr */
149987 220, /* (216) nexprlist ::= expr */
149988 241, /* (217) paren_exprlist ::= */
149989 241, /* (218) paren_exprlist ::= LP exprlist RP */
149990 160, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
149991 245, /* (220) uniqueflag ::= UNIQUE */
149992 245, /* (221) uniqueflag ::= */
149993 189, /* (222) eidlist_opt ::= */
149994 189, /* (223) eidlist_opt ::= LP eidlist RP */
149995 199, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */
149996 199, /* (225) eidlist ::= nm collate sortorder */
149997 246, /* (226) collate ::= */
149998 246, /* (227) collate ::= COLLATE ID|STRING */
149999 160, /* (228) cmd ::= DROP INDEX ifexists fullname */
150000 160, /* (229) cmd ::= VACUUM vinto */
150001 160, /* (230) cmd ::= VACUUM nm vinto */
150002 247, /* (231) vinto ::= INTO expr */
150003 247, /* (232) vinto ::= */
150004 160, /* (233) cmd ::= PRAGMA nm dbnm */
150005 160, /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */
150006 160, /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */
150007 160, /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */
150008 160, /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */
150009 180, /* (238) plus_num ::= PLUS INTEGER|FLOAT */
150010 181, /* (239) minus_num ::= MINUS INTEGER|FLOAT */
150011 160, /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
150012 249, /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
150013 251, /* (242) trigger_time ::= BEFORE|AFTER */
150014 251, /* (243) trigger_time ::= INSTEAD OF */
150015 251, /* (244) trigger_time ::= */
150016 252, /* (245) trigger_event ::= DELETE|INSERT */
150017 252, /* (246) trigger_event ::= UPDATE */
150018 252, /* (247) trigger_event ::= UPDATE OF idlist */
150019 254, /* (248) when_clause ::= */
150020 254, /* (249) when_clause ::= WHEN expr */
150021 250, /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
150022 250, /* (251) trigger_cmd_list ::= trigger_cmd SEMI */
150023 256, /* (252) trnm ::= nm DOT nm */
150024 257, /* (253) tridxby ::= INDEXED BY nm */
150025 257, /* (254) tridxby ::= NOT INDEXED */
150026 255, /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
150027 255, /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
150028 255, /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
150029 255, /* (258) trigger_cmd ::= scanpt select scanpt */
150030 185, /* (259) expr ::= RAISE LP IGNORE RP */
150031 185, /* (260) expr ::= RAISE LP raisetype COMMA nm RP */
150032 203, /* (261) raisetype ::= ROLLBACK */
150033 203, /* (262) raisetype ::= ABORT */
150034 203, /* (263) raisetype ::= FAIL */
150035 160, /* (264) cmd ::= DROP TRIGGER ifexists fullname */
150036 160, /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
150037 160, /* (266) cmd ::= DETACH database_kw_opt expr */
150038 259, /* (267) key_opt ::= */
150039 259, /* (268) key_opt ::= KEY expr */
150040 160, /* (269) cmd ::= REINDEX */
150041 160, /* (270) cmd ::= REINDEX nm dbnm */
150042 160, /* (271) cmd ::= ANALYZE */
150043 160, /* (272) cmd ::= ANALYZE nm dbnm */
150044 160, /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */
150045 160, /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
150046 260, /* (275) add_column_fullname ::= fullname */
150047 160, /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
150048 160, /* (277) cmd ::= create_vtab */
150049 160, /* (278) cmd ::= create_vtab LP vtabarglist RP */
150050 262, /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
150051 264, /* (280) vtabarg ::= */
150052 265, /* (281) vtabargtoken ::= ANY */
150053 265, /* (282) vtabargtoken ::= lp anylist RP */
150054 266, /* (283) lp ::= LP */
150055 232, /* (284) with ::= WITH wqlist */
150056 232, /* (285) with ::= WITH RECURSIVE wqlist */
150057 208, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150058 208, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150059 268, /* (288) windowdefn_list ::= windowdefn */
150060 268, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150061 269, /* (290) windowdefn ::= nm AS window */
150062 270, /* (291) window ::= LP part_opt orderby_opt frame_opt RP */
150063 272, /* (292) part_opt ::= PARTITION BY nexprlist */
150064 272, /* (293) part_opt ::= */
150065 271, /* (294) frame_opt ::= */
150066 271, /* (295) frame_opt ::= range_or_rows frame_bound_s */
150067 271, /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
150068 274, /* (297) range_or_rows ::= RANGE */
150069 274, /* (298) range_or_rows ::= ROWS */
150070 276, /* (299) frame_bound_s ::= frame_bound */
150071 276, /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */
150072 277, /* (301) frame_bound_e ::= frame_bound */
150073 277, /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */
150074 275, /* (303) frame_bound ::= expr PRECEDING */
150075 275, /* (304) frame_bound ::= CURRENT ROW */
150076 275, /* (305) frame_bound ::= expr FOLLOWING */
150077 218, /* (306) window_clause ::= WINDOW windowdefn_list */
150078 237, /* (307) over_clause ::= filter_opt OVER window */
150079 237, /* (308) over_clause ::= filter_opt OVER nm */
150080 273, /* (309) filter_opt ::= */
150081 273, /* (310) filter_opt ::= FILTER LP WHERE expr RP */
150082 155, /* (311) input ::= cmdlist */
150083 156, /* (312) cmdlist ::= cmdlist ecmd */
150084 156, /* (313) cmdlist ::= ecmd */
150085 157, /* (314) ecmd ::= SEMI */
150086 157, /* (315) ecmd ::= cmdx SEMI */
150087 157, /* (316) ecmd ::= explain cmdx */
150088 162, /* (317) trans_opt ::= */
150089 162, /* (318) trans_opt ::= TRANSACTION */
150090 162, /* (319) trans_opt ::= TRANSACTION nm */
150091 164, /* (320) savepoint_opt ::= SAVEPOINT */
150092 164, /* (321) savepoint_opt ::= */
150093 160, /* (322) cmd ::= create_table create_table_args */
150094 171, /* (323) columnlist ::= columnlist COMMA columnname carglist */
150095 171, /* (324) columnlist ::= columnname carglist */
150096 163, /* (325) nm ::= ID|INDEXED */
150097 163, /* (326) nm ::= STRING */
150098 163, /* (327) nm ::= JOIN_KW */
150099 177, /* (328) typetoken ::= typename */
150100 178, /* (329) typename ::= ID|STRING */
150101 179, /* (330) signed ::= plus_num */
150102 179, /* (331) signed ::= minus_num */
150103 176, /* (332) carglist ::= carglist ccons */
150104 176, /* (333) carglist ::= */
150105 183, /* (334) ccons ::= NULL onconf */
150106 172, /* (335) conslist_opt ::= COMMA conslist */
150107 195, /* (336) conslist ::= conslist tconscomma tcons */
150108 195, /* (337) conslist ::= tcons */
150109 196, /* (338) tconscomma ::= */
150110 200, /* (339) defer_subclause_opt ::= defer_subclause */
150111 202, /* (340) resolvetype ::= raisetype */
150112 206, /* (341) selectnowith ::= oneselect */
150113 207, /* (342) oneselect ::= values */
150114 221, /* (343) sclp ::= selcollist COMMA */
150115 222, /* (344) as ::= ID|STRING */
150116 185, /* (345) expr ::= term */
150117 238, /* (346) likeop ::= LIKE_KW|MATCH */
150118 229, /* (347) exprlist ::= nexprlist */
150119 248, /* (348) nmnum ::= plus_num */
150120 248, /* (349) nmnum ::= nm */
150121 248, /* (350) nmnum ::= ON */
150122 248, /* (351) nmnum ::= DELETE */
150123 248, /* (352) nmnum ::= DEFAULT */
150124 180, /* (353) plus_num ::= INTEGER|FLOAT */
150125 253, /* (354) foreach_clause ::= */
150126 253, /* (355) foreach_clause ::= FOR EACH ROW */
150127 256, /* (356) trnm ::= nm */
150128 257, /* (357) tridxby ::= */
150129 258, /* (358) database_kw_opt ::= DATABASE */
150130 258, /* (359) database_kw_opt ::= */
150131 261, /* (360) kwcolumn_opt ::= */
150132 261, /* (361) kwcolumn_opt ::= COLUMNKW */
150133 263, /* (362) vtabarglist ::= vtabarg */
150134 263, /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */
150135 264, /* (364) vtabarg ::= vtabarg vtabargtoken */
150136 267, /* (365) anylist ::= */
150137 267, /* (366) anylist ::= anylist LP anylist RP */
150138 267, /* (367) anylist ::= anylist ANY */
150139 232, /* (368) with ::= */
 
 
 
 
 
 
150140 };
150141
150142 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
150143 ** of symbols on the right-hand side of that rule. */
150144 static const signed char yyRuleInfoNRhs[] = {
@@ -150430,89 +151067,95 @@
150430 -3, /* (285) with ::= WITH RECURSIVE wqlist */
150431 -6, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150432 -8, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150433 -1, /* (288) windowdefn_list ::= windowdefn */
150434 -3, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150435 -3, /* (290) windowdefn ::= nm AS window */
150436 -5, /* (291) window ::= LP part_opt orderby_opt frame_opt RP */
150437 -3, /* (292) part_opt ::= PARTITION BY nexprlist */
150438 0, /* (293) part_opt ::= */
150439 0, /* (294) frame_opt ::= */
150440 -2, /* (295) frame_opt ::= range_or_rows frame_bound_s */
150441 -5, /* (296) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
150442 -1, /* (297) range_or_rows ::= RANGE */
150443 -1, /* (298) range_or_rows ::= ROWS */
150444 -1, /* (299) frame_bound_s ::= frame_bound */
150445 -2, /* (300) frame_bound_s ::= UNBOUNDED PRECEDING */
150446 -1, /* (301) frame_bound_e ::= frame_bound */
150447 -2, /* (302) frame_bound_e ::= UNBOUNDED FOLLOWING */
150448 -2, /* (303) frame_bound ::= expr PRECEDING */
150449 -2, /* (304) frame_bound ::= CURRENT ROW */
150450 -2, /* (305) frame_bound ::= expr FOLLOWING */
150451 -2, /* (306) window_clause ::= WINDOW windowdefn_list */
150452 -3, /* (307) over_clause ::= filter_opt OVER window */
150453 -3, /* (308) over_clause ::= filter_opt OVER nm */
150454 0, /* (309) filter_opt ::= */
150455 -5, /* (310) filter_opt ::= FILTER LP WHERE expr RP */
150456 -1, /* (311) input ::= cmdlist */
150457 -2, /* (312) cmdlist ::= cmdlist ecmd */
150458 -1, /* (313) cmdlist ::= ecmd */
150459 -1, /* (314) ecmd ::= SEMI */
150460 -2, /* (315) ecmd ::= cmdx SEMI */
150461 -2, /* (316) ecmd ::= explain cmdx */
150462 0, /* (317) trans_opt ::= */
150463 -1, /* (318) trans_opt ::= TRANSACTION */
150464 -2, /* (319) trans_opt ::= TRANSACTION nm */
150465 -1, /* (320) savepoint_opt ::= SAVEPOINT */
150466 0, /* (321) savepoint_opt ::= */
150467 -2, /* (322) cmd ::= create_table create_table_args */
150468 -4, /* (323) columnlist ::= columnlist COMMA columnname carglist */
150469 -2, /* (324) columnlist ::= columnname carglist */
150470 -1, /* (325) nm ::= ID|INDEXED */
150471 -1, /* (326) nm ::= STRING */
150472 -1, /* (327) nm ::= JOIN_KW */
150473 -1, /* (328) typetoken ::= typename */
150474 -1, /* (329) typename ::= ID|STRING */
150475 -1, /* (330) signed ::= plus_num */
150476 -1, /* (331) signed ::= minus_num */
150477 -2, /* (332) carglist ::= carglist ccons */
150478 0, /* (333) carglist ::= */
150479 -2, /* (334) ccons ::= NULL onconf */
150480 -2, /* (335) conslist_opt ::= COMMA conslist */
150481 -3, /* (336) conslist ::= conslist tconscomma tcons */
150482 -1, /* (337) conslist ::= tcons */
150483 0, /* (338) tconscomma ::= */
150484 -1, /* (339) defer_subclause_opt ::= defer_subclause */
150485 -1, /* (340) resolvetype ::= raisetype */
150486 -1, /* (341) selectnowith ::= oneselect */
150487 -1, /* (342) oneselect ::= values */
150488 -2, /* (343) sclp ::= selcollist COMMA */
150489 -1, /* (344) as ::= ID|STRING */
150490 -1, /* (345) expr ::= term */
150491 -1, /* (346) likeop ::= LIKE_KW|MATCH */
150492 -1, /* (347) exprlist ::= nexprlist */
150493 -1, /* (348) nmnum ::= plus_num */
150494 -1, /* (349) nmnum ::= nm */
150495 -1, /* (350) nmnum ::= ON */
150496 -1, /* (351) nmnum ::= DELETE */
150497 -1, /* (352) nmnum ::= DEFAULT */
150498 -1, /* (353) plus_num ::= INTEGER|FLOAT */
150499 0, /* (354) foreach_clause ::= */
150500 -3, /* (355) foreach_clause ::= FOR EACH ROW */
150501 -1, /* (356) trnm ::= nm */
150502 0, /* (357) tridxby ::= */
150503 -1, /* (358) database_kw_opt ::= DATABASE */
150504 0, /* (359) database_kw_opt ::= */
150505 0, /* (360) kwcolumn_opt ::= */
150506 -1, /* (361) kwcolumn_opt ::= COLUMNKW */
150507 -1, /* (362) vtabarglist ::= vtabarg */
150508 -3, /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */
150509 -2, /* (364) vtabarg ::= vtabarg vtabargtoken */
150510 0, /* (365) anylist ::= */
150511 -4, /* (366) anylist ::= anylist LP anylist RP */
150512 -2, /* (367) anylist ::= anylist ANY */
150513 0, /* (368) with ::= */
 
 
 
 
 
 
150514 };
150515
150516 static void yy_accept(yyParser*); /* Forward Declaration */
150517
150518 /*
@@ -150605,19 +151248,20 @@
150605 break;
150606 case 2: /* cmdx ::= cmd */
150607 { sqlite3FinishCoding(pParse); }
150608 break;
150609 case 3: /* cmd ::= BEGIN transtype trans_opt */
150610 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy96);}
150611 break;
150612 case 4: /* transtype ::= */
150613 {yymsp[1].minor.yy96 = TK_DEFERRED;}
150614 break;
150615 case 5: /* transtype ::= DEFERRED */
150616 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
150617 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
150618 {yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/}
 
150619 break;
150620 case 8: /* cmd ::= COMMIT|END trans_opt */
150621 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
150622 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
150623 break;
@@ -150636,11 +151280,11 @@
150636 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
150637 }
150638 break;
150639 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
150640 {
150641 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy96,0,0,yymsp[-2].minor.yy96);
150642 }
150643 break;
150644 case 14: /* createkw ::= CREATE */
150645 {disableLookaside(pParse);}
150646 break;
@@ -150651,36 +151295,36 @@
150651 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
150652 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
150653 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
150654 case 93: /* distinct ::= */ yytestcase(yyruleno==93);
150655 case 226: /* collate ::= */ yytestcase(yyruleno==226);
150656 {yymsp[1].minor.yy96 = 0;}
150657 break;
150658 case 16: /* ifnotexists ::= IF NOT EXISTS */
150659 {yymsp[-2].minor.yy96 = 1;}
150660 break;
150661 case 17: /* temp ::= TEMP */
150662 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
150663 {yymsp[0].minor.yy96 = 1;}
150664 break;
150665 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
150666 {
150667 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy96,0);
150668 }
150669 break;
150670 case 20: /* create_table_args ::= AS select */
150671 {
150672 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy423);
150673 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);
150674 }
150675 break;
150676 case 22: /* table_options ::= WITHOUT nm */
150677 {
150678 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
150679 yymsp[-1].minor.yy96 = TF_WithoutRowid | TF_NoVisibleRowid;
150680 }else{
150681 yymsp[-1].minor.yy96 = 0;
150682 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
150683 }
150684 }
150685 break;
150686 case 23: /* columnname ::= nm typetoken */
@@ -150705,30 +151349,30 @@
150705 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
150706 break;
150707 case 28: /* scanpt ::= */
150708 {
150709 assert( yyLookahead!=YYNOCODE );
150710 yymsp[1].minor.yy464 = yyLookaheadToken.z;
150711 }
150712 break;
150713 case 29: /* ccons ::= CONSTRAINT nm */
150714 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
150715 {pParse->constraintName = yymsp[0].minor.yy0;}
150716 break;
150717 case 30: /* ccons ::= DEFAULT scanpt term scanpt */
150718 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy464,yymsp[0].minor.yy464);}
150719 break;
150720 case 31: /* ccons ::= DEFAULT LP expr RP */
150721 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
150722 break;
150723 case 32: /* ccons ::= DEFAULT PLUS term scanpt */
150724 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy490,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);}
150725 break;
150726 case 33: /* ccons ::= DEFAULT MINUS term scanpt */
150727 {
150728 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy490, 0);
150729 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy464);
150730 }
150731 break;
150732 case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
150733 {
150734 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -150738,319 +151382,319 @@
150738 }
150739 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
150740 }
150741 break;
150742 case 35: /* ccons ::= NOT NULL onconf */
150743 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy96);}
150744 break;
150745 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
150746 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy96,yymsp[0].minor.yy96,yymsp[-2].minor.yy96);}
150747 break;
150748 case 37: /* ccons ::= UNIQUE onconf */
150749 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy96,0,0,0,0,
150750 SQLITE_IDXTYPE_UNIQUE);}
150751 break;
150752 case 38: /* ccons ::= CHECK LP expr RP */
150753 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy490);}
150754 break;
150755 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
150756 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy42,yymsp[0].minor.yy96);}
150757 break;
150758 case 40: /* ccons ::= defer_subclause */
150759 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy96);}
150760 break;
150761 case 41: /* ccons ::= COLLATE ID|STRING */
150762 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
150763 break;
150764 case 44: /* refargs ::= */
150765 { yymsp[1].minor.yy96 = OE_None*0x0101; /* EV: R-19803-45884 */}
150766 break;
150767 case 45: /* refargs ::= refargs refarg */
150768 { yymsp[-1].minor.yy96 = (yymsp[-1].minor.yy96 & ~yymsp[0].minor.yy367.mask) | yymsp[0].minor.yy367.value; }
150769 break;
150770 case 46: /* refarg ::= MATCH nm */
150771 { yymsp[-1].minor.yy367.value = 0; yymsp[-1].minor.yy367.mask = 0x000000; }
150772 break;
150773 case 47: /* refarg ::= ON INSERT refact */
150774 { yymsp[-2].minor.yy367.value = 0; yymsp[-2].minor.yy367.mask = 0x000000; }
150775 break;
150776 case 48: /* refarg ::= ON DELETE refact */
150777 { yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96; yymsp[-2].minor.yy367.mask = 0x0000ff; }
150778 break;
150779 case 49: /* refarg ::= ON UPDATE refact */
150780 { yymsp[-2].minor.yy367.value = yymsp[0].minor.yy96<<8; yymsp[-2].minor.yy367.mask = 0x00ff00; }
150781 break;
150782 case 50: /* refact ::= SET NULL */
150783 { yymsp[-1].minor.yy96 = OE_SetNull; /* EV: R-33326-45252 */}
150784 break;
150785 case 51: /* refact ::= SET DEFAULT */
150786 { yymsp[-1].minor.yy96 = OE_SetDflt; /* EV: R-33326-45252 */}
150787 break;
150788 case 52: /* refact ::= CASCADE */
150789 { yymsp[0].minor.yy96 = OE_Cascade; /* EV: R-33326-45252 */}
150790 break;
150791 case 53: /* refact ::= RESTRICT */
150792 { yymsp[0].minor.yy96 = OE_Restrict; /* EV: R-33326-45252 */}
150793 break;
150794 case 54: /* refact ::= NO ACTION */
150795 { yymsp[-1].minor.yy96 = OE_None; /* EV: R-33326-45252 */}
150796 break;
150797 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
150798 {yymsp[-2].minor.yy96 = 0;}
150799 break;
150800 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
150801 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
150802 case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156);
150803 {yymsp[-1].minor.yy96 = yymsp[0].minor.yy96;}
150804 break;
150805 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
150806 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
150807 case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198);
150808 case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201);
150809 case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227);
150810 {yymsp[-1].minor.yy96 = 1;}
150811 break;
150812 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
150813 {yymsp[-1].minor.yy96 = 0;}
150814 break;
150815 case 61: /* tconscomma ::= COMMA */
150816 {pParse->constraintName.n = 0;}
150817 break;
150818 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
150819 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy42,yymsp[0].minor.yy96,yymsp[-2].minor.yy96,0);}
150820 break;
150821 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
150822 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy42,yymsp[0].minor.yy96,0,0,0,0,
150823 SQLITE_IDXTYPE_UNIQUE);}
150824 break;
150825 case 65: /* tcons ::= CHECK LP expr RP onconf */
150826 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy490);}
150827 break;
150828 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
150829 {
150830 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy42, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy96);
150831 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy96);
150832 }
150833 break;
150834 case 68: /* onconf ::= */
150835 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
150836 {yymsp[1].minor.yy96 = OE_Default;}
150837 break;
150838 case 69: /* onconf ::= ON CONFLICT resolvetype */
150839 {yymsp[-2].minor.yy96 = yymsp[0].minor.yy96;}
150840 break;
150841 case 72: /* resolvetype ::= IGNORE */
150842 {yymsp[0].minor.yy96 = OE_Ignore;}
150843 break;
150844 case 73: /* resolvetype ::= REPLACE */
150845 case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157);
150846 {yymsp[0].minor.yy96 = OE_Replace;}
150847 break;
150848 case 74: /* cmd ::= DROP TABLE ifexists fullname */
150849 {
150850 sqlite3DropTable(pParse, yymsp[0].minor.yy167, 0, yymsp[-1].minor.yy96);
150851 }
150852 break;
150853 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
150854 {
150855 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy42, yymsp[0].minor.yy423, yymsp[-7].minor.yy96, yymsp[-5].minor.yy96);
150856 }
150857 break;
150858 case 78: /* cmd ::= DROP VIEW ifexists fullname */
150859 {
150860 sqlite3DropTable(pParse, yymsp[0].minor.yy167, 1, yymsp[-1].minor.yy96);
150861 }
150862 break;
150863 case 79: /* cmd ::= select */
150864 {
150865 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
150866 sqlite3Select(pParse, yymsp[0].minor.yy423, &dest);
150867 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy423);
150868 }
150869 break;
150870 case 80: /* select ::= WITH wqlist selectnowith */
150871 {
150872 Select *p = yymsp[0].minor.yy423;
150873 if( p ){
150874 p->pWith = yymsp[-1].minor.yy499;
150875 parserDoubleLinkSelect(pParse, p);
150876 }else{
150877 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);
150878 }
150879 yymsp[-2].minor.yy423 = p;
150880 }
150881 break;
150882 case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
150883 {
150884 Select *p = yymsp[0].minor.yy423;
150885 if( p ){
150886 p->pWith = yymsp[-1].minor.yy499;
150887 parserDoubleLinkSelect(pParse, p);
150888 }else{
150889 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy499);
150890 }
150891 yymsp[-3].minor.yy423 = p;
150892 }
150893 break;
150894 case 82: /* select ::= selectnowith */
150895 {
150896 Select *p = yymsp[0].minor.yy423;
150897 if( p ){
150898 parserDoubleLinkSelect(pParse, p);
150899 }
150900 yymsp[0].minor.yy423 = p; /*A-overwrites-X*/
150901 }
150902 break;
150903 case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
150904 {
150905 Select *pRhs = yymsp[0].minor.yy423;
150906 Select *pLhs = yymsp[-2].minor.yy423;
150907 if( pRhs && pRhs->pPrior ){
150908 SrcList *pFrom;
150909 Token x;
150910 x.n = 0;
150911 parserDoubleLinkSelect(pParse, pRhs);
150912 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
150913 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
150914 }
150915 if( pRhs ){
150916 pRhs->op = (u8)yymsp[-1].minor.yy96;
150917 pRhs->pPrior = pLhs;
150918 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
150919 pRhs->selFlags &= ~SF_MultiValue;
150920 if( yymsp[-1].minor.yy96!=TK_ALL ) pParse->hasCompound = 1;
150921 }else{
150922 sqlite3SelectDelete(pParse->db, pLhs);
150923 }
150924 yymsp[-2].minor.yy423 = pRhs;
150925 }
150926 break;
150927 case 84: /* multiselect_op ::= UNION */
150928 case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
150929 {yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-OP*/}
150930 break;
150931 case 85: /* multiselect_op ::= UNION ALL */
150932 {yymsp[-1].minor.yy96 = TK_ALL;}
150933 break;
150934 case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
150935 {
150936 yymsp[-8].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy42,yymsp[-5].minor.yy167,yymsp[-4].minor.yy490,yymsp[-3].minor.yy42,yymsp[-2].minor.yy490,yymsp[-1].minor.yy42,yymsp[-7].minor.yy96,yymsp[0].minor.yy490);
150937 }
150938 break;
150939 case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
150940 {
150941 yymsp[-9].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy42,yymsp[-6].minor.yy167,yymsp[-5].minor.yy490,yymsp[-4].minor.yy42,yymsp[-3].minor.yy490,yymsp[-1].minor.yy42,yymsp[-8].minor.yy96,yymsp[0].minor.yy490);
150942 if( yymsp[-9].minor.yy423 ){
150943 yymsp[-9].minor.yy423->pWinDefn = yymsp[-2].minor.yy147;
150944 }else{
150945 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy147);
150946 }
150947 }
150948 break;
150949 case 89: /* values ::= VALUES LP nexprlist RP */
150950 {
150951 yymsp[-3].minor.yy423 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values,0);
150952 }
150953 break;
150954 case 90: /* values ::= values COMMA LP nexprlist RP */
150955 {
150956 Select *pRight, *pLeft = yymsp[-4].minor.yy423;
150957 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy42,0,0,0,0,0,SF_Values|SF_MultiValue,0);
150958 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
150959 if( pRight ){
150960 pRight->op = TK_ALL;
150961 pRight->pPrior = pLeft;
150962 yymsp[-4].minor.yy423 = pRight;
150963 }else{
150964 yymsp[-4].minor.yy423 = pLeft;
150965 }
150966 }
150967 break;
150968 case 91: /* distinct ::= DISTINCT */
150969 {yymsp[0].minor.yy96 = SF_Distinct;}
150970 break;
150971 case 92: /* distinct ::= ALL */
150972 {yymsp[0].minor.yy96 = SF_All;}
150973 break;
150974 case 94: /* sclp ::= */
150975 case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127);
150976 case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134);
150977 case 214: /* exprlist ::= */ yytestcase(yyruleno==214);
150978 case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217);
150979 case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222);
150980 {yymsp[1].minor.yy42 = 0;}
150981 break;
150982 case 95: /* selcollist ::= sclp scanpt expr scanpt as */
150983 {
150984 yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);
150985 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[0].minor.yy0, 1);
150986 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy42,yymsp[-3].minor.yy464,yymsp[-1].minor.yy464);
150987 }
150988 break;
150989 case 96: /* selcollist ::= sclp scanpt STAR */
150990 {
150991 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
150992 yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy42, p);
150993 }
150994 break;
150995 case 97: /* selcollist ::= sclp scanpt nm DOT STAR */
150996 {
150997 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
150998 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
150999 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
151000 yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, pDot);
151001 }
151002 break;
151003 case 98: /* as ::= AS nm */
151004 case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109);
151005 case 238: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==238);
151006 case 239: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==239);
151007 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
151008 break;
151009 case 100: /* from ::= */
151010 {yymsp[1].minor.yy167 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy167));}
151011 break;
151012 case 101: /* from ::= FROM seltablist */
151013 {
151014 yymsp[-1].minor.yy167 = yymsp[0].minor.yy167;
151015 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy167);
151016 }
151017 break;
151018 case 102: /* stl_prefix ::= seltablist joinop */
151019 {
151020 if( ALWAYS(yymsp[-1].minor.yy167 && yymsp[-1].minor.yy167->nSrc>0) ) yymsp[-1].minor.yy167->a[yymsp[-1].minor.yy167->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy96;
151021 }
151022 break;
151023 case 103: /* stl_prefix ::= */
151024 {yymsp[1].minor.yy167 = 0;}
151025 break;
151026 case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151027 {
151028 yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151029 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy167, &yymsp[-2].minor.yy0);
151030 }
151031 break;
151032 case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151033 {
151034 yymsp[-8].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy167,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151035 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy167, yymsp[-4].minor.yy42);
151036 }
151037 break;
151038 case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151039 {
151040 yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy423,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151041 }
151042 break;
151043 case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151044 {
151045 if( yymsp[-6].minor.yy167==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy490==0 && yymsp[0].minor.yy336==0 ){
151046 yymsp[-6].minor.yy167 = yymsp[-4].minor.yy167;
151047 }else if( yymsp[-4].minor.yy167->nSrc==1 ){
151048 yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151049 if( yymsp[-6].minor.yy167 ){
151050 struct SrcList_item *pNew = &yymsp[-6].minor.yy167->a[yymsp[-6].minor.yy167->nSrc-1];
151051 struct SrcList_item *pOld = yymsp[-4].minor.yy167->a;
151052 pNew->zName = pOld->zName;
151053 pNew->zDatabase = pOld->zDatabase;
151054 pNew->pSelect = pOld->pSelect;
151055 if( pOld->fg.isTabFunc ){
151056 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -151059,215 +151703,215 @@
151059 pNew->fg.isTabFunc = 1;
151060 }
151061 pOld->zName = pOld->zDatabase = 0;
151062 pOld->pSelect = 0;
151063 }
151064 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy167);
151065 }else{
151066 Select *pSubquery;
151067 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy167);
151068 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy167,0,0,0,0,SF_NestedFrom,0);
151069 yymsp[-6].minor.yy167 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy167,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy490,yymsp[0].minor.yy336);
151070 }
151071 }
151072 break;
151073 case 108: /* dbnm ::= */
151074 case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
151075 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
151076 break;
151077 case 110: /* fullname ::= nm */
151078 {
151079 yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
151080 if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);
151081 }
151082 yymsp[0].minor.yy167 = yylhsminor.yy167;
151083 break;
151084 case 111: /* fullname ::= nm DOT nm */
151085 {
151086 yylhsminor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
151087 if( IN_RENAME_OBJECT && yylhsminor.yy167 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy167->a[0].zName, &yymsp[0].minor.yy0);
151088 }
151089 yymsp[-2].minor.yy167 = yylhsminor.yy167;
151090 break;
151091 case 112: /* xfullname ::= nm */
151092 {yymsp[0].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
151093 break;
151094 case 113: /* xfullname ::= nm DOT nm */
151095 {yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
151096 break;
151097 case 114: /* xfullname ::= nm DOT nm AS nm */
151098 {
151099 yymsp[-4].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
151100 if( yymsp[-4].minor.yy167 ) yymsp[-4].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151101 }
151102 break;
151103 case 115: /* xfullname ::= nm AS nm */
151104 {
151105 yymsp[-2].minor.yy167 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
151106 if( yymsp[-2].minor.yy167 ) yymsp[-2].minor.yy167->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151107 }
151108 break;
151109 case 116: /* joinop ::= COMMA|JOIN */
151110 { yymsp[0].minor.yy96 = JT_INNER; }
151111 break;
151112 case 117: /* joinop ::= JOIN_KW JOIN */
151113 {yymsp[-1].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
151114 break;
151115 case 118: /* joinop ::= JOIN_KW nm JOIN */
151116 {yymsp[-2].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
151117 break;
151118 case 119: /* joinop ::= JOIN_KW nm nm JOIN */
151119 {yymsp[-3].minor.yy96 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
151120 break;
151121 case 120: /* on_opt ::= ON expr */
151122 case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137);
151123 case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144);
151124 case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210);
151125 case 231: /* vinto ::= INTO expr */ yytestcase(yyruleno==231);
151126 {yymsp[-1].minor.yy490 = yymsp[0].minor.yy490;}
151127 break;
151128 case 121: /* on_opt ::= */
151129 case 136: /* having_opt ::= */ yytestcase(yyruleno==136);
151130 case 138: /* limit_opt ::= */ yytestcase(yyruleno==138);
151131 case 143: /* where_opt ::= */ yytestcase(yyruleno==143);
151132 case 211: /* case_else ::= */ yytestcase(yyruleno==211);
151133 case 213: /* case_operand ::= */ yytestcase(yyruleno==213);
151134 case 232: /* vinto ::= */ yytestcase(yyruleno==232);
151135 {yymsp[1].minor.yy490 = 0;}
151136 break;
151137 case 123: /* indexed_opt ::= INDEXED BY nm */
151138 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
151139 break;
151140 case 124: /* indexed_opt ::= NOT INDEXED */
151141 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
151142 break;
151143 case 125: /* using_opt ::= USING LP idlist RP */
151144 {yymsp[-3].minor.yy336 = yymsp[-1].minor.yy336;}
151145 break;
151146 case 126: /* using_opt ::= */
151147 case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158);
151148 {yymsp[1].minor.yy336 = 0;}
151149 break;
151150 case 128: /* orderby_opt ::= ORDER BY sortlist */
151151 case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135);
151152 {yymsp[-2].minor.yy42 = yymsp[0].minor.yy42;}
151153 break;
151154 case 129: /* sortlist ::= sortlist COMMA expr sortorder */
151155 {
151156 yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42,yymsp[-1].minor.yy490);
151157 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy42,yymsp[0].minor.yy96);
151158 }
151159 break;
151160 case 130: /* sortlist ::= expr sortorder */
151161 {
151162 yymsp[-1].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy490); /*A-overwrites-Y*/
151163 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy42,yymsp[0].minor.yy96);
151164 }
151165 break;
151166 case 131: /* sortorder ::= ASC */
151167 {yymsp[0].minor.yy96 = SQLITE_SO_ASC;}
151168 break;
151169 case 132: /* sortorder ::= DESC */
151170 {yymsp[0].minor.yy96 = SQLITE_SO_DESC;}
151171 break;
151172 case 133: /* sortorder ::= */
151173 {yymsp[1].minor.yy96 = SQLITE_SO_UNDEFINED;}
151174 break;
151175 case 139: /* limit_opt ::= LIMIT expr */
151176 {yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,0);}
151177 break;
151178 case 140: /* limit_opt ::= LIMIT expr OFFSET expr */
151179 {yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}
151180 break;
151181 case 141: /* limit_opt ::= LIMIT expr COMMA expr */
151182 {yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy490,yymsp[-2].minor.yy490);}
151183 break;
151184 case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151185 {
151186 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy167, &yymsp[-1].minor.yy0);
151187 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy167,yymsp[0].minor.yy490,0,0);
151188 }
151189 break;
151190 case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151191 {
151192 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy167, &yymsp[-3].minor.yy0);
151193 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy42,"set list");
151194 sqlite3Update(pParse,yymsp[-4].minor.yy167,yymsp[-1].minor.yy42,yymsp[0].minor.yy490,yymsp[-5].minor.yy96,0,0,0);
151195 }
151196 break;
151197 case 146: /* setlist ::= setlist COMMA nm EQ expr */
151198 {
151199 yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy42, yymsp[0].minor.yy490);
151200 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, 1);
151201 }
151202 break;
151203 case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
151204 {
151205 yymsp[-6].minor.yy42 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy42, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);
151206 }
151207 break;
151208 case 148: /* setlist ::= nm EQ expr */
151209 {
151210 yylhsminor.yy42 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy490);
151211 sqlite3ExprListSetName(pParse, yylhsminor.yy42, &yymsp[-2].minor.yy0, 1);
151212 }
151213 yymsp[-2].minor.yy42 = yylhsminor.yy42;
151214 break;
151215 case 149: /* setlist ::= LP idlist RP EQ expr */
151216 {
151217 yymsp[-4].minor.yy42 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy336, yymsp[0].minor.yy490);
151218 }
151219 break;
151220 case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151221 {
151222 sqlite3Insert(pParse, yymsp[-3].minor.yy167, yymsp[-1].minor.yy423, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, yymsp[0].minor.yy266);
151223 }
151224 break;
151225 case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151226 {
151227 sqlite3Insert(pParse, yymsp[-3].minor.yy167, 0, yymsp[-2].minor.yy336, yymsp[-5].minor.yy96, 0);
151228 }
151229 break;
151230 case 152: /* upsert ::= */
151231 { yymsp[1].minor.yy266 = 0; }
151232 break;
151233 case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151234 { yymsp[-10].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy42,yymsp[-5].minor.yy490,yymsp[-1].minor.yy42,yymsp[0].minor.yy490);}
151235 break;
151236 case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151237 { yymsp[-7].minor.yy266 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy42,yymsp[-2].minor.yy490,0,0); }
151238 break;
151239 case 155: /* upsert ::= ON CONFLICT DO NOTHING */
151240 { yymsp[-3].minor.yy266 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
151241 break;
151242 case 159: /* idlist_opt ::= LP idlist RP */
151243 {yymsp[-2].minor.yy336 = yymsp[-1].minor.yy336;}
151244 break;
151245 case 160: /* idlist ::= idlist COMMA nm */
151246 {yymsp[-2].minor.yy336 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy336,&yymsp[0].minor.yy0);}
151247 break;
151248 case 161: /* idlist ::= nm */
151249 {yymsp[0].minor.yy336 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
151250 break;
151251 case 162: /* expr ::= LP expr RP */
151252 {yymsp[-2].minor.yy490 = yymsp[-1].minor.yy490;}
151253 break;
151254 case 163: /* expr ::= ID|INDEXED */
151255 case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164);
151256 {yymsp[0].minor.yy490=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151257 break;
151258 case 165: /* expr ::= nm DOT nm */
151259 {
151260 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
151261 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
151262 if( IN_RENAME_OBJECT ){
151263 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
151264 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
151265 }
151266 yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
151267 }
151268 yymsp[-2].minor.yy490 = yylhsminor.yy490;
151269 break;
151270 case 166: /* expr ::= nm DOT nm DOT nm */
151271 {
151272 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
151273 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -151275,95 +151919,95 @@
151275 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
151276 if( IN_RENAME_OBJECT ){
151277 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
151278 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
151279 }
151280 yylhsminor.yy490 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
151281 }
151282 yymsp[-4].minor.yy490 = yylhsminor.yy490;
151283 break;
151284 case 167: /* term ::= NULL|FLOAT|BLOB */
151285 case 168: /* term ::= STRING */ yytestcase(yyruleno==168);
151286 {yymsp[0].minor.yy490=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151287 break;
151288 case 169: /* term ::= INTEGER */
151289 {
151290 yylhsminor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
151291 }
151292 yymsp[0].minor.yy490 = yylhsminor.yy490;
151293 break;
151294 case 170: /* expr ::= VARIABLE */
151295 {
151296 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
151297 u32 n = yymsp[0].minor.yy0.n;
151298 yymsp[0].minor.yy490 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
151299 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy490, n);
151300 }else{
151301 /* When doing a nested parse, one can include terms in an expression
151302 ** that look like this: #1 #2 ... These terms refer to registers
151303 ** in the virtual machine. #N is the N-th register. */
151304 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
151305 assert( t.n>=2 );
151306 if( pParse->nested==0 ){
151307 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
151308 yymsp[0].minor.yy490 = 0;
151309 }else{
151310 yymsp[0].minor.yy490 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
151311 if( yymsp[0].minor.yy490 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy490->iTable);
151312 }
151313 }
151314 }
151315 break;
151316 case 171: /* expr ::= expr COLLATE ID|STRING */
151317 {
151318 yymsp[-2].minor.yy490 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0, 1);
151319 }
151320 break;
151321 case 172: /* expr ::= CAST LP expr AS typetoken RP */
151322 {
151323 yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
151324 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy490, yymsp[-3].minor.yy490, 0);
151325 }
151326 break;
151327 case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */
151328 {
151329 yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy42, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy96);
151330 }
151331 yymsp[-4].minor.yy490 = yylhsminor.yy490;
151332 break;
151333 case 174: /* expr ::= ID|INDEXED LP STAR RP */
151334 {
151335 yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
151336 }
151337 yymsp[-3].minor.yy490 = yylhsminor.yy490;
151338 break;
151339 case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151340 {
151341 yylhsminor.yy490 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy42, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy96);
151342 sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);
151343 }
151344 yymsp[-5].minor.yy490 = yylhsminor.yy490;
151345 break;
151346 case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */
151347 {
151348 yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
151349 sqlite3WindowAttach(pParse, yylhsminor.yy490, yymsp[0].minor.yy147);
151350 }
151351 yymsp[-4].minor.yy490 = yylhsminor.yy490;
151352 break;
151353 case 177: /* term ::= CTIME_KW */
151354 {
151355 yylhsminor.yy490 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
151356 }
151357 yymsp[0].minor.yy490 = yylhsminor.yy490;
151358 break;
151359 case 178: /* expr ::= LP nexprlist COMMA expr RP */
151360 {
151361 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy42, yymsp[-1].minor.yy490);
151362 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
151363 if( yymsp[-4].minor.yy490 ){
151364 yymsp[-4].minor.yy490->x.pList = pList;
151365 }else{
151366 sqlite3ExprListDelete(pParse->db, pList);
151367 }
151368 }
151369 break;
@@ -151373,101 +152017,101 @@
151373 case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182);
151374 case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183);
151375 case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184);
151376 case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185);
151377 case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186);
151378 {yymsp[-2].minor.yy490=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);}
151379 break;
151380 case 187: /* likeop ::= NOT LIKE_KW|MATCH */
151381 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
151382 break;
151383 case 188: /* expr ::= expr likeop expr */
151384 {
151385 ExprList *pList;
151386 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
151387 yymsp[-1].minor.yy0.n &= 0x7fffffff;
151388 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy490);
151389 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy490);
151390 yymsp[-2].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
151391 if( bNot ) yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy490, 0);
151392 if( yymsp[-2].minor.yy490 ) yymsp[-2].minor.yy490->flags |= EP_InfixFunc;
151393 }
151394 break;
151395 case 189: /* expr ::= expr likeop expr ESCAPE expr */
151396 {
151397 ExprList *pList;
151398 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
151399 yymsp[-3].minor.yy0.n &= 0x7fffffff;
151400 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151401 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy490);
151402 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);
151403 yymsp[-4].minor.yy490 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
151404 if( bNot ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151405 if( yymsp[-4].minor.yy490 ) yymsp[-4].minor.yy490->flags |= EP_InfixFunc;
151406 }
151407 break;
151408 case 190: /* expr ::= expr ISNULL|NOTNULL */
151409 {yymsp[-1].minor.yy490 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy490,0);}
151410 break;
151411 case 191: /* expr ::= expr NOT NULL */
151412 {yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy490,0);}
151413 break;
151414 case 192: /* expr ::= expr IS expr */
151415 {
151416 yymsp[-2].minor.yy490 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy490,yymsp[0].minor.yy490);
151417 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-2].minor.yy490, TK_ISNULL);
151418 }
151419 break;
151420 case 193: /* expr ::= expr IS NOT expr */
151421 {
151422 yymsp[-3].minor.yy490 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy490,yymsp[0].minor.yy490);
151423 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy490, yymsp[-3].minor.yy490, TK_NOTNULL);
151424 }
151425 break;
151426 case 194: /* expr ::= NOT expr */
151427 case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195);
151428 {yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy490, 0);/*A-overwrites-B*/}
151429 break;
151430 case 196: /* expr ::= PLUS|MINUS expr */
151431 {
151432 yymsp[-1].minor.yy490 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy490, 0);
151433 /*A-overwrites-B*/
151434 }
151435 break;
151436 case 197: /* between_op ::= BETWEEN */
151437 case 200: /* in_op ::= IN */ yytestcase(yyruleno==200);
151438 {yymsp[0].minor.yy96 = 0;}
151439 break;
151440 case 199: /* expr ::= expr between_op expr AND expr */
151441 {
151442 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151443 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy490);
151444 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy490, 0);
151445 if( yymsp[-4].minor.yy490 ){
151446 yymsp[-4].minor.yy490->x.pList = pList;
151447 }else{
151448 sqlite3ExprListDelete(pParse->db, pList);
151449 }
151450 if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151451 }
151452 break;
151453 case 202: /* expr ::= expr in_op LP exprlist RP */
151454 {
151455 if( yymsp[-1].minor.yy42==0 ){
151456 /* Expressions of the form
151457 **
151458 ** expr1 IN ()
151459 ** expr1 NOT IN ()
151460 **
151461 ** simplify to constants 0 (false) and 1 (true), respectively,
151462 ** regardless of the value of expr1.
151463 */
151464 if( IN_RENAME_OBJECT==0 ){
151465 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy490);
151466 yymsp[-4].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy96],1);
151467 }
151468 }else if( yymsp[-1].minor.yy42->nExpr==1 ){
151469 /* Expressions of the form:
151470 **
151471 ** expr1 IN (?1)
151472 ** expr1 NOT IN (?2)
151473 **
@@ -151480,134 +152124,134 @@
151480 ** But, the RHS of the == or <> is marked with the EP_Generic flag
151481 ** so that it may not contribute to the computation of comparison
151482 ** affinity or the collating sequence to use for comparison. Otherwise,
151483 ** the semantics would be subtly different from IN or NOT IN.
151484 */
151485 Expr *pRHS = yymsp[-1].minor.yy42->a[0].pExpr;
151486 yymsp[-1].minor.yy42->a[0].pExpr = 0;
151487 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);
151488 /* pRHS cannot be NULL because a malloc error would have been detected
151489 ** before now and control would have never reached this point */
151490 if( ALWAYS(pRHS) ){
151491 pRHS->flags &= ~EP_Collate;
151492 pRHS->flags |= EP_Generic;
151493 }
151494 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, yymsp[-3].minor.yy96 ? TK_NE : TK_EQ, yymsp[-4].minor.yy490, pRHS);
151495 }else{
151496 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151497 if( yymsp[-4].minor.yy490 ){
151498 yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy42;
151499 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);
151500 }else{
151501 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy42);
151502 }
151503 if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151504 }
151505 }
151506 break;
151507 case 203: /* expr ::= LP select RP */
151508 {
151509 yymsp[-2].minor.yy490 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
151510 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy490, yymsp[-1].minor.yy423);
151511 }
151512 break;
151513 case 204: /* expr ::= expr in_op LP select RP */
151514 {
151515 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151516 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, yymsp[-1].minor.yy423);
151517 if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151518 }
151519 break;
151520 case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */
151521 {
151522 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
151523 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
151524 if( yymsp[0].minor.yy42 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy42);
151525 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy490, 0);
151526 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy490, pSelect);
151527 if( yymsp[-3].minor.yy96 ) yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy490, 0);
151528 }
151529 break;
151530 case 206: /* expr ::= EXISTS LP select RP */
151531 {
151532 Expr *p;
151533 p = yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
151534 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy423);
151535 }
151536 break;
151537 case 207: /* expr ::= CASE case_operand case_exprlist case_else END */
151538 {
151539 yymsp[-4].minor.yy490 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy490, 0);
151540 if( yymsp[-4].minor.yy490 ){
151541 yymsp[-4].minor.yy490->x.pList = yymsp[-1].minor.yy490 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[-1].minor.yy490) : yymsp[-2].minor.yy42;
151542 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy490);
151543 }else{
151544 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy42);
151545 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy490);
151546 }
151547 }
151548 break;
151549 case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
151550 {
151551 yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[-2].minor.yy490);
151552 yymsp[-4].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy42, yymsp[0].minor.yy490);
151553 }
151554 break;
151555 case 209: /* case_exprlist ::= WHEN expr THEN expr */
151556 {
151557 yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy490);
151558 yymsp[-3].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy42, yymsp[0].minor.yy490);
151559 }
151560 break;
151561 case 212: /* case_operand ::= expr */
151562 {yymsp[0].minor.yy490 = yymsp[0].minor.yy490; /*A-overwrites-X*/}
151563 break;
151564 case 215: /* nexprlist ::= nexprlist COMMA expr */
151565 {yymsp[-2].minor.yy42 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy42,yymsp[0].minor.yy490);}
151566 break;
151567 case 216: /* nexprlist ::= expr */
151568 {yymsp[0].minor.yy42 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy490); /*A-overwrites-Y*/}
151569 break;
151570 case 218: /* paren_exprlist ::= LP exprlist RP */
151571 case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223);
151572 {yymsp[-2].minor.yy42 = yymsp[-1].minor.yy42;}
151573 break;
151574 case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
151575 {
151576 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
151577 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy42, yymsp[-10].minor.yy96,
151578 &yymsp[-11].minor.yy0, yymsp[0].minor.yy490, SQLITE_SO_ASC, yymsp[-8].minor.yy96, SQLITE_IDXTYPE_APPDEF);
151579 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
151580 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
151581 }
151582 }
151583 break;
151584 case 220: /* uniqueflag ::= UNIQUE */
151585 case 262: /* raisetype ::= ABORT */ yytestcase(yyruleno==262);
151586 {yymsp[0].minor.yy96 = OE_Abort;}
151587 break;
151588 case 221: /* uniqueflag ::= */
151589 {yymsp[1].minor.yy96 = OE_None;}
151590 break;
151591 case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */
151592 {
151593 yymsp[-4].minor.yy42 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy42, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96);
151594 }
151595 break;
151596 case 225: /* eidlist ::= nm collate sortorder */
151597 {
151598 yymsp[-2].minor.yy42 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy96, yymsp[0].minor.yy96); /*A-overwrites-Y*/
151599 }
151600 break;
151601 case 228: /* cmd ::= DROP INDEX ifexists fullname */
151602 {sqlite3DropIndex(pParse, yymsp[0].minor.yy167, yymsp[-1].minor.yy96);}
151603 break;
151604 case 229: /* cmd ::= VACUUM vinto */
151605 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy490);}
151606 break;
151607 case 230: /* cmd ::= VACUUM nm vinto */
151608 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy490);}
151609 break;
151610 case 233: /* cmd ::= PRAGMA nm dbnm */
151611 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
151612 break;
151613 case 234: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -151625,55 +152269,55 @@
151625 case 240: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
151626 {
151627 Token all;
151628 all.z = yymsp[-3].minor.yy0.z;
151629 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
151630 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy119, &all);
151631 }
151632 break;
151633 case 241: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
151634 {
151635 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy96, yymsp[-4].minor.yy350.a, yymsp[-4].minor.yy350.b, yymsp[-2].minor.yy167, yymsp[0].minor.yy490, yymsp[-10].minor.yy96, yymsp[-8].minor.yy96);
151636 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
151637 }
151638 break;
151639 case 242: /* trigger_time ::= BEFORE|AFTER */
151640 { yymsp[0].minor.yy96 = yymsp[0].major; /*A-overwrites-X*/ }
151641 break;
151642 case 243: /* trigger_time ::= INSTEAD OF */
151643 { yymsp[-1].minor.yy96 = TK_INSTEAD;}
151644 break;
151645 case 244: /* trigger_time ::= */
151646 { yymsp[1].minor.yy96 = TK_BEFORE; }
151647 break;
151648 case 245: /* trigger_event ::= DELETE|INSERT */
151649 case 246: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==246);
151650 {yymsp[0].minor.yy350.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy350.b = 0;}
151651 break;
151652 case 247: /* trigger_event ::= UPDATE OF idlist */
151653 {yymsp[-2].minor.yy350.a = TK_UPDATE; yymsp[-2].minor.yy350.b = yymsp[0].minor.yy336;}
151654 break;
151655 case 248: /* when_clause ::= */
151656 case 267: /* key_opt ::= */ yytestcase(yyruleno==267);
151657 case 309: /* filter_opt ::= */ yytestcase(yyruleno==309);
151658 { yymsp[1].minor.yy490 = 0; }
151659 break;
151660 case 249: /* when_clause ::= WHEN expr */
151661 case 268: /* key_opt ::= KEY expr */ yytestcase(yyruleno==268);
151662 { yymsp[-1].minor.yy490 = yymsp[0].minor.yy490; }
151663 break;
151664 case 250: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
151665 {
151666 assert( yymsp[-2].minor.yy119!=0 );
151667 yymsp[-2].minor.yy119->pLast->pNext = yymsp[-1].minor.yy119;
151668 yymsp[-2].minor.yy119->pLast = yymsp[-1].minor.yy119;
151669 }
151670 break;
151671 case 251: /* trigger_cmd_list ::= trigger_cmd SEMI */
151672 {
151673 assert( yymsp[-1].minor.yy119!=0 );
151674 yymsp[-1].minor.yy119->pLast = yymsp[-1].minor.yy119;
151675 }
151676 break;
151677 case 252: /* trnm ::= nm DOT nm */
151678 {
151679 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -151695,62 +152339,62 @@
151695 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
151696 "within triggers");
151697 }
151698 break;
151699 case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
151700 {yylhsminor.yy119 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy42, yymsp[-1].minor.yy490, yymsp[-6].minor.yy96, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy464);}
151701 yymsp[-7].minor.yy119 = yylhsminor.yy119;
151702 break;
151703 case 256: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
151704 {
151705 yylhsminor.yy119 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy336,yymsp[-2].minor.yy423,yymsp[-6].minor.yy96,yymsp[-1].minor.yy266,yymsp[-7].minor.yy464,yymsp[0].minor.yy464);/*yylhsminor.yy119-overwrites-yymsp[-6].minor.yy96*/
151706 }
151707 yymsp[-7].minor.yy119 = yylhsminor.yy119;
151708 break;
151709 case 257: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
151710 {yylhsminor.yy119 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy490, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy464);}
151711 yymsp[-5].minor.yy119 = yylhsminor.yy119;
151712 break;
151713 case 258: /* trigger_cmd ::= scanpt select scanpt */
151714 {yylhsminor.yy119 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy423, yymsp[-2].minor.yy464, yymsp[0].minor.yy464); /*yylhsminor.yy119-overwrites-yymsp[-1].minor.yy423*/}
151715 yymsp[-2].minor.yy119 = yylhsminor.yy119;
151716 break;
151717 case 259: /* expr ::= RAISE LP IGNORE RP */
151718 {
151719 yymsp[-3].minor.yy490 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
151720 if( yymsp[-3].minor.yy490 ){
151721 yymsp[-3].minor.yy490->affinity = OE_Ignore;
151722 }
151723 }
151724 break;
151725 case 260: /* expr ::= RAISE LP raisetype COMMA nm RP */
151726 {
151727 yymsp[-5].minor.yy490 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
151728 if( yymsp[-5].minor.yy490 ) {
151729 yymsp[-5].minor.yy490->affinity = (char)yymsp[-3].minor.yy96;
151730 }
151731 }
151732 break;
151733 case 261: /* raisetype ::= ROLLBACK */
151734 {yymsp[0].minor.yy96 = OE_Rollback;}
151735 break;
151736 case 263: /* raisetype ::= FAIL */
151737 {yymsp[0].minor.yy96 = OE_Fail;}
151738 break;
151739 case 264: /* cmd ::= DROP TRIGGER ifexists fullname */
151740 {
151741 sqlite3DropTrigger(pParse,yymsp[0].minor.yy167,yymsp[-1].minor.yy96);
151742 }
151743 break;
151744 case 265: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
151745 {
151746 sqlite3Attach(pParse, yymsp[-3].minor.yy490, yymsp[-1].minor.yy490, yymsp[0].minor.yy490);
151747 }
151748 break;
151749 case 266: /* cmd ::= DETACH database_kw_opt expr */
151750 {
151751 sqlite3Detach(pParse, yymsp[0].minor.yy490);
151752 }
151753 break;
151754 case 269: /* cmd ::= REINDEX */
151755 {sqlite3Reindex(pParse, 0, 0);}
151756 break;
@@ -151763,11 +152407,11 @@
151763 case 272: /* cmd ::= ANALYZE nm dbnm */
151764 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
151765 break;
151766 case 273: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
151767 {
151768 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy167,&yymsp[0].minor.yy0);
151769 }
151770 break;
151771 case 274: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
151772 {
151773 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -151775,16 +152419,16 @@
151775 }
151776 break;
151777 case 275: /* add_column_fullname ::= fullname */
151778 {
151779 disableLookaside(pParse);
151780 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy167);
151781 }
151782 break;
151783 case 276: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
151784 {
151785 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy167, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
151786 }
151787 break;
151788 case 277: /* cmd ::= create_vtab */
151789 {sqlite3VtabFinishParse(pParse,0);}
151790 break;
@@ -151791,11 +152435,11 @@
151791 case 278: /* cmd ::= create_vtab LP vtabarglist RP */
151792 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
151793 break;
151794 case 279: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
151795 {
151796 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy96);
151797 }
151798 break;
151799 case 280: /* vtabarg ::= */
151800 {sqlite3VtabArgInit(pParse);}
151801 break;
@@ -151804,186 +152448,208 @@
151804 case 283: /* lp ::= LP */ yytestcase(yyruleno==283);
151805 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
151806 break;
151807 case 284: /* with ::= WITH wqlist */
151808 case 285: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==285);
151809 { sqlite3WithPush(pParse, yymsp[0].minor.yy499, 1); }
151810 break;
151811 case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */
151812 {
151813 yymsp[-5].minor.yy499 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423); /*A-overwrites-X*/
151814 }
151815 break;
151816 case 287: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151817 {
151818 yymsp[-7].minor.yy499 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy499, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy42, yymsp[-1].minor.yy423);
151819 }
151820 break;
151821 case 288: /* windowdefn_list ::= windowdefn */
151822 { yylhsminor.yy147 = yymsp[0].minor.yy147; }
151823 yymsp[0].minor.yy147 = yylhsminor.yy147;
151824 break;
151825 case 289: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
151826 {
151827 assert( yymsp[0].minor.yy147!=0 );
151828 yymsp[0].minor.yy147->pNextWin = yymsp[-2].minor.yy147;
151829 yylhsminor.yy147 = yymsp[0].minor.yy147;
151830 }
151831 yymsp[-2].minor.yy147 = yylhsminor.yy147;
151832 break;
151833 case 290: /* windowdefn ::= nm AS window */
151834 {
151835 if( ALWAYS(yymsp[0].minor.yy147) ){
151836 yymsp[0].minor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[-2].minor.yy0.z, yymsp[-2].minor.yy0.n);
151837 }
151838 yylhsminor.yy147 = yymsp[0].minor.yy147;
151839 }
151840 yymsp[-2].minor.yy147 = yylhsminor.yy147;
151841 break;
151842 case 291: /* window ::= LP part_opt orderby_opt frame_opt RP */
151843 {
151844 yymsp[-4].minor.yy147 = yymsp[-1].minor.yy147;
151845 if( ALWAYS(yymsp[-4].minor.yy147) ){
151846 yymsp[-4].minor.yy147->pPartition = yymsp[-3].minor.yy42;
151847 yymsp[-4].minor.yy147->pOrderBy = yymsp[-2].minor.yy42;
151848 }
151849 }
151850 break;
151851 case 292: /* part_opt ::= PARTITION BY nexprlist */
151852 { yymsp[-2].minor.yy42 = yymsp[0].minor.yy42; }
151853 break;
151854 case 293: /* part_opt ::= */
151855 { yymsp[1].minor.yy42 = 0; }
151856 break;
151857 case 294: /* frame_opt ::= */
151858 {
151859 yymsp[1].minor.yy147 = sqlite3WindowAlloc(pParse, TK_RANGE, TK_UNBOUNDED, 0, TK_CURRENT, 0);
151860 }
151861 break;
151862 case 295: /* frame_opt ::= range_or_rows frame_bound_s */
151863 {
151864 yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-1].minor.yy96, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr, TK_CURRENT, 0);
151865 }
151866 yymsp[-1].minor.yy147 = yylhsminor.yy147;
151867 break;
151868 case 296: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e */
151869 {
151870 yylhsminor.yy147 = sqlite3WindowAlloc(pParse, yymsp[-4].minor.yy96, yymsp[-2].minor.yy317.eType, yymsp[-2].minor.yy317.pExpr, yymsp[0].minor.yy317.eType, yymsp[0].minor.yy317.pExpr);
151871 }
151872 yymsp[-4].minor.yy147 = yylhsminor.yy147;
151873 break;
151874 case 297: /* range_or_rows ::= RANGE */
151875 { yymsp[0].minor.yy96 = TK_RANGE; }
151876 break;
151877 case 298: /* range_or_rows ::= ROWS */
151878 { yymsp[0].minor.yy96 = TK_ROWS; }
151879 break;
151880 case 299: /* frame_bound_s ::= frame_bound */
151881 case 301: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==301);
151882 { yylhsminor.yy317 = yymsp[0].minor.yy317; }
151883 yymsp[0].minor.yy317 = yylhsminor.yy317;
151884 break;
151885 case 300: /* frame_bound_s ::= UNBOUNDED PRECEDING */
151886 case 302: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==302);
151887 {yymsp[-1].minor.yy317.eType = TK_UNBOUNDED; yymsp[-1].minor.yy317.pExpr = 0;}
151888 break;
151889 case 303: /* frame_bound ::= expr PRECEDING */
151890 { yylhsminor.yy317.eType = TK_PRECEDING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }
151891 yymsp[-1].minor.yy317 = yylhsminor.yy317;
151892 break;
151893 case 304: /* frame_bound ::= CURRENT ROW */
151894 { yymsp[-1].minor.yy317.eType = TK_CURRENT ; yymsp[-1].minor.yy317.pExpr = 0; }
151895 break;
151896 case 305: /* frame_bound ::= expr FOLLOWING */
151897 { yylhsminor.yy317.eType = TK_FOLLOWING; yylhsminor.yy317.pExpr = yymsp[-1].minor.yy490; }
151898 yymsp[-1].minor.yy317 = yylhsminor.yy317;
151899 break;
151900 case 306: /* window_clause ::= WINDOW windowdefn_list */
151901 { yymsp[-1].minor.yy147 = yymsp[0].minor.yy147; }
151902 break;
151903 case 307: /* over_clause ::= filter_opt OVER window */
151904 {
151905 yylhsminor.yy147 = yymsp[0].minor.yy147;
151906 assert( yylhsminor.yy147!=0 );
151907 yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;
151908 }
151909 yymsp[-2].minor.yy147 = yylhsminor.yy147;
151910 break;
151911 case 308: /* over_clause ::= filter_opt OVER nm */
151912 {
151913 yylhsminor.yy147 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
151914 if( yylhsminor.yy147 ){
151915 yylhsminor.yy147->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
151916 yylhsminor.yy147->pFilter = yymsp[-2].minor.yy490;
151917 }else{
151918 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy490);
151919 }
151920 }
151921 yymsp[-2].minor.yy147 = yylhsminor.yy147;
151922 break;
151923 case 310: /* filter_opt ::= FILTER LP WHERE expr RP */
151924 { yymsp[-4].minor.yy490 = yymsp[-1].minor.yy490; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151925 break;
151926 default:
151927 /* (311) input ::= cmdlist */ yytestcase(yyruleno==311);
151928 /* (312) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==312);
151929 /* (313) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=313);
151930 /* (314) ecmd ::= SEMI */ yytestcase(yyruleno==314);
151931 /* (315) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==315);
151932 /* (316) ecmd ::= explain cmdx */ yytestcase(yyruleno==316);
151933 /* (317) trans_opt ::= */ yytestcase(yyruleno==317);
151934 /* (318) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==318);
151935 /* (319) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==319);
151936 /* (320) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==320);
151937 /* (321) savepoint_opt ::= */ yytestcase(yyruleno==321);
151938 /* (322) cmd ::= create_table create_table_args */ yytestcase(yyruleno==322);
151939 /* (323) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==323);
151940 /* (324) columnlist ::= columnname carglist */ yytestcase(yyruleno==324);
151941 /* (325) nm ::= ID|INDEXED */ yytestcase(yyruleno==325);
151942 /* (326) nm ::= STRING */ yytestcase(yyruleno==326);
151943 /* (327) nm ::= JOIN_KW */ yytestcase(yyruleno==327);
151944 /* (328) typetoken ::= typename */ yytestcase(yyruleno==328);
151945 /* (329) typename ::= ID|STRING */ yytestcase(yyruleno==329);
151946 /* (330) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=330);
151947 /* (331) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=331);
151948 /* (332) carglist ::= carglist ccons */ yytestcase(yyruleno==332);
151949 /* (333) carglist ::= */ yytestcase(yyruleno==333);
151950 /* (334) ccons ::= NULL onconf */ yytestcase(yyruleno==334);
151951 /* (335) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==335);
151952 /* (336) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==336);
151953 /* (337) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=337);
151954 /* (338) tconscomma ::= */ yytestcase(yyruleno==338);
151955 /* (339) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=339);
151956 /* (340) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=340);
151957 /* (341) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=341);
151958 /* (342) oneselect ::= values */ yytestcase(yyruleno==342);
151959 /* (343) sclp ::= selcollist COMMA */ yytestcase(yyruleno==343);
151960 /* (344) as ::= ID|STRING */ yytestcase(yyruleno==344);
151961 /* (345) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=345);
151962 /* (346) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==346);
151963 /* (347) exprlist ::= nexprlist */ yytestcase(yyruleno==347);
151964 /* (348) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=348);
151965 /* (349) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=349);
151966 /* (350) nmnum ::= ON */ yytestcase(yyruleno==350);
151967 /* (351) nmnum ::= DELETE */ yytestcase(yyruleno==351);
151968 /* (352) nmnum ::= DEFAULT */ yytestcase(yyruleno==352);
151969 /* (353) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==353);
151970 /* (354) foreach_clause ::= */ yytestcase(yyruleno==354);
151971 /* (355) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==355);
151972 /* (356) trnm ::= nm */ yytestcase(yyruleno==356);
151973 /* (357) tridxby ::= */ yytestcase(yyruleno==357);
151974 /* (358) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==358);
151975 /* (359) database_kw_opt ::= */ yytestcase(yyruleno==359);
151976 /* (360) kwcolumn_opt ::= */ yytestcase(yyruleno==360);
151977 /* (361) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==361);
151978 /* (362) vtabarglist ::= vtabarg */ yytestcase(yyruleno==362);
151979 /* (363) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==363);
151980 /* (364) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==364);
151981 /* (365) anylist ::= */ yytestcase(yyruleno==365);
151982 /* (366) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==366);
151983 /* (367) anylist ::= anylist ANY */ yytestcase(yyruleno==367);
151984 /* (368) with ::= */ yytestcase(yyruleno==368);
151985 break;
151986 /********** End reduce actions ************************************************/
151987 };
151988 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
151989 yygoto = yyRuleInfoLhs[yyruleno];
@@ -152442,148 +153108,148 @@
152442 ** might be implemented more directly using a hand-written hash table.
152443 ** But by using this automatically generated code, the size of the code
152444 ** is substantially reduced. This is important for embedded applications
152445 ** on platforms with limited memory.
152446 */
152447 /* Hash score: 208 */
152448 /* zKWText[] encodes 923 bytes of keyword text in 614 bytes */
152449 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
152450 /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
152451 /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
152452 /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERANGEBETWEEN */
152453 /* OTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
152454 /* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMIT */
152455 /* WHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULTAUTOINCREMENTCAST */
152456 /* COLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMPARTITIONDEFERRED */
152457 /* ISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWINGFROMFULLIFISNULL */
152458 /* ORDERESTRICTOVERIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEW */
152459 /* INDOWINITIALLYPRIMARY */
152460 static const char zKWText[613] = {
152461 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
152462 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
152463 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
152464 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
152465 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
152466 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
152467 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
152468 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
152469 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
152470 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
152471 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
152472 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
152473 'T','E','B','E','G','I','N','N','E','R','A','N','G','E','B','E','T','W',
152474 'E','E','N','O','T','H','I','N','G','L','O','B','Y','C','A','S','C','A',
152475 'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C',
152476 'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D',
152477 'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N',
152478 'S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N','A',
152479 'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
152480 'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','O',
152481 'T','N','U','L','L','W','H','E','R','E','C','U','R','S','I','V','E','A',
152482 'F','T','E','R','E','N','A','M','E','A','N','D','E','F','A','U','L','T',
152483 'A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C',
152484 'O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C',
152485 'T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E',
152486 'S','T','A','M','P','A','R','T','I','T','I','O','N','D','E','F','E','R',
152487 'R','E','D','I','S','T','I','N','C','T','D','R','O','P','R','E','C','E',
152488 'D','I','N','G','F','A','I','L','F','I','L','T','E','R','E','P','L','A',
152489 'C','E','F','O','L','L','O','W','I','N','G','F','R','O','M','F','U','L',
152490 'L','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R',
152491 'I','C','T','O','V','E','R','I','G','H','T','R','O','L','L','B','A','C',
152492 'K','R','O','W','S','U','N','B','O','U','N','D','E','D','U','N','I','O',
152493 'N','U','S','I','N','G','V','A','C','U','U','M','V','I','E','W','I','N',
152494 'D','O','W','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R',
152495 'Y',
152496 };
152497 /* aKWHash[i] is the hash value for the i-th keyword */
152498 static const unsigned char aKWHash[127] = {
152499 74, 109, 124, 72, 106, 45, 0, 0, 81, 0, 76, 61, 0,
152500 42, 12, 77, 15, 0, 123, 84, 54, 118, 125, 19, 0, 0,
152501 130, 0, 128, 121, 0, 22, 96, 0, 9, 0, 0, 115, 69,
152502 0, 67, 6, 0, 48, 93, 136, 0, 126, 104, 0, 0, 44,
152503 0, 107, 24, 0, 17, 0, 131, 53, 23, 0, 5, 62, 132,
152504 99, 0, 0, 135, 110, 60, 134, 57, 113, 55, 0, 94, 0,
152505 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 105, 117, 14,
152506 39, 116, 0, 80, 0, 133, 114, 92, 59, 0, 129, 79, 119,
152507 86, 46, 83, 0, 0, 97, 40, 122, 120, 0, 127, 0, 0,
152508 29, 0, 89, 87, 88, 0, 20, 85, 111, 56,
152509 };
152510 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
152511 ** then the i-th keyword has no more hash collisions. Otherwise,
152512 ** the next keyword with the same hash is aKWHash[i]-1. */
152513 static const unsigned char aKWNext[136] = {
152514 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
152515 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
152516 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152517 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
152518 0, 43, 3, 47, 0, 0, 32, 0, 0, 0, 0, 0, 0,
152519 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0,
152520 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 0, 31,
152521 63, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70,
152522 91, 0, 0, 8, 0, 108, 0, 101, 28, 52, 68, 0, 112,
152523 0, 73, 51, 0, 90, 27, 37, 0, 71, 36, 82, 0, 35,
152524 66, 25, 18, 0, 0, 78,
152525 };
152526 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
152527 static const unsigned char aKWLen[136] = {
152528 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
152529 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
152530 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
152531 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
152532 6, 6, 5, 6, 5, 5, 5, 7, 7, 4, 2, 7, 3,
152533 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7,
152534 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 9, 5,
152535 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12,
152536 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9, 4, 4,
152537 2, 6, 5, 8, 4, 5, 8, 4, 3, 9, 5, 5, 6,
152538 4, 6, 2, 9, 3, 7,
152539 };
152540 /* aKWOffset[i] is the index into zKWText[] of the start of
152541 ** the text for the i-th keyword. */
152542 static const unsigned short int aKWOffset[136] = {
152543 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
152544 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
152545 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
152546 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
152547 199, 204, 209, 212, 218, 221, 225, 230, 236, 242, 245, 247, 248,
152548 252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 314, 319, 321,
152549 328, 333, 338, 344, 350, 355, 358, 358, 358, 361, 365, 368, 377,
152550 381, 387, 389, 396, 398, 400, 409, 413, 419, 425, 433, 438, 438,
152551 438, 454, 463, 470, 471, 478, 481, 490, 494, 499, 506, 515, 519,
152552 523, 525, 531, 535, 543, 546, 551, 559, 559, 563, 572, 577, 582,
152553 588, 591, 594, 597, 602, 606,
152554 };
152555 /* aKWCode[i] is the parser symbol code for the i-th keyword */
152556 static const unsigned char aKWCode[136] = {
152557 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
152558 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
152559 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
152560 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
152561 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
152562 TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
152563 TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
152564 TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
152565 TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
152566 TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
152567 TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
152568 TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RANGE, TK_BETWEEN,
152569 TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC,
152570 TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW,
152571 TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW,
152572 TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
152573 TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL,
152574 TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RECURSIVE,
152575 TK_AFTER, TK_RENAME, TK_AND, TK_DEFAULT, TK_AUTOINCR,
152576 TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT,
152577 TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT,
152578 TK_PARTITION, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
152579 TK_PRECEDING, TK_FAIL, TK_FILTER, TK_REPLACE, TK_FOLLOWING,
152580 TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_ORDER,
152581 TK_RESTRICT, TK_OVER, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS,
152582 TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM,
152583 TK_VIEW, TK_WINDOW, TK_DO, TK_INITIALLY, TK_ALL,
152584 TK_PRIMARY,
152585 };
152586 /* Check to see if z[0..n-1] is a keyword. If it is, write the
152587 ** parser symbol code for that keyword into *pType. Always
152588 ** return the integer n (the length of the token). */
152589 static int keywordCode(const char *z, int n, int *pType){
@@ -152625,121 +153291,125 @@
152625 testcase( i==20 ); /* LEFT */
152626 testcase( i==21 ); /* THEN */
152627 testcase( i==22 ); /* END */
152628 testcase( i==23 ); /* DEFERRABLE */
152629 testcase( i==24 ); /* ELSE */
152630 testcase( i==25 ); /* EXCEPT */
152631 testcase( i==26 ); /* TRANSACTION */
152632 testcase( i==27 ); /* ACTION */
152633 testcase( i==28 ); /* ON */
152634 testcase( i==29 ); /* NATURAL */
152635 testcase( i==30 ); /* ALTER */
152636 testcase( i==31 ); /* RAISE */
152637 testcase( i==32 ); /* EXCLUSIVE */
152638 testcase( i==33 ); /* EXISTS */
152639 testcase( i==34 ); /* SAVEPOINT */
152640 testcase( i==35 ); /* INTERSECT */
152641 testcase( i==36 ); /* TRIGGER */
152642 testcase( i==37 ); /* REFERENCES */
152643 testcase( i==38 ); /* CONSTRAINT */
152644 testcase( i==39 ); /* INTO */
152645 testcase( i==40 ); /* OFFSET */
152646 testcase( i==41 ); /* OF */
152647 testcase( i==42 ); /* SET */
152648 testcase( i==43 ); /* TEMPORARY */
152649 testcase( i==44 ); /* TEMP */
152650 testcase( i==45 ); /* OR */
152651 testcase( i==46 ); /* UNIQUE */
152652 testcase( i==47 ); /* QUERY */
152653 testcase( i==48 ); /* WITHOUT */
152654 testcase( i==49 ); /* WITH */
152655 testcase( i==50 ); /* OUTER */
152656 testcase( i==51 ); /* RELEASE */
152657 testcase( i==52 ); /* ATTACH */
152658 testcase( i==53 ); /* HAVING */
152659 testcase( i==54 ); /* GROUP */
152660 testcase( i==55 ); /* UPDATE */
152661 testcase( i==56 ); /* BEGIN */
152662 testcase( i==57 ); /* INNER */
152663 testcase( i==58 ); /* RANGE */
152664 testcase( i==59 ); /* BETWEEN */
152665 testcase( i==60 ); /* NOTHING */
152666 testcase( i==61 ); /* GLOB */
152667 testcase( i==62 ); /* BY */
152668 testcase( i==63 ); /* CASCADE */
152669 testcase( i==64 ); /* ASC */
152670 testcase( i==65 ); /* DELETE */
152671 testcase( i==66 ); /* CASE */
152672 testcase( i==67 ); /* COLLATE */
152673 testcase( i==68 ); /* CREATE */
152674 testcase( i==69 ); /* CURRENT_DATE */
152675 testcase( i==70 ); /* DETACH */
152676 testcase( i==71 ); /* IMMEDIATE */
152677 testcase( i==72 ); /* JOIN */
152678 testcase( i==73 ); /* INSERT */
152679 testcase( i==74 ); /* LIKE */
152680 testcase( i==75 ); /* MATCH */
152681 testcase( i==76 ); /* PLAN */
152682 testcase( i==77 ); /* ANALYZE */
152683 testcase( i==78 ); /* PRAGMA */
152684 testcase( i==79 ); /* ABORT */
152685 testcase( i==80 ); /* VALUES */
152686 testcase( i==81 ); /* VIRTUAL */
152687 testcase( i==82 ); /* LIMIT */
152688 testcase( i==83 ); /* WHEN */
152689 testcase( i==84 ); /* NOTNULL */
152690 testcase( i==85 ); /* NOT */
152691 testcase( i==86 ); /* NO */
152692 testcase( i==87 ); /* NULL */
152693 testcase( i==88 ); /* WHERE */
152694 testcase( i==89 ); /* RECURSIVE */
152695 testcase( i==90 ); /* AFTER */
152696 testcase( i==91 ); /* RENAME */
152697 testcase( i==92 ); /* AND */
152698 testcase( i==93 ); /* DEFAULT */
152699 testcase( i==94 ); /* AUTOINCREMENT */
152700 testcase( i==95 ); /* TO */
152701 testcase( i==96 ); /* IN */
152702 testcase( i==97 ); /* CAST */
152703 testcase( i==98 ); /* COLUMN */
152704 testcase( i==99 ); /* COMMIT */
152705 testcase( i==100 ); /* CONFLICT */
152706 testcase( i==101 ); /* CROSS */
152707 testcase( i==102 ); /* CURRENT_TIMESTAMP */
152708 testcase( i==103 ); /* CURRENT_TIME */
152709 testcase( i==104 ); /* CURRENT */
152710 testcase( i==105 ); /* PARTITION */
152711 testcase( i==106 ); /* DEFERRED */
152712 testcase( i==107 ); /* DISTINCT */
152713 testcase( i==108 ); /* IS */
152714 testcase( i==109 ); /* DROP */
152715 testcase( i==110 ); /* PRECEDING */
152716 testcase( i==111 ); /* FAIL */
152717 testcase( i==112 ); /* FILTER */
152718 testcase( i==113 ); /* REPLACE */
152719 testcase( i==114 ); /* FOLLOWING */
152720 testcase( i==115 ); /* FROM */
152721 testcase( i==116 ); /* FULL */
152722 testcase( i==117 ); /* IF */
152723 testcase( i==118 ); /* ISNULL */
152724 testcase( i==119 ); /* ORDER */
152725 testcase( i==120 ); /* RESTRICT */
152726 testcase( i==121 ); /* OVER */
152727 testcase( i==122 ); /* RIGHT */
152728 testcase( i==123 ); /* ROLLBACK */
152729 testcase( i==124 ); /* ROWS */
152730 testcase( i==125 ); /* ROW */
152731 testcase( i==126 ); /* UNBOUNDED */
152732 testcase( i==127 ); /* UNION */
152733 testcase( i==128 ); /* USING */
152734 testcase( i==129 ); /* VACUUM */
152735 testcase( i==130 ); /* VIEW */
152736 testcase( i==131 ); /* WINDOW */
152737 testcase( i==132 ); /* DO */
152738 testcase( i==133 ); /* INITIALLY */
152739 testcase( i==134 ); /* ALL */
152740 testcase( i==135 ); /* PRIMARY */
 
 
 
 
152741 *pType = aKWCode[i];
152742 break;
152743 }
152744 }
152745 return n;
@@ -152747,11 +153417,11 @@
152747 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
152748 int id = TK_ID;
152749 keywordCode((char*)z, n, &id);
152750 return id;
152751 }
152752 #define SQLITE_N_KEYWORD 136
152753 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
152754 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
152755 *pzName = zKWText + aKWOffset[i];
152756 *pnName = aKWLen[i];
152757 return SQLITE_OK;
@@ -154715,10 +155385,12 @@
154715 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
154716 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
154717 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
154718 { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
154719 { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive },
 
 
154720 };
154721 unsigned int i;
154722 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
154723 for(i=0; i<ArraySize(aFlagOp); i++){
154724 if( aFlagOp[i].op==op ){
@@ -168496,11 +169168,11 @@
168496
168497 zName = sqlite3_value_text(argv[0]);
168498 nName = sqlite3_value_bytes(argv[0])+1;
168499
168500 if( argc==2 ){
168501 if( fts3TokenizerEnabled(context) ){
168502 void *pOld;
168503 int n = sqlite3_value_bytes(argv[1]);
168504 if( zName==0 || n!=sizeof(pPtr) ){
168505 sqlite3_result_error(context, "argument type mismatch", -1);
168506 return;
@@ -168523,11 +169195,11 @@
168523 sqlite3_result_error(context, zErr, -1);
168524 sqlite3_free(zErr);
168525 return;
168526 }
168527 }
168528 if( fts3TokenizerEnabled(context) ){
168529 sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
168530 }
168531 }
168532
168533 SQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){
@@ -184160,53 +184832,49 @@
184160 ** entry for each cell in the r-tree node. Each entry is itself a
184161 ** list, containing the 8-byte rowid/pageno followed by the
184162 ** <num-dimension>*2 coordinates.
184163 */
184164 static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
184165 char *zText = 0;
184166 RtreeNode node;
184167 Rtree tree;
184168 int ii;
 
 
 
184169
184170 UNUSED_PARAMETER(nArg);
184171 memset(&node, 0, sizeof(RtreeNode));
184172 memset(&tree, 0, sizeof(Rtree));
184173 tree.nDim = (u8)sqlite3_value_int(apArg[0]);
 
184174 tree.nDim2 = tree.nDim*2;
184175 tree.nBytesPerCell = 8 + 8 * tree.nDim;
184176 node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
 
 
 
184177
 
184178 for(ii=0; ii<NCELL(&node); ii++){
184179 char zCell[512];
184180 int nCell = 0;
184181 RtreeCell cell;
184182 int jj;
184183
184184 nodeGetCell(&tree, &node, ii, &cell);
184185 sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
184186 nCell = (int)strlen(zCell);
184187 for(jj=0; jj<tree.nDim2; jj++){
184188 #ifndef SQLITE_RTREE_INT_ONLY
184189 sqlite3_snprintf(512-nCell,&zCell[nCell], " %g",
184190 (double)cell.aCoord[jj].f);
184191 #else
184192 sqlite3_snprintf(512-nCell,&zCell[nCell], " %d",
184193 cell.aCoord[jj].i);
184194 #endif
184195 nCell = (int)strlen(zCell);
184196 }
184197
184198 if( zText ){
184199 char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
184200 sqlite3_free(zText);
184201 zText = zTextNew;
184202 }else{
184203 zText = sqlite3_mprintf("{%s}", zCell);
184204 }
184205 }
184206
184207 sqlite3_result_text(ctx, zText, -1, sqlite3_free);
184208 }
184209
184210 /* This routine implements an SQL function that returns the "depth" parameter
184211 ** from the front of a blob that is an r-tree node. For example:
184212 **
@@ -198080,11 +198748,11 @@
198080
198081 return rc;
198082 }
198083
198084 /*
198085 ** This function is called from within sqlite3changset_apply_v2() when
198086 ** a conflict is encountered and resolved using conflict resolution
198087 ** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE)..
198088 ** It adds a conflict resolution record to the buffer in
198089 ** SessionApplyCtx.rebase, which will eventually be returned to the caller
198090 ** of apply_v2() as the "rebase" buffer.
@@ -200859,12 +201527,13 @@
200859 */
200860 static void sqlite3Fts5HashClear(Fts5Hash*);
200861
200862 static int sqlite3Fts5HashQuery(
200863 Fts5Hash*, /* Hash table to query */
 
200864 const char *pTerm, int nTerm, /* Query term */
200865 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
200866 int *pnDoclist /* OUT: Size of doclist in bytes */
200867 );
200868
200869 static int sqlite3Fts5HashScanInit(
200870 Fts5Hash*, /* Hash table to query */
@@ -202930,11 +203599,11 @@
202930 *pnScore = nScore;
202931 if( piPos ){
202932 sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
202933 if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
202934 if( iAdj<0 ) iAdj = 0;
202935 *piPos = iAdj;
202936 }
202937
202938 return rc;
202939 }
202940
@@ -203158,11 +203827,11 @@
203158 nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
203159 p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
203160 if( p==0 ){
203161 rc = SQLITE_NOMEM;
203162 }else{
203163 memset(p, 0, nByte);
203164 p->nPhrase = nPhrase;
203165 p->aIDF = (double*)&p[1];
203166 p->aFreq = &p->aIDF[nPhrase];
203167 }
203168
@@ -203321,11 +203990,11 @@
203321 pNew = sqlite3_realloc64(pBuf->p, nNew);
203322 if( pNew==0 ){
203323 *pRc = SQLITE_NOMEM;
203324 return 1;
203325 }else{
203326 pBuf->nSpace = nNew;
203327 pBuf->p = pNew;
203328 }
203329 }
203330 return 0;
203331 }
@@ -203545,11 +204214,11 @@
203545 if( *pRc==SQLITE_OK ){
203546 pRet = sqlite3_malloc64(nByte);
203547 if( pRet==0 ){
203548 if( nByte>0 ) *pRc = SQLITE_NOMEM;
203549 }else{
203550 memset(pRet, 0, nByte);
203551 }
203552 }
203553 return pRet;
203554 }
203555
@@ -204014,11 +204683,11 @@
204014 if( p==0 ){
204015 *pzErr = sqlite3_mprintf("parse error in tokenize directive");
204016 rc = SQLITE_ERROR;
204017 }else{
204018 rc = sqlite3Fts5GetTokenizer(pGlobal,
204019 (const char**)azArg, nArg, &pConfig->pTok, &pConfig->pTokApi,
204020 pzErr
204021 );
204022 }
204023 }
204024 }
@@ -204124,11 +204793,11 @@
204124 *pzOut = 0;
204125
204126 if( zOut==0 ){
204127 *pRc = SQLITE_NOMEM;
204128 }else{
204129 memcpy(zOut, zIn, nIn+1);
204130 if( fts5_isopenquote(zOut[0]) ){
204131 int ii = fts5Dequote(zOut);
204132 zRet = &zIn[ii];
204133 *pbQuoted = 1;
204134 }else{
@@ -206138,11 +206807,11 @@
206138 nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
206139 pRet = sqlite3_malloc64(nByte);
206140 if( pRet==0 ){
206141 pParse->rc = SQLITE_NOMEM;
206142 }else{
206143 memset(pRet, 0, nByte);
206144 }
206145 }else if( (pNear->nPhrase % SZALLOC)==0 ){
206146 int nNew = pNear->nPhrase + SZALLOC;
206147 sqlite3_int64 nByte;
206148
@@ -206214,11 +206883,11 @@
206214 sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
206215 pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
206216 if( pSyn==0 ){
206217 rc = SQLITE_NOMEM;
206218 }else{
206219 memset(pSyn, 0, nByte);
206220 pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);
206221 memcpy(pSyn->zTerm, pToken, nToken);
206222 pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;
206223 pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;
206224 }
@@ -206374,11 +207043,11 @@
206374 sqlite3_int64 nByte;
206375 Fts5Colset *pColset;
206376 nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
206377 pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
206378 if( pColset ){
206379 memcpy(pColset, pColsetOrig, nByte);
206380 }
206381 pNew->pRoot->pNear->pColset = pColset;
206382 }
206383 }
206384
@@ -206591,11 +207260,11 @@
206591 Fts5Colset *pRet;
206592 if( pOrig ){
206593 sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
206594 pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
206595 if( pRet ){
206596 memcpy(pRet, pOrig, nByte);
206597 }
206598 }else{
206599 pRet = 0;
206600 }
206601 return pRet;
@@ -207608,11 +208277,11 @@
207608 if( pNew->aSlot==0 ){
207609 sqlite3_free(pNew);
207610 *ppNew = 0;
207611 rc = SQLITE_NOMEM;
207612 }else{
207613 memset(pNew->aSlot, 0, nByte);
207614 }
207615 }
207616 return rc;
207617 }
207618
@@ -207692,40 +208361,51 @@
207692 pHash->nSlot = nNew;
207693 pHash->aSlot = apNew;
207694 return SQLITE_OK;
207695 }
207696
207697 static void fts5HashAddPoslistSize(Fts5Hash *pHash, Fts5HashEntry *p){
 
 
 
 
 
207698 if( p->iSzPoslist ){
207699 u8 *pPtr = (u8*)p;
 
207700 if( pHash->eDetail==FTS5_DETAIL_NONE ){
207701 assert( p->nData==p->iSzPoslist );
207702 if( p->bDel ){
207703 pPtr[p->nData++] = 0x00;
207704 if( p->bContent ){
207705 pPtr[p->nData++] = 0x00;
207706 }
207707 }
207708 }else{
207709 int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */
207710 int nPos = nSz*2 + p->bDel; /* Value of nPos field */
207711
207712 assert( p->bDel==0 || p->bDel==1 );
207713 if( nPos<=127 ){
207714 pPtr[p->iSzPoslist] = (u8)nPos;
207715 }else{
207716 int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
207717 memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
207718 sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
207719 p->nData += (nByte-1);
207720 }
207721 }
207722
207723 p->iSzPoslist = 0;
207724 p->bDel = 0;
207725 p->bContent = 0;
 
 
 
 
207726 }
 
207727 }
207728
207729 /*
207730 ** Add an entry to the in-memory hash table. The key is the concatenation
207731 ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).
@@ -207778,11 +208458,11 @@
207778
207779 /* Allocate new Fts5HashEntry and add it to the hash table. */
207780 p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
207781 if( !p ) return SQLITE_NOMEM;
207782 memset(p, 0, sizeof(Fts5HashEntry));
207783 p->nAlloc = nByte;
207784 zKey = fts5EntryKey(p);
207785 zKey[0] = bByte;
207786 memcpy(&zKey[1], pToken, nToken);
207787 assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
207788 p->nKey = nToken;
@@ -207833,11 +208513,11 @@
207833 pPtr = (u8*)p;
207834
207835 /* If this is a new rowid, append the 4-byte size field for the previous
207836 ** entry, and the new rowid for this entry. */
207837 if( iRowid!=p->iRowid ){
207838 fts5HashAddPoslistSize(pHash, p);
207839 p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);
207840 p->iRowid = iRowid;
207841 bNew = 1;
207842 p->iSzPoslist = p->nData;
207843 if( pHash->eDetail!=FTS5_DETAIL_NONE ){
@@ -207950,11 +208630,13 @@
207950 memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
207951
207952 for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
207953 Fts5HashEntry *pIter;
207954 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
207955 if( pTerm==0 || 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm) ){
 
 
207956 Fts5HashEntry *pEntry = pIter;
207957 pEntry->pScanNext = 0;
207958 for(i=0; ap[i]; i++){
207959 pEntry = fts5HashEntryMerge(pEntry, ap[i]);
207960 ap[i] = 0;
@@ -207978,12 +208660,13 @@
207978 /*
207979 ** Query the hash table for a doclist associated with term pTerm/nTerm.
207980 */
207981 static int sqlite3Fts5HashQuery(
207982 Fts5Hash *pHash, /* Hash table to query */
 
207983 const char *pTerm, int nTerm, /* Query term */
207984 const u8 **ppDoclist, /* OUT: Pointer to doclist for pTerm */
207985 int *pnDoclist /* OUT: Size of doclist in bytes */
207986 ){
207987 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
207988 char *zKey = 0;
207989 Fts5HashEntry *p;
@@ -207993,15 +208676,24 @@
207993 assert( p->nKey+1==(int)strlen(zKey) );
207994 if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
207995 }
207996
207997 if( p ){
207998 fts5HashAddPoslistSize(pHash, p);
207999 *ppDoclist = (const u8*)&zKey[nTerm+1];
208000 *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
 
 
 
 
 
 
 
 
 
208001 }else{
208002 *ppDoclist = 0;
208003 *pnDoclist = 0;
208004 }
208005
208006 return SQLITE_OK;
208007 }
@@ -208030,11 +208722,11 @@
208030 ){
208031 Fts5HashEntry *p;
208032 if( (p = pHash->pScan) ){
208033 char *zKey = fts5EntryKey(p);
208034 int nTerm = (int)strlen(zKey);
208035 fts5HashAddPoslistSize(pHash, p);
208036 *pzTerm = zKey;
208037 *ppDoclist = (const u8*)&zKey[nTerm+1];
208038 *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
208039 }else{
208040 *pzTerm = 0;
@@ -210500,35 +211192,44 @@
210500 Fts5Index *p, /* FTS5 backend */
210501 const u8 *pTerm, int nTerm, /* Term to seek to */
210502 int flags, /* Mask of FTS5INDEX_XXX flags */
210503 Fts5SegIter *pIter /* Object to populate */
210504 ){
210505 const u8 *pList = 0;
210506 int nList = 0;
210507 const u8 *z = 0;
210508 int n = 0;
 
210509
210510 assert( p->pHash );
210511 assert( p->rc==SQLITE_OK );
210512
210513 if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){
 
 
210514 p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);
210515 sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);
210516 n = (z ? (int)strlen((const char*)z) : 0);
 
 
 
 
 
 
210517 }else{
210518 pIter->flags |= FTS5_SEGITER_ONETERM;
210519 sqlite3Fts5HashQuery(p->pHash, (const char*)pTerm, nTerm, &pList, &nList);
 
 
 
 
210520 z = pTerm;
210521 n = nTerm;
 
210522 }
210523
210524 if( pList ){
210525 Fts5Data *pLeaf;
210526 sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
210527 pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));
210528 if( pLeaf==0 ) return;
210529 pLeaf->p = (u8*)pList;
210530 pLeaf->nn = pLeaf->szLeaf = nList;
210531 pIter->pLeaf = pLeaf;
210532 pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);
210533 pIter->iEndofDoclist = pLeaf->nn;
210534
@@ -215241,11 +215942,11 @@
215241 if( rc==SQLITE_OK ){
215242 nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
215243 pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
215244 if( pCsr ){
215245 Fts5Global *pGlobal = pTab->pGlobal;
215246 memset(pCsr, 0, nByte);
215247 pCsr->aColumnSize = (int*)&pCsr[1];
215248 pCsr->pNext = pGlobal->pCsr;
215249 pGlobal->pCsr = pCsr;
215250 pCsr->iCsrId = ++pGlobal->iNextId;
215251 }else{
@@ -215522,11 +216223,11 @@
215522
215523 nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
215524 nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
215525 pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
215526 if( pSorter==0 ) return SQLITE_NOMEM;
215527 memset(pSorter, 0, nByte);
215528 pSorter->nIdx = nPhrase;
215529
215530 /* TODO: It would be better to have some system for reusing statement
215531 ** handles here, rather than preparing a new one for each query. But that
215532 ** is not possible as SQLite reference counts the virtual table objects.
@@ -217256,11 +217957,11 @@
217256 int nArg, /* Number of args */
217257 sqlite3_value **apUnused /* Function arguments */
217258 ){
217259 assert( nArg==0 );
217260 UNUSED_PARAM2(nArg, apUnused);
217261 sqlite3_result_text(pCtx, "fts5: 2019-03-15 16:17:32 0f2129f59f7df929106e2af876c2976dea6528c1dc1850d64cddb256f20e121a", -1, SQLITE_TRANSIENT);
217262 }
217263
217264 /*
217265 ** Return true if zName is the extension on one of the shadow tables used
217266 ** by this module.
@@ -217679,11 +218380,11 @@
217679 nByte = sizeof(Fts5Storage) /* Fts5Storage object */
217680 + pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */
217681 *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
217682 if( !p ) return SQLITE_NOMEM;
217683
217684 memset(p, 0, nByte);
217685 p->aTotalSize = (i64*)&p[1];
217686 p->pConfig = pConfig;
217687 p->pIndex = pIndex;
217688
217689 if( bCreate ){
@@ -220589,11 +221290,11 @@
220589 int iTbl = 0;
220590 while( i<128 ){
220591 int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
220592 int n = (aFts5UnicodeData[iTbl] >> 5) + i;
220593 for(; i<128 && i<n; i++){
220594 aAscii[i] = bToken;
220595 }
220596 iTbl++;
220597 }
220598 }
220599
@@ -222020,12 +222721,12 @@
222020 }
222021 #endif /* SQLITE_CORE */
222022 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
222023
222024 /************** End of stmt.c ************************************************/
222025 #if __LINE__!=222025
222026 #undef SQLITE_SOURCE_ID
222027 #define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07ealt2"
222028 #endif
222029 /* Return the source-id for this library */
222030 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
222031 /************************** End of sqlite3.c ******************************/
222032
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.28.0"
1166 #define SQLITE_VERSION_NUMBER 3028000
1167 #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -1226,10 +1226,13 @@
1226 ** [sqlite_compileoption_get()] and the [compile_options pragma].
1227 */
1228 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
1229 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
1230 SQLITE_API const char *sqlite3_compileoption_get(int N);
1231 #else
1232 # define sqlite3_compileoption_used(X) 0
1233 # define sqlite3_compileoption_get(X) ((void*)0)
1234 #endif
1235
1236 /*
1237 ** CAPI3REF: Test To See If The Library Is Threadsafe
1238 **
@@ -3236,10 +3239,21 @@
3239 ** <li> The [PRAGMA writable_schema=ON] statement.
3240 ** <li> Writes to the [sqlite_dbpage] virtual table.
3241 ** <li> Direct writes to [shadow tables].
3242 ** </ul>
3243 ** </dd>
3244 **
3245 ** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
3246 ** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
3247 ** "writable_schema" flag. This has the same effect and is logically equivalent
3248 ** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF].
3249 ** The first argument to this setting is an integer which is 0 to disable
3250 ** the writable_schema, positive to enable writable_schema, or negative to
3251 ** leave the setting unchanged. The second parameter is a pointer to an
3252 ** integer into which is written 0 or 1 to indicate whether the writable_schema
3253 ** is enabled or disabled following this call.
3254 ** </dd>
3255 ** </dl>
3256 */
3257 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
3258 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
3259 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -3249,11 +3263,12 @@
3263 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
3264 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
3265 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
3266 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
3267 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
3268 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
3269 #define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */
3270
3271 /*
3272 ** CAPI3REF: Enable Or Disable Extended Result Codes
3273 ** METHOD: sqlite3
3274 **
@@ -6001,10 +6016,12 @@
6016 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
6017 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
6018 ** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
6019 ** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
6020 ** against a virtual table.
6021 ** <tr><td><b>sqlite3_value_frombind&nbsp;&nbsp;</b>
6022 ** <td>&rarr;&nbsp;&nbsp;<td>True if value originated a bound parameter
6023 ** </table></blockquote>
6024 **
6025 ** <b>Details:</b>
6026 **
6027 ** These routines extract type, size, and content information from
@@ -6061,10 +6078,15 @@
6078 ** was unchanging). ^Within an [xUpdate] method, any value for which
6079 ** sqlite3_value_nochange(X) is true will in all other respects appear
6080 ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
6081 ** than within an [xUpdate] method call for an UPDATE statement, then
6082 ** the return value is arbitrary and meaningless.
6083 **
6084 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
6085 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
6086 ** interfaces. ^If X comes from an SQL literal value, or a table column,
6087 ** and expression, then sqlite3_value_frombind(X) returns zero.
6088 **
6089 ** Please pay particular attention to the fact that the pointer returned
6090 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
6091 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
6092 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -6107,10 +6129,11 @@
6129 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
6130 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
6131 SQLITE_API int sqlite3_value_type(sqlite3_value*);
6132 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
6133 SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
6134 SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
6135
6136 /*
6137 ** CAPI3REF: Finding The Subtype Of SQL Values
6138 ** METHOD: sqlite3_value
6139 **
@@ -11943,11 +11966,11 @@
11966 **
11967 ** Argument pIn must point to a buffer containing a changeset nIn bytes
11968 ** in size. This function allocates and populates a buffer with a copy
11969 ** of the changeset rebased rebased according to the configuration of the
11970 ** rebaser object passed as the first argument. If successful, (*ppOut)
11971 ** is set to point to the new buffer containing the rebased changeset and
11972 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
11973 ** responsibility of the caller to eventually free the new buffer using
11974 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
11975 ** are set to zero and an SQLite error code returned.
11976 */
@@ -13534,96 +13557,100 @@
13557 #define TK_FOLLOWING 83
13558 #define TK_PARTITION 84
13559 #define TK_PRECEDING 85
13560 #define TK_RANGE 86
13561 #define TK_UNBOUNDED 87
13562 #define TK_EXCLUDE 88
13563 #define TK_GROUPS 89
13564 #define TK_OTHERS 90
13565 #define TK_TIES 91
13566 #define TK_REINDEX 92
13567 #define TK_RENAME 93
13568 #define TK_CTIME_KW 94
13569 #define TK_ANY 95
13570 #define TK_BITAND 96
13571 #define TK_BITOR 97
13572 #define TK_LSHIFT 98
13573 #define TK_RSHIFT 99
13574 #define TK_PLUS 100
13575 #define TK_MINUS 101
13576 #define TK_STAR 102
13577 #define TK_SLASH 103
13578 #define TK_REM 104
13579 #define TK_CONCAT 105
13580 #define TK_COLLATE 106
13581 #define TK_BITNOT 107
13582 #define TK_ON 108
13583 #define TK_INDEXED 109
13584 #define TK_STRING 110
13585 #define TK_JOIN_KW 111
13586 #define TK_CONSTRAINT 112
13587 #define TK_DEFAULT 113
13588 #define TK_NULL 114
13589 #define TK_PRIMARY 115
13590 #define TK_UNIQUE 116
13591 #define TK_CHECK 117
13592 #define TK_REFERENCES 118
13593 #define TK_AUTOINCR 119
13594 #define TK_INSERT 120
13595 #define TK_DELETE 121
13596 #define TK_UPDATE 122
13597 #define TK_SET 123
13598 #define TK_DEFERRABLE 124
13599 #define TK_FOREIGN 125
13600 #define TK_DROP 126
13601 #define TK_UNION 127
13602 #define TK_ALL 128
13603 #define TK_EXCEPT 129
13604 #define TK_INTERSECT 130
13605 #define TK_SELECT 131
13606 #define TK_VALUES 132
13607 #define TK_DISTINCT 133
13608 #define TK_DOT 134
13609 #define TK_FROM 135
13610 #define TK_JOIN 136
13611 #define TK_USING 137
13612 #define TK_ORDER 138
13613 #define TK_GROUP 139
13614 #define TK_HAVING 140
13615 #define TK_LIMIT 141
13616 #define TK_WHERE 142
13617 #define TK_INTO 143
13618 #define TK_NOTHING 144
13619 #define TK_FLOAT 145
13620 #define TK_BLOB 146
13621 #define TK_INTEGER 147
13622 #define TK_VARIABLE 148
13623 #define TK_CASE 149
13624 #define TK_WHEN 150
13625 #define TK_THEN 151
13626 #define TK_ELSE 152
13627 #define TK_INDEX 153
13628 #define TK_ALTER 154
13629 #define TK_ADD 155
13630 #define TK_WINDOW 156
13631 #define TK_OVER 157
13632 #define TK_FILTER 158
13633 #define TK_TRUEFALSE 159
13634 #define TK_ISNOT 160
13635 #define TK_FUNCTION 161
13636 #define TK_COLUMN 162
13637 #define TK_AGG_FUNCTION 163
13638 #define TK_AGG_COLUMN 164
13639 #define TK_UMINUS 165
13640 #define TK_UPLUS 166
13641 #define TK_TRUTH 167
13642 #define TK_REGISTER 168
13643 #define TK_VECTOR 169
13644 #define TK_SELECT_COLUMN 170
13645 #define TK_IF_NULL_ROW 171
13646 #define TK_ASTERISK 172
13647 #define TK_SPAN 173
13648 #define TK_END_OF_FILE 174
13649 #define TK_UNCLOSED_STRING 175
13650 #define TK_SPACE 176
13651 #define TK_ILLEGAL 177
13652
13653 /* The token codes above must all fit in 8 bits */
13654 #define TKFLG_MASK 0xff
13655
13656 /* Flags that can be added to a token code when it is not
@@ -14558,13 +14585,10 @@
14585 };
14586
14587 SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
14588 int flags, int seekResult);
14589 SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
 
 
 
14590 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
14591 SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags);
14592 SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*);
14593 SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags);
14594 SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*);
@@ -14918,29 +14942,29 @@
14942 #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */
14943 #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
14944 #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */
14945 #define OP_Column 90 /* synopsis: r[P3]=PX */
14946 #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */
14947 #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
14948 #define OP_Count 93 /* synopsis: r[P2]=count() */
14949 #define OP_ReadCookie 94
14950 #define OP_SetCookie 95
14951 #define OP_BitAnd 96 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
14952 #define OP_BitOr 97 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
14953 #define OP_ShiftLeft 98 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
14954 #define OP_ShiftRight 99 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */
14955 #define OP_Add 100 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */
14956 #define OP_Subtract 101 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */
14957 #define OP_Multiply 102 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */
14958 #define OP_Divide 103 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
14959 #define OP_Remainder 104 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
14960 #define OP_Concat 105 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
14961 #define OP_ReopenIdx 106 /* synopsis: root=P2 iDb=P3 */
14962 #define OP_BitNot 107 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
14963 #define OP_OpenRead 108 /* synopsis: root=P2 iDb=P3 */
14964 #define OP_OpenWrite 109 /* synopsis: root=P2 iDb=P3 */
14965 #define OP_String8 110 /* same as TK_STRING, synopsis: r[P2]='P4' */
14966 #define OP_OpenDup 111
14967 #define OP_OpenAutoindex 112 /* synopsis: nColumn=P2 */
14968 #define OP_OpenEphemeral 113 /* synopsis: nColumn=P2 */
14969 #define OP_SorterOpen 114
14970 #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
@@ -14967,15 +14991,15 @@
14991 #define OP_Destroy 136
14992 #define OP_Clear 137
14993 #define OP_ResetSorter 138
14994 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
14995 #define OP_SqlExec 140
14996 #define OP_ParseSchema 141
14997 #define OP_LoadAnalysis 142
14998 #define OP_DropTable 143
14999 #define OP_DropIndex 144
15000 #define OP_Real 145 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15001 #define OP_DropTrigger 146
15002 #define OP_IntegrityCk 147
15003 #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
15004 #define OP_Param 149
15005 #define OP_FkCounter 150 /* synopsis: fkctr[P1]+=P2 */
@@ -15022,18 +15046,18 @@
15046 /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
15047 /* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
15048 /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
15049 /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
15050 /* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
15051 /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
15052 /* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
15053 /* 104 */ 0x26, 0x26, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00,\
15054 /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15055 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15056 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15057 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15058 /* 144 */ 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\
15059 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15060 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
15061 /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00,}
15062
15063 /* The sqlite3P2Values() routine is able to run faster if it knows
@@ -16479,11 +16503,11 @@
16503 ** Bits of the sqlite3.dbOptFlags field that are used by the
16504 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
16505 ** selectively disable various optimizations.
16506 */
16507 #define SQLITE_QueryFlattener 0x0001 /* Query flattening */
16508 #define SQLITE_WindowFunc 0x0002 /* Use xInverse for window functions */
16509 #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */
16510 #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */
16511 #define SQLITE_DistinctOpt 0x0010 /* DISTINCT using indexes */
16512 #define SQLITE_CoverIdxScan 0x0020 /* Covering index scans */
16513 #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */
@@ -16597,11 +16621,10 @@
16621 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
16622 ** single query - might change over time */
16623 #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
16624 #define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
16625 #define SQLITE_FUNC_WINDOW 0x00010000 /* Built-in window-only function */
 
16626 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
16627
16628 /*
16629 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
16630 ** used to create the initializers for the FuncDef structures.
@@ -17403,16 +17426,20 @@
17426 } y;
17427 };
17428
17429 /*
17430 ** The following are the meanings of bits in the Expr.flags field.
17431 ** Value restrictions:
17432 **
17433 ** EP_Agg == NC_HasAgg == SF_HasAgg
17434 ** EP_Win == NC_HasWin
17435 */
17436 #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
17437 #define EP_Distinct 0x000002 /* Aggregate function with DISTINCT keyword */
17438 #define EP_HasFunc 0x000004 /* Contains one or more functions of any kind */
17439 #define EP_FixedCol 0x000008 /* TK_Column with a known fixed value */
17440 #define EP_Agg 0x000010 /* Contains one or more aggregate functions */
17441 #define EP_VarSelect 0x000020 /* pSelect is correlated, not constant */
17442 #define EP_DblQuoted 0x000040 /* token.z was originally in "..." */
17443 #define EP_InfixFunc 0x000080 /* True for an infix function: LIKE, GLOB, etc */
17444 #define EP_Collate 0x000100 /* Tree contains a TK_COLLATE operator */
17445 #define EP_Generic 0x000200 /* Ignore COLLATE or affinity on this tree */
@@ -17419,11 +17446,11 @@
17446 #define EP_IntValue 0x000400 /* Integer value contained in u.iValue */
17447 #define EP_xIsSelect 0x000800 /* x.pSelect is valid (otherwise x.pList is) */
17448 #define EP_Skip 0x001000 /* COLLATE, AS, or UNLIKELY */
17449 #define EP_Reduced 0x002000 /* Expr struct EXPR_REDUCEDSIZE bytes only */
17450 #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */
17451 #define EP_Win 0x008000 /* Contains window functions */
17452 #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
17453 #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
17454 #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
17455 #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
17456 #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
@@ -17431,10 +17458,11 @@
17458 #define EP_Alias 0x400000 /* Is an alias for a result set column */
17459 #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
17460 #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
17461 #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
17462 #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
17463 #define EP_Static 0x8000000 /* Held in memory not obtained from malloc() */
17464
17465 /*
17466 ** The EP_Propagate mask is a set of properties that automatically propagate
17467 ** upwards into parent nodes.
17468 */
@@ -17670,12 +17698,13 @@
17698
17699 /*
17700 ** Allowed values for the NameContext, ncFlags field.
17701 **
17702 ** Value constraints (all checked via assert()):
17703 ** NC_HasAgg == SF_HasAgg == EP_Agg
17704 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17705 ** NC_HasWin == EP_Win
17706 **
17707 */
17708 #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */
17709 #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */
17710 #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */
@@ -17687,10 +17716,11 @@
17716 #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
17717 #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
17718 #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
17719 #define NC_Complex 0x2000 /* True if a function or subquery seen */
17720 #define NC_AllowWin 0x4000 /* Window functions are allowed here */
17721 #define NC_HasWin 0x8000 /* One or more window functions seen */
17722
17723 /*
17724 ** An instance of the following object describes a single ON CONFLICT
17725 ** clause in an upsert.
17726 **
@@ -18442,11 +18472,11 @@
18472 u8 bLine[100]; /* Draw vertical in column i if bLine[i] is true */
18473 };
18474 #endif /* SQLITE_DEBUG */
18475
18476 /*
18477 ** This object is used in various ways, all related to window functions
18478 **
18479 ** (1) A single instance of this structure is attached to the
18480 ** the Expr.pWin field for each window function in an expression tree.
18481 ** This object holds the information contained in the OVER clause,
18482 ** plus additional fields used during code generation.
@@ -18457,19 +18487,22 @@
18487 **
18488 ** (3) The terms of the WINDOW clause of a SELECT are instances of this
18489 ** object on a linked list attached to Select.pWinDefn.
18490 **
18491 ** The uses (1) and (2) are really the same Window object that just happens
18492 ** to be accessible in two different ways. Use case (3) are separate objects.
18493 */
18494 struct Window {
18495 char *zName; /* Name of window (may be NULL) */
18496 char *zBase; /* Name of base window for chaining (may be NULL) */
18497 ExprList *pPartition; /* PARTITION BY clause */
18498 ExprList *pOrderBy; /* ORDER BY clause */
18499 u8 eFrmType; /* TK_RANGE, TK_GROUPS, TK_ROWS, or 0 */
18500 u8 eStart; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18501 u8 eEnd; /* UNBOUNDED, CURRENT, PRECEDING or FOLLOWING */
18502 u8 bImplicitFrame; /* True if frame was implicitly specified */
18503 u8 eExclude; /* TK_NO, TK_CURRENT, TK_TIES, TK_GROUP, or 0 */
18504 Expr *pStart; /* Expression for "<expr> PRECEDING" */
18505 Expr *pEnd; /* Expression for "<expr> FOLLOWING" */
18506 Window *pNextWin; /* Next window function belonging to this SELECT */
18507 Expr *pFilter; /* The FILTER expression */
18508 FuncDef *pFunc; /* The function */
@@ -18476,21 +18509,23 @@
18509 int iEphCsr; /* Partition buffer or Peer buffer */
18510 int regAccum;
18511 int regResult;
18512 int csrApp; /* Function cursor (used by min/max) */
18513 int regApp; /* Function register (also used by min/max) */
18514 int regPart; /* Array of registers for PARTITION BY values */
 
18515 Expr *pOwner; /* Expression object this window is attached to */
18516 int nBufferCol; /* Number of columns in buffer table */
18517 int iArgCol; /* Offset of first argument for this function */
18518 int regOne; /* Register containing constant value 1 */
18519 int regStartRowid;
18520 int regEndRowid;
18521 };
18522
18523 #ifndef SQLITE_OMIT_WINDOWFUNC
18524 SQLITE_PRIVATE void sqlite3WindowDelete(sqlite3*, Window*);
18525 SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p);
18526 SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8);
18527 SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*);
18528 SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*);
18529 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Window*);
18530 SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int);
18531 SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*);
@@ -18497,10 +18532,12 @@
18532 SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
18533 SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*);
18534 SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p);
18535 SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p);
18536 SQLITE_PRIVATE void sqlite3WindowFunctions(void);
18537 SQLITE_PRIVATE void sqlite3WindowChain(Parse*, Window*, Window*);
18538 SQLITE_PRIVATE Window *sqlite3WindowAssemble(Parse*, Window*, ExprList*, ExprList*, Token*);
18539 #else
18540 # define sqlite3WindowDelete(a,b)
18541 # define sqlite3WindowFunctions()
18542 # define sqlite3WindowAttach(a,b,c)
18543 #endif
@@ -20149,15 +20186,15 @@
20186 #define MEM_Str 0x0002 /* Value is a string */
20187 #define MEM_Int 0x0004 /* Value is an integer */
20188 #define MEM_Real 0x0008 /* Value is a real number */
20189 #define MEM_Blob 0x0010 /* Value is a BLOB */
20190 #define MEM_AffMask 0x001f /* Mask of affinity bits */
20191 #define MEM_FromBind 0x0020 /* Value originates from sqlite3_bind() */
20192 /* Available 0x0040 */
20193 #define MEM_Undefined 0x0080 /* Value is undefined */
20194 #define MEM_Cleared 0x0100 /* NULL set by OP_Null, not from data */
20195 #define MEM_TypeMask 0xc1df /* Mask of type bits */
20196
20197
20198 /* Whenever Mem contains a valid string or blob representation, one of
20199 ** the following flags must be set to determine the memory management
20200 ** policy for Mem.z. The MEM_Term flag tells us whether or not the
@@ -28786,28 +28823,66 @@
28823 #ifndef SQLITE_OMIT_WINDOWFUNC
28824 /*
28825 ** Generate a human-readable explanation for a Window object
28826 */
28827 SQLITE_PRIVATE void sqlite3TreeViewWindow(TreeView *pView, const Window *pWin, u8 more){
28828 int nElement = 0;
28829 if( pWin->pFilter ){
28830 sqlite3TreeViewItem(pView, "FILTER", 1);
28831 sqlite3TreeViewExpr(pView, pWin->pFilter, 0);
28832 sqlite3TreeViewPop(pView);
28833 }
28834 pView = sqlite3TreeViewPush(pView, more);
28835 if( pWin->zName ){
28836 sqlite3TreeViewLine(pView, "OVER %s (%p)", pWin->zName, pWin);
28837 }else{
28838 sqlite3TreeViewLine(pView, "OVER (%p)", pWin);
28839 }
28840 if( pWin->zBase ) nElement++;
28841 if( pWin->pOrderBy ) nElement++;
28842 if( pWin->eFrmType ) nElement++;
28843 if( pWin->eExclude ) nElement++;
28844 if( pWin->zBase ){
28845 sqlite3TreeViewPush(pView, (--nElement)>0);
28846 sqlite3TreeViewLine(pView, "window: %s", pWin->zBase);
28847 sqlite3TreeViewPop(pView);
28848 }
28849 if( pWin->pPartition ){
28850 sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY");
28851 }
28852 if( pWin->pOrderBy ){
28853 sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY");
28854 }
28855 if( pWin->eFrmType ){
28856 char zBuf[30];
28857 const char *zFrmType = "ROWS";
28858 if( pWin->eFrmType==TK_RANGE ) zFrmType = "RANGE";
28859 if( pWin->eFrmType==TK_GROUPS ) zFrmType = "GROUPS";
28860 sqlite3_snprintf(sizeof(zBuf),zBuf,"%s%s",zFrmType,
28861 pWin->bImplicitFrame ? " (implied)" : "");
28862 sqlite3TreeViewItem(pView, zBuf, (--nElement)>0);
28863 sqlite3TreeViewBound(pView, pWin->eStart, pWin->pStart, 1);
28864 sqlite3TreeViewBound(pView, pWin->eEnd, pWin->pEnd, 0);
28865 sqlite3TreeViewPop(pView);
28866 }
28867 if( pWin->eExclude ){
28868 char zBuf[30];
28869 const char *zExclude;
28870 switch( pWin->eExclude ){
28871 case TK_NO: zExclude = "NO OTHERS"; break;
28872 case TK_CURRENT: zExclude = "CURRENT ROW"; break;
28873 case TK_GROUP: zExclude = "GROUP"; break;
28874 case TK_TIES: zExclude = "TIES"; break;
28875 default:
28876 sqlite3_snprintf(sizeof(zBuf),zBuf,"invalid(%d)", pWin->eExclude);
28877 zExclude = zBuf;
28878 break;
28879 }
28880 sqlite3TreeViewPush(pView, 0);
28881 sqlite3TreeViewLine(pView, "EXCLUDE %s", zExclude);
28882 sqlite3TreeViewPop(pView);
28883 }
28884 sqlite3TreeViewPop(pView);
28885 }
28886 #endif /* SQLITE_OMIT_WINDOWFUNC */
28887
28888 #ifndef SQLITE_OMIT_WINDOWFUNC
@@ -32124,29 +32199,29 @@
32199 /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
32200 /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
32201 /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
32202 /* 90 */ "Column" OpHelp("r[P3]=PX"),
32203 /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
32204 /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
32205 /* 93 */ "Count" OpHelp("r[P2]=count()"),
32206 /* 94 */ "ReadCookie" OpHelp(""),
32207 /* 95 */ "SetCookie" OpHelp(""),
32208 /* 96 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
32209 /* 97 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
32210 /* 98 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
32211 /* 99 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"),
32212 /* 100 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"),
32213 /* 101 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"),
32214 /* 102 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"),
32215 /* 103 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
32216 /* 104 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
32217 /* 105 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
32218 /* 106 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
32219 /* 107 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
32220 /* 108 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
32221 /* 109 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
32222 /* 110 */ "String8" OpHelp("r[P2]='P4'"),
32223 /* 111 */ "OpenDup" OpHelp(""),
32224 /* 112 */ "OpenAutoindex" OpHelp("nColumn=P2"),
32225 /* 113 */ "OpenEphemeral" OpHelp("nColumn=P2"),
32226 /* 114 */ "SorterOpen" OpHelp(""),
32227 /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
@@ -32173,15 +32248,15 @@
32248 /* 136 */ "Destroy" OpHelp(""),
32249 /* 137 */ "Clear" OpHelp(""),
32250 /* 138 */ "ResetSorter" OpHelp(""),
32251 /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
32252 /* 140 */ "SqlExec" OpHelp(""),
32253 /* 141 */ "ParseSchema" OpHelp(""),
32254 /* 142 */ "LoadAnalysis" OpHelp(""),
32255 /* 143 */ "DropTable" OpHelp(""),
32256 /* 144 */ "DropIndex" OpHelp(""),
32257 /* 145 */ "Real" OpHelp("r[P2]=P4"),
32258 /* 146 */ "DropTrigger" OpHelp(""),
32259 /* 147 */ "IntegrityCk" OpHelp(""),
32260 /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
32261 /* 149 */ "Param" OpHelp(""),
32262 /* 150 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
@@ -59204,10 +59279,11 @@
59279 static void walCleanupHash(Wal *pWal){
59280 WalHashLoc sLoc; /* Hash table location */
59281 int iLimit = 0; /* Zero values greater than this */
59282 int nByte; /* Number of bytes to zero in aPgno[] */
59283 int i; /* Used to iterate through aHash[] */
59284 int rc; /* Return code form walHashGet() */
59285
59286 assert( pWal->writeLock );
59287 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 );
59288 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE );
59289 testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE+1 );
@@ -59214,15 +59290,16 @@
59290
59291 if( pWal->hdr.mxFrame==0 ) return;
59292
59293 /* Obtain pointers to the hash-table and page-number array containing
59294 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
59295 ** that the page said hash-table and array reside on is already mapped.(1)
59296 */
59297 assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) );
59298 assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] );
59299 rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc);
59300 if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */
59301
59302 /* Zero all hash-table entries that correspond to frame numbers greater
59303 ** than pWal->hdr.mxFrame.
59304 */
59305 iLimit = pWal->hdr.mxFrame - sLoc.iZero;
@@ -63922,18 +63999,22 @@
63999 ** at most one effective restoreCursorPosition() call after each
64000 ** saveCursorPosition().
64001 */
64002 static int btreeRestoreCursorPosition(BtCursor *pCur){
64003 int rc;
64004 int skipNext = 0;
64005 assert( cursorOwnsBtShared(pCur) );
64006 assert( pCur->eState>=CURSOR_REQUIRESEEK );
64007 if( pCur->eState==CURSOR_FAULT ){
64008 return pCur->skipNext;
64009 }
64010 pCur->eState = CURSOR_INVALID;
64011 if( sqlite3FaultSim(410) ){
64012 rc = SQLITE_IOERR;
64013 }else{
64014 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
64015 }
64016 if( rc==SQLITE_OK ){
64017 sqlite3_free(pCur->pKey);
64018 pCur->pKey = 0;
64019 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
64020 if( skipNext ) pCur->skipNext = skipNext;
@@ -64521,15 +64602,11 @@
64602 ** two (or one) blocks of cells using memmove() and add the required
64603 ** offsets to each pointer in the cell-pointer array than it is to
64604 ** reconstruct the entire page. */
64605 if( (int)data[hdr+7]<=nMaxFrag ){
64606 int iFree = get2byte(&data[hdr+1]);
64607 if( iFree>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
 
 
 
 
64608 if( iFree ){
64609 int iFree2 = get2byte(&data[iFree]);
64610 if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
64611 if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
64612 u8 *pEnd = &data[cellOffset + nCell*2];
@@ -64544,11 +64621,14 @@
64621 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
64622 sz2 = get2byte(&data[iFree2+2]);
64623 if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
64624 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
64625 sz += sz2;
64626 }else if( iFree+sz>usableSize ){
64627 return SQLITE_CORRUPT_PAGE(pPage);
64628 }
64629
64630 cbrk = top+sz;
64631 assert( cbrk+(iFree-top) <= usableSize );
64632 memmove(&data[cbrk], &data[top], iFree-top);
64633 for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){
64634 pc = get2byte(pAddr);
@@ -65102,11 +65182,11 @@
65182 /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
65183 ** possible for a root page of a table that contains no rows) then the
65184 ** offset to the cell content area will equal the page size minus the
65185 ** bytes of reserved space. */
65186 assert( pPage->nCell>0
65187 || get2byteNotZero(&data[5])==(int)pBt->usableSize
65188 || CORRUPT_DB );
65189 pPage->nFree = -1; /* Indicate that this value is yet uncomputed */
65190 pPage->isInit = 1;
65191 if( pBt->db->flags & SQLITE_CellSizeCk ){
65192 return btreeCellSizeCheck(pPage);
@@ -68359,27 +68439,10 @@
68439 rc = SQLITE_OK;
68440 }
68441 return rc;
68442 }
68443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68444 /* Move the cursor to the last entry in the table. Return SQLITE_OK
68445 ** on success. Set *pRes to 0 if the cursor actually points to something
68446 ** or set *pRes to 1 if the table is empty.
68447 */
68448 SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){
@@ -69279,11 +69342,13 @@
69342
69343 assert( sqlite3_mutex_held(pBt->mutex) );
69344 assert( CORRUPT_DB || iPage>1 );
69345 assert( !pMemPage || pMemPage->pgno==iPage );
69346
69347 if( iPage<2 || iPage>pBt->nPage ){
69348 return SQLITE_CORRUPT_BKPT;
69349 }
69350 if( pMemPage ){
69351 pPage = pMemPage;
69352 sqlite3PagerRef(pPage->pDbPage);
69353 }else{
69354 pPage = btreePageLookup(pBt, iPage);
@@ -70648,11 +70713,10 @@
70713 if( rc ){
70714 memset(apOld, 0, (i)*sizeof(MemPage*));
70715 goto balance_cleanup;
70716 }
70717 }
 
70718 if( (i--)==0 ) break;
70719
70720 if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
70721 apDiv[i] = pParent->apOvfl[0];
70722 pgno = get4byte(apDiv[i]);
@@ -70692,10 +70756,11 @@
70756 }
70757 }
70758
70759 /* Make nMaxCells a multiple of 4 in order to preserve 8-byte
70760 ** alignment */
70761 nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
70762 nMaxCells = (nMaxCells + 3)&~3;
70763
70764 /*
70765 ** Allocate space for memory structures
70766 */
@@ -70702,11 +70767,11 @@
70767 szScratch =
70768 nMaxCells*sizeof(u8*) /* b.apCell */
70769 + nMaxCells*sizeof(u16) /* b.szCell */
70770 + pBt->pageSize; /* aSpace1 */
70771
70772 assert( szScratch<=7*(int)pBt->pageSize );
70773 b.apCell = sqlite3StackAllocRaw(0, szScratch );
70774 if( b.apCell==0 ){
70775 rc = SQLITE_NOMEM_BKPT;
70776 goto balance_cleanup;
70777 }
@@ -71252,11 +71317,12 @@
71317 */
71318 assert( nNew==1 || CORRUPT_DB );
71319 rc = defragmentPage(apNew[0], -1);
71320 testcase( rc!=SQLITE_OK );
71321 assert( apNew[0]->nFree ==
71322 (get2byteNotZero(&apNew[0]->aData[5]) - apNew[0]->cellOffset
71323 - apNew[0]->nCell*2)
71324 || rc!=SQLITE_OK
71325 );
71326 copyNodeContent(apNew[0], pParent, &rc);
71327 freePage(apNew[0], &rc);
71328 }else if( ISAUTOVACUUM && !leafCorrection ){
@@ -71917,13 +71983,16 @@
71983 assert( pBt->inTransaction==TRANS_WRITE );
71984 assert( (pBt->btsFlags & BTS_READ_ONLY)==0 );
71985 assert( pCur->curFlags & BTCF_WriteFlag );
71986 assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
71987 assert( !hasReadConflicts(p, pCur->pgnoRoot) );
 
 
71988 assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
71989 if( pCur->eState==CURSOR_REQUIRESEEK ){
71990 rc = btreeRestoreCursorPosition(pCur);
71991 if( rc ) return rc;
71992 }
71993 assert( pCur->eState==CURSOR_VALID );
71994
71995 iCellDepth = pCur->iPage;
71996 iCellIdx = pCur->ix;
71997 pPage = pCur->pPage;
71998 pCell = findCell(pPage, iCellIdx);
@@ -74387,11 +74456,11 @@
74456 assert( ((p->flags&MEM_Dyn)!=0 ? 1 : 0) +
74457 ((p->flags&MEM_Ephem)!=0 ? 1 : 0) +
74458 ((p->flags&MEM_Static)!=0 ? 1 : 0) <= 1 );
74459
74460 /* No other bits set */
74461 assert( (p->flags & ~(MEM_Null|MEM_Term|MEM_Subtype|MEM_FromBind
74462 |MEM_Dyn|MEM_Ephem|MEM_Static))==0 );
74463 }else{
74464 /* A pure NULL might have other flags, such as MEM_Static, MEM_Dyn,
74465 ** MEM_Ephem, MEM_Cleared, or MEM_Subtype */
74466 }
@@ -81474,10 +81543,15 @@
81543
81544 /* Return true if a parameter to xUpdate represents an unchanged column */
81545 SQLITE_API int sqlite3_value_nochange(sqlite3_value *pVal){
81546 return (pVal->flags&(MEM_Null|MEM_Zero))==(MEM_Null|MEM_Zero);
81547 }
81548
81549 /* Return true if a parameter value originated from an sqlite3_bind() */
81550 SQLITE_API int sqlite3_value_frombind(sqlite3_value *pVal){
81551 return (pVal->flags&MEM_FromBind)!=0;
81552 }
81553
81554 /* Make a copy of an sqlite3_value object
81555 */
81556 SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *pOrig){
81557 sqlite3_value *pNew;
@@ -83505,16 +83579,24 @@
83579 /*
83580 ** Invoke the VDBE coverage callback, if that callback is defined. This
83581 ** feature is used for test suite validation only and does not appear an
83582 ** production builds.
83583 **
83584 ** M is the type of branch. I is the direction taken for this instance of
83585 ** the branch.
83586 **
83587 ** M: 2 - two-way branch (I=0: fall-thru 1: jump )
83588 ** 3 - two-way + NULL (I=0: fall-thru 1: jump 2: NULL )
83589 ** 4 - OP_Jump (I=0: jump p1 1: jump p2 2: jump p3)
83590 **
83591 ** In other words, if M is 2, then I is either 0 (for fall-through) or
83592 ** 1 (for when the branch is taken). If M is 3, the I is 0 for an
83593 ** ordinary fall-through, I is 1 if the branch was taken, and I is 2
83594 ** if the result of comparison is NULL. For M=3, I=2 the jump may or
83595 ** may not be taken, depending on the SQLITE_JUMPIFNULL flags in p5.
83596 ** When M is 4, that means that an OP_Jump is being run. I is 0, 1, or 2
83597 ** depending on if the operands are less than, equal, or greater than.
83598 **
83599 ** iSrcLine is the source code line (from the __LINE__ macro) that
83600 ** generated the VDBE instruction combined with flag bits. The source
83601 ** code line number is in the lower 24 bits of iSrcLine and the upper
83602 ** 8 bytes are flags. The lower three bits of the flags indicate
@@ -83521,13 +83603,13 @@
83603 ** values for I that should never occur. For example, if the branch is
83604 ** always taken, the flags should be 0x05 since the fall-through and
83605 ** alternate branch are never taken. If a branch is never taken then
83606 ** flags should be 0x06 since only the fall-through approach is allowed.
83607 **
83608 ** Bit 0x08 of the flags indicates an OP_Jump opcode that is only
83609 ** interested in equal or not-equal. In other words, I==0 and I==2
83610 ** should be treated as equivalent
83611 **
83612 ** Since only a line number is retained, not the filename, this macro
83613 ** only works for amalgamation builds. But that is ok, since these macros
83614 ** should be no-ops except for special builds used to measure test coverage.
83615 */
@@ -83547,10 +83629,22 @@
83629 ** a branch really does go in one of those directions, assert right
83630 ** away. */
83631 mNever = iSrcLine >> 24;
83632 assert( (I & mNever)==0 );
83633 if( sqlite3GlobalConfig.xVdbeBranch==0 ) return; /*NO_TEST*/
83634 /* Invoke the branch coverage callback with three arguments:
83635 ** iSrcLine - the line number of the VdbeCoverage() macro, with
83636 ** flags removed.
83637 ** I - Mask of bits 0x07 indicating which cases are are
83638 ** fulfilled by this instance of the jump. 0x01 means
83639 ** fall-thru, 0x02 means taken, 0x04 means NULL. Any
83640 ** impossible cases (ex: if the comparison is never NULL)
83641 ** are filled in automatically so that the coverage
83642 ** measurement logic does not flag those impossible cases
83643 ** as missed coverage.
83644 ** M - Type of jump. Same as M argument above
83645 */
83646 I |= mNever;
83647 if( M==2 ) I |= 0x04;
83648 if( M==4 ){
83649 I |= 0x08;
83650 if( (mNever&0x08)!=0 && (I&0x05)!=0) I |= 0x05; /*NO_TEST*/
@@ -84708,11 +84802,14 @@
84802 pVar = &p->aVar[pOp->p1 - 1];
84803 if( sqlite3VdbeMemTooBig(pVar) ){
84804 goto too_big;
84805 }
84806 pOut = &aMem[pOp->p2];
84807 if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
84808 memcpy(pOut, pVar, MEMCELLSIZE);
84809 pOut->flags &= ~(MEM_Dyn|MEM_Ephem);
84810 pOut->flags |= MEM_Static|MEM_FromBind;
84811 UPDATE_MAX_BLOBSIZE(pOut);
84812 break;
84813 }
84814
84815 /* Opcode: Move P1 P2 P3 * *
@@ -85206,20 +85303,21 @@
85303 */
85304 case OP_MustBeInt: { /* jump, in1 */
85305 pIn1 = &aMem[pOp->p1];
85306 if( (pIn1->flags & MEM_Int)==0 ){
85307 applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
 
85308 if( (pIn1->flags & MEM_Int)==0 ){
85309 VdbeBranchTaken(1, 2);
85310 if( pOp->p2==0 ){
85311 rc = SQLITE_MISMATCH;
85312 goto abort_due_to_error;
85313 }else{
85314 goto jump_to_p2;
85315 }
85316 }
85317 }
85318 VdbeBranchTaken(0, 2);
85319 MemSetTypeFlag(pIn1, MEM_Int);
85320 break;
85321 }
85322
85323 #ifndef SQLITE_OMIT_FLOATING_POINT
@@ -85390,20 +85488,19 @@
85488 if( pOp->p5 & SQLITE_NULLEQ ){
85489 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
85490 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
85491 ** or not both operands are null.
85492 */
 
85493 assert( (flags1 & MEM_Cleared)==0 );
85494 assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );
85495 testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );
85496 if( (flags1&flags3&MEM_Null)!=0
85497 && (flags3&MEM_Cleared)==0
85498 ){
85499 res = 0; /* Operands are equal */
85500 }else{
85501 res = ((flags3 & MEM_Null) ? -1 : +1); /* Operands are not equal */
85502 }
85503 }else{
85504 /* SQLITE_NULLEQ is clear and at least one operand is NULL,
85505 ** then the result is always NULL.
85506 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
@@ -85517,11 +85614,11 @@
85614 memAboutToChange(p, pOut);
85615 MemSetTypeFlag(pOut, MEM_Int);
85616 pOut->u.i = res2;
85617 REGISTER_TRACE(pOp->p2, pOut);
85618 }else{
85619 VdbeBranchTaken(res2!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
85620 if( res2 ){
85621 goto jump_to_p2;
85622 }
85623 }
85624 break;
@@ -87078,10 +87175,11 @@
87175 pCx->nullRow = 1;
87176 pCx->isEphemeral = 1;
87177 pCx->pKeyInfo = pOrig->pKeyInfo;
87178 pCx->isTable = pOrig->isTable;
87179 pCx->pgnoRoot = pOrig->pgnoRoot;
87180 pCx->isOrdered = pOrig->isOrdered;
87181 rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
87182 pCx->pKeyInfo, pCx->uc.pCursor);
87183 /* The sqlite3BtreeCursor() routine can only fail for the first cursor
87184 ** opened for a database. Since there is already an open cursor when this
87185 ** opcode is run, the sqlite3BtreeCursor() cannot fail */
@@ -88586,22 +88684,18 @@
88684 sqlite3_search_count--;
88685 #endif
88686 p->aCounter[SQLITE_STMTSTATUS_SORT]++;
88687 /* Fall through into OP_Rewind */
88688 }
88689 /* Opcode: Rewind P1 P2 * * *
88690 **
88691 ** The next use of the Rowid or Column or Next instruction for P1
88692 ** will refer to the first entry in the database table or index.
88693 ** If the table or index is empty, jump immediately to P2.
88694 ** If the table or index is not empty, fall through to the following
88695 ** instruction.
88696 **
 
 
 
 
88697 ** This opcode leaves the cursor configured to move in forward order,
88698 ** from the beginning toward the end. In other words, the cursor is
88699 ** configured to use Next, not Prev.
88700 */
88701 case OP_Rewind: { /* jump */
@@ -88608,10 +88702,11 @@
88702 VdbeCursor *pC;
88703 BtCursor *pCrsr;
88704 int res;
88705
88706 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
88707 assert( pOp->p5==0 );
88708 pC = p->apCsr[pOp->p1];
88709 assert( pC!=0 );
88710 assert( isSorter(pC)==(pOp->opcode==OP_SorterSort) );
88711 res = 1;
88712 #ifdef SQLITE_DEBUG
@@ -88622,13 +88717,10 @@
88717 }else{
88718 assert( pC->eCurType==CURTYPE_BTREE );
88719 pCrsr = pC->uc.pCursor;
88720 assert( pCrsr );
88721 rc = sqlite3BtreeFirst(pCrsr, &res);
 
 
 
88722 pC->deferredMoveto = 0;
88723 pC->cacheStatus = CACHE_STALE;
88724 }
88725 if( rc ) goto abort_due_to_error;
88726 pC->nullRow = (u8)res;
@@ -90006,10 +90098,11 @@
90098 assert( pOp->p3==0 || pOp->opcode==OP_AggValue );
90099 pMem = &aMem[pOp->p1];
90100 assert( (pMem->flags & ~(MEM_Null|MEM_Agg))==0 );
90101 #ifndef SQLITE_OMIT_WINDOWFUNC
90102 if( pOp->p3 ){
90103 memAboutToChange(p, &aMem[pOp->p3]);
90104 rc = sqlite3VdbeMemAggValue(pMem, &aMem[pOp->p3], pOp->p4.pFunc);
90105 pMem = &aMem[pOp->p3];
90106 }else
90107 #endif
90108 {
@@ -95424,10 +95517,14 @@
95517 assert( pExpr->x.pSelect==0 );
95518 pOrig = pEList->a[j].pExpr;
95519 if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){
95520 sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs);
95521 return WRC_Abort;
95522 }
95523 if( (pNC->ncFlags&NC_AllowWin)==0 && ExprHasProperty(pOrig, EP_Win) ){
95524 sqlite3ErrorMsg(pParse, "misuse of aliased window function %s",zAs);
95525 return WRC_Abort;
95526 }
95527 if( sqlite3ExprVectorSize(pOrig)!=1 ){
95528 sqlite3ErrorMsg(pParse, "row value misused");
95529 return WRC_Abort;
95530 }
@@ -95715,10 +95812,11 @@
95812 int is_agg = 0; /* True if is an aggregate function */
95813 int nId; /* Number of characters in function name */
95814 const char *zId; /* The function name. */
95815 FuncDef *pDef; /* Information about the function */
95816 u8 enc = ENC(pParse->db); /* The database encoding */
95817 int savedAllowFlags = (pNC->ncFlags & (NC_AllowAgg | NC_AllowWin));
95818
95819 assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
95820 zId = pExpr->u.zToken;
95821 nId = sqlite3Strlen30(zId);
95822 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
@@ -95836,12 +95934,15 @@
95934 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
95935 nId, zId);
95936 pNC->nErr++;
95937 }
95938 if( is_agg ){
95939 /* Window functions may not be arguments of aggregate functions.
95940 ** Or arguments of other window functions. But aggregate functions
95941 ** may be arguments for window functions. */
95942 #ifndef SQLITE_OMIT_WINDOWFUNC
95943 pNC->ncFlags &= ~(NC_AllowWin | (!pExpr->y.pWin ? NC_AllowAgg : 0));
95944 #else
95945 pNC->ncFlags &= ~NC_AllowAgg;
95946 #endif
95947 }
95948 }
@@ -95858,11 +95959,11 @@
95959 || 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
95960 ){
95961 pExpr->y.pWin->pNextWin = pSel->pWin;
95962 pSel->pWin = pExpr->y.pWin;
95963 }
95964 pNC->ncFlags |= NC_HasWin;
95965 }else
95966 #endif /* SQLITE_OMIT_WINDOWFUNC */
95967 {
95968 NameContext *pNC2 = pNC;
95969 pExpr->op = TK_AGG_FUNCTION;
@@ -95876,12 +95977,12 @@
95977 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
95978 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
95979 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
95980
95981 }
 
95982 }
95983 pNC->ncFlags |= savedAllowFlags;
95984 }
95985 /* FIX ME: Compute pExpr->affinity based on the expected return
95986 ** type of the function
95987 */
95988 return WRC_Prune;
@@ -96414,11 +96515,11 @@
96515
96516 /* Recursively resolve names in all subqueries
96517 */
96518 for(i=0; i<p->pSrc->nSrc; i++){
96519 struct SrcList_item *pItem = &p->pSrc->a[i];
96520 if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
96521 NameContext *pNC; /* Used to iterate name contexts */
96522 int nRef = 0; /* Refcount for pOuterNC and outer contexts */
96523 const char *zSavedContext = pParse->zAuthContext;
96524
96525 /* Count the total number of references to pOuterNC and all of its
@@ -96638,12 +96739,12 @@
96739 ){
96740 u16 savedHasAgg;
96741 Walker w;
96742
96743 if( pExpr==0 ) return SQLITE_OK;
96744 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
96745 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
96746 w.pParse = pNC->pParse;
96747 w.xExprCallback = resolveExprStep;
96748 w.xSelectCallback = resolveSelectStep;
96749 w.xSelectCallback2 = 0;
96750 w.u.pNC = pNC;
@@ -96655,13 +96756,15 @@
96756 #endif
96757 sqlite3WalkExpr(&w, pExpr);
96758 #if SQLITE_MAX_EXPR_DEPTH>0
96759 w.pParse->nHeight -= pExpr->nHeight;
96760 #endif
96761 assert( EP_Agg==NC_HasAgg );
96762 assert( EP_Win==NC_HasWin );
96763 testcase( pNC->ncFlags & NC_HasAgg );
96764 testcase( pNC->ncFlags & NC_HasWin );
96765 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
96766 pNC->ncFlags |= savedHasAgg;
96767 return pNC->nErr>0 || w.pParse->nErr>0;
96768 }
96769
96770 /*
@@ -101788,10 +101891,21 @@
101891 ** be non-NULL, then the LEFT JOIN can be safely converted into an
101892 ** ordinary join.
101893 */
101894 SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
101895 Walker w;
101896 p = sqlite3ExprSkipCollate(p);
101897 while( p ){
101898 if( p->op==TK_NOTNULL ){
101899 p = p->pLeft;
101900 }else if( p->op==TK_AND ){
101901 if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
101902 p = p->pRight;
101903 }else{
101904 break;
101905 }
101906 }
101907 w.xExprCallback = impliesNotNullRow;
101908 w.xSelectCallback = 0;
101909 w.xSelectCallback2 = 0;
101910 w.eCode = 0;
101911 w.u.iCur = iTab;
@@ -106961,10 +107075,11 @@
107075 if( zSql==0 ){
107076 /* This can result either from an OOM or because the formatted string
107077 ** exceeds SQLITE_LIMIT_LENGTH. In the latter case, we need to set
107078 ** an error */
107079 if( !db->mallocFailed ) pParse->rc = SQLITE_TOOBIG;
107080 pParse->nErr++;
107081 return;
107082 }
107083 pParse->nested++;
107084 memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
107085 memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
@@ -108101,11 +108216,12 @@
108216 && pCol
108217 && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
108218 && sortOrder!=SQLITE_SO_DESC
108219 ){
108220 if( IN_RENAME_OBJECT && pList ){
108221 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[0].pExpr);
108222 sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pCExpr);
108223 }
108224 pTab->iPKey = iCol;
108225 pTab->keyConf = (u8)onError;
108226 assert( autoInc==0 || autoInc==1 );
108227 pTab->tabFlags |= autoInc*TF_Autoincrement;
@@ -109850,17 +109966,17 @@
109966
109967 assert( pTab!=0 );
109968 assert( pParse->nErr==0 );
109969 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
109970 && db->init.busy==0
109971 && pTblName!=0
109972 #if SQLITE_USER_AUTHENTICATION
109973 && sqlite3UserAuthTable(pTab->zName)==0
109974 #endif
109975 #ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX
109976 && sqlite3StrICmp(&pTab->zName[7],"master")!=0
109977 #endif
 
109978 ){
109979 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
109980 goto exit_create_index;
109981 }
109982 #ifndef SQLITE_OMIT_VIEW
@@ -109960,10 +110076,11 @@
110076 if( pList==0 ) goto exit_create_index;
110077 assert( pList->nExpr==1 );
110078 sqlite3ExprListSetSortOrder(pList, sortOrder);
110079 }else{
110080 sqlite3ExprListCheckLength(pParse, pList, "index");
110081 if( pParse->nErr ) goto exit_create_index;
110082 }
110083
110084 /* Figure out how many bytes of space are required to store explicitly
110085 ** specified collation sequence names.
110086 */
@@ -109978,10 +110095,11 @@
110095 /*
110096 ** Allocate the index structure.
110097 */
110098 nName = sqlite3Strlen30(zName);
110099 nExtraCol = pPk ? pPk->nKeyCol : 1;
110100 assert( pList->nExpr + nExtraCol <= 32767 /* Fits in i16 */ );
110101 pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,
110102 nName + nExtra + 1, &zExtra);
110103 if( db->mallocFailed ){
110104 goto exit_create_index;
110105 }
@@ -119232,10 +119350,13 @@
119350 void (*xValue)(sqlite3_context*),
119351 void (*xInv)(sqlite3_context*,int,sqlite3_value**),
119352 void(*xDestroy)(void*));
119353 /* Version 3.26.0 and later */
119354 const char *(*normalized_sql)(sqlite3_stmt*);
119355 /* Version 3.28.0 and later */
119356 int (*stmt_isexplain)(sqlite3_stmt*);
119357 int (*value_frombind)(sqlite3_value*);
119358 };
119359
119360 /*
119361 ** This is the function signature used for all extension entry points. It
119362 ** is also defined in the file "loadext.c".
@@ -119521,10 +119642,13 @@
119642 #define sqlite3_str_value sqlite3_api->str_value
119643 /* Version 3.25.0 and later */
119644 #define sqlite3_create_window_function sqlite3_api->create_window_function
119645 /* Version 3.26.0 and later */
119646 #define sqlite3_normalized_sql sqlite3_api->normalized_sql
119647 /* Version 3.28.0 and later */
119648 #define sqlite3_stmt_isexplain sqlite3_api->isexplain
119649 #define sqlite3_value_frombind sqlite3_api->frombind
119650 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
119651
119652 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
119653 /* This case when the file really is being compiled as a loadable
119654 ** extension */
@@ -133859,19 +133983,20 @@
133983 */
133984 SQLITE_PRIVATE int sqlite3RunVacuum(
133985 char **pzErrMsg, /* Write error message here */
133986 sqlite3 *db, /* Database connection */
133987 int iDb, /* Which attached DB to vacuum */
133988 sqlite3_value *pOut /* Write results here, if not NULL. VACUUM INTO */
133989 ){
133990 int rc = SQLITE_OK; /* Return code from service routines */
133991 Btree *pMain; /* The database being vacuumed */
133992 Btree *pTemp; /* The temporary database we vacuum into */
133993 u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
133994 u64 saved_flags; /* Saved value of db->flags */
133995 int saved_nChange; /* Saved value of db->nChange */
133996 int saved_nTotalChange; /* Saved value of db->nTotalChange */
133997 u32 saved_openFlags; /* Saved value of db->openFlags */
133998 u8 saved_mTrace; /* Saved trace settings */
133999 Db *pDb = 0; /* Database to detach at end of vacuum */
134000 int isMemDb; /* True if vacuuming a :memory: database */
134001 int nRes; /* Bytes of reserved space at the end of each page */
134002 int nDb; /* Number of attached databases */
@@ -133884,16 +134009,19 @@
134009 }
134010 if( db->nVdbeActive>1 ){
134011 sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
134012 return SQLITE_ERROR;
134013 }
134014 saved_openFlags = db->openFlags;
134015 if( pOut ){
134016 if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
134017 sqlite3SetString(pzErrMsg, db, "non-text filename");
134018 return SQLITE_ERROR;
134019 }
134020 zOut = (const char*)sqlite3_value_text(pOut);
134021 db->openFlags &= ~SQLITE_OPEN_READONLY;
134022 db->openFlags |= SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
134023 }else{
134024 zOut = "";
134025 }
134026
134027 /* Save the current value of the database flags so that it can be
@@ -133928,10 +134056,11 @@
134056 ** time to parse and run the PRAGMA to turn journalling off than it does
134057 ** to write the journal header file.
134058 */
134059 nDb = db->nDb;
134060 rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
134061 db->openFlags = saved_openFlags;
134062 if( rc!=SQLITE_OK ) goto end_of_vacuum;
134063 assert( (db->nDb-1)==nDb );
134064 pDb = &db->aDb[nDb];
134065 assert( strcmp(pDb->zDbSName,"vacuum_db")==0 );
134066 pTemp = pDb->pBt;
@@ -138164,12 +138293,13 @@
138293 continue;
138294 #else
138295 u32 x = pLevel->iLikeRepCntr;
138296 if( x>0 ){
138297 skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1));
138298 VdbeCoverageIf(v, (x&1)==1);
138299 VdbeCoverageIf(v, (x&1)==0);
138300 }
 
138301 #endif
138302 }
138303 #ifdef WHERETRACE_ENABLED /* 0xffff */
138304 if( sqlite3WhereTrace ){
138305 VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d",
@@ -143189,15 +143319,15 @@
143319 WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
143320 WHERETRACE(0x40, (" VirtualOne: all usable\n"));
143321 rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
143322
143323 /* If the call to xBestIndex() with all terms enabled produced a plan
143324 ** that does not require any source tables (IOW: a plan with mBest==0)
143325 ** and does not use an IN(...) operator, then there is no point in making
143326 ** any further calls to xBestIndex() since they will all return the same
143327 ** result (if the xBestIndex() implementation is sane). */
143328 if( rc==SQLITE_OK && ((mBest = (pNew->prereq & ~mPrereq))!=0 || bIn) ){
143329 int seenZero = 0; /* True if a plan with no prereqs seen */
143330 int seenZeroNoIN = 0; /* Plan with no prereqs and no IN(...) seen */
143331 Bitmask mPrev = 0;
143332 Bitmask mBestNoIn = 0;
143333
@@ -145426,10 +145556,100 @@
145556 }
145557 sqlite3_result_int64(pCtx, p->nValue);
145558 }
145559 }
145560
145561 /*
145562 ** Implementation of built-in window function nth_value(). This
145563 ** implementation is used in "slow mode" only - when the EXCLUDE clause
145564 ** is not set to the default value "NO OTHERS".
145565 */
145566 struct NthValueCtx {
145567 i64 nStep;
145568 sqlite3_value *pValue;
145569 };
145570 static void nth_valueStepFunc(
145571 sqlite3_context *pCtx,
145572 int nArg,
145573 sqlite3_value **apArg
145574 ){
145575 struct NthValueCtx *p;
145576 p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145577 if( p ){
145578 i64 iVal;
145579 switch( sqlite3_value_numeric_type(apArg[1]) ){
145580 case SQLITE_INTEGER:
145581 iVal = sqlite3_value_int64(apArg[1]);
145582 break;
145583 case SQLITE_FLOAT: {
145584 double fVal = sqlite3_value_double(apArg[1]);
145585 if( ((i64)fVal)!=fVal ) goto error_out;
145586 iVal = (i64)fVal;
145587 break;
145588 }
145589 default:
145590 goto error_out;
145591 }
145592 if( iVal<=0 ) goto error_out;
145593
145594 p->nStep++;
145595 if( iVal==p->nStep ){
145596 p->pValue = sqlite3_value_dup(apArg[0]);
145597 if( !p->pValue ){
145598 sqlite3_result_error_nomem(pCtx);
145599 }
145600 }
145601 }
145602 UNUSED_PARAMETER(nArg);
145603 UNUSED_PARAMETER(apArg);
145604 return;
145605
145606 error_out:
145607 sqlite3_result_error(
145608 pCtx, "second argument to nth_value must be a positive integer", -1
145609 );
145610 }
145611 static void nth_valueFinalizeFunc(sqlite3_context *pCtx){
145612 struct NthValueCtx *p;
145613 p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, 0);
145614 if( p && p->pValue ){
145615 sqlite3_result_value(pCtx, p->pValue);
145616 sqlite3_value_free(p->pValue);
145617 p->pValue = 0;
145618 }
145619 }
145620 #define nth_valueInvFunc noopStepFunc
145621 #define nth_valueValueFunc noopValueFunc
145622
145623 static void first_valueStepFunc(
145624 sqlite3_context *pCtx,
145625 int nArg,
145626 sqlite3_value **apArg
145627 ){
145628 struct NthValueCtx *p;
145629 p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145630 if( p && p->pValue==0 ){
145631 p->pValue = sqlite3_value_dup(apArg[0]);
145632 if( !p->pValue ){
145633 sqlite3_result_error_nomem(pCtx);
145634 }
145635 }
145636 UNUSED_PARAMETER(nArg);
145637 UNUSED_PARAMETER(apArg);
145638 }
145639 static void first_valueFinalizeFunc(sqlite3_context *pCtx){
145640 struct NthValueCtx *p;
145641 p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145642 if( p && p->pValue ){
145643 sqlite3_result_value(pCtx, p->pValue);
145644 sqlite3_value_free(p->pValue);
145645 p->pValue = 0;
145646 }
145647 }
145648 #define first_valueInvFunc noopStepFunc
145649 #define first_valueValueFunc noopValueFunc
145650
145651 /*
145652 ** Implementation of built-in window function rank(). Assumes that
145653 ** the window frame has been set to:
145654 **
145655 ** RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
@@ -145461,75 +145681,90 @@
145681
145682 /*
145683 ** Implementation of built-in window function percent_rank(). Assumes that
145684 ** the window frame has been set to:
145685 **
145686 ** GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
145687 */
145688 static void percent_rankStepFunc(
145689 sqlite3_context *pCtx,
145690 int nArg,
145691 sqlite3_value **apArg
145692 ){
145693 struct CallCount *p;
145694 UNUSED_PARAMETER(nArg); assert( nArg==0 );
145695 UNUSED_PARAMETER(apArg);
145696 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145697 if( p ){
145698 p->nTotal++;
145699 }
145700 }
145701 static void percent_rankInvFunc(
145702 sqlite3_context *pCtx,
145703 int nArg,
145704 sqlite3_value **apArg
145705 ){
145706 struct CallCount *p;
145707 UNUSED_PARAMETER(nArg); assert( nArg==0 );
145708 UNUSED_PARAMETER(apArg);
145709 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145710 p->nStep++;
 
 
 
 
 
 
 
 
145711 }
145712 static void percent_rankValueFunc(sqlite3_context *pCtx){
145713 struct CallCount *p;
145714 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145715 if( p ){
145716 p->nValue = p->nStep;
145717 if( p->nTotal>1 ){
145718 double r = (double)p->nValue / (double)(p->nTotal-1);
145719 sqlite3_result_double(pCtx, r);
145720 }else{
145721 sqlite3_result_double(pCtx, 0.0);
145722 }
 
145723 }
145724 }
145725 #define percent_rankFinalizeFunc percent_rankValueFunc
145726
145727 /*
145728 ** Implementation of built-in window function cume_dist(). Assumes that
145729 ** the window frame has been set to:
145730 **
145731 ** GROUPS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING
145732 */
145733 static void cume_distStepFunc(
145734 sqlite3_context *pCtx,
145735 int nArg,
145736 sqlite3_value **apArg
145737 ){
145738 struct CallCount *p;
145739 UNUSED_PARAMETER(nArg); assert( nArg==0 );
145740 UNUSED_PARAMETER(apArg);
145741 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145742 if( p ){
145743 p->nTotal++;
145744 }
145745 }
145746 static void cume_distInvFunc(
145747 sqlite3_context *pCtx,
145748 int nArg,
145749 sqlite3_value **apArg
145750 ){
145751 struct CallCount *p;
145752 UNUSED_PARAMETER(nArg); assert( nArg==0 );
145753 UNUSED_PARAMETER(apArg);
145754 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145755 p->nStep++;
 
 
 
 
 
145756 }
145757 static void cume_distValueFunc(sqlite3_context *pCtx){
145758 struct CallCount *p;
145759 p = (struct CallCount*)sqlite3_aggregate_context(pCtx, 0);
145760 if( p ){
145761 double r = (double)(p->nStep) / (double)(p->nTotal);
145762 sqlite3_result_double(pCtx, r);
145763 }
145764 }
145765 #define cume_distFinalizeFunc cume_distValueFunc
145766
145767 /*
145768 ** Context object for ntile() window function.
145769 */
145770 struct NtileCtx {
@@ -145540,44 +145775,54 @@
145775
145776 /*
145777 ** Implementation of ntile(). This assumes that the window frame has
145778 ** been coerced to:
145779 **
145780 ** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING
145781 */
145782 static void ntileStepFunc(
145783 sqlite3_context *pCtx,
145784 int nArg,
145785 sqlite3_value **apArg
145786 ){
145787 struct NtileCtx *p;
145788 assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145789 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145790 if( p ){
145791 if( p->nTotal==0 ){
145792 p->nParam = sqlite3_value_int64(apArg[0]);
 
145793 if( p->nParam<=0 ){
145794 sqlite3_result_error(
145795 pCtx, "argument of ntile must be a positive integer", -1
145796 );
145797 }
145798 }
145799 p->nTotal++;
145800 }
145801 }
145802 static void ntileInvFunc(
145803 sqlite3_context *pCtx,
145804 int nArg,
145805 sqlite3_value **apArg
145806 ){
145807 struct NtileCtx *p;
145808 assert( nArg==1 ); UNUSED_PARAMETER(nArg);
145809 UNUSED_PARAMETER(apArg);
145810 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145811 p->iRow++;
145812 }
145813 static void ntileValueFunc(sqlite3_context *pCtx){
145814 struct NtileCtx *p;
145815 p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
145816 if( p && p->nParam>0 ){
145817 int nSize = (p->nTotal / p->nParam);
145818 if( nSize==0 ){
145819 sqlite3_result_int64(pCtx, p->iRow+1);
145820 }else{
145821 i64 nLarge = p->nTotal - p->nParam*nSize;
145822 i64 iSmall = nLarge*(nSize+1);
145823 i64 iRow = p->iRow;
145824
145825 assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );
145826
145827 if( iRow<iSmall ){
145828 sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
@@ -145585,10 +145830,11 @@
145830 sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
145831 }
145832 }
145833 }
145834 }
145835 #define ntileFinalizeFunc ntileValueFunc
145836
145837 /*
145838 ** Context object for last_value() window function.
145839 */
145840 struct LastValueCtx {
@@ -145634,11 +145880,11 @@
145880 }
145881 }
145882 }
145883 static void last_valueValueFunc(sqlite3_context *pCtx){
145884 struct LastValueCtx *p;
145885 p = (struct LastValueCtx*)sqlite3_aggregate_context(pCtx, 0);
145886 if( p && p->pVal ){
145887 sqlite3_result_value(pCtx, p->pVal);
145888 }
145889 }
145890 static void last_valueFinalizeFunc(sqlite3_context *pCtx){
@@ -145724,25 +145970,36 @@
145970 SQLITE_PRIVATE void sqlite3WindowFunctions(void){
145971 static FuncDef aWindowFuncs[] = {
145972 WINDOWFUNCX(row_number, 0, 0),
145973 WINDOWFUNCX(dense_rank, 0, 0),
145974 WINDOWFUNCX(rank, 0, 0),
145975 WINDOWFUNCALL(percent_rank, 0, 0),
145976 WINDOWFUNCALL(cume_dist, 0, 0),
145977 WINDOWFUNCALL(ntile, 1, 0),
145978 WINDOWFUNCALL(last_value, 1, 0),
145979 WINDOWFUNCALL(nth_value, 2, 0),
145980 WINDOWFUNCALL(first_value, 1, 0),
145981 WINDOWFUNCNOOP(lead, 1, 0),
145982 WINDOWFUNCNOOP(lead, 2, 0),
145983 WINDOWFUNCNOOP(lead, 3, 0),
145984 WINDOWFUNCNOOP(lag, 1, 0),
145985 WINDOWFUNCNOOP(lag, 2, 0),
145986 WINDOWFUNCNOOP(lag, 3, 0),
145987 };
145988 sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
145989 }
145990
145991 static Window *windowFind(Parse *pParse, Window *pList, const char *zName){
145992 Window *p;
145993 for(p=pList; p; p=p->pNextWin){
145994 if( sqlite3StrICmp(p->zName, zName)==0 ) break;
145995 }
145996 if( p==0 ){
145997 sqlite3ErrorMsg(pParse, "no such window: %s", zName);
145998 }
145999 return p;
146000 }
146001
146002 /*
146003 ** This function is called immediately after resolving the function name
146004 ** for a window function within a SELECT statement. Argument pList is a
146005 ** linked list of WINDOW definitions for the current SELECT statement.
@@ -145763,52 +146020,70 @@
146020 Parse *pParse,
146021 Window *pList, /* List of named windows for this SELECT */
146022 Window *pWin, /* Window frame to update */
146023 FuncDef *pFunc /* Window function definition */
146024 ){
146025 if( pWin->zName && pWin->eFrmType==0 ){
146026 Window *p = windowFind(pParse, pList, pWin->zName);
146027 if( p==0 ) return;
 
 
 
 
 
 
146028 pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
146029 pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
146030 pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
146031 pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
146032 pWin->eStart = p->eStart;
146033 pWin->eEnd = p->eEnd;
146034 pWin->eFrmType = p->eFrmType;
146035 pWin->eExclude = p->eExclude;
146036 }else{
146037 sqlite3WindowChain(pParse, pWin, pList);
146038 }
146039 if( (pWin->eFrmType==TK_RANGE)
146040 && (pWin->pStart || pWin->pEnd)
146041 && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1)
146042 ){
146043 sqlite3ErrorMsg(pParse,
146044 "RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression"
146045 );
146046 }else
146047 if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
146048 sqlite3 *db = pParse->db;
146049 if( pWin->pFilter ){
146050 sqlite3ErrorMsg(pParse,
146051 "FILTER clause may only be used with aggregate window functions"
146052 );
146053 }else{
146054 struct WindowUpdate {
146055 const char *zFunc;
146056 int eFrmType;
146057 int eStart;
146058 int eEnd;
146059 } aUp[] = {
146060 { row_numberName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT },
146061 { dense_rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT },
146062 { rankName, TK_RANGE, TK_UNBOUNDED, TK_CURRENT },
146063 { percent_rankName, TK_GROUPS, TK_CURRENT, TK_UNBOUNDED },
146064 { cume_distName, TK_GROUPS, TK_FOLLOWING, TK_UNBOUNDED },
146065 { ntileName, TK_ROWS, TK_CURRENT, TK_UNBOUNDED },
146066 { leadName, TK_ROWS, TK_UNBOUNDED, TK_UNBOUNDED },
146067 { lagName, TK_ROWS, TK_UNBOUNDED, TK_CURRENT },
146068 };
146069 int i;
146070 for(i=0; i<ArraySize(aUp); i++){
146071 if( pFunc->zName==aUp[i].zFunc ){
146072 sqlite3ExprDelete(db, pWin->pStart);
146073 sqlite3ExprDelete(db, pWin->pEnd);
146074 pWin->pEnd = pWin->pStart = 0;
146075 pWin->eFrmType = aUp[i].eFrmType;
146076 pWin->eStart = aUp[i].eStart;
146077 pWin->eEnd = aUp[i].eEnd;
146078 pWin->eExclude = 0;
146079 if( pWin->eStart==TK_FOLLOWING ){
146080 pWin->pStart = sqlite3Expr(db, TK_INTEGER, "1");
146081 }
146082 break;
146083 }
146084 }
146085 }
146086 }
146087 pWin->pFunc = pFunc;
146088 }
146089
@@ -146009,10 +146284,11 @@
146284
146285 /* Assign a cursor number for the ephemeral table used to buffer rows.
146286 ** The OpenEphemeral instruction is coded later, after it is known how
146287 ** many columns the table will have. */
146288 pMWin->iEphCsr = pParse->nTab++;
146289 pParse->nTab += 3;
146290
146291 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pEList, &pSublist);
146292 selectWindowRewriteEList(pParse, pMWin, pSrc, p->pOrderBy, &pSublist);
146293 pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);
146294
@@ -146064,10 +146340,13 @@
146340 p->selFlags &= ~SF_Aggregate;
146341 sqlite3SelectPrep(pParse, pSub, 0);
146342 }
146343
146344 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
146345 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+1, pMWin->iEphCsr);
146346 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+2, pMWin->iEphCsr);
146347 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->iEphCsr+3, pMWin->iEphCsr);
146348 }else{
146349 sqlite3SelectDelete(db, pSub);
146350 }
146351 if( db->mallocFailed ) rc = SQLITE_NOMEM;
146352 }
@@ -146084,10 +146363,11 @@
146363 sqlite3ExprListDelete(db, p->pPartition);
146364 sqlite3ExprListDelete(db, p->pOrderBy);
146365 sqlite3ExprDelete(db, p->pEnd);
146366 sqlite3ExprDelete(db, p->pStart);
146367 sqlite3DbFree(db, p->zName);
146368 sqlite3DbFree(db, p->zBase);
146369 sqlite3DbFree(db, p);
146370 }
146371 }
146372
146373 /*
@@ -146120,34 +146400,32 @@
146400 /*
146401 ** Allocate and return a new Window object describing a Window Definition.
146402 */
146403 SQLITE_PRIVATE Window *sqlite3WindowAlloc(
146404 Parse *pParse, /* Parsing context */
146405 int eType, /* Frame type. TK_RANGE, TK_ROWS, TK_GROUPS, or 0 */
146406 int eStart, /* Start type: CURRENT, PRECEDING, FOLLOWING, UNBOUNDED */
146407 Expr *pStart, /* Start window size if TK_PRECEDING or FOLLOWING */
146408 int eEnd, /* End type: CURRENT, FOLLOWING, TK_UNBOUNDED, PRECEDING */
146409 Expr *pEnd, /* End window size if TK_FOLLOWING or PRECEDING */
146410 u8 eExclude /* EXCLUDE clause */
146411 ){
146412 Window *pWin = 0;
146413 int bImplicitFrame = 0;
146414
146415 /* Parser assures the following: */
146416 assert( eType==0 || eType==TK_RANGE || eType==TK_ROWS || eType==TK_GROUPS );
146417 assert( eStart==TK_CURRENT || eStart==TK_PRECEDING
146418 || eStart==TK_UNBOUNDED || eStart==TK_FOLLOWING );
146419 assert( eEnd==TK_CURRENT || eEnd==TK_FOLLOWING
146420 || eEnd==TK_UNBOUNDED || eEnd==TK_PRECEDING );
146421 assert( (eStart==TK_PRECEDING || eStart==TK_FOLLOWING)==(pStart!=0) );
146422 assert( (eEnd==TK_FOLLOWING || eEnd==TK_PRECEDING)==(pEnd!=0) );
146423
146424 if( eType==0 ){
146425 bImplicitFrame = 1;
146426 eType = TK_RANGE;
 
 
 
 
146427 }
146428
146429 /* Additionally, the
146430 ** starting boundary type may not occur earlier in the following list than
146431 ** the ending boundary type:
@@ -146163,28 +146441,96 @@
146441 ** frame boundary.
146442 */
146443 if( (eStart==TK_CURRENT && eEnd==TK_PRECEDING)
146444 || (eStart==TK_FOLLOWING && (eEnd==TK_PRECEDING || eEnd==TK_CURRENT))
146445 ){
146446 sqlite3ErrorMsg(pParse, "unsupported frame specification");
146447 goto windowAllocErr;
146448 }
146449
146450 pWin = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
146451 if( pWin==0 ) goto windowAllocErr;
146452 pWin->eFrmType = eType;
146453 pWin->eStart = eStart;
146454 pWin->eEnd = eEnd;
146455 if( eExclude==0 && OptimizationDisabled(pParse->db, SQLITE_WindowFunc) ){
146456 eExclude = TK_NO;
146457 }
146458 pWin->eExclude = eExclude;
146459 pWin->bImplicitFrame = bImplicitFrame;
146460 pWin->pEnd = sqlite3WindowOffsetExpr(pParse, pEnd);
146461 pWin->pStart = sqlite3WindowOffsetExpr(pParse, pStart);
146462 return pWin;
146463
146464 windowAllocErr:
146465 sqlite3ExprDelete(pParse->db, pEnd);
146466 sqlite3ExprDelete(pParse->db, pStart);
146467 return 0;
146468 }
146469
146470 /*
146471 ** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
146472 ** pWin. Also, if parameter pBase is not NULL, set pWin->zBase to the
146473 ** equivalent nul-terminated string.
146474 */
146475 SQLITE_PRIVATE Window *sqlite3WindowAssemble(
146476 Parse *pParse,
146477 Window *pWin,
146478 ExprList *pPartition,
146479 ExprList *pOrderBy,
146480 Token *pBase
146481 ){
146482 if( pWin ){
146483 pWin->pPartition = pPartition;
146484 pWin->pOrderBy = pOrderBy;
146485 if( pBase ){
146486 pWin->zBase = sqlite3DbStrNDup(pParse->db, pBase->z, pBase->n);
146487 }
146488 }else{
146489 sqlite3ExprListDelete(pParse->db, pPartition);
146490 sqlite3ExprListDelete(pParse->db, pOrderBy);
146491 }
146492 return pWin;
146493 }
146494
146495 /*
146496 ** Window *pWin has just been created from a WINDOW clause. Tokne pBase
146497 ** is the base window. Earlier windows from the same WINDOW clause are
146498 ** stored in the linked list starting at pWin->pNextWin. This function
146499 ** either updates *pWin according to the base specification, or else
146500 ** leaves an error in pParse.
146501 */
146502 SQLITE_PRIVATE void sqlite3WindowChain(Parse *pParse, Window *pWin, Window *pList){
146503 if( pWin->zBase ){
146504 sqlite3 *db = pParse->db;
146505 Window *pExist = windowFind(pParse, pList, pWin->zBase);
146506 if( pExist ){
146507 const char *zErr = 0;
146508 /* Check for errors */
146509 if( pWin->pPartition ){
146510 zErr = "PARTITION clause";
146511 }else if( pExist->pOrderBy && pWin->pOrderBy ){
146512 zErr = "ORDER BY clause";
146513 }else if( pExist->bImplicitFrame==0 ){
146514 zErr = "frame specification";
146515 }
146516 if( zErr ){
146517 sqlite3ErrorMsg(pParse,
146518 "cannot override %s of window: %s", zErr, pWin->zBase
146519 );
146520 }else{
146521 pWin->pPartition = sqlite3ExprListDup(db, pExist->pPartition, 0);
146522 if( pExist->pOrderBy ){
146523 assert( pWin->pOrderBy==0 );
146524 pWin->pOrderBy = sqlite3ExprListDup(db, pExist->pOrderBy, 0);
146525 }
146526 sqlite3DbFree(db, pWin->zBase);
146527 pWin->zBase = 0;
146528 }
146529 }
146530 }
146531 }
146532
146533 /*
146534 ** Attach window object pWin to expression p.
146535 */
146536 SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){
@@ -146210,13 +146556,14 @@
146556 /*
146557 ** Return 0 if the two window objects are identical, or non-zero otherwise.
146558 ** Identical window objects can be processed in a single scan.
146559 */
146560 SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2){
146561 if( p1->eFrmType!=p2->eFrmType ) return 1;
146562 if( p1->eStart!=p2->eStart ) return 1;
146563 if( p1->eEnd!=p2->eEnd ) return 1;
146564 if( p1->eExclude!=p2->eExclude ) return 1;
146565 if( sqlite3ExprCompare(pParse, p1->pStart, p2->pStart, -1) ) return 1;
146566 if( sqlite3ExprCompare(pParse, p1->pEnd, p2->pEnd, -1) ) return 1;
146567 if( sqlite3ExprListCompare(p1->pPartition, p2->pPartition, -1) ) return 1;
146568 if( sqlite3ExprListCompare(p1->pOrderBy, p2->pOrderBy, -1) ) return 1;
146569 return 0;
@@ -146229,16 +146576,31 @@
146576 ** and initialize registers and cursors used by sqlite3WindowCodeStep().
146577 */
146578 SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Window *pMWin){
146579 Window *pWin;
146580 Vdbe *v = sqlite3GetVdbe(pParse);
146581
146582 /* Allocate registers to use for PARTITION BY values, if any. Initialize
146583 ** said registers to NULL. */
146584 if( pMWin->pPartition ){
146585 int nExpr = pMWin->pPartition->nExpr;
146586 pMWin->regPart = pParse->nMem+1;
146587 pParse->nMem += nExpr;
146588 sqlite3VdbeAddOp3(v, OP_Null, 0, pMWin->regPart, pMWin->regPart+nExpr-1);
146589 }
146590
146591 pMWin->regOne = ++pParse->nMem;
146592 sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regOne);
146593
146594 if( pMWin->eExclude ){
146595 pMWin->regStartRowid = ++pParse->nMem;
146596 pMWin->regEndRowid = ++pParse->nMem;
146597 pMWin->csrApp = pParse->nTab++;
146598 sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid);
146599 sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid);
146600 sqlite3VdbeAddOp2(v, OP_OpenDup, pMWin->csrApp, pMWin->iEphCsr);
146601 return;
146602 }
146603
146604 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146605 FuncDef *p = pWin->pFunc;
146606 if( (p->funcFlags & SQLITE_FUNC_MINMAX) && pWin->eStart!=TK_UNBOUNDED ){
@@ -146263,50 +146625,71 @@
146625 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
146626 }
146627 else if( p->zName==nth_valueName || p->zName==first_valueName ){
146628 /* Allocate two registers at pWin->regApp. These will be used to
146629 ** store the start and end index of the current frame. */
 
146630 pWin->regApp = pParse->nMem+1;
146631 pWin->csrApp = pParse->nTab++;
146632 pParse->nMem += 2;
146633 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146634 }
146635 else if( p->zName==leadName || p->zName==lagName ){
 
146636 pWin->csrApp = pParse->nTab++;
146637 sqlite3VdbeAddOp2(v, OP_OpenDup, pWin->csrApp, pMWin->iEphCsr);
146638 }
146639 }
146640 }
146641
146642 #define WINDOW_STARTING_INT 0
146643 #define WINDOW_ENDING_INT 1
146644 #define WINDOW_NTH_VALUE_INT 2
146645 #define WINDOW_STARTING_NUM 3
146646 #define WINDOW_ENDING_NUM 4
146647
146648 /*
146649 ** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
146650 ** value of the second argument to nth_value() (eCond==2) has just been
146651 ** evaluated and the result left in register reg. This function generates VM
146652 ** code to check that the value is a non-negative integer and throws an
146653 ** exception if it is not.
146654 */
146655 static void windowCheckValue(Parse *pParse, int reg, int eCond){
146656 static const char *azErr[] = {
146657 "frame starting offset must be a non-negative integer",
146658 "frame ending offset must be a non-negative integer",
146659 "second argument to nth_value must be a positive integer",
146660 "frame starting offset must be a non-negative number",
146661 "frame ending offset must be a non-negative number",
146662 };
146663 static int aOp[] = { OP_Ge, OP_Ge, OP_Gt, OP_Ge, OP_Ge };
146664 Vdbe *v = sqlite3GetVdbe(pParse);
146665 int regZero = sqlite3GetTempReg(pParse);
146666 assert( eCond>=0 && eCond<ArraySize(azErr) );
146667 sqlite3VdbeAddOp2(v, OP_Integer, 0, regZero);
146668 if( eCond>=WINDOW_STARTING_NUM ){
146669 int regString = sqlite3GetTempReg(pParse);
146670 sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
146671 sqlite3VdbeAddOp3(v, OP_Ge, regString, sqlite3VdbeCurrentAddr(v)+2, reg);
146672 sqlite3VdbeChangeP5(v, SQLITE_AFF_NUMERIC|SQLITE_JUMPIFNULL);
146673 VdbeCoverage(v);
146674 assert( eCond==3 || eCond==4 );
146675 VdbeCoverageIf(v, eCond==3);
146676 VdbeCoverageIf(v, eCond==4);
146677 }else{
146678 sqlite3VdbeAddOp2(v, OP_MustBeInt, reg, sqlite3VdbeCurrentAddr(v)+2);
146679 VdbeCoverage(v);
146680 assert( eCond==0 || eCond==1 || eCond==2 );
146681 VdbeCoverageIf(v, eCond==0);
146682 VdbeCoverageIf(v, eCond==1);
146683 VdbeCoverageIf(v, eCond==2);
146684 }
146685 sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg);
146686 VdbeCoverageNeverNullIf(v, eCond==0); /* NULL case captured by */
146687 VdbeCoverageNeverNullIf(v, eCond==1); /* the OP_MustBeInt */
146688 VdbeCoverageNeverNullIf(v, eCond==2);
146689 VdbeCoverageNeverNullIf(v, eCond==3); /* NULL case caught by */
146690 VdbeCoverageNeverNullIf(v, eCond==4); /* the OP_Ge */
146691 sqlite3MayAbort(pParse);
146692 sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
146693 sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
146694 sqlite3ReleaseTempReg(pParse, regZero);
146695 }
@@ -146342,41 +146725,32 @@
146725 static void windowAggStep(
146726 Parse *pParse,
146727 Window *pMWin, /* Linked list of window functions */
146728 int csr, /* Read arguments from this cursor */
146729 int bInverse, /* True to invoke xInverse instead of xStep */
146730 int reg /* Array of registers */
 
146731 ){
146732 Vdbe *v = sqlite3GetVdbe(pParse);
146733 Window *pWin;
146734 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146735 FuncDef *pFunc = pWin->pFunc;
146736 int regArg;
146737 int nArg = windowArgCount(pWin);
146738 int i;
146739
146740 for(i=0; i<nArg; i++){
146741 if( i!=1 || pFunc->zName!=nth_valueName ){
 
146742 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
146743 }else{
146744 sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
146745 }
146746 }
146747 regArg = reg;
146748
146749 if( pMWin->regStartRowid==0
146750 && (pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146751 && (pWin->eStart!=TK_UNBOUNDED)
 
 
 
 
 
 
 
 
146752 ){
146753 int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg);
146754 VdbeCoverage(v);
146755 if( bInverse==0 ){
146756 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
@@ -146389,151 +146763,223 @@
146763 sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp);
146764 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
146765 }
146766 sqlite3VdbeJumpHere(v, addrIsNull);
146767 }else if( pWin->regApp ){
146768 assert( pFunc->zName==nth_valueName
146769 || pFunc->zName==first_valueName
146770 );
146771 assert( bInverse==0 || bInverse==1 );
146772 sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1);
146773 }else if( pFunc->xSFunc!=noopStepFunc ){
 
 
 
 
146774 int addrIf = 0;
146775 if( pWin->pFilter ){
146776 int regTmp;
146777 assert( nArg==0 || nArg==pWin->pOwner->x.pList->nExpr );
146778 assert( nArg || pWin->pOwner->x.pList==0 );
146779 regTmp = sqlite3GetTempReg(pParse);
146780 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp);
 
 
 
 
146781 addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1);
146782 VdbeCoverage(v);
146783 sqlite3ReleaseTempReg(pParse, regTmp);
 
 
146784 }
146785 if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
146786 CollSeq *pColl;
146787 assert( nArg>0 );
146788 pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
146789 sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
146790 }
146791 sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
146792 bInverse, regArg, pWin->regAccum);
146793 sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
146794 sqlite3VdbeChangeP5(v, (u8)nArg);
146795 if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
146796 }
146797 }
146798 }
146799
146800 typedef struct WindowCodeArg WindowCodeArg;
146801 typedef struct WindowCsrAndReg WindowCsrAndReg;
146802 struct WindowCsrAndReg {
146803 int csr;
146804 int reg;
146805 };
146806
146807 struct WindowCodeArg {
146808 Parse *pParse;
146809 Window *pMWin;
146810 Vdbe *pVdbe;
146811 int regGosub;
146812 int addrGosub;
146813 int regArg;
146814 int eDelete;
146815
146816 WindowCsrAndReg start;
146817 WindowCsrAndReg current;
146818 WindowCsrAndReg end;
146819 };
146820
146821 /*
146822 ** Values that may be passed as the second argument to windowCodeOp().
146823 */
146824 #define WINDOW_RETURN_ROW 1
146825 #define WINDOW_AGGINVERSE 2
146826 #define WINDOW_AGGSTEP 3
146827
146828 /*
146829 ** Generate VM code to read the window frames peer values from cursor csr into
146830 ** an array of registers starting at reg.
146831 */
146832 static void windowReadPeerValues(
146833 WindowCodeArg *p,
146834 int csr,
146835 int reg
146836 ){
146837 Window *pMWin = p->pMWin;
146838 ExprList *pOrderBy = pMWin->pOrderBy;
146839 if( pOrderBy ){
146840 Vdbe *v = sqlite3GetVdbe(p->pParse);
146841 ExprList *pPart = pMWin->pPartition;
146842 int iColOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
146843 int i;
146844 for(i=0; i<pOrderBy->nExpr; i++){
146845 sqlite3VdbeAddOp3(v, OP_Column, csr, iColOff+i, reg+i);
146846 }
146847 }
146848 }
146849
146850 /*
146851 ** Generate VM code to invoke either xValue() (bFin==0) or xFinalize()
146852 ** (bFin==1) for each window function in the linked list starting at
146853 ** pMWin. Or, for built-in window-functions that do not use the standard
146854 ** API, generate the equivalent VM code.
146855 */
146856 static void windowAggFinal(WindowCodeArg *p, int bFin){
146857 Parse *pParse = p->pParse;
146858 Window *pMWin = p->pMWin;
146859 Vdbe *v = sqlite3GetVdbe(pParse);
146860 Window *pWin;
146861
146862 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146863 if( pMWin->regStartRowid==0
146864 && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX)
146865 && (pWin->eStart!=TK_UNBOUNDED)
146866 ){
146867 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
146868 sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
146869 VdbeCoverage(v);
146870 sqlite3VdbeAddOp3(v, OP_Column, pWin->csrApp, 0, pWin->regResult);
146871 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
 
 
 
146872 }else if( pWin->regApp ){
146873 assert( pMWin->regStartRowid==0 );
146874 }else{
146875 int nArg = windowArgCount(pWin);
146876 if( bFin ){
146877 sqlite3VdbeAddOp2(v, OP_AggFinal, pWin->regAccum, nArg);
146878 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146879 sqlite3VdbeAddOp2(v, OP_Copy, pWin->regAccum, pWin->regResult);
146880 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146881 }else{
146882 sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
 
146883 sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
146884 }
146885 }
146886 }
146887 }
146888
146889 /*
146890 ** Generate code to calculate the current values of all window functions in the
146891 ** p->pMWin list by doing a full scan of the current window frame. Store the
146892 ** results in the Window.regResult registers, ready to return the upper
146893 ** layer.
146894 */
146895 static void windowFullScan(WindowCodeArg *p){
146896 Window *pWin;
146897 Parse *pParse = p->pParse;
146898 Window *pMWin = p->pMWin;
146899 Vdbe *v = p->pVdbe;
146900
146901 int regCRowid = 0; /* Current rowid value */
146902 int regCPeer = 0; /* Current peer values */
146903 int regRowid = 0; /* AggStep rowid value */
146904 int regPeer = 0; /* AggStep peer values */
146905
146906 int nPeer;
146907 int lblNext;
146908 int lblBrk;
146909 int addrNext;
146910 int csr = pMWin->csrApp;
146911
146912 nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
146913
146914 lblNext = sqlite3VdbeMakeLabel(pParse);
146915 lblBrk = sqlite3VdbeMakeLabel(pParse);
146916
146917 regCRowid = sqlite3GetTempReg(pParse);
146918 regRowid = sqlite3GetTempReg(pParse);
146919 if( nPeer ){
146920 regCPeer = sqlite3GetTempRange(pParse, nPeer);
146921 regPeer = sqlite3GetTempRange(pParse, nPeer);
146922 }
146923
146924 sqlite3VdbeAddOp2(v, OP_Rowid, pMWin->iEphCsr, regCRowid);
146925 windowReadPeerValues(p, pMWin->iEphCsr, regCPeer);
146926
146927 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
146928 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
146929 }
146930
146931 sqlite3VdbeAddOp3(v, OP_SeekGE, csr, lblBrk, pMWin->regStartRowid);
146932 VdbeCoverage(v);
146933 addrNext = sqlite3VdbeCurrentAddr(v);
146934 sqlite3VdbeAddOp2(v, OP_Rowid, csr, regRowid);
146935 sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, lblBrk, regRowid);
146936 VdbeCoverageNeverNull(v);
146937
146938 if( pMWin->eExclude==TK_CURRENT ){
146939 sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid);
146940 VdbeCoverageNeverNull(v);
146941 }else if( pMWin->eExclude!=TK_NO ){
146942 int addr;
146943 int addrEq = 0;
146944 KeyInfo *pKeyInfo = 0;
146945
146946 if( pMWin->pOrderBy ){
146947 pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy, 0, 0);
146948 }
146949 if( pMWin->eExclude==TK_TIES ){
146950 addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, 0, regRowid);
146951 VdbeCoverageNeverNull(v);
146952 }
146953 if( pKeyInfo ){
146954 windowReadPeerValues(p, csr, regPeer);
146955 sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer);
146956 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
146957 addr = sqlite3VdbeCurrentAddr(v)+1;
146958 sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr);
146959 VdbeCoverageEqNe(v);
146960 }else{
146961 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblNext);
146962 }
146963 if( addrEq ) sqlite3VdbeJumpHere(v, addrEq);
146964 }
146965
146966 windowAggStep(pParse, pMWin, csr, 0, p->regArg);
146967
146968 sqlite3VdbeResolveLabel(v, lblNext);
146969 sqlite3VdbeAddOp2(v, OP_Next, csr, addrNext);
146970 VdbeCoverage(v);
146971 sqlite3VdbeJumpHere(v, addrNext-1);
146972 sqlite3VdbeJumpHere(v, addrNext+1);
146973 sqlite3ReleaseTempReg(pParse, regRowid);
146974 sqlite3ReleaseTempReg(pParse, regCRowid);
146975 if( nPeer ){
146976 sqlite3ReleaseTempRange(pParse, regPeer, nPeer);
146977 sqlite3ReleaseTempRange(pParse, regCPeer, nPeer);
146978 }
146979
146980 windowAggFinal(p, 1);
146981 }
146982
146983 /*
146984 ** Invoke the sub-routine at regGosub (generated by code in select.c) to
146985 ** return the current row of Window.iEphCsr. If all window functions are
@@ -146545,114 +146991,78 @@
146991 ** nth_value()
146992 ** first_value()
146993 ** lag()
146994 ** lead()
146995 */
146996 static void windowReturnOneRow(WindowCodeArg *p){
146997 Window *pMWin = p->pMWin;
146998 Vdbe *v = p->pVdbe;
146999
147000 if( pMWin->regStartRowid ){
147001 windowFullScan(p);
147002 }else{
147003 Parse *pParse = p->pParse;
147004 Window *pWin;
147005
147006 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147007 FuncDef *pFunc = pWin->pFunc;
147008 if( pFunc->zName==nth_valueName
147009 || pFunc->zName==first_valueName
147010 ){
147011 int csr = pWin->csrApp;
147012 int lbl = sqlite3VdbeMakeLabel(pParse);
147013 int tmpReg = sqlite3GetTempReg(pParse);
147014 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
147015
147016 if( pFunc->zName==nth_valueName ){
147017 sqlite3VdbeAddOp3(v, OP_Column,pMWin->iEphCsr,pWin->iArgCol+1,tmpReg);
147018 windowCheckValue(pParse, tmpReg, 2);
147019 }else{
147020 sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
147021 }
147022 sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
147023 sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
147024 VdbeCoverageNeverNull(v);
147025 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
147026 VdbeCoverageNeverTaken(v);
147027 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
147028 sqlite3VdbeResolveLabel(v, lbl);
147029 sqlite3ReleaseTempReg(pParse, tmpReg);
147030 }
147031 else if( pFunc->zName==leadName || pFunc->zName==lagName ){
147032 int nArg = pWin->pOwner->x.pList->nExpr;
147033 int csr = pWin->csrApp;
147034 int lbl = sqlite3VdbeMakeLabel(pParse);
147035 int tmpReg = sqlite3GetTempReg(pParse);
147036 int iEph = pMWin->iEphCsr;
147037
147038 if( nArg<3 ){
147039 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
147040 }else{
147041 sqlite3VdbeAddOp3(v, OP_Column, iEph,pWin->iArgCol+2,pWin->regResult);
147042 }
147043 sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
147044 if( nArg<2 ){
147045 int val = (pFunc->zName==leadName ? 1 : -1);
147046 sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
147047 }else{
147048 int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
147049 int tmpReg2 = sqlite3GetTempReg(pParse);
147050 sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
147051 sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
147052 sqlite3ReleaseTempReg(pParse, tmpReg2);
147053 }
147054
147055 sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
147056 VdbeCoverage(v);
147057 sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
147058 sqlite3VdbeResolveLabel(v, lbl);
147059 sqlite3ReleaseTempReg(pParse, tmpReg);
147060 }
147061 }
147062 }
147063 sqlite3VdbeAddOp2(v, OP_Gosub, p->regGosub, p->addrGosub);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147064 }
147065
147066 /*
147067 ** Generate code to set the accumulator register for each window function
147068 ** in the linked list passed as the second argument to NULL. And perform
@@ -146666,693 +147076,269 @@
147076 Window *pWin;
147077 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147078 FuncDef *pFunc = pWin->pFunc;
147079 sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
147080 nArg = MAX(nArg, windowArgCount(pWin));
147081 if( pMWin->regStartRowid==0 ){
147082 if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){
147083 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp);
147084 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147085 }
147086
147087 if( (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && pWin->csrApp ){
147088 assert( pWin->eStart!=TK_UNBOUNDED );
147089 sqlite3VdbeAddOp1(v, OP_ResetSorter, pWin->csrApp);
147090 sqlite3VdbeAddOp2(v, OP_Integer, 0, pWin->regApp+1);
147091 }
147092 }
147093 }
147094 regArg = pParse->nMem+1;
147095 pParse->nMem += nArg;
147096 return regArg;
147097 }
147098
147099 /*
147100 ** Return true if the current frame should be cached in the ephemeral table,
147101 ** even if there are no xInverse() calls required.
147102 */
147103 static int windowCacheFrame(Window *pMWin){
147104 Window *pWin;
147105 if( pMWin->regStartRowid ) return 1;
147106 for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
147107 FuncDef *pFunc = pWin->pFunc;
147108 if( (pFunc->zName==nth_valueName)
147109 || (pFunc->zName==first_valueName)
147110 || (pFunc->zName==leadName)
147111 || (pFunc->zName==lagName)
147112 ){
147113 return 1;
147114 }
147115 }
147116 return 0;
147117 }
147118
147119 /*
147120 ** regOld and regNew are each the first register in an array of size
147121 ** pOrderBy->nExpr. This function generates code to compare the two
147122 ** arrays of registers using the collation sequences and other comparison
147123 ** parameters specified by pOrderBy.
147124 **
147125 ** If the two arrays are not equal, the contents of regNew is copied to
147126 ** regOld and control falls through. Otherwise, if the contents of the arrays
147127 ** are equal, an OP_Goto is executed. The address of the OP_Goto is returned.
147128 */
147129 static void windowIfNewPeer(
147130 Parse *pParse,
147131 ExprList *pOrderBy,
147132 int regNew, /* First in array of new values */
147133 int regOld, /* First in array of old values */
147134 int addr /* Jump here */
147135 ){
147136 Vdbe *v = sqlite3GetVdbe(pParse);
147137 if( pOrderBy ){
147138 int nVal = pOrderBy->nExpr;
147139 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pOrderBy, 0, 0);
147140 sqlite3VdbeAddOp3(v, OP_Compare, regOld, regNew, nVal);
147141 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147142 sqlite3VdbeAddOp3(v, OP_Jump,
147143 sqlite3VdbeCurrentAddr(v)+1, addr, sqlite3VdbeCurrentAddr(v)+1
147144 );
147145 VdbeCoverageEqNe(v);
147146 sqlite3VdbeAddOp3(v, OP_Copy, regNew, regOld, nVal-1);
147147 }else{
147148 sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
147149 }
147150 }
147151
147152 /*
147153 ** This function is called as part of generating VM programs for RANGE
147154 ** offset PRECEDING/FOLLOWING frame boundaries. Assuming "ASC" order for
147155 ** the ORDER BY term in the window, it generates code equivalent to:
147156 **
147157 ** if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
147158 **
147159 ** A special type of arithmetic is used such that if csr.peerVal is not
147160 ** a numeric type (real or integer), then the result of the addition is
147161 ** a copy of csr1.peerVal.
147162 */
147163 static void windowCodeRangeTest(
147164 WindowCodeArg *p,
147165 int op, /* OP_Ge or OP_Gt */
147166 int csr1,
147167 int regVal,
147168 int csr2,
147169 int lbl
147170 ){
147171 Parse *pParse = p->pParse;
147172 Vdbe *v = sqlite3GetVdbe(pParse);
147173 int reg1 = sqlite3GetTempReg(pParse);
147174 int reg2 = sqlite3GetTempReg(pParse);
147175 int arith = OP_Add;
147176 int addrGe;
147177
147178 int regString = ++pParse->nMem;
147179
147180 assert( op==OP_Ge || op==OP_Gt || op==OP_Le );
147181 assert( p->pMWin->pOrderBy && p->pMWin->pOrderBy->nExpr==1 );
147182 if( p->pMWin->pOrderBy->a[0].sortOrder ){
147183 switch( op ){
147184 case OP_Ge: op = OP_Le; break;
147185 case OP_Gt: op = OP_Lt; break;
147186 default: assert( op==OP_Le ); op = OP_Ge; break;
147187 }
147188 arith = OP_Subtract;
147189 }
147190
147191 windowReadPeerValues(p, csr1, reg1);
147192 windowReadPeerValues(p, csr2, reg2);
147193
147194 /* Check if the peer value for csr1 value is a text or blob by comparing
147195 ** it to the smallest possible string - ''. If it is, jump over the
147196 ** OP_Add or OP_Subtract operation and proceed directly to the comparison. */
147197 sqlite3VdbeAddOp4(v, OP_String8, 0, regString, 0, "", P4_STATIC);
147198 addrGe = sqlite3VdbeAddOp3(v, OP_Ge, regString, 0, reg1);
147199 VdbeCoverage(v);
147200 sqlite3VdbeAddOp3(v, arith, regVal, reg1, reg1);
147201 sqlite3VdbeJumpHere(v, addrGe);
147202 sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v);
147203 sqlite3VdbeChangeP5(v, SQLITE_NULLEQ);
147204 assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le );
147205 testcase(op==OP_Ge); VdbeCoverageIf(v, op==OP_Ge);
147206 testcase(op==OP_Lt); VdbeCoverageIf(v, op==OP_Lt);
147207 testcase(op==OP_Le); VdbeCoverageIf(v, op==OP_Le);
147208 testcase(op==OP_Gt); VdbeCoverageIf(v, op==OP_Gt);
147209
147210 sqlite3ReleaseTempReg(pParse, reg1);
147211 sqlite3ReleaseTempReg(pParse, reg2);
147212 }
147213
147214 /*
147215 ** Helper function for sqlite3WindowCodeStep(). Each call to this function
147216 ** generates VM code for a single RETURN_ROW, AGGSTEP or AGGINVERSE
147217 ** operation. Refer to the header comment for sqlite3WindowCodeStep() for
147218 ** details.
147219 */
147220 static int windowCodeOp(
147221 WindowCodeArg *p, /* Context object */
147222 int op, /* WINDOW_RETURN_ROW, AGGSTEP or AGGINVERSE */
147223 int regCountdown, /* Register for OP_IfPos countdown */
147224 int jumpOnEof /* Jump here if stepped cursor reaches EOF */
147225 ){
147226 int csr, reg;
147227 Parse *pParse = p->pParse;
147228 Window *pMWin = p->pMWin;
147229 int ret = 0;
147230 Vdbe *v = p->pVdbe;
147231 int addrIf = 0;
147232 int addrContinue = 0;
147233 int addrGoto = 0;
147234 int bPeer = (pMWin->eFrmType!=TK_ROWS);
147235
147236 int lblDone = sqlite3VdbeMakeLabel(pParse);
147237 int addrNextRange = 0;
147238
147239 /* Special case - WINDOW_AGGINVERSE is always a no-op if the frame
147240 ** starts with UNBOUNDED PRECEDING. */
147241 if( op==WINDOW_AGGINVERSE && pMWin->eStart==TK_UNBOUNDED ){
147242 assert( regCountdown==0 && jumpOnEof==0 );
147243 return 0;
147244 }
147245
147246 if( regCountdown>0 ){
147247 if( pMWin->eFrmType==TK_RANGE ){
147248 addrNextRange = sqlite3VdbeCurrentAddr(v);
147249 assert( op==WINDOW_AGGINVERSE || op==WINDOW_AGGSTEP );
147250 if( op==WINDOW_AGGINVERSE ){
147251 if( pMWin->eStart==TK_FOLLOWING ){
147252 windowCodeRangeTest(
147253 p, OP_Le, p->current.csr, regCountdown, p->start.csr, lblDone
147254 );
147255 }else{
147256 windowCodeRangeTest(
147257 p, OP_Ge, p->start.csr, regCountdown, p->current.csr, lblDone
147258 );
147259 }
147260 }else{
147261 windowCodeRangeTest(
147262 p, OP_Gt, p->end.csr, regCountdown, p->current.csr, lblDone
147263 );
147264 }
147265 }else{
147266 addrIf = sqlite3VdbeAddOp3(v, OP_IfPos, regCountdown, 0, 1);
147267 VdbeCoverage(v);
147268 }
147269 }
147270
147271 if( op==WINDOW_RETURN_ROW && pMWin->regStartRowid==0 ){
147272 windowAggFinal(p, 0);
147273 }
147274 addrContinue = sqlite3VdbeCurrentAddr(v);
147275 switch( op ){
147276 case WINDOW_RETURN_ROW:
147277 csr = p->current.csr;
147278 reg = p->current.reg;
147279 windowReturnOneRow(p);
147280 break;
147281
147282 case WINDOW_AGGINVERSE:
147283 csr = p->start.csr;
147284 reg = p->start.reg;
147285 if( pMWin->regStartRowid ){
147286 assert( pMWin->regEndRowid );
147287 sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regStartRowid, 1);
147288 }else{
147289 windowAggStep(pParse, pMWin, csr, 1, p->regArg);
147290 }
147291 break;
147292
147293 default:
147294 assert( op==WINDOW_AGGSTEP );
147295 csr = p->end.csr;
147296 reg = p->end.reg;
147297 if( pMWin->regStartRowid ){
147298 assert( pMWin->regEndRowid );
147299 sqlite3VdbeAddOp2(v, OP_AddImm, pMWin->regEndRowid, 1);
147300 }else{
147301 windowAggStep(pParse, pMWin, csr, 0, p->regArg);
147302 }
147303 break;
147304 }
147305
147306 if( op==p->eDelete ){
147307 sqlite3VdbeAddOp1(v, OP_Delete, csr);
147308 sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION);
147309 }
147310
147311 if( jumpOnEof ){
147312 sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+2);
147313 VdbeCoverage(v);
147314 ret = sqlite3VdbeAddOp0(v, OP_Goto);
147315 }else{
147316 sqlite3VdbeAddOp2(v, OP_Next, csr, sqlite3VdbeCurrentAddr(v)+1+bPeer);
147317 VdbeCoverage(v);
147318 if( bPeer ){
147319 addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);
147320 }
147321 }
147322
147323 if( bPeer ){
147324 int nReg = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);
147325 int regTmp = (nReg ? sqlite3GetTempRange(pParse, nReg) : 0);
147326 windowReadPeerValues(p, csr, regTmp);
147327 windowIfNewPeer(pParse, pMWin->pOrderBy, regTmp, reg, addrContinue);
147328 sqlite3ReleaseTempRange(pParse, regTmp, nReg);
147329 }
147330
147331 if( addrNextRange ){
147332 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNextRange);
147333 }
147334 sqlite3VdbeResolveLabel(v, lblDone);
147335 if( addrGoto ) sqlite3VdbeJumpHere(v, addrGoto);
147336 if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
147337 return ret;
147338 }
147339
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147340
147341 /*
147342 ** Allocate and return a duplicate of the Window object indicated by the
147343 ** third argument. Set the Window.pOwner field of the new object to
147344 ** pOwner.
@@ -147365,13 +147351,14 @@
147351 pNew->zName = sqlite3DbStrDup(db, p->zName);
147352 pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
147353 pNew->pFunc = p->pFunc;
147354 pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
147355 pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
147356 pNew->eFrmType = p->eFrmType;
147357 pNew->eEnd = p->eEnd;
147358 pNew->eStart = p->eStart;
147359 pNew->eExclude = p->eExclude;
147360 pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
147361 pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
147362 pNew->pOwner = pOwner;
147363 }
147364 }
@@ -147393,95 +147380,689 @@
147380 pp = &((*pp)->pNextWin);
147381 }
147382
147383 return pRet;
147384 }
147385
147386 /*
147387 ** Return true if it can be determined at compile time that expression
147388 ** pExpr evaluates to a value that, when cast to an integer, is greater
147389 ** than zero. False otherwise.
147390 **
147391 ** If an OOM error occurs, this function sets the Parse.db.mallocFailed
147392 ** flag and returns zero.
147393 */
147394 static int windowExprGtZero(Parse *pParse, Expr *pExpr){
147395 int ret = 0;
147396 sqlite3 *db = pParse->db;
147397 sqlite3_value *pVal = 0;
147398 sqlite3ValueFromExpr(db, pExpr, db->enc, SQLITE_AFF_NUMERIC, &pVal);
147399 if( pVal && sqlite3_value_int(pVal)>0 ){
147400 ret = 1;
147401 }
147402 sqlite3ValueFree(pVal);
147403 return ret;
147404 }
147405
147406 /*
147407 ** sqlite3WhereBegin() has already been called for the SELECT statement
147408 ** passed as the second argument when this function is invoked. It generates
147409 ** code to populate the Window.regResult register for each window function
147410 ** and invoke the sub-routine at instruction addrGosub once for each row.
147411 ** sqlite3WhereEnd() is always called before returning.
147412 **
147413 ** This function handles several different types of window frames, which
147414 ** require slightly different processing. The following pseudo code is
147415 ** used to implement window frames of the form:
147416 **
147417 ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
147418 **
147419 ** Other window frame types use variants of the following:
147420 **
147421 ** ... loop started by sqlite3WhereBegin() ...
147422 ** if( new partition ){
147423 ** Gosub flush
147424 ** }
147425 ** Insert new row into eph table.
147426 **
147427 ** if( first row of partition ){
147428 ** // Rewind three cursors, all open on the eph table.
147429 ** Rewind(csrEnd);
147430 ** Rewind(csrStart);
147431 ** Rewind(csrCurrent);
147432 **
147433 ** regEnd = <expr2> // FOLLOWING expression
147434 ** regStart = <expr1> // PRECEDING expression
147435 ** }else{
147436 ** // First time this branch is taken, the eph table contains two
147437 ** // rows. The first row in the partition, which all three cursors
147438 ** // currently point to, and the following row.
147439 ** AGGSTEP
147440 ** if( (regEnd--)<=0 ){
147441 ** RETURN_ROW
147442 ** if( (regStart--)<=0 ){
147443 ** AGGINVERSE
147444 ** }
147445 ** }
147446 ** }
147447 ** }
147448 ** flush:
147449 ** AGGSTEP
147450 ** while( 1 ){
147451 ** RETURN ROW
147452 ** if( csrCurrent is EOF ) break;
147453 ** if( (regStart--)<=0 ){
147454 ** AggInverse(csrStart)
147455 ** Next(csrStart)
147456 ** }
147457 ** }
147458 **
147459 ** The pseudo-code above uses the following shorthand:
147460 **
147461 ** AGGSTEP: invoke the aggregate xStep() function for each window function
147462 ** with arguments read from the current row of cursor csrEnd, then
147463 ** step cursor csrEnd forward one row (i.e. sqlite3BtreeNext()).
147464 **
147465 ** RETURN_ROW: return a row to the caller based on the contents of the
147466 ** current row of csrCurrent and the current state of all
147467 ** aggregates. Then step cursor csrCurrent forward one row.
147468 **
147469 ** AGGINVERSE: invoke the aggregate xInverse() function for each window
147470 ** functions with arguments read from the current row of cursor
147471 ** csrStart. Then step csrStart forward one row.
147472 **
147473 ** There are two other ROWS window frames that are handled significantly
147474 ** differently from the above - "BETWEEN <expr> PRECEDING AND <expr> PRECEDING"
147475 ** and "BETWEEN <expr> FOLLOWING AND <expr> FOLLOWING". These are special
147476 ** cases because they change the order in which the three cursors (csrStart,
147477 ** csrCurrent and csrEnd) iterate through the ephemeral table. Cases that
147478 ** use UNBOUNDED or CURRENT ROW are much simpler variations on one of these
147479 ** three.
147480 **
147481 ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147482 **
147483 ** ... loop started by sqlite3WhereBegin() ...
147484 ** if( new partition ){
147485 ** Gosub flush
147486 ** }
147487 ** Insert new row into eph table.
147488 ** if( first row of partition ){
147489 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147490 ** regEnd = <expr2>
147491 ** regStart = <expr1>
147492 ** }else{
147493 ** if( (regEnd--)<=0 ){
147494 ** AGGSTEP
147495 ** }
147496 ** RETURN_ROW
147497 ** if( (regStart--)<=0 ){
147498 ** AGGINVERSE
147499 ** }
147500 ** }
147501 ** }
147502 ** flush:
147503 ** if( (regEnd--)<=0 ){
147504 ** AGGSTEP
147505 ** }
147506 ** RETURN_ROW
147507 **
147508 **
147509 ** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147510 **
147511 ** ... loop started by sqlite3WhereBegin() ...
147512 ** if( new partition ){
147513 ** Gosub flush
147514 ** }
147515 ** Insert new row into eph table.
147516 ** if( first row of partition ){
147517 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147518 ** regEnd = <expr2>
147519 ** regStart = regEnd - <expr1>
147520 ** }else{
147521 ** AGGSTEP
147522 ** if( (regEnd--)<=0 ){
147523 ** RETURN_ROW
147524 ** }
147525 ** if( (regStart--)<=0 ){
147526 ** AGGINVERSE
147527 ** }
147528 ** }
147529 ** }
147530 ** flush:
147531 ** AGGSTEP
147532 ** while( 1 ){
147533 ** if( (regEnd--)<=0 ){
147534 ** RETURN_ROW
147535 ** if( eof ) break;
147536 ** }
147537 ** if( (regStart--)<=0 ){
147538 ** AGGINVERSE
147539 ** if( eof ) break
147540 ** }
147541 ** }
147542 ** while( !eof csrCurrent ){
147543 ** RETURN_ROW
147544 ** }
147545 **
147546 ** For the most part, the patterns above are adapted to support UNBOUNDED by
147547 ** assuming that it is equivalent to "infinity PRECEDING/FOLLOWING" and
147548 ** CURRENT ROW by assuming that it is equivilent to "0 PRECEDING/FOLLOWING".
147549 ** This is optimized of course - branches that will never be taken and
147550 ** conditions that are always true are omitted from the VM code. The only
147551 ** exceptional case is:
147552 **
147553 ** ROWS BETWEEN <expr1> FOLLOWING AND UNBOUNDED FOLLOWING
147554 **
147555 ** ... loop started by sqlite3WhereBegin() ...
147556 ** if( new partition ){
147557 ** Gosub flush
147558 ** }
147559 ** Insert new row into eph table.
147560 ** if( first row of partition ){
147561 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147562 ** regStart = <expr1>
147563 ** }else{
147564 ** AGGSTEP
147565 ** }
147566 ** }
147567 ** flush:
147568 ** AGGSTEP
147569 ** while( 1 ){
147570 ** if( (regStart--)<=0 ){
147571 ** AGGINVERSE
147572 ** if( eof ) break
147573 ** }
147574 ** RETURN_ROW
147575 ** }
147576 ** while( !eof csrCurrent ){
147577 ** RETURN_ROW
147578 ** }
147579 **
147580 ** Also requiring special handling are the cases:
147581 **
147582 ** ROWS BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147583 ** ROWS BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147584 **
147585 ** when (expr1 < expr2). This is detected at runtime, not by this function.
147586 ** To handle this case, the pseudo-code programs depicted above are modified
147587 ** slightly to be:
147588 **
147589 ** ... loop started by sqlite3WhereBegin() ...
147590 ** if( new partition ){
147591 ** Gosub flush
147592 ** }
147593 ** Insert new row into eph table.
147594 ** if( first row of partition ){
147595 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147596 ** regEnd = <expr2>
147597 ** regStart = <expr1>
147598 ** if( regEnd < regStart ){
147599 ** RETURN_ROW
147600 ** delete eph table contents
147601 ** continue
147602 ** }
147603 ** ...
147604 **
147605 ** The new "continue" statement in the above jumps to the next iteration
147606 ** of the outer loop - the one started by sqlite3WhereBegin().
147607 **
147608 ** The various GROUPS cases are implemented using the same patterns as
147609 ** ROWS. The VM code is modified slightly so that:
147610 **
147611 ** 1. The else branch in the main loop is only taken if the row just
147612 ** added to the ephemeral table is the start of a new group. In
147613 ** other words, it becomes:
147614 **
147615 ** ... loop started by sqlite3WhereBegin() ...
147616 ** if( new partition ){
147617 ** Gosub flush
147618 ** }
147619 ** Insert new row into eph table.
147620 ** if( first row of partition ){
147621 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147622 ** regEnd = <expr2>
147623 ** regStart = <expr1>
147624 ** }else if( new group ){
147625 ** ...
147626 ** }
147627 ** }
147628 **
147629 ** 2. Instead of processing a single row, each RETURN_ROW, AGGSTEP or
147630 ** AGGINVERSE step processes the current row of the relevant cursor and
147631 ** all subsequent rows belonging to the same group.
147632 **
147633 ** RANGE window frames are a little different again. As for GROUPS, the
147634 ** main loop runs once per group only. And RETURN_ROW, AGGSTEP and AGGINVERSE
147635 ** deal in groups instead of rows. As for ROWS and GROUPS, there are three
147636 ** basic cases:
147637 **
147638 ** RANGE BETWEEN <expr1> PRECEDING AND <expr2> FOLLOWING
147639 **
147640 ** ... loop started by sqlite3WhereBegin() ...
147641 ** if( new partition ){
147642 ** Gosub flush
147643 ** }
147644 ** Insert new row into eph table.
147645 ** if( first row of partition ){
147646 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147647 ** regEnd = <expr2>
147648 ** regStart = <expr1>
147649 ** }else{
147650 ** AGGSTEP
147651 ** while( (csrCurrent.key + regEnd) < csrEnd.key ){
147652 ** RETURN_ROW
147653 ** while( csrStart.key + regStart) < csrCurrent.key ){
147654 ** AGGINVERSE
147655 ** }
147656 ** }
147657 ** }
147658 ** }
147659 ** flush:
147660 ** AGGSTEP
147661 ** while( 1 ){
147662 ** RETURN ROW
147663 ** if( csrCurrent is EOF ) break;
147664 ** while( csrStart.key + regStart) < csrCurrent.key ){
147665 ** AGGINVERSE
147666 ** }
147667 ** }
147668 ** }
147669 **
147670 ** In the above notation, "csr.key" means the current value of the ORDER BY
147671 ** expression (there is only ever 1 for a RANGE that uses an <expr> FOLLOWING
147672 ** or <expr PRECEDING) read from cursor csr.
147673 **
147674 ** RANGE BETWEEN <expr1> PRECEDING AND <expr2> PRECEDING
147675 **
147676 ** ... loop started by sqlite3WhereBegin() ...
147677 ** if( new partition ){
147678 ** Gosub flush
147679 ** }
147680 ** Insert new row into eph table.
147681 ** if( first row of partition ){
147682 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147683 ** regEnd = <expr2>
147684 ** regStart = <expr1>
147685 ** }else{
147686 ** if( (csrEnd.key + regEnd) <= csrCurrent.key ){
147687 ** AGGSTEP
147688 ** }
147689 ** while( (csrStart.key + regStart) < csrCurrent.key ){
147690 ** AGGINVERSE
147691 ** }
147692 ** RETURN_ROW
147693 ** }
147694 ** }
147695 ** flush:
147696 ** while( (csrEnd.key + regEnd) <= csrCurrent.key ){
147697 ** AGGSTEP
147698 ** }
147699 ** while( (csrStart.key + regStart) < csrCurrent.key ){
147700 ** AGGINVERSE
147701 ** }
147702 ** RETURN_ROW
147703 **
147704 ** RANGE BETWEEN <expr1> FOLLOWING AND <expr2> FOLLOWING
147705 **
147706 ** ... loop started by sqlite3WhereBegin() ...
147707 ** if( new partition ){
147708 ** Gosub flush
147709 ** }
147710 ** Insert new row into eph table.
147711 ** if( first row of partition ){
147712 ** Rewind(csrEnd) ; Rewind(csrStart) ; Rewind(csrCurrent)
147713 ** regEnd = <expr2>
147714 ** regStart = <expr1>
147715 ** }else{
147716 ** AGGSTEP
147717 ** while( (csrCurrent.key + regEnd) < csrEnd.key ){
147718 ** while( (csrCurrent.key + regStart) > csrStart.key ){
147719 ** AGGINVERSE
147720 ** }
147721 ** RETURN_ROW
147722 ** }
147723 ** }
147724 ** }
147725 ** flush:
147726 ** AGGSTEP
147727 ** while( 1 ){
147728 ** while( (csrCurrent.key + regStart) > csrStart.key ){
147729 ** AGGINVERSE
147730 ** if( eof ) break "while( 1 )" loop.
147731 ** }
147732 ** RETURN_ROW
147733 ** }
147734 ** while( !eof csrCurrent ){
147735 ** RETURN_ROW
147736 ** }
147737 **
147738 ** The text above leaves out many details. Refer to the code and comments
147739 ** below for a more complete picture.
147740 */
147741 SQLITE_PRIVATE void sqlite3WindowCodeStep(
147742 Parse *pParse, /* Parse context */
147743 Select *p, /* Rewritten SELECT statement */
147744 WhereInfo *pWInfo, /* Context returned by sqlite3WhereBegin() */
147745 int regGosub, /* Register for OP_Gosub */
147746 int addrGosub /* OP_Gosub here to return each row */
147747 ){
147748 Window *pMWin = p->pWin;
147749 ExprList *pOrderBy = pMWin->pOrderBy;
147750 Vdbe *v = sqlite3GetVdbe(pParse);
147751 int csrWrite; /* Cursor used to write to eph. table */
147752 int csrInput = p->pSrc->a[0].iCursor; /* Cursor of sub-select */
147753 int nInput = p->pSrc->a[0].pTab->nCol; /* Number of cols returned by sub */
147754 int iInput; /* To iterate through sub cols */
147755 int addrNe; /* Address of OP_Ne */
147756 int addrGosubFlush = 0; /* Address of OP_Gosub to flush: */
147757 int addrInteger = 0; /* Address of OP_Integer */
147758 int addrEmpty; /* Address of OP_Rewind in flush: */
147759 int regStart = 0; /* Value of <expr> PRECEDING */
147760 int regEnd = 0; /* Value of <expr> FOLLOWING */
147761 int regNew; /* Array of registers holding new input row */
147762 int regRecord; /* regNew array in record form */
147763 int regRowid; /* Rowid for regRecord in eph table */
147764 int regNewPeer = 0; /* Peer values for new row (part of regNew) */
147765 int regPeer = 0; /* Peer values for current row */
147766 int regFlushPart = 0; /* Register for "Gosub flush_partition" */
147767 WindowCodeArg s; /* Context object for sub-routines */
147768 int lblWhereEnd; /* Label just before sqlite3WhereEnd() code */
147769
147770 assert( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_CURRENT
147771 || pMWin->eStart==TK_FOLLOWING || pMWin->eStart==TK_UNBOUNDED
147772 );
147773 assert( pMWin->eEnd==TK_FOLLOWING || pMWin->eEnd==TK_CURRENT
147774 || pMWin->eEnd==TK_UNBOUNDED || pMWin->eEnd==TK_PRECEDING
147775 );
147776 assert( pMWin->eExclude==0 || pMWin->eExclude==TK_CURRENT
147777 || pMWin->eExclude==TK_GROUP || pMWin->eExclude==TK_TIES
147778 || pMWin->eExclude==TK_NO
147779 );
147780
147781 lblWhereEnd = sqlite3VdbeMakeLabel(pParse);
147782
147783 /* Fill in the context object */
147784 memset(&s, 0, sizeof(WindowCodeArg));
147785 s.pParse = pParse;
147786 s.pMWin = pMWin;
147787 s.pVdbe = v;
147788 s.regGosub = regGosub;
147789 s.addrGosub = addrGosub;
147790 s.current.csr = pMWin->iEphCsr;
147791 csrWrite = s.current.csr+1;
147792 s.start.csr = s.current.csr+2;
147793 s.end.csr = s.current.csr+3;
147794
147795 /* Figure out when rows may be deleted from the ephemeral table. There
147796 ** are four options - they may never be deleted (eDelete==0), they may
147797 ** be deleted as soon as they are no longer part of the window frame
147798 ** (eDelete==WINDOW_AGGINVERSE), they may be deleted as after the row
147799 ** has been returned to the caller (WINDOW_RETURN_ROW), or they may
147800 ** be deleted after they enter the frame (WINDOW_AGGSTEP). */
147801 switch( pMWin->eStart ){
147802 case TK_FOLLOWING:
147803 if( pMWin->eFrmType!=TK_RANGE
147804 && windowExprGtZero(pParse, pMWin->pStart)
147805 ){
147806 s.eDelete = WINDOW_RETURN_ROW;
147807 }
147808 break;
147809 case TK_UNBOUNDED:
147810 if( windowCacheFrame(pMWin)==0 ){
147811 if( pMWin->eEnd==TK_PRECEDING ){
147812 if( pMWin->eFrmType!=TK_RANGE
147813 && windowExprGtZero(pParse, pMWin->pEnd)
147814 ){
147815 s.eDelete = WINDOW_AGGSTEP;
147816 }
147817 }else{
147818 s.eDelete = WINDOW_RETURN_ROW;
147819 }
147820 }
147821 break;
147822 default:
147823 s.eDelete = WINDOW_AGGINVERSE;
147824 break;
147825 }
147826
147827 /* Allocate registers for the array of values from the sub-query, the
147828 ** samve values in record form, and the rowid used to insert said record
147829 ** into the ephemeral table. */
147830 regNew = pParse->nMem+1;
147831 pParse->nMem += nInput;
147832 regRecord = ++pParse->nMem;
147833 regRowid = ++pParse->nMem;
147834
147835 /* If the window frame contains an "<expr> PRECEDING" or "<expr> FOLLOWING"
147836 ** clause, allocate registers to store the results of evaluating each
147837 ** <expr>. */
147838 if( pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){
147839 regStart = ++pParse->nMem;
147840 }
147841 if( pMWin->eEnd==TK_PRECEDING || pMWin->eEnd==TK_FOLLOWING ){
147842 regEnd = ++pParse->nMem;
147843 }
147844
147845 /* If this is not a "ROWS BETWEEN ..." frame, then allocate arrays of
147846 ** registers to store copies of the ORDER BY expressions (peer values)
147847 ** for the main loop, and for each cursor (start, current and end). */
147848 if( pMWin->eFrmType!=TK_ROWS ){
147849 int nPeer = (pOrderBy ? pOrderBy->nExpr : 0);
147850 regNewPeer = regNew + pMWin->nBufferCol;
147851 if( pMWin->pPartition ) regNewPeer += pMWin->pPartition->nExpr;
147852 regPeer = pParse->nMem+1; pParse->nMem += nPeer;
147853 s.start.reg = pParse->nMem+1; pParse->nMem += nPeer;
147854 s.current.reg = pParse->nMem+1; pParse->nMem += nPeer;
147855 s.end.reg = pParse->nMem+1; pParse->nMem += nPeer;
147856 }
147857
147858 /* Load the column values for the row returned by the sub-select
147859 ** into an array of registers starting at regNew. Assemble them into
147860 ** a record in register regRecord. */
147861 for(iInput=0; iInput<nInput; iInput++){
147862 sqlite3VdbeAddOp3(v, OP_Column, csrInput, iInput, regNew+iInput);
147863 }
147864 sqlite3VdbeAddOp3(v, OP_MakeRecord, regNew, nInput, regRecord);
147865
147866 /* An input row has just been read into an array of registers starting
147867 ** at regNew. If the window has a PARTITION clause, this block generates
147868 ** VM code to check if the input row is the start of a new partition.
147869 ** If so, it does an OP_Gosub to an address to be filled in later. The
147870 ** address of the OP_Gosub is stored in local variable addrGosubFlush. */
147871 if( pMWin->pPartition ){
147872 int addr;
147873 ExprList *pPart = pMWin->pPartition;
147874 int nPart = pPart->nExpr;
147875 int regNewPart = regNew + pMWin->nBufferCol;
147876 KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pPart, 0, 0);
147877
147878 regFlushPart = ++pParse->nMem;
147879 addr = sqlite3VdbeAddOp3(v, OP_Compare, regNewPart, pMWin->regPart, nPart);
147880 sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
147881 sqlite3VdbeAddOp3(v, OP_Jump, addr+2, addr+4, addr+2);
147882 VdbeCoverageEqNe(v);
147883 addrGosubFlush = sqlite3VdbeAddOp1(v, OP_Gosub, regFlushPart);
147884 VdbeComment((v, "call flush_partition"));
147885 sqlite3VdbeAddOp3(v, OP_Copy, regNewPart, pMWin->regPart, nPart-1);
147886 }
147887
147888 /* Insert the new row into the ephemeral table */
147889 sqlite3VdbeAddOp2(v, OP_NewRowid, csrWrite, regRowid);
147890 sqlite3VdbeAddOp3(v, OP_Insert, csrWrite, regRecord, regRowid);
147891 addrNe = sqlite3VdbeAddOp3(v, OP_Ne, pMWin->regOne, 0, regRowid);
147892 VdbeCoverageNeverNull(v);
147893
147894 /* This block is run for the first row of each partition */
147895 s.regArg = windowInitAccum(pParse, pMWin);
147896
147897 if( regStart ){
147898 sqlite3ExprCode(pParse, pMWin->pStart, regStart);
147899 windowCheckValue(pParse, regStart, 0 + (pMWin->eFrmType==TK_RANGE ? 3 : 0));
147900 }
147901 if( regEnd ){
147902 sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
147903 windowCheckValue(pParse, regEnd, 1 + (pMWin->eFrmType==TK_RANGE ? 3 : 0));
147904 }
147905
147906 if( pMWin->eStart==pMWin->eEnd && regStart ){
147907 int op = ((pMWin->eStart==TK_FOLLOWING) ? OP_Ge : OP_Le);
147908 int addrGe = sqlite3VdbeAddOp3(v, op, regStart, 0, regEnd);
147909 VdbeCoverageNeverNullIf(v, op==OP_Ge); /* NeverNull because bound <expr> */
147910 VdbeCoverageNeverNullIf(v, op==OP_Le); /* values previously checked */
147911 windowAggFinal(&s, 0);
147912 sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
147913 VdbeCoverageNeverTaken(v);
147914 windowReturnOneRow(&s);
147915 sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
147916 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
147917 sqlite3VdbeJumpHere(v, addrGe);
147918 }
147919 if( pMWin->eStart==TK_FOLLOWING && pMWin->eFrmType!=TK_RANGE && regEnd ){
147920 assert( pMWin->eEnd==TK_FOLLOWING );
147921 sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regStart);
147922 }
147923
147924 if( pMWin->eStart!=TK_UNBOUNDED ){
147925 sqlite3VdbeAddOp2(v, OP_Rewind, s.start.csr, 1);
147926 VdbeCoverageNeverTaken(v);
147927 }
147928 sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
147929 VdbeCoverageNeverTaken(v);
147930 sqlite3VdbeAddOp2(v, OP_Rewind, s.end.csr, 1);
147931 VdbeCoverageNeverTaken(v);
147932 if( regPeer && pOrderBy ){
147933 sqlite3VdbeAddOp3(v, OP_Copy, regNewPeer, regPeer, pOrderBy->nExpr-1);
147934 sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.start.reg, pOrderBy->nExpr-1);
147935 sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.current.reg, pOrderBy->nExpr-1);
147936 sqlite3VdbeAddOp3(v, OP_Copy, regPeer, s.end.reg, pOrderBy->nExpr-1);
147937 }
147938
147939 sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
147940
147941 sqlite3VdbeJumpHere(v, addrNe);
147942
147943 /* Beginning of the block executed for the second and subsequent rows. */
147944 if( regPeer ){
147945 windowIfNewPeer(pParse, pOrderBy, regNewPeer, regPeer, lblWhereEnd);
147946 }
147947 if( pMWin->eStart==TK_FOLLOWING ){
147948 windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
147949 if( pMWin->eEnd!=TK_UNBOUNDED ){
147950 if( pMWin->eFrmType==TK_RANGE ){
147951 int lbl = sqlite3VdbeMakeLabel(pParse);
147952 int addrNext = sqlite3VdbeCurrentAddr(v);
147953 windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl);
147954 windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147955 windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147956 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrNext);
147957 sqlite3VdbeResolveLabel(v, lbl);
147958 }else{
147959 windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 0);
147960 windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147961 }
147962 }
147963 }else
147964 if( pMWin->eEnd==TK_PRECEDING ){
147965 int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
147966 windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
147967 if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147968 windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147969 if( !bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147970 }else{
147971 int addr = 0;
147972 windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
147973 if( pMWin->eEnd!=TK_UNBOUNDED ){
147974 if( pMWin->eFrmType==TK_RANGE ){
147975 int lbl = 0;
147976 addr = sqlite3VdbeCurrentAddr(v);
147977 if( regEnd ){
147978 lbl = sqlite3VdbeMakeLabel(pParse);
147979 windowCodeRangeTest(&s, OP_Ge, s.current.csr, regEnd, s.end.csr, lbl);
147980 }
147981 windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147982 windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147983 if( regEnd ){
147984 sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
147985 sqlite3VdbeResolveLabel(v, lbl);
147986 }
147987 }else{
147988 if( regEnd ){
147989 addr = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0, 1);
147990 VdbeCoverage(v);
147991 }
147992 windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
147993 windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
147994 if( regEnd ) sqlite3VdbeJumpHere(v, addr);
147995 }
147996 }
147997 }
147998
147999 /* End of the main input loop */
148000 sqlite3VdbeResolveLabel(v, lblWhereEnd);
148001 sqlite3WhereEnd(pWInfo);
148002
148003 /* Fall through */
148004 if( pMWin->pPartition ){
148005 addrInteger = sqlite3VdbeAddOp2(v, OP_Integer, 0, regFlushPart);
148006 sqlite3VdbeJumpHere(v, addrGosubFlush);
148007 }
148008
148009 addrEmpty = sqlite3VdbeAddOp1(v, OP_Rewind, csrWrite);
148010 VdbeCoverage(v);
148011 if( pMWin->eEnd==TK_PRECEDING ){
148012 int bRPS = (pMWin->eStart==TK_PRECEDING && pMWin->eFrmType==TK_RANGE);
148013 windowCodeOp(&s, WINDOW_AGGSTEP, regEnd, 0);
148014 if( bRPS ) windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
148015 windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 0);
148016 }else if( pMWin->eStart==TK_FOLLOWING ){
148017 int addrStart;
148018 int addrBreak1;
148019 int addrBreak2;
148020 int addrBreak3;
148021 windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
148022 if( pMWin->eFrmType==TK_RANGE ){
148023 addrStart = sqlite3VdbeCurrentAddr(v);
148024 addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1);
148025 addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148026 }else
148027 if( pMWin->eEnd==TK_UNBOUNDED ){
148028 addrStart = sqlite3VdbeCurrentAddr(v);
148029 addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regStart, 1);
148030 addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, 0, 1);
148031 }else{
148032 assert( pMWin->eEnd==TK_FOLLOWING );
148033 addrStart = sqlite3VdbeCurrentAddr(v);
148034 addrBreak1 = windowCodeOp(&s, WINDOW_RETURN_ROW, regEnd, 1);
148035 addrBreak2 = windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 1);
148036 }
148037 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148038 sqlite3VdbeJumpHere(v, addrBreak2);
148039 addrStart = sqlite3VdbeCurrentAddr(v);
148040 addrBreak3 = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148041 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148042 sqlite3VdbeJumpHere(v, addrBreak1);
148043 sqlite3VdbeJumpHere(v, addrBreak3);
148044 }else{
148045 int addrBreak;
148046 int addrStart;
148047 windowCodeOp(&s, WINDOW_AGGSTEP, 0, 0);
148048 addrStart = sqlite3VdbeCurrentAddr(v);
148049 addrBreak = windowCodeOp(&s, WINDOW_RETURN_ROW, 0, 1);
148050 windowCodeOp(&s, WINDOW_AGGINVERSE, regStart, 0);
148051 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrStart);
148052 sqlite3VdbeJumpHere(v, addrBreak);
148053 }
148054 sqlite3VdbeJumpHere(v, addrEmpty);
148055
148056 sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
148057 if( pMWin->pPartition ){
148058 if( pMWin->regStartRowid ){
148059 sqlite3VdbeAddOp2(v, OP_Integer, 1, pMWin->regStartRowid);
148060 sqlite3VdbeAddOp2(v, OP_Integer, 0, pMWin->regEndRowid);
148061 }
148062 sqlite3VdbeChangeP1(v, addrInteger, sqlite3VdbeCurrentAddr(v));
148063 sqlite3VdbeAddOp1(v, OP_Return, regFlushPart);
148064 }
148065 }
148066
148067 #endif /* SQLITE_OMIT_WINDOWFUNC */
148068
@@ -147729,31 +148310,32 @@
148310 #ifndef INTERFACE
148311 # define INTERFACE 1
148312 #endif
148313 /************* Begin control #defines *****************************************/
148314 #define YYCODETYPE unsigned short int
148315 #define YYNOCODE 284
148316 #define YYACTIONTYPE unsigned short int
148317 #define YYWILDCARD 95
148318 #define sqlite3ParserTOKENTYPE Token
148319 typedef union {
148320 int yyinit;
148321 sqlite3ParserTOKENTYPE yy0;
148322 u8 yy10;
148323 const char* yy104;
148324 Expr* yy130;
148325 SrcList* yy147;
148326 IdList* yy200;
148327 struct FrameBound yy273;
148328 Window* yy395;
148329 int yy420;
148330 Upsert* yy426;
148331 ExprList* yy442;
148332 Select* yy491;
148333 struct TrigEvent yy498;
148334 With* yy523;
148335 TriggerStep* yy524;
148336 struct {int value; int mask;} yy527;
148337 } YYMINORTYPE;
148338 #ifndef YYSTACKDEPTH
148339 #define YYSTACKDEPTH 100
148340 #endif
148341 #define sqlite3ParserARG_SDECL
@@ -147765,21 +148347,21 @@
148347 #define sqlite3ParserCTX_PDECL ,Parse *pParse
148348 #define sqlite3ParserCTX_PARAM ,pParse
148349 #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
148350 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
148351 #define YYFALLBACK 1
148352 #define YYNSTATE 541
148353 #define YYNRULE 375
148354 #define YYNTOKEN 159
148355 #define YY_MAX_SHIFT 540
148356 #define YY_MIN_SHIFTREDUCE 784
148357 #define YY_MAX_SHIFTREDUCE 1158
148358 #define YY_ERROR_ACTION 1159
148359 #define YY_ACCEPT_ACTION 1160
148360 #define YY_NO_ACTION 1161
148361 #define YY_MIN_REDUCE 1162
148362 #define YY_MAX_REDUCE 1536
148363 /************* End control #defines *******************************************/
148364 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
148365
148366 /* Define the yytestcase() macro to be a no-op if is not already defined
148367 ** otherwise.
@@ -147842,573 +148424,606 @@
148424 ** yy_reduce_ofst[] For each state, the offset into yy_action for
148425 ** shifting non-terminals after a reduce.
148426 ** yy_default[] Default action for each state.
148427 **
148428 *********** Begin parsing tables **********************************************/
148429 #define YY_ACTTAB_COUNT (2142)
148430 static const YYACTIONTYPE yy_action[] = {
148431 /* 0 */ 388, 112, 109, 209, 535, 190, 442, 259, 1160, 1,
148432 /* 10 */ 1, 540, 2, 1164, 535, 1292, 1500, 371, 289, 384,
148433 /* 20 */ 134, 1484, 1427, 1164, 1202, 69, 69, 1241, 289, 492,
148434 /* 30 */ 134, 915, 382, 296, 175, 42, 42, 1241, 242, 916,
148435 /* 40 */ 112, 109, 209, 119, 120, 110, 1136, 1136, 981, 984,
148436 /* 50 */ 974, 974, 117, 117, 118, 118, 118, 118, 1291, 264,
148437 /* 60 */ 264, 264, 264, 112, 109, 209, 112, 109, 209, 264,
148438 /* 70 */ 264, 1115, 532, 1134, 532, 176, 270, 453, 239, 206,
148439 /* 80 */ 379, 450, 532, 356, 380, 219, 118, 118, 118, 118,
148440 /* 90 */ 111, 444, 535, 1233, 1233, 219, 116, 116, 116, 116,
148441 /* 100 */ 115, 115, 114, 114, 114, 113, 415, 258, 258, 112,
148442 /* 110 */ 109, 209, 1115, 42, 42, 419, 384, 1391, 1504, 1115,
148443 /* 120 */ 532, 1115, 1116, 1117, 1134, 419, 1463, 351, 116, 116,
148444 /* 130 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 961,
148445 /* 140 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
148446 /* 150 */ 117, 118, 118, 118, 118, 952, 1228, 1207, 1115, 951,
148447 /* 160 */ 412, 411, 1115, 1116, 1117, 1228, 535, 876, 1140, 1115,
148448 /* 170 */ 1116, 1117, 875, 1142, 941, 114, 114, 114, 113, 415,
148449 /* 180 */ 1089, 1141, 1089, 118, 118, 118, 118, 42, 42, 202,
148450 /* 190 */ 951, 951, 953, 116, 116, 116, 116, 115, 115, 114,
148451 /* 200 */ 114, 114, 113, 415, 1465, 1143, 350, 1143, 1115, 1116,
148452 /* 210 */ 1117, 231, 415, 384, 472, 469, 468, 412, 411, 442,
148453 /* 220 */ 96, 311, 430, 299, 467, 116, 116, 116, 116, 115,
148454 /* 230 */ 115, 114, 114, 114, 113, 415, 160, 119, 120, 110,
148455 /* 240 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148456 /* 250 */ 118, 118, 115, 115, 114, 114, 114, 113, 415, 529,
148457 /* 260 */ 529, 529, 1143, 121, 1143, 116, 116, 116, 116, 115,
148458 /* 270 */ 115, 114, 114, 114, 113, 415, 941, 337, 1463, 506,
148459 /* 280 */ 491, 1067, 1530, 384, 160, 1530, 288, 526, 1115, 274,
148460 /* 290 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148461 /* 300 */ 415, 16, 16, 406, 535, 93, 512, 119, 120, 110,
148462 /* 310 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148463 /* 320 */ 118, 118, 141, 311, 231, 54, 54, 472, 469, 468,
148464 /* 330 */ 427, 79, 368, 1156, 288, 526, 32, 467, 1115, 1116,
148465 /* 340 */ 1117, 1323, 1480, 540, 2, 1164, 971, 971, 982, 985,
148466 /* 350 */ 289, 384, 134, 459, 1065, 533, 80, 870, 870, 1241,
148467 /* 360 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148468 /* 370 */ 415, 818, 82, 1115, 1476, 119, 120, 110, 1136, 1136,
148469 /* 380 */ 981, 984, 974, 974, 117, 117, 118, 118, 118, 118,
148470 /* 390 */ 403, 264, 264, 238, 535, 1426, 250, 267, 336, 475,
148471 /* 400 */ 331, 474, 236, 459, 532, 1157, 961, 459, 329, 397,
148472 /* 410 */ 373, 513, 1450, 159, 975, 70, 70, 219, 413, 413,
148473 /* 420 */ 413, 818, 952, 1115, 1116, 1117, 951, 534, 116, 116,
148474 /* 430 */ 116, 116, 115, 115, 114, 114, 114, 113, 415, 1115,
148475 /* 440 */ 535, 442, 264, 264, 1115, 1390, 535, 419, 384, 422,
148476 /* 450 */ 1115, 517, 326, 1245, 304, 532, 1084, 951, 951, 953,
148477 /* 460 */ 493, 70, 70, 167, 509, 532, 1084, 70, 70, 1084,
148478 /* 470 */ 440, 535, 119, 120, 110, 1136, 1136, 981, 984, 974,
148479 /* 480 */ 974, 117, 117, 118, 118, 118, 118, 881, 535, 1115,
148480 /* 490 */ 1116, 1117, 55, 55, 1115, 1116, 1117, 517, 288, 526,
148481 /* 500 */ 1115, 1116, 1117, 517, 420, 494, 516, 113, 415, 13,
148482 /* 510 */ 13, 275, 482, 836, 349, 301, 535, 303, 500, 5,
148483 /* 520 */ 480, 1457, 138, 395, 6, 116, 116, 116, 116, 115,
148484 /* 530 */ 115, 114, 114, 114, 113, 415, 1458, 13, 13, 6,
148485 /* 540 */ 535, 1024, 1115, 535, 473, 384, 535, 435, 312, 822,
148486 /* 550 */ 1084, 400, 837, 159, 518, 181, 1115, 483, 502, 811,
148487 /* 560 */ 1084, 70, 70, 1084, 70, 70, 1115, 50, 50, 119,
148488 /* 570 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148489 /* 580 */ 118, 118, 118, 118, 95, 338, 264, 264, 1115, 264,
148490 /* 590 */ 264, 302, 1115, 1116, 1117, 495, 3, 498, 535, 532,
148491 /* 600 */ 517, 404, 532, 484, 801, 287, 1115, 1116, 1117, 519,
148492 /* 610 */ 811, 337, 501, 12, 535, 381, 1115, 1116, 1117, 70,
148493 /* 620 */ 70, 401, 116, 116, 116, 116, 115, 115, 114, 114,
148494 /* 630 */ 114, 113, 415, 1115, 1084, 13, 13, 535, 1115, 1116,
148495 /* 640 */ 1117, 1115, 384, 902, 1084, 1211, 815, 1084, 393, 402,
148496 /* 650 */ 160, 435, 312, 1532, 369, 284, 143, 297, 70, 70,
148497 /* 660 */ 510, 1457, 337, 433, 6, 901, 119, 120, 110, 1136,
148498 /* 670 */ 1136, 981, 984, 974, 974, 117, 117, 118, 118, 118,
148499 /* 680 */ 118, 1045, 426, 1115, 1116, 1117, 449, 535, 12, 264,
148500 /* 690 */ 264, 1115, 1116, 1117, 285, 535, 1046, 265, 265, 1004,
148501 /* 700 */ 288, 526, 532, 789, 790, 791, 190, 140, 70, 70,
148502 /* 710 */ 532, 1047, 1323, 535, 309, 298, 13, 13, 383, 116,
148503 /* 720 */ 116, 116, 116, 115, 115, 114, 114, 114, 113, 415,
148504 /* 730 */ 277, 535, 856, 190, 13, 13, 1383, 497, 278, 384,
148505 /* 740 */ 278, 362, 857, 1100, 410, 376, 264, 264, 184, 900,
148506 /* 750 */ 1210, 1239, 70, 70, 1182, 1455, 187, 535, 6, 532,
148507 /* 760 */ 535, 434, 207, 119, 120, 110, 1136, 1136, 981, 984,
148508 /* 770 */ 974, 974, 117, 117, 118, 118, 118, 118, 13, 13,
148509 /* 780 */ 398, 13, 13, 264, 264, 393, 264, 264, 414, 1185,
148510 /* 790 */ 390, 425, 185, 1396, 1084, 514, 532, 485, 9, 532,
148511 /* 800 */ 242, 464, 1067, 1531, 1084, 488, 1531, 1084, 425, 424,
148512 /* 810 */ 1396, 1398, 520, 1029, 1029, 456, 116, 116, 116, 116,
148513 /* 820 */ 115, 115, 114, 114, 114, 113, 415, 535, 235, 264,
148514 /* 830 */ 264, 508, 535, 393, 208, 1134, 384, 264, 264, 448,
148515 /* 840 */ 962, 448, 532, 261, 264, 264, 900, 507, 15, 15,
148516 /* 850 */ 532, 1026, 271, 44, 44, 1026, 1095, 532, 535, 900,
148517 /* 860 */ 119, 120, 110, 1136, 1136, 981, 984, 974, 974, 117,
148518 /* 870 */ 117, 118, 118, 118, 118, 1065, 425, 1045, 1396, 56,
148519 /* 880 */ 56, 535, 368, 1066, 1231, 1231, 1134, 454, 535, 324,
148520 /* 890 */ 389, 355, 1046, 234, 233, 232, 512, 459, 459, 459,
148521 /* 900 */ 272, 448, 57, 57, 1095, 1438, 329, 1047, 535, 58,
148522 /* 910 */ 58, 421, 477, 116, 116, 116, 116, 115, 115, 114,
148523 /* 920 */ 114, 114, 113, 415, 1323, 535, 515, 535, 523, 59,
148524 /* 930 */ 59, 208, 273, 384, 310, 1435, 1323, 946, 876, 1240,
148525 /* 940 */ 1236, 317, 1456, 875, 136, 6, 60, 60, 61, 61,
148526 /* 950 */ 319, 535, 322, 384, 535, 1157, 900, 119, 120, 110,
148527 /* 960 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148528 /* 970 */ 118, 118, 45, 45, 535, 46, 46, 119, 120, 110,
148529 /* 980 */ 1136, 1136, 981, 984, 974, 974, 117, 117, 118, 118,
148530 /* 990 */ 118, 118, 399, 338, 276, 48, 48, 337, 1477, 479,
148531 /* 1000 */ 535, 107, 1451, 535, 455, 535, 1119, 95, 1338, 235,
148532 /* 1010 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148533 /* 1020 */ 415, 49, 49, 123, 62, 62, 63, 63, 535, 408,
148534 /* 1030 */ 116, 116, 116, 116, 115, 115, 114, 114, 114, 113,
148535 /* 1040 */ 415, 535, 142, 535, 481, 535, 1323, 535, 1503, 64,
148536 /* 1050 */ 64, 845, 1454, 1337, 535, 6, 535, 1119, 535, 357,
148537 /* 1060 */ 535, 353, 14, 14, 65, 65, 125, 125, 66, 66,
148538 /* 1070 */ 535, 389, 535, 291, 535, 51, 51, 67, 67, 68,
148539 /* 1080 */ 68, 52, 52, 292, 1453, 98, 535, 6, 535, 481,
148540 /* 1090 */ 535, 147, 147, 148, 148, 75, 75, 535, 915, 535,
148541 /* 1100 */ 827, 201, 200, 528, 390, 384, 916, 53, 53, 71,
148542 /* 1110 */ 71, 126, 126, 515, 409, 288, 526, 216, 72, 72,
148543 /* 1120 */ 127, 127, 391, 161, 535, 384, 535, 263, 206, 119,
148544 /* 1130 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148545 /* 1140 */ 118, 118, 118, 118, 535, 128, 128, 124, 124, 119,
148546 /* 1150 */ 120, 110, 1136, 1136, 981, 984, 974, 974, 117, 117,
148547 /* 1160 */ 118, 118, 118, 118, 446, 146, 146, 102, 1209, 100,
148548 /* 1170 */ 1133, 212, 139, 535, 38, 437, 1062, 308, 535, 370,
148549 /* 1180 */ 95, 295, 116, 116, 116, 116, 115, 115, 114, 114,
148550 /* 1190 */ 114, 113, 415, 535, 145, 145, 535, 938, 535, 132,
148551 /* 1200 */ 132, 535, 116, 116, 116, 116, 115, 115, 114, 114,
148552 /* 1210 */ 114, 113, 415, 535, 131, 131, 1151, 129, 129, 130,
148553 /* 1220 */ 130, 30, 74, 74, 535, 17, 535, 218, 535, 943,
148554 /* 1230 */ 441, 1277, 241, 241, 76, 76, 443, 101, 313, 241,
148555 /* 1240 */ 465, 95, 1023, 237, 1023, 73, 73, 43, 43, 47,
148556 /* 1250 */ 47, 335, 31, 327, 447, 266, 95, 384, 1276, 835,
148557 /* 1260 */ 834, 334, 193, 1007, 436, 429, 237, 825, 842, 843,
148558 /* 1270 */ 1011, 909, 873, 955, 241, 107, 1022, 384, 1022, 197,
148559 /* 1280 */ 1441, 119, 120, 110, 1136, 1136, 981, 984, 974, 974,
148560 /* 1290 */ 117, 117, 118, 118, 118, 118, 809, 305, 1264, 137,
148561 /* 1300 */ 1415, 119, 108, 110, 1136, 1136, 981, 984, 974, 974,
148562 /* 1310 */ 117, 117, 118, 118, 118, 118, 874, 522, 825, 107,
148563 /* 1320 */ 283, 1011, 1414, 1470, 955, 451, 314, 1273, 318, 321,
148564 /* 1330 */ 323, 325, 1224, 1208, 116, 116, 116, 116, 115, 115,
148565 /* 1340 */ 114, 114, 114, 113, 415, 330, 339, 340, 1285, 1322,
148566 /* 1350 */ 1260, 1271, 521, 1328, 116, 116, 116, 116, 115, 115,
148567 /* 1360 */ 114, 114, 114, 113, 415, 1191, 256, 1493, 1184, 1173,
148568 /* 1370 */ 460, 1172, 1174, 1257, 384, 342, 1487, 344, 346, 199,
148569 /* 1380 */ 195, 367, 11, 211, 307, 445, 1307, 428, 1315, 375,
148570 /* 1390 */ 203, 1207, 470, 188, 384, 189, 525, 1490, 1151, 120,
148571 /* 1400 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
148572 /* 1410 */ 118, 118, 118, 333, 1387, 1386, 245, 300, 348, 1434,
148573 /* 1420 */ 110, 1136, 1136, 981, 984, 974, 974, 117, 117, 118,
148574 /* 1430 */ 118, 118, 118, 198, 360, 163, 1432, 1148, 78, 81,
148575 /* 1440 */ 392, 82, 1392, 439, 173, 105, 527, 157, 4, 165,
148576 /* 1450 */ 1312, 116, 116, 116, 116, 115, 115, 114, 114, 114,
148577 /* 1460 */ 113, 415, 530, 93, 35, 431, 432, 1304, 168, 463,
148578 /* 1470 */ 221, 116, 116, 116, 116, 115, 115, 114, 114, 114,
148579 /* 1480 */ 113, 415, 169, 170, 171, 416, 372, 438, 1318, 177,
148580 /* 1490 */ 452, 374, 36, 225, 1381, 87, 458, 524, 257, 1403,
148581 /* 1500 */ 316, 105, 527, 227, 4, 182, 461, 160, 320, 228,
148582 /* 1510 */ 377, 1175, 229, 476, 405, 1227, 1226, 1225, 530, 827,
148583 /* 1520 */ 961, 1218, 378, 1199, 1198, 407, 103, 103, 281, 1217,
148584 /* 1530 */ 8, 332, 1197, 104, 1502, 416, 537, 536, 282, 487,
148585 /* 1540 */ 951, 416, 490, 496, 1268, 92, 341, 243, 244, 1461,
148586 /* 1550 */ 1269, 1267, 122, 524, 1266, 515, 10, 288, 526, 343,
148587 /* 1560 */ 352, 1460, 354, 99, 504, 94, 499, 251, 1181, 503,
148588 /* 1570 */ 194, 951, 951, 953, 954, 27, 961, 1250, 345, 347,
148589 /* 1580 */ 1249, 358, 103, 103, 359, 34, 538, 1110, 1367, 104,
148590 /* 1590 */ 255, 416, 537, 536, 539, 1170, 951, 286, 252, 254,
148591 /* 1600 */ 149, 1165, 1419, 135, 1420, 785, 279, 1418, 417, 1417,
148592 /* 1610 */ 1195, 196, 150, 290, 210, 269, 151, 1021, 133, 1194,
148593 /* 1620 */ 1019, 935, 162, 386, 387, 77, 1192, 951, 951, 953,
148594 /* 1630 */ 954, 27, 1479, 1104, 418, 164, 153, 268, 217, 166,
148595 /* 1640 */ 859, 306, 366, 366, 365, 253, 363, 220, 1035, 798,
148596 /* 1650 */ 172, 939, 105, 527, 155, 4, 394, 174, 396, 83,
148597 /* 1660 */ 84, 85, 213, 86, 294, 1038, 156, 223, 222, 530,
148598 /* 1670 */ 1034, 144, 293, 18, 224, 241, 315, 1027, 1145, 178,
148599 /* 1680 */ 457, 226, 37, 179, 800, 334, 462, 230, 328, 466,
148600 /* 1690 */ 180, 471, 416, 88, 19, 20, 89, 280, 838, 158,
148601 /* 1700 */ 191, 478, 215, 1097, 524, 90, 204, 192, 987, 91,
148602 /* 1710 */ 152, 1070, 39, 154, 1071, 504, 486, 40, 489, 205,
148603 /* 1720 */ 505, 260, 105, 527, 214, 4, 908, 961, 262, 183,
148604 /* 1730 */ 240, 21, 903, 103, 103, 107, 22, 1086, 23, 530,
148605 /* 1740 */ 104, 1074, 416, 537, 536, 24, 1088, 951, 25, 1093,
148606 /* 1750 */ 1090, 1094, 7, 33, 511, 186, 26, 1002, 385, 95,
148607 /* 1760 */ 988, 986, 416, 288, 526, 990, 1044, 246, 1043, 247,
148608 /* 1770 */ 991, 28, 41, 106, 524, 956, 810, 29, 951, 951,
148609 /* 1780 */ 953, 954, 27, 531, 869, 504, 423, 248, 249, 1495,
148610 /* 1790 */ 503, 1494, 361, 364, 1105, 1161, 1161, 961, 1161, 1161,
148611 /* 1800 */ 1161, 1161, 1161, 103, 103, 1161, 1161, 1161, 1161, 1161,
148612 /* 1810 */ 104, 1161, 416, 537, 536, 1104, 418, 951, 1161, 268,
148613 /* 1820 */ 1161, 1161, 1161, 1161, 366, 366, 365, 253, 363, 1161,
148614 /* 1830 */ 1161, 798, 1161, 1161, 1161, 1161, 105, 527, 1161, 4,
148615 /* 1840 */ 1161, 1161, 1161, 1161, 213, 1161, 294, 1161, 951, 951,
148616 /* 1850 */ 953, 954, 27, 530, 293, 1161, 1161, 1161, 1161, 1161,
148617 /* 1860 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148618 /* 1870 */ 1161, 1161, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161,
148619 /* 1880 */ 1161, 1161, 1161, 1161, 215, 1161, 1161, 1161, 524, 1161,
148620 /* 1890 */ 1161, 1161, 152, 1161, 1161, 154, 105, 527, 1161, 4,
148621 /* 1900 */ 1161, 1161, 1161, 1161, 1161, 1161, 214, 1161, 1161, 1161,
148622 /* 1910 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 880,
148623 /* 1920 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148624 /* 1930 */ 1161, 951, 1161, 1161, 1161, 1161, 416, 1161, 1161, 1161,
148625 /* 1940 */ 385, 1161, 1161, 1161, 1161, 288, 526, 1161, 524, 1161,
148626 /* 1950 */ 1161, 1161, 1161, 1161, 1161, 1161, 97, 527, 1161, 4,
148627 /* 1960 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 423, 1161,
148628 /* 1970 */ 1161, 961, 1161, 530, 1161, 1161, 1161, 103, 103, 1161,
148629 /* 1980 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148630 /* 1990 */ 1161, 951, 268, 1161, 1161, 1161, 416, 366, 366, 365,
148631 /* 2000 */ 253, 363, 1161, 1161, 798, 1161, 1161, 1161, 524, 1161,
148632 /* 2010 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 213, 1161, 294,
148633 /* 2020 */ 1161, 1161, 951, 951, 953, 954, 27, 293, 1161, 1161,
148634 /* 2030 */ 1161, 961, 1161, 1161, 1161, 1161, 1161, 103, 103, 1161,
148635 /* 2040 */ 1161, 1161, 1161, 1161, 104, 1161, 416, 537, 536, 1161,
148636 /* 2050 */ 1161, 951, 1161, 1161, 1161, 1161, 1161, 215, 1161, 1161,
148637 /* 2060 */ 1161, 1161, 1161, 1161, 1161, 152, 1161, 1161, 154, 1161,
148638 /* 2070 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 214,
148639 /* 2080 */ 1161, 1161, 951, 951, 953, 954, 27, 1161, 1161, 1161,
148640 /* 2090 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148641 /* 2100 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148642 /* 2110 */ 1161, 1161, 1161, 385, 1161, 1161, 1161, 1161, 288, 526,
148643 /* 2120 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148644 /* 2130 */ 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161,
148645 /* 2140 */ 1161, 423,
148646 };
148647 static const YYCODETYPE yy_lookahead[] = {
148648 /* 0 */ 172, 242, 243, 244, 167, 167, 167, 186, 159, 160,
148649 /* 10 */ 161, 162, 163, 164, 167, 191, 187, 179, 169, 19,
148650 /* 20 */ 171, 162, 263, 164, 195, 188, 189, 178, 169, 178,
148651 /* 30 */ 171, 31, 188, 167, 22, 188, 189, 178, 24, 39,
148652 /* 40 */ 242, 243, 244, 43, 44, 45, 46, 47, 48, 49,
148653 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 210,
148654 /* 60 */ 211, 210, 211, 242, 243, 244, 242, 243, 244, 210,
148655 /* 70 */ 211, 59, 223, 59, 223, 22, 237, 249, 227, 228,
148656 /* 80 */ 188, 253, 223, 246, 188, 236, 54, 55, 56, 57,
148657 /* 90 */ 58, 167, 167, 206, 207, 236, 96, 97, 98, 99,
148658 /* 100 */ 100, 101, 102, 103, 104, 105, 106, 210, 211, 242,
148659 /* 110 */ 243, 244, 59, 188, 189, 266, 19, 251, 201, 59,
148660 /* 120 */ 223, 109, 110, 111, 110, 266, 279, 280, 96, 97,
148661 /* 130 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 94,
148662 /* 140 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148663 /* 150 */ 53, 54, 55, 56, 57, 110, 195, 196, 59, 114,
148664 /* 160 */ 100, 101, 109, 110, 111, 204, 167, 128, 108, 109,
148665 /* 170 */ 110, 111, 133, 113, 73, 102, 103, 104, 105, 106,
148666 /* 180 */ 83, 121, 85, 54, 55, 56, 57, 188, 189, 26,
148667 /* 190 */ 145, 146, 147, 96, 97, 98, 99, 100, 101, 102,
148668 /* 200 */ 103, 104, 105, 106, 279, 145, 281, 147, 109, 110,
148669 /* 210 */ 111, 112, 106, 19, 115, 116, 117, 100, 101, 167,
148670 /* 220 */ 26, 120, 121, 122, 125, 96, 97, 98, 99, 100,
148671 /* 230 */ 101, 102, 103, 104, 105, 106, 81, 43, 44, 45,
148672 /* 240 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148673 /* 250 */ 56, 57, 100, 101, 102, 103, 104, 105, 106, 183,
148674 /* 260 */ 184, 185, 145, 69, 147, 96, 97, 98, 99, 100,
148675 /* 270 */ 101, 102, 103, 104, 105, 106, 73, 167, 279, 280,
148676 /* 280 */ 167, 22, 23, 19, 81, 26, 131, 132, 59, 237,
148677 /* 290 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148678 /* 300 */ 106, 188, 189, 19, 167, 142, 167, 43, 44, 45,
148679 /* 310 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148680 /* 320 */ 56, 57, 212, 120, 112, 188, 189, 115, 116, 117,
148681 /* 330 */ 238, 67, 22, 23, 131, 132, 22, 125, 109, 110,
148682 /* 340 */ 111, 167, 161, 162, 163, 164, 46, 47, 48, 49,
148683 /* 350 */ 169, 19, 171, 167, 95, 127, 24, 129, 130, 178,
148684 /* 360 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148685 /* 370 */ 106, 59, 143, 59, 167, 43, 44, 45, 46, 47,
148686 /* 380 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
148687 /* 390 */ 106, 210, 211, 26, 167, 209, 112, 113, 114, 115,
148688 /* 400 */ 116, 117, 118, 167, 223, 95, 94, 167, 124, 235,
148689 /* 410 */ 178, 272, 273, 167, 114, 188, 189, 236, 183, 184,
148690 /* 420 */ 185, 109, 110, 109, 110, 111, 114, 167, 96, 97,
148691 /* 430 */ 98, 99, 100, 101, 102, 103, 104, 105, 106, 59,
148692 /* 440 */ 167, 167, 210, 211, 59, 209, 167, 266, 19, 209,
148693 /* 450 */ 59, 224, 23, 211, 16, 223, 76, 145, 146, 147,
148694 /* 460 */ 233, 188, 189, 72, 84, 223, 86, 188, 189, 89,
148695 /* 470 */ 238, 167, 43, 44, 45, 46, 47, 48, 49, 50,
148696 /* 480 */ 51, 52, 53, 54, 55, 56, 57, 102, 167, 109,
148697 /* 490 */ 110, 111, 188, 189, 109, 110, 111, 224, 131, 132,
148698 /* 500 */ 109, 110, 111, 224, 264, 19, 233, 105, 106, 188,
148699 /* 510 */ 189, 237, 233, 35, 167, 77, 167, 79, 138, 22,
148700 /* 520 */ 274, 275, 22, 202, 278, 96, 97, 98, 99, 100,
148701 /* 530 */ 101, 102, 103, 104, 105, 106, 275, 188, 189, 278,
148702 /* 540 */ 167, 11, 59, 167, 66, 19, 167, 121, 122, 23,
148703 /* 550 */ 76, 202, 74, 167, 178, 72, 59, 178, 84, 59,
148704 /* 560 */ 86, 188, 189, 89, 188, 189, 59, 188, 189, 43,
148705 /* 570 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148706 /* 580 */ 54, 55, 56, 57, 26, 167, 210, 211, 59, 210,
148707 /* 590 */ 211, 153, 109, 110, 111, 109, 22, 224, 167, 223,
148708 /* 600 */ 224, 123, 223, 224, 21, 215, 109, 110, 111, 233,
148709 /* 610 */ 110, 167, 138, 186, 167, 225, 109, 110, 111, 188,
148710 /* 620 */ 189, 203, 96, 97, 98, 99, 100, 101, 102, 103,
148711 /* 630 */ 104, 105, 106, 59, 76, 188, 189, 167, 109, 110,
148712 /* 640 */ 111, 59, 19, 136, 86, 197, 23, 89, 167, 202,
148713 /* 650 */ 81, 121, 122, 269, 270, 224, 212, 178, 188, 189,
148714 /* 660 */ 274, 275, 167, 80, 278, 136, 43, 44, 45, 46,
148715 /* 670 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
148716 /* 680 */ 57, 12, 113, 109, 110, 111, 259, 167, 186, 210,
148717 /* 690 */ 211, 109, 110, 111, 224, 167, 27, 210, 211, 116,
148718 /* 700 */ 131, 132, 223, 7, 8, 9, 167, 212, 188, 189,
148719 /* 710 */ 223, 42, 167, 167, 178, 234, 188, 189, 179, 96,
148720 /* 720 */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
148721 /* 730 */ 202, 167, 63, 167, 188, 189, 153, 167, 199, 19,
148722 /* 740 */ 201, 175, 73, 23, 224, 179, 210, 211, 202, 26,
148723 /* 750 */ 197, 178, 188, 189, 178, 275, 254, 167, 278, 223,
148724 /* 760 */ 167, 259, 167, 43, 44, 45, 46, 47, 48, 49,
148725 /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 188, 189,
148726 /* 780 */ 235, 188, 189, 210, 211, 167, 210, 211, 224, 181,
148727 /* 790 */ 182, 167, 202, 167, 76, 202, 223, 178, 22, 223,
148728 /* 800 */ 24, 19, 22, 23, 86, 178, 26, 89, 184, 185,
148729 /* 810 */ 184, 185, 178, 120, 121, 122, 96, 97, 98, 99,
148730 /* 820 */ 100, 101, 102, 103, 104, 105, 106, 167, 46, 210,
148731 /* 830 */ 211, 66, 167, 167, 111, 59, 19, 210, 211, 167,
148732 /* 840 */ 23, 167, 223, 23, 210, 211, 26, 82, 188, 189,
148733 /* 850 */ 223, 29, 234, 188, 189, 33, 91, 223, 167, 136,
148734 /* 860 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
148735 /* 870 */ 53, 54, 55, 56, 57, 95, 252, 12, 252, 188,
148736 /* 880 */ 189, 167, 22, 23, 206, 207, 110, 65, 167, 16,
148737 /* 890 */ 108, 167, 27, 120, 121, 122, 167, 167, 167, 167,
148738 /* 900 */ 234, 167, 188, 189, 139, 167, 124, 42, 167, 188,
148739 /* 910 */ 189, 167, 102, 96, 97, 98, 99, 100, 101, 102,
148740 /* 920 */ 103, 104, 105, 106, 167, 167, 138, 167, 63, 188,
148741 /* 930 */ 189, 111, 260, 19, 260, 167, 167, 23, 128, 209,
148742 /* 940 */ 209, 209, 275, 133, 156, 278, 188, 189, 188, 189,
148743 /* 950 */ 77, 167, 79, 19, 167, 95, 136, 43, 44, 45,
148744 /* 960 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148745 /* 970 */ 56, 57, 188, 189, 167, 188, 189, 43, 44, 45,
148746 /* 980 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
148747 /* 990 */ 56, 57, 235, 167, 260, 188, 189, 167, 157, 158,
148748 /* 1000 */ 167, 26, 273, 167, 235, 167, 59, 26, 241, 46,
148749 /* 1010 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148750 /* 1020 */ 106, 188, 189, 22, 188, 189, 188, 189, 167, 203,
148751 /* 1030 */ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
148752 /* 1040 */ 106, 167, 212, 167, 277, 167, 167, 167, 23, 188,
148753 /* 1050 */ 189, 26, 275, 241, 167, 278, 167, 110, 167, 220,
148754 /* 1060 */ 167, 222, 188, 189, 188, 189, 188, 189, 188, 189,
148755 /* 1070 */ 167, 108, 167, 167, 167, 188, 189, 188, 189, 188,
148756 /* 1080 */ 189, 188, 189, 167, 275, 151, 167, 278, 167, 277,
148757 /* 1090 */ 167, 188, 189, 188, 189, 188, 189, 167, 31, 167,
148758 /* 1100 */ 119, 100, 101, 181, 182, 19, 39, 188, 189, 188,
148759 /* 1110 */ 189, 188, 189, 138, 235, 131, 132, 24, 188, 189,
148760 /* 1120 */ 188, 189, 267, 268, 167, 19, 167, 227, 228, 43,
148761 /* 1130 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148762 /* 1140 */ 54, 55, 56, 57, 167, 188, 189, 188, 189, 43,
148763 /* 1150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
148764 /* 1160 */ 54, 55, 56, 57, 19, 188, 189, 150, 197, 152,
148765 /* 1170 */ 26, 15, 22, 167, 24, 122, 23, 23, 167, 26,
148766 /* 1180 */ 26, 167, 96, 97, 98, 99, 100, 101, 102, 103,
148767 /* 1190 */ 104, 105, 106, 167, 188, 189, 167, 144, 167, 188,
148768 /* 1200 */ 189, 167, 96, 97, 98, 99, 100, 101, 102, 103,
148769 /* 1210 */ 104, 105, 106, 167, 188, 189, 60, 188, 189, 188,
148770 /* 1220 */ 189, 22, 188, 189, 167, 22, 167, 134, 167, 23,
148771 /* 1230 */ 23, 167, 26, 26, 188, 189, 23, 151, 23, 26,
148772 /* 1240 */ 23, 26, 145, 26, 147, 188, 189, 188, 189, 188,
148773 /* 1250 */ 189, 114, 53, 23, 109, 22, 26, 19, 167, 113,
148774 /* 1260 */ 114, 124, 24, 23, 61, 167, 26, 59, 7, 8,
148775 /* 1270 */ 59, 23, 23, 59, 26, 26, 145, 19, 147, 135,
148776 /* 1280 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148777 /* 1290 */ 52, 53, 54, 55, 56, 57, 23, 167, 229, 26,
148778 /* 1300 */ 167, 43, 44, 45, 46, 47, 48, 49, 50, 51,
148779 /* 1310 */ 52, 53, 54, 55, 56, 57, 23, 207, 110, 26,
148780 /* 1320 */ 226, 110, 167, 283, 110, 167, 167, 167, 167, 167,
148781 /* 1330 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101,
148782 /* 1340 */ 102, 103, 104, 105, 106, 167, 167, 167, 167, 167,
148783 /* 1350 */ 167, 167, 167, 167, 96, 97, 98, 99, 100, 101,
148784 /* 1360 */ 102, 103, 104, 105, 106, 167, 255, 134, 167, 167,
148785 /* 1370 */ 256, 167, 167, 226, 19, 226, 167, 226, 226, 186,
148786 /* 1380 */ 213, 165, 214, 265, 261, 261, 217, 230, 217, 217,
148787 /* 1390 */ 200, 196, 192, 220, 19, 220, 248, 170, 60, 44,
148788 /* 1400 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148789 /* 1410 */ 55, 56, 57, 191, 191, 191, 134, 230, 230, 174,
148790 /* 1420 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
148791 /* 1430 */ 55, 56, 57, 214, 216, 265, 174, 38, 262, 262,
148792 /* 1440 */ 174, 143, 251, 108, 22, 19, 20, 43, 22, 205,
148793 /* 1450 */ 240, 96, 97, 98, 99, 100, 101, 102, 103, 104,
148794 /* 1460 */ 105, 106, 36, 142, 239, 18, 174, 217, 208, 18,
148795 /* 1470 */ 173, 96, 97, 98, 99, 100, 101, 102, 103, 104,
148796 /* 1480 */ 105, 106, 208, 208, 208, 59, 217, 217, 205, 205,
148797 /* 1490 */ 174, 240, 239, 173, 217, 150, 62, 71, 174, 258,
148798 /* 1500 */ 257, 19, 20, 173, 22, 22, 193, 81, 174, 173,
148799 /* 1510 */ 193, 174, 173, 108, 64, 190, 190, 190, 36, 119,
148800 /* 1520 */ 94, 198, 193, 190, 192, 106, 100, 101, 250, 198,
148801 /* 1530 */ 48, 190, 190, 107, 190, 109, 110, 111, 250, 193,
148802 /* 1540 */ 114, 59, 193, 137, 232, 108, 231, 174, 88, 282,
148803 /* 1550 */ 232, 232, 141, 71, 232, 138, 22, 131, 132, 231,
148804 /* 1560 */ 220, 282, 174, 150, 82, 140, 139, 25, 177, 87,
148805 /* 1570 */ 219, 145, 146, 147, 148, 149, 94, 221, 231, 231,
148806 /* 1580 */ 221, 218, 100, 101, 217, 26, 176, 13, 245, 107,
148807 /* 1590 */ 6, 109, 110, 111, 166, 166, 114, 247, 168, 168,
148808 /* 1600 */ 180, 166, 186, 194, 186, 4, 194, 186, 3, 186,
148809 /* 1610 */ 186, 22, 180, 155, 15, 93, 180, 23, 16, 186,
148810 /* 1620 */ 23, 132, 268, 271, 271, 186, 186, 145, 146, 147,
148811 /* 1630 */ 148, 149, 0, 1, 2, 143, 123, 5, 24, 135,
148812 /* 1640 */ 20, 16, 10, 11, 12, 13, 14, 137, 1, 17,
148813 /* 1650 */ 135, 144, 19, 20, 123, 22, 61, 143, 37, 53,
148814 /* 1660 */ 53, 53, 30, 53, 32, 109, 123, 134, 34, 36,
148815 /* 1670 */ 1, 5, 40, 22, 108, 26, 153, 68, 75, 68,
148816 /* 1680 */ 41, 134, 24, 108, 20, 124, 19, 118, 23, 67,
148817 /* 1690 */ 22, 67, 59, 22, 22, 22, 22, 67, 28, 37,
148818 /* 1700 */ 23, 22, 70, 23, 71, 142, 157, 23, 23, 26,
148819 /* 1710 */ 78, 23, 22, 81, 23, 82, 24, 22, 24, 134,
148820 /* 1720 */ 87, 23, 19, 20, 92, 22, 109, 94, 23, 22,
148821 /* 1730 */ 34, 34, 136, 100, 101, 26, 34, 85, 34, 36,
148822 /* 1740 */ 107, 23, 109, 110, 111, 34, 83, 114, 34, 90,
148823 /* 1750 */ 75, 75, 44, 22, 24, 26, 34, 23, 126, 26,
148824 /* 1760 */ 23, 23, 59, 131, 132, 23, 23, 26, 23, 22,
148825 /* 1770 */ 11, 22, 22, 22, 71, 23, 23, 22, 145, 146,
148826 /* 1780 */ 147, 148, 149, 26, 128, 82, 154, 134, 134, 134,
148827 /* 1790 */ 87, 134, 23, 15, 1, 284, 284, 94, 284, 284,
148828 /* 1800 */ 284, 284, 284, 100, 101, 284, 284, 284, 284, 284,
148829 /* 1810 */ 107, 284, 109, 110, 111, 1, 2, 114, 284, 5,
148830 /* 1820 */ 284, 284, 284, 284, 10, 11, 12, 13, 14, 284,
148831 /* 1830 */ 284, 17, 284, 284, 284, 284, 19, 20, 284, 22,
148832 /* 1840 */ 284, 284, 284, 284, 30, 284, 32, 284, 145, 146,
148833 /* 1850 */ 147, 148, 149, 36, 40, 284, 284, 284, 284, 284,
148834 /* 1860 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148835 /* 1870 */ 284, 284, 284, 284, 284, 284, 59, 284, 284, 284,
148836 /* 1880 */ 284, 284, 284, 284, 70, 284, 284, 284, 71, 284,
148837 /* 1890 */ 284, 284, 78, 284, 284, 81, 19, 20, 284, 22,
148838 /* 1900 */ 284, 284, 284, 284, 284, 284, 92, 284, 284, 284,
148839 /* 1910 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 102,
148840 /* 1920 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148841 /* 1930 */ 284, 114, 284, 284, 284, 284, 59, 284, 284, 284,
148842 /* 1940 */ 126, 284, 284, 284, 284, 131, 132, 284, 71, 284,
148843 /* 1950 */ 284, 284, 284, 284, 284, 284, 19, 20, 284, 22,
148844 /* 1960 */ 284, 284, 145, 146, 147, 148, 149, 284, 154, 284,
148845 /* 1970 */ 284, 94, 284, 36, 284, 284, 284, 100, 101, 284,
148846 /* 1980 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148847 /* 1990 */ 284, 114, 5, 284, 284, 284, 59, 10, 11, 12,
148848 /* 2000 */ 13, 14, 284, 284, 17, 284, 284, 284, 71, 284,
148849 /* 2010 */ 284, 284, 284, 284, 284, 284, 284, 30, 284, 32,
148850 /* 2020 */ 284, 284, 145, 146, 147, 148, 149, 40, 284, 284,
148851 /* 2030 */ 284, 94, 284, 284, 284, 284, 284, 100, 101, 284,
148852 /* 2040 */ 284, 284, 284, 284, 107, 284, 109, 110, 111, 284,
148853 /* 2050 */ 284, 114, 284, 284, 284, 284, 284, 70, 284, 284,
148854 /* 2060 */ 284, 284, 284, 284, 284, 78, 284, 284, 81, 284,
148855 /* 2070 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 92,
148856 /* 2080 */ 284, 284, 145, 146, 147, 148, 149, 284, 284, 284,
148857 /* 2090 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148858 /* 2100 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148859 /* 2110 */ 284, 284, 284, 126, 284, 284, 284, 284, 131, 132,
148860 /* 2120 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148861 /* 2130 */ 284, 284, 284, 284, 284, 284, 284, 284, 284, 284,
148862 /* 2140 */ 284, 154, 284, 284, 284, 284, 284, 284, 284, 284,
148863 /* 2150 */ 284, 284,
148864 };
148865 #define YY_SHIFT_COUNT (540)
148866 #define YY_SHIFT_MIN (0)
148867 #define YY_SHIFT_MAX (1987)
148868 static const unsigned short int yy_shift_ofst[] = {
148869 /* 0 */ 1814, 1632, 1987, 1426, 1426, 155, 1482, 1633, 1703, 1877,
148870 /* 10 */ 1877, 1877, 203, 0, 0, 264, 1106, 1877, 1877, 1877,
148871 /* 20 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148872 /* 30 */ 60, 60, 380, 380, 99, 569, 155, 155, 155, 155,
148873 /* 40 */ 155, 155, 97, 194, 332, 429, 526, 623, 720, 817,
148874 /* 50 */ 914, 934, 1086, 1238, 1106, 1106, 1106, 1106, 1106, 1106,
148875 /* 60 */ 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106, 1106,
148876 /* 70 */ 1106, 1106, 1258, 1106, 1355, 1375, 1375, 1817, 1877, 1877,
148877 /* 80 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148878 /* 90 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148879 /* 100 */ 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148880 /* 110 */ 1937, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877, 1877,
148881 /* 120 */ 1877, 1877, 1877, 1877, 32, 129, 129, 129, 129, 129,
148882 /* 130 */ 169, 152, 73, 582, 583, 782, 582, 117, 117, 582,
148883 /* 140 */ 367, 367, 367, 367, 426, 402, 106, 2142, 2142, 284,
148884 /* 150 */ 284, 284, 229, 12, 391, 12, 12, 669, 669, 474,
148885 /* 160 */ 483, 259, 780, 582, 582, 582, 582, 582, 582, 582,
148886 /* 170 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
148887 /* 180 */ 582, 582, 582, 582, 558, 558, 582, 530, 718, 718,
148888 /* 190 */ 947, 841, 841, 947, 788, 984, 2142, 2142, 2142, 312,
148889 /* 200 */ 45, 45, 53, 212, 314, 385, 497, 507, 529, 574,
148890 /* 210 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 101,
148891 /* 220 */ 582, 582, 582, 582, 582, 582, 582, 582, 582, 582,
148892 /* 230 */ 582, 582, 478, 478, 478, 582, 582, 582, 582, 820,
148893 /* 240 */ 582, 582, 582, 776, 765, 582, 582, 865, 582, 582,
148894 /* 250 */ 582, 582, 582, 582, 582, 582, 693, 822, 228, 14,
148895 /* 260 */ 14, 14, 14, 723, 228, 228, 810, 1001, 696, 1156,
148896 /* 270 */ 163, 486, 486, 1145, 163, 163, 1145, 981, 1025, 963,
148897 /* 280 */ 1067, 1067, 1067, 486, 975, 975, 1017, 1144, 39, 1150,
148898 /* 290 */ 1338, 1282, 1282, 1399, 1399, 1282, 1298, 1335, 1422, 1404,
148899 /* 300 */ 1321, 1447, 1447, 1447, 1447, 1282, 1451, 1321, 1321, 1335,
148900 /* 310 */ 1422, 1404, 1404, 1321, 1282, 1451, 1345, 1434, 1282, 1451,
148901 /* 320 */ 1483, 1282, 1451, 1282, 1451, 1483, 1405, 1405, 1405, 1450,
148902 /* 330 */ 1483, 1405, 1400, 1405, 1450, 1405, 1405, 1483, 1419, 1419,
148903 /* 340 */ 1483, 1406, 1437, 1406, 1437, 1406, 1437, 1406, 1437, 1282,
148904 /* 350 */ 1460, 1460, 1411, 1417, 1534, 1282, 1413, 1411, 1425, 1427,
148905 /* 360 */ 1321, 1542, 1559, 1574, 1574, 1584, 1584, 1584, 2142, 2142,
148906 /* 370 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142,
148907 /* 380 */ 2142, 2142, 2142, 2142, 300, 438, 310, 860, 873, 773,
148908 /* 390 */ 500, 1153, 1199, 1093, 1053, 1154, 1203, 1206, 1207, 1213,
148909 /* 400 */ 1215, 1217, 1230, 1208, 1146, 1261, 1137, 1211, 1240, 1248,
148910 /* 410 */ 1249, 1097, 1131, 1273, 1293, 1214, 1233, 1601, 1605, 1589,
148911 /* 420 */ 1458, 1599, 1522, 1602, 1594, 1597, 1489, 1492, 1513, 1614,
148912 /* 430 */ 1504, 1620, 1510, 1625, 1647, 1515, 1507, 1531, 1595, 1621,
148913 /* 440 */ 1514, 1606, 1607, 1608, 1610, 1543, 1556, 1634, 1533, 1669,
148914 /* 450 */ 1666, 1651, 1566, 1523, 1609, 1649, 1611, 1603, 1639, 1547,
148915 /* 460 */ 1575, 1658, 1664, 1667, 1561, 1569, 1668, 1622, 1671, 1672,
148916 /* 470 */ 1665, 1673, 1624, 1670, 1674, 1630, 1662, 1677, 1563, 1679,
148917 /* 480 */ 1680, 1549, 1684, 1685, 1683, 1688, 1690, 1692, 1691, 1695,
148918 /* 490 */ 1694, 1585, 1698, 1705, 1617, 1696, 1707, 1596, 1709, 1697,
148919 /* 500 */ 1702, 1704, 1711, 1652, 1675, 1663, 1708, 1676, 1659, 1714,
148920 /* 510 */ 1718, 1731, 1730, 1729, 1733, 1722, 1734, 1709, 1737, 1738,
148921 /* 520 */ 1742, 1743, 1741, 1745, 1747, 1759, 1749, 1750, 1752, 1753,
148922 /* 530 */ 1751, 1755, 1757, 1656, 1653, 1654, 1655, 1657, 1769, 1778,
148923 /* 540 */ 1793,
148924 };
148925 #define YY_REDUCE_COUNT (383)
148926 #define YY_REDUCE_MIN (-241)
148927 #define YY_REDUCE_MAX (1440)
148928 static const short yy_reduce_ofst[] = {
148929 /* 0 */ -151, 181, -141, 376, 379, -149, -153, -75, -1, 227,
148930 /* 10 */ 273, 279, 232, -176, -133, -241, -179, 321, 349, 447,
148931 /* 20 */ 528, 373, 546, 590, 431, 470, 593, -163, 520, 564,
148932 /* 30 */ 624, 626, 246, 386, 539, 479, 536, 573, 576, 619,
148933 /* 40 */ 627, 634, -202, -202, -202, -202, -202, -202, -202, -202,
148934 /* 50 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,
148935 /* 60 */ -202, -202, -202, -202, -202, -202, -202, -202, -202, -202,
148936 /* 70 */ -202, -202, -202, -202, -202, -202, -202, 113, 137, 304,
148937 /* 80 */ 660, 665, 691, 714, 721, 741, 758, 760, 784, 787,
148938 /* 90 */ 807, 833, 836, 838, 861, 874, 876, 878, 880, 887,
148939 /* 100 */ 889, 891, 893, 903, 905, 907, 919, 921, 923, 930,
148940 /* 110 */ 932, 957, 959, 977, 1006, 1011, 1026, 1029, 1031, 1034,
148941 /* 120 */ 1046, 1057, 1059, 1061, -202, -202, -202, -202, -202, -202,
148942 /* 130 */ -202, -202, -202, 240, -172, -39, 139, 76, 235, 566,
148943 /* 140 */ -103, 487, -103, 487, 502, -202, -202, -202, -202, -171,
148944 /* 150 */ -171, -171, -134, -161, 110, 52, 274, -113, 678, 261,
148945 /* 160 */ 444, 384, 384, -162, 481, 618, 666, 495, 186, 236,
148946 /* 170 */ 730, 731, 672, 174, 674, 545, 757, 734, 769, 732,
148947 /* 180 */ 418, 830, 826, 879, 480, 667, 729, 427, 777, 809,
148948 /* 190 */ 608, 767, 812, 922, 839, 242, 855, 900, 390, -156,
148949 /* 200 */ -108, -104, -76, -83, 207, 260, 347, 570, 595, 724,
148950 /* 210 */ 738, 744, 768, 906, 916, 1014, 1064, 1091, 1098, 92,
148951 /* 220 */ 1113, 1130, 1133, 1155, 1158, 1159, 1160, 1161, 1162, 1163,
148952 /* 230 */ 1164, 1165, 448, 553, 971, 1166, 1178, 1179, 1180, 1069,
148953 /* 240 */ 1181, 1182, 1183, 1094, 1040, 1184, 1185, 1110, 1186, 260,
148954 /* 250 */ 1198, 1201, 1202, 1204, 1205, 1209, 1114, 1111, 1167, 1147,
148955 /* 260 */ 1149, 1151, 1152, 1069, 1167, 1167, 1168, 1193, 1216, 1118,
148956 /* 270 */ 1169, 1157, 1187, 1123, 1171, 1172, 1124, 1200, 1190, 1195,
148957 /* 280 */ 1222, 1223, 1224, 1188, 1173, 1175, 1148, 1218, 1219, 1227,
148958 /* 290 */ 1170, 1245, 1262, 1176, 1177, 1266, 1191, 1210, 1225, 1244,
148959 /* 300 */ 1250, 1260, 1274, 1275, 1276, 1292, 1297, 1269, 1270, 1251,
148960 /* 310 */ 1253, 1283, 1284, 1277, 1316, 1320, 1241, 1243, 1324, 1330,
148961 /* 320 */ 1313, 1334, 1336, 1337, 1339, 1317, 1325, 1326, 1327, 1323,
148962 /* 330 */ 1329, 1333, 1332, 1341, 1331, 1342, 1344, 1346, 1278, 1288,
148963 /* 340 */ 1349, 1312, 1315, 1318, 1328, 1319, 1347, 1322, 1348, 1373,
148964 /* 350 */ 1267, 1279, 1356, 1340, 1343, 1388, 1350, 1359, 1351, 1363,
148965 /* 360 */ 1367, 1391, 1410, 1430, 1431, 1428, 1429, 1435, 1352, 1353,
148966 /* 370 */ 1354, 1420, 1416, 1418, 1421, 1423, 1432, 1409, 1412, 1424,
148967 /* 380 */ 1433, 1439, 1440, 1436,
148968 };
148969 static const YYACTIONTYPE yy_default[] = {
148970 /* 0 */ 1536, 1536, 1536, 1376, 1159, 1265, 1159, 1159, 1159, 1376,
148971 /* 10 */ 1376, 1376, 1159, 1295, 1295, 1429, 1190, 1159, 1159, 1159,
148972 /* 20 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1375, 1159, 1159,
148973 /* 30 */ 1159, 1159, 1459, 1459, 1159, 1159, 1159, 1159, 1159, 1159,
148974 /* 40 */ 1159, 1159, 1159, 1301, 1159, 1159, 1159, 1159, 1159, 1377,
148975 /* 50 */ 1378, 1159, 1159, 1159, 1428, 1430, 1393, 1311, 1310, 1309,
148976 /* 60 */ 1308, 1411, 1282, 1306, 1299, 1303, 1371, 1372, 1370, 1374,
148977 /* 70 */ 1378, 1377, 1159, 1302, 1342, 1356, 1341, 1159, 1159, 1159,
148978 /* 80 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148979 /* 90 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148980 /* 100 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148981 /* 110 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148982 /* 120 */ 1159, 1159, 1159, 1159, 1350, 1355, 1361, 1354, 1351, 1344,
148983 /* 130 */ 1343, 1345, 1346, 1159, 1180, 1229, 1159, 1159, 1159, 1159,
148984 /* 140 */ 1447, 1446, 1159, 1159, 1190, 1347, 1348, 1358, 1357, 1436,
148985 /* 150 */ 1492, 1491, 1394, 1159, 1159, 1159, 1159, 1159, 1159, 1459,
148986 /* 160 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148987 /* 170 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148988 /* 180 */ 1159, 1159, 1159, 1159, 1459, 1459, 1159, 1190, 1459, 1459,
148989 /* 190 */ 1186, 1336, 1335, 1186, 1289, 1159, 1442, 1265, 1256, 1159,
148990 /* 200 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148991 /* 210 */ 1159, 1159, 1159, 1433, 1431, 1159, 1159, 1159, 1159, 1159,
148992 /* 220 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148993 /* 230 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
148994 /* 240 */ 1159, 1159, 1159, 1261, 1159, 1159, 1159, 1159, 1159, 1159,
148995 /* 250 */ 1159, 1159, 1159, 1159, 1159, 1486, 1159, 1406, 1243, 1261,
148996 /* 260 */ 1261, 1261, 1261, 1263, 1244, 1242, 1255, 1190, 1166, 1528,
148997 /* 270 */ 1305, 1284, 1284, 1525, 1305, 1305, 1525, 1204, 1506, 1201,
148998 /* 280 */ 1295, 1295, 1295, 1284, 1289, 1289, 1373, 1262, 1255, 1159,
148999 /* 290 */ 1528, 1270, 1270, 1527, 1527, 1270, 1394, 1314, 1320, 1232,
149000 /* 300 */ 1305, 1238, 1238, 1238, 1238, 1270, 1177, 1305, 1305, 1314,
149001 /* 310 */ 1320, 1232, 1232, 1305, 1270, 1177, 1410, 1522, 1270, 1177,
149002 /* 320 */ 1384, 1270, 1177, 1270, 1177, 1384, 1230, 1230, 1230, 1219,
149003 /* 330 */ 1384, 1230, 1204, 1230, 1219, 1230, 1230, 1384, 1388, 1388,
149004 /* 340 */ 1384, 1288, 1283, 1288, 1283, 1288, 1283, 1288, 1283, 1270,
149005 /* 350 */ 1469, 1469, 1300, 1289, 1379, 1270, 1159, 1300, 1298, 1296,
149006 /* 360 */ 1305, 1183, 1222, 1489, 1489, 1485, 1485, 1485, 1533, 1533,
149007 /* 370 */ 1442, 1501, 1190, 1190, 1190, 1190, 1501, 1206, 1206, 1190,
149008 /* 380 */ 1190, 1190, 1190, 1501, 1159, 1159, 1159, 1159, 1159, 1159,
149009 /* 390 */ 1496, 1159, 1395, 1274, 1159, 1159, 1159, 1159, 1159, 1159,
149010 /* 400 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149011 /* 410 */ 1159, 1159, 1159, 1159, 1159, 1159, 1325, 1159, 1162, 1439,
149012 /* 420 */ 1159, 1159, 1437, 1159, 1159, 1159, 1159, 1159, 1159, 1275,
149013 /* 430 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149014 /* 440 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1524, 1159,
149015 /* 450 */ 1159, 1159, 1159, 1159, 1159, 1409, 1408, 1159, 1159, 1272,
149016 /* 460 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149017 /* 470 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149018 /* 480 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149019 /* 490 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1297, 1159,
149020 /* 500 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149021 /* 510 */ 1159, 1159, 1159, 1474, 1290, 1159, 1159, 1515, 1159, 1159,
149022 /* 520 */ 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159,
149023 /* 530 */ 1159, 1159, 1510, 1246, 1327, 1159, 1326, 1330, 1159, 1171,
149024 /* 540 */ 1159,
149025 };
149026 /********** End of lemon-generated parsing tables *****************************/
149027
149028 /* The next table maps tokens (terminal symbols) into fallback tokens.
149029 ** If a construct like the following:
@@ -148512,10 +149127,14 @@
149127 59, /* FOLLOWING => ID */
149128 59, /* PARTITION => ID */
149129 59, /* PRECEDING => ID */
149130 59, /* RANGE => ID */
149131 59, /* UNBOUNDED => ID */
149132 59, /* EXCLUDE => ID */
149133 59, /* GROUPS => ID */
149134 59, /* OTHERS => ID */
149135 59, /* TIES => ID */
149136 59, /* REINDEX => ID */
149137 59, /* RENAME => ID */
149138 59, /* CTIME_KW => ID */
149139 };
149140 #endif /* YYFALLBACK */
@@ -148690,200 +149309,206 @@
149309 /* 83 */ "FOLLOWING",
149310 /* 84 */ "PARTITION",
149311 /* 85 */ "PRECEDING",
149312 /* 86 */ "RANGE",
149313 /* 87 */ "UNBOUNDED",
149314 /* 88 */ "EXCLUDE",
149315 /* 89 */ "GROUPS",
149316 /* 90 */ "OTHERS",
149317 /* 91 */ "TIES",
149318 /* 92 */ "REINDEX",
149319 /* 93 */ "RENAME",
149320 /* 94 */ "CTIME_KW",
149321 /* 95 */ "ANY",
149322 /* 96 */ "BITAND",
149323 /* 97 */ "BITOR",
149324 /* 98 */ "LSHIFT",
149325 /* 99 */ "RSHIFT",
149326 /* 100 */ "PLUS",
149327 /* 101 */ "MINUS",
149328 /* 102 */ "STAR",
149329 /* 103 */ "SLASH",
149330 /* 104 */ "REM",
149331 /* 105 */ "CONCAT",
149332 /* 106 */ "COLLATE",
149333 /* 107 */ "BITNOT",
149334 /* 108 */ "ON",
149335 /* 109 */ "INDEXED",
149336 /* 110 */ "STRING",
149337 /* 111 */ "JOIN_KW",
149338 /* 112 */ "CONSTRAINT",
149339 /* 113 */ "DEFAULT",
149340 /* 114 */ "NULL",
149341 /* 115 */ "PRIMARY",
149342 /* 116 */ "UNIQUE",
149343 /* 117 */ "CHECK",
149344 /* 118 */ "REFERENCES",
149345 /* 119 */ "AUTOINCR",
149346 /* 120 */ "INSERT",
149347 /* 121 */ "DELETE",
149348 /* 122 */ "UPDATE",
149349 /* 123 */ "SET",
149350 /* 124 */ "DEFERRABLE",
149351 /* 125 */ "FOREIGN",
149352 /* 126 */ "DROP",
149353 /* 127 */ "UNION",
149354 /* 128 */ "ALL",
149355 /* 129 */ "EXCEPT",
149356 /* 130 */ "INTERSECT",
149357 /* 131 */ "SELECT",
149358 /* 132 */ "VALUES",
149359 /* 133 */ "DISTINCT",
149360 /* 134 */ "DOT",
149361 /* 135 */ "FROM",
149362 /* 136 */ "JOIN",
149363 /* 137 */ "USING",
149364 /* 138 */ "ORDER",
149365 /* 139 */ "GROUP",
149366 /* 140 */ "HAVING",
149367 /* 141 */ "LIMIT",
149368 /* 142 */ "WHERE",
149369 /* 143 */ "INTO",
149370 /* 144 */ "NOTHING",
149371 /* 145 */ "FLOAT",
149372 /* 146 */ "BLOB",
149373 /* 147 */ "INTEGER",
149374 /* 148 */ "VARIABLE",
149375 /* 149 */ "CASE",
149376 /* 150 */ "WHEN",
149377 /* 151 */ "THEN",
149378 /* 152 */ "ELSE",
149379 /* 153 */ "INDEX",
149380 /* 154 */ "ALTER",
149381 /* 155 */ "ADD",
149382 /* 156 */ "WINDOW",
149383 /* 157 */ "OVER",
149384 /* 158 */ "FILTER",
149385 /* 159 */ "input",
149386 /* 160 */ "cmdlist",
149387 /* 161 */ "ecmd",
149388 /* 162 */ "cmdx",
149389 /* 163 */ "explain",
149390 /* 164 */ "cmd",
149391 /* 165 */ "transtype",
149392 /* 166 */ "trans_opt",
149393 /* 167 */ "nm",
149394 /* 168 */ "savepoint_opt",
149395 /* 169 */ "create_table",
149396 /* 170 */ "create_table_args",
149397 /* 171 */ "createkw",
149398 /* 172 */ "temp",
149399 /* 173 */ "ifnotexists",
149400 /* 174 */ "dbnm",
149401 /* 175 */ "columnlist",
149402 /* 176 */ "conslist_opt",
149403 /* 177 */ "table_options",
149404 /* 178 */ "select",
149405 /* 179 */ "columnname",
149406 /* 180 */ "carglist",
149407 /* 181 */ "typetoken",
149408 /* 182 */ "typename",
149409 /* 183 */ "signed",
149410 /* 184 */ "plus_num",
149411 /* 185 */ "minus_num",
149412 /* 186 */ "scanpt",
149413 /* 187 */ "ccons",
149414 /* 188 */ "term",
149415 /* 189 */ "expr",
149416 /* 190 */ "onconf",
149417 /* 191 */ "sortorder",
149418 /* 192 */ "autoinc",
149419 /* 193 */ "eidlist_opt",
149420 /* 194 */ "refargs",
149421 /* 195 */ "defer_subclause",
149422 /* 196 */ "refarg",
149423 /* 197 */ "refact",
149424 /* 198 */ "init_deferred_pred_opt",
149425 /* 199 */ "conslist",
149426 /* 200 */ "tconscomma",
149427 /* 201 */ "tcons",
149428 /* 202 */ "sortlist",
149429 /* 203 */ "eidlist",
149430 /* 204 */ "defer_subclause_opt",
149431 /* 205 */ "orconf",
149432 /* 206 */ "resolvetype",
149433 /* 207 */ "raisetype",
149434 /* 208 */ "ifexists",
149435 /* 209 */ "fullname",
149436 /* 210 */ "selectnowith",
149437 /* 211 */ "oneselect",
149438 /* 212 */ "wqlist",
149439 /* 213 */ "multiselect_op",
149440 /* 214 */ "distinct",
149441 /* 215 */ "selcollist",
149442 /* 216 */ "from",
149443 /* 217 */ "where_opt",
149444 /* 218 */ "groupby_opt",
149445 /* 219 */ "having_opt",
149446 /* 220 */ "orderby_opt",
149447 /* 221 */ "limit_opt",
149448 /* 222 */ "window_clause",
149449 /* 223 */ "values",
149450 /* 224 */ "nexprlist",
149451 /* 225 */ "sclp",
149452 /* 226 */ "as",
149453 /* 227 */ "seltablist",
149454 /* 228 */ "stl_prefix",
149455 /* 229 */ "joinop",
149456 /* 230 */ "indexed_opt",
149457 /* 231 */ "on_opt",
149458 /* 232 */ "using_opt",
149459 /* 233 */ "exprlist",
149460 /* 234 */ "xfullname",
149461 /* 235 */ "idlist",
149462 /* 236 */ "with",
149463 /* 237 */ "setlist",
149464 /* 238 */ "insert_cmd",
149465 /* 239 */ "idlist_opt",
149466 /* 240 */ "upsert",
149467 /* 241 */ "over_clause",
149468 /* 242 */ "likeop",
149469 /* 243 */ "between_op",
149470 /* 244 */ "in_op",
149471 /* 245 */ "paren_exprlist",
149472 /* 246 */ "case_operand",
149473 /* 247 */ "case_exprlist",
149474 /* 248 */ "case_else",
149475 /* 249 */ "uniqueflag",
149476 /* 250 */ "collate",
149477 /* 251 */ "vinto",
149478 /* 252 */ "nmnum",
149479 /* 253 */ "trigger_decl",
149480 /* 254 */ "trigger_cmd_list",
149481 /* 255 */ "trigger_time",
149482 /* 256 */ "trigger_event",
149483 /* 257 */ "foreach_clause",
149484 /* 258 */ "when_clause",
149485 /* 259 */ "trigger_cmd",
149486 /* 260 */ "trnm",
149487 /* 261 */ "tridxby",
149488 /* 262 */ "database_kw_opt",
149489 /* 263 */ "key_opt",
149490 /* 264 */ "add_column_fullname",
149491 /* 265 */ "kwcolumn_opt",
149492 /* 266 */ "create_vtab",
149493 /* 267 */ "vtabarglist",
149494 /* 268 */ "vtabarg",
149495 /* 269 */ "vtabargtoken",
149496 /* 270 */ "lp",
149497 /* 271 */ "anylist",
149498 /* 272 */ "windowdefn_list",
149499 /* 273 */ "windowdefn",
149500 /* 274 */ "window",
149501 /* 275 */ "frame_opt",
149502 /* 276 */ "part_opt",
149503 /* 277 */ "filter_opt",
149504 /* 278 */ "range_or_rows",
149505 /* 279 */ "frame_bound",
149506 /* 280 */ "frame_bound_s",
149507 /* 281 */ "frame_bound_e",
149508 /* 282 */ "frame_exclude_opt",
149509 /* 283 */ "frame_exclude",
149510 };
149511 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
149512
149513 #ifndef NDEBUG
149514 /* For tracing reduce actions, the names of all rules are required.
@@ -149177,89 +149802,95 @@
149802 /* 285 */ "with ::= WITH RECURSIVE wqlist",
149803 /* 286 */ "wqlist ::= nm eidlist_opt AS LP select RP",
149804 /* 287 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
149805 /* 288 */ "windowdefn_list ::= windowdefn",
149806 /* 289 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
149807 /* 290 */ "windowdefn ::= nm AS LP window RP",
149808 /* 291 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
149809 /* 292 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
149810 /* 293 */ "window ::= ORDER BY sortlist frame_opt",
149811 /* 294 */ "window ::= nm ORDER BY sortlist frame_opt",
149812 /* 295 */ "window ::= frame_opt",
149813 /* 296 */ "window ::= nm frame_opt",
149814 /* 297 */ "frame_opt ::=",
149815 /* 298 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
149816 /* 299 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
149817 /* 300 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
149818 /* 301 */ "frame_bound_s ::= frame_bound",
149819 /* 302 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
149820 /* 303 */ "frame_bound_e ::= frame_bound",
149821 /* 304 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
149822 /* 305 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
149823 /* 306 */ "frame_bound ::= CURRENT ROW",
149824 /* 307 */ "frame_exclude_opt ::=",
149825 /* 308 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
149826 /* 309 */ "frame_exclude ::= NO OTHERS",
149827 /* 310 */ "frame_exclude ::= CURRENT ROW",
149828 /* 311 */ "frame_exclude ::= GROUP|TIES",
149829 /* 312 */ "window_clause ::= WINDOW windowdefn_list",
149830 /* 313 */ "over_clause ::= filter_opt OVER LP window RP",
149831 /* 314 */ "over_clause ::= filter_opt OVER nm",
149832 /* 315 */ "filter_opt ::=",
149833 /* 316 */ "filter_opt ::= FILTER LP WHERE expr RP",
149834 /* 317 */ "input ::= cmdlist",
149835 /* 318 */ "cmdlist ::= cmdlist ecmd",
149836 /* 319 */ "cmdlist ::= ecmd",
149837 /* 320 */ "ecmd ::= SEMI",
149838 /* 321 */ "ecmd ::= cmdx SEMI",
149839 /* 322 */ "ecmd ::= explain cmdx",
149840 /* 323 */ "trans_opt ::=",
149841 /* 324 */ "trans_opt ::= TRANSACTION",
149842 /* 325 */ "trans_opt ::= TRANSACTION nm",
149843 /* 326 */ "savepoint_opt ::= SAVEPOINT",
149844 /* 327 */ "savepoint_opt ::=",
149845 /* 328 */ "cmd ::= create_table create_table_args",
149846 /* 329 */ "columnlist ::= columnlist COMMA columnname carglist",
149847 /* 330 */ "columnlist ::= columnname carglist",
149848 /* 331 */ "nm ::= ID|INDEXED",
149849 /* 332 */ "nm ::= STRING",
149850 /* 333 */ "nm ::= JOIN_KW",
149851 /* 334 */ "typetoken ::= typename",
149852 /* 335 */ "typename ::= ID|STRING",
149853 /* 336 */ "signed ::= plus_num",
149854 /* 337 */ "signed ::= minus_num",
149855 /* 338 */ "carglist ::= carglist ccons",
149856 /* 339 */ "carglist ::=",
149857 /* 340 */ "ccons ::= NULL onconf",
149858 /* 341 */ "conslist_opt ::= COMMA conslist",
149859 /* 342 */ "conslist ::= conslist tconscomma tcons",
149860 /* 343 */ "conslist ::= tcons",
149861 /* 344 */ "tconscomma ::=",
149862 /* 345 */ "defer_subclause_opt ::= defer_subclause",
149863 /* 346 */ "resolvetype ::= raisetype",
149864 /* 347 */ "selectnowith ::= oneselect",
149865 /* 348 */ "oneselect ::= values",
149866 /* 349 */ "sclp ::= selcollist COMMA",
149867 /* 350 */ "as ::= ID|STRING",
149868 /* 351 */ "expr ::= term",
149869 /* 352 */ "likeop ::= LIKE_KW|MATCH",
149870 /* 353 */ "exprlist ::= nexprlist",
149871 /* 354 */ "nmnum ::= plus_num",
149872 /* 355 */ "nmnum ::= nm",
149873 /* 356 */ "nmnum ::= ON",
149874 /* 357 */ "nmnum ::= DELETE",
149875 /* 358 */ "nmnum ::= DEFAULT",
149876 /* 359 */ "plus_num ::= INTEGER|FLOAT",
149877 /* 360 */ "foreach_clause ::=",
149878 /* 361 */ "foreach_clause ::= FOR EACH ROW",
149879 /* 362 */ "trnm ::= nm",
149880 /* 363 */ "tridxby ::=",
149881 /* 364 */ "database_kw_opt ::= DATABASE",
149882 /* 365 */ "database_kw_opt ::=",
149883 /* 366 */ "kwcolumn_opt ::=",
149884 /* 367 */ "kwcolumn_opt ::= COLUMNKW",
149885 /* 368 */ "vtabarglist ::= vtabarg",
149886 /* 369 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
149887 /* 370 */ "vtabarg ::= vtabarg vtabargtoken",
149888 /* 371 */ "anylist ::=",
149889 /* 372 */ "anylist ::= anylist LP anylist RP",
149890 /* 373 */ "anylist ::= anylist ANY",
149891 /* 374 */ "with ::=",
149892 };
149893 #endif /* NDEBUG */
149894
149895
149896 #if YYSTACKDEPTH<=0
@@ -149381,101 +150012,101 @@
150012 ** Note: during a reduce, the only symbols destroyed are those
150013 ** which appear on the RHS of the rule, but which are *not* used
150014 ** inside the C code.
150015 */
150016 /********* Begin destructor definitions ***************************************/
150017 case 178: /* select */
150018 case 210: /* selectnowith */
150019 case 211: /* oneselect */
150020 case 223: /* values */
150021 {
150022 sqlite3SelectDelete(pParse->db, (yypminor->yy491));
150023 }
150024 break;
150025 case 188: /* term */
150026 case 189: /* expr */
150027 case 217: /* where_opt */
150028 case 219: /* having_opt */
150029 case 231: /* on_opt */
150030 case 246: /* case_operand */
150031 case 248: /* case_else */
150032 case 251: /* vinto */
150033 case 258: /* when_clause */
150034 case 263: /* key_opt */
150035 case 277: /* filter_opt */
150036 {
150037 sqlite3ExprDelete(pParse->db, (yypminor->yy130));
150038 }
150039 break;
150040 case 193: /* eidlist_opt */
150041 case 202: /* sortlist */
150042 case 203: /* eidlist */
150043 case 215: /* selcollist */
150044 case 218: /* groupby_opt */
150045 case 220: /* orderby_opt */
150046 case 224: /* nexprlist */
150047 case 225: /* sclp */
150048 case 233: /* exprlist */
150049 case 237: /* setlist */
150050 case 245: /* paren_exprlist */
150051 case 247: /* case_exprlist */
150052 case 276: /* part_opt */
150053 {
150054 sqlite3ExprListDelete(pParse->db, (yypminor->yy442));
150055 }
150056 break;
150057 case 209: /* fullname */
150058 case 216: /* from */
150059 case 227: /* seltablist */
150060 case 228: /* stl_prefix */
150061 case 234: /* xfullname */
150062 {
150063 sqlite3SrcListDelete(pParse->db, (yypminor->yy147));
150064 }
150065 break;
150066 case 212: /* wqlist */
150067 {
150068 sqlite3WithDelete(pParse->db, (yypminor->yy523));
150069 }
150070 break;
150071 case 222: /* window_clause */
150072 case 272: /* windowdefn_list */
150073 {
150074 sqlite3WindowListDelete(pParse->db, (yypminor->yy395));
150075 }
150076 break;
150077 case 232: /* using_opt */
150078 case 235: /* idlist */
150079 case 239: /* idlist_opt */
150080 {
150081 sqlite3IdListDelete(pParse->db, (yypminor->yy200));
150082 }
150083 break;
150084 case 241: /* over_clause */
150085 case 273: /* windowdefn */
150086 case 274: /* window */
150087 case 275: /* frame_opt */
150088 {
150089 sqlite3WindowDelete(pParse->db, (yypminor->yy395));
150090 }
150091 break;
150092 case 254: /* trigger_cmd_list */
150093 case 259: /* trigger_cmd */
150094 {
150095 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy524));
150096 }
150097 break;
150098 case 256: /* trigger_event */
150099 {
150100 sqlite3IdListDelete(pParse->db, (yypminor->yy498).b);
150101 }
150102 break;
150103 case 279: /* frame_bound */
150104 case 280: /* frame_bound_s */
150105 case 281: /* frame_bound_e */
150106 {
150107 sqlite3ExprDelete(pParse->db, (yypminor->yy273).pExpr);
150108 }
150109 break;
150110 /********* End destructor definitions *****************************************/
150111 default: break; /* If no destructor action specified: do nothing */
150112 }
@@ -149766,379 +150397,385 @@
150397 }
150398
150399 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
150400 ** of that rule */
150401 static const YYCODETYPE yyRuleInfoLhs[] = {
150402 163, /* (0) explain ::= EXPLAIN */
150403 163, /* (1) explain ::= EXPLAIN QUERY PLAN */
150404 162, /* (2) cmdx ::= cmd */
150405 164, /* (3) cmd ::= BEGIN transtype trans_opt */
150406 165, /* (4) transtype ::= */
150407 165, /* (5) transtype ::= DEFERRED */
150408 165, /* (6) transtype ::= IMMEDIATE */
150409 165, /* (7) transtype ::= EXCLUSIVE */
150410 164, /* (8) cmd ::= COMMIT|END trans_opt */
150411 164, /* (9) cmd ::= ROLLBACK trans_opt */
150412 164, /* (10) cmd ::= SAVEPOINT nm */
150413 164, /* (11) cmd ::= RELEASE savepoint_opt nm */
150414 164, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
150415 169, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
150416 171, /* (14) createkw ::= CREATE */
150417 173, /* (15) ifnotexists ::= */
150418 173, /* (16) ifnotexists ::= IF NOT EXISTS */
150419 172, /* (17) temp ::= TEMP */
150420 172, /* (18) temp ::= */
150421 170, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
150422 170, /* (20) create_table_args ::= AS select */
150423 177, /* (21) table_options ::= */
150424 177, /* (22) table_options ::= WITHOUT nm */
150425 179, /* (23) columnname ::= nm typetoken */
150426 181, /* (24) typetoken ::= */
150427 181, /* (25) typetoken ::= typename LP signed RP */
150428 181, /* (26) typetoken ::= typename LP signed COMMA signed RP */
150429 182, /* (27) typename ::= typename ID|STRING */
150430 186, /* (28) scanpt ::= */
150431 187, /* (29) ccons ::= CONSTRAINT nm */
150432 187, /* (30) ccons ::= DEFAULT scanpt term scanpt */
150433 187, /* (31) ccons ::= DEFAULT LP expr RP */
150434 187, /* (32) ccons ::= DEFAULT PLUS term scanpt */
150435 187, /* (33) ccons ::= DEFAULT MINUS term scanpt */
150436 187, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
150437 187, /* (35) ccons ::= NOT NULL onconf */
150438 187, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
150439 187, /* (37) ccons ::= UNIQUE onconf */
150440 187, /* (38) ccons ::= CHECK LP expr RP */
150441 187, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
150442 187, /* (40) ccons ::= defer_subclause */
150443 187, /* (41) ccons ::= COLLATE ID|STRING */
150444 192, /* (42) autoinc ::= */
150445 192, /* (43) autoinc ::= AUTOINCR */
150446 194, /* (44) refargs ::= */
150447 194, /* (45) refargs ::= refargs refarg */
150448 196, /* (46) refarg ::= MATCH nm */
150449 196, /* (47) refarg ::= ON INSERT refact */
150450 196, /* (48) refarg ::= ON DELETE refact */
150451 196, /* (49) refarg ::= ON UPDATE refact */
150452 197, /* (50) refact ::= SET NULL */
150453 197, /* (51) refact ::= SET DEFAULT */
150454 197, /* (52) refact ::= CASCADE */
150455 197, /* (53) refact ::= RESTRICT */
150456 197, /* (54) refact ::= NO ACTION */
150457 195, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
150458 195, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
150459 198, /* (57) init_deferred_pred_opt ::= */
150460 198, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
150461 198, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
150462 176, /* (60) conslist_opt ::= */
150463 200, /* (61) tconscomma ::= COMMA */
150464 201, /* (62) tcons ::= CONSTRAINT nm */
150465 201, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
150466 201, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
150467 201, /* (65) tcons ::= CHECK LP expr RP onconf */
150468 201, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
150469 204, /* (67) defer_subclause_opt ::= */
150470 190, /* (68) onconf ::= */
150471 190, /* (69) onconf ::= ON CONFLICT resolvetype */
150472 205, /* (70) orconf ::= */
150473 205, /* (71) orconf ::= OR resolvetype */
150474 206, /* (72) resolvetype ::= IGNORE */
150475 206, /* (73) resolvetype ::= REPLACE */
150476 164, /* (74) cmd ::= DROP TABLE ifexists fullname */
150477 208, /* (75) ifexists ::= IF EXISTS */
150478 208, /* (76) ifexists ::= */
150479 164, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
150480 164, /* (78) cmd ::= DROP VIEW ifexists fullname */
150481 164, /* (79) cmd ::= select */
150482 178, /* (80) select ::= WITH wqlist selectnowith */
150483 178, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
150484 178, /* (82) select ::= selectnowith */
150485 210, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
150486 213, /* (84) multiselect_op ::= UNION */
150487 213, /* (85) multiselect_op ::= UNION ALL */
150488 213, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
150489 211, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
150490 211, /* (88) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
150491 223, /* (89) values ::= VALUES LP nexprlist RP */
150492 223, /* (90) values ::= values COMMA LP nexprlist RP */
150493 214, /* (91) distinct ::= DISTINCT */
150494 214, /* (92) distinct ::= ALL */
150495 214, /* (93) distinct ::= */
150496 225, /* (94) sclp ::= */
150497 215, /* (95) selcollist ::= sclp scanpt expr scanpt as */
150498 215, /* (96) selcollist ::= sclp scanpt STAR */
150499 215, /* (97) selcollist ::= sclp scanpt nm DOT STAR */
150500 226, /* (98) as ::= AS nm */
150501 226, /* (99) as ::= */
150502 216, /* (100) from ::= */
150503 216, /* (101) from ::= FROM seltablist */
150504 228, /* (102) stl_prefix ::= seltablist joinop */
150505 228, /* (103) stl_prefix ::= */
150506 227, /* (104) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
150507 227, /* (105) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
150508 227, /* (106) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
150509 227, /* (107) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
150510 174, /* (108) dbnm ::= */
150511 174, /* (109) dbnm ::= DOT nm */
150512 209, /* (110) fullname ::= nm */
150513 209, /* (111) fullname ::= nm DOT nm */
150514 234, /* (112) xfullname ::= nm */
150515 234, /* (113) xfullname ::= nm DOT nm */
150516 234, /* (114) xfullname ::= nm DOT nm AS nm */
150517 234, /* (115) xfullname ::= nm AS nm */
150518 229, /* (116) joinop ::= COMMA|JOIN */
150519 229, /* (117) joinop ::= JOIN_KW JOIN */
150520 229, /* (118) joinop ::= JOIN_KW nm JOIN */
150521 229, /* (119) joinop ::= JOIN_KW nm nm JOIN */
150522 231, /* (120) on_opt ::= ON expr */
150523 231, /* (121) on_opt ::= */
150524 230, /* (122) indexed_opt ::= */
150525 230, /* (123) indexed_opt ::= INDEXED BY nm */
150526 230, /* (124) indexed_opt ::= NOT INDEXED */
150527 232, /* (125) using_opt ::= USING LP idlist RP */
150528 232, /* (126) using_opt ::= */
150529 220, /* (127) orderby_opt ::= */
150530 220, /* (128) orderby_opt ::= ORDER BY sortlist */
150531 202, /* (129) sortlist ::= sortlist COMMA expr sortorder */
150532 202, /* (130) sortlist ::= expr sortorder */
150533 191, /* (131) sortorder ::= ASC */
150534 191, /* (132) sortorder ::= DESC */
150535 191, /* (133) sortorder ::= */
150536 218, /* (134) groupby_opt ::= */
150537 218, /* (135) groupby_opt ::= GROUP BY nexprlist */
150538 219, /* (136) having_opt ::= */
150539 219, /* (137) having_opt ::= HAVING expr */
150540 221, /* (138) limit_opt ::= */
150541 221, /* (139) limit_opt ::= LIMIT expr */
150542 221, /* (140) limit_opt ::= LIMIT expr OFFSET expr */
150543 221, /* (141) limit_opt ::= LIMIT expr COMMA expr */
150544 164, /* (142) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
150545 217, /* (143) where_opt ::= */
150546 217, /* (144) where_opt ::= WHERE expr */
150547 164, /* (145) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
150548 237, /* (146) setlist ::= setlist COMMA nm EQ expr */
150549 237, /* (147) setlist ::= setlist COMMA LP idlist RP EQ expr */
150550 237, /* (148) setlist ::= nm EQ expr */
150551 237, /* (149) setlist ::= LP idlist RP EQ expr */
150552 164, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
150553 164, /* (151) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
150554 240, /* (152) upsert ::= */
150555 240, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
150556 240, /* (154) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
150557 240, /* (155) upsert ::= ON CONFLICT DO NOTHING */
150558 238, /* (156) insert_cmd ::= INSERT orconf */
150559 238, /* (157) insert_cmd ::= REPLACE */
150560 239, /* (158) idlist_opt ::= */
150561 239, /* (159) idlist_opt ::= LP idlist RP */
150562 235, /* (160) idlist ::= idlist COMMA nm */
150563 235, /* (161) idlist ::= nm */
150564 189, /* (162) expr ::= LP expr RP */
150565 189, /* (163) expr ::= ID|INDEXED */
150566 189, /* (164) expr ::= JOIN_KW */
150567 189, /* (165) expr ::= nm DOT nm */
150568 189, /* (166) expr ::= nm DOT nm DOT nm */
150569 188, /* (167) term ::= NULL|FLOAT|BLOB */
150570 188, /* (168) term ::= STRING */
150571 188, /* (169) term ::= INTEGER */
150572 189, /* (170) expr ::= VARIABLE */
150573 189, /* (171) expr ::= expr COLLATE ID|STRING */
150574 189, /* (172) expr ::= CAST LP expr AS typetoken RP */
150575 189, /* (173) expr ::= ID|INDEXED LP distinct exprlist RP */
150576 189, /* (174) expr ::= ID|INDEXED LP STAR RP */
150577 189, /* (175) expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
150578 189, /* (176) expr ::= ID|INDEXED LP STAR RP over_clause */
150579 188, /* (177) term ::= CTIME_KW */
150580 189, /* (178) expr ::= LP nexprlist COMMA expr RP */
150581 189, /* (179) expr ::= expr AND expr */
150582 189, /* (180) expr ::= expr OR expr */
150583 189, /* (181) expr ::= expr LT|GT|GE|LE expr */
150584 189, /* (182) expr ::= expr EQ|NE expr */
150585 189, /* (183) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
150586 189, /* (184) expr ::= expr PLUS|MINUS expr */
150587 189, /* (185) expr ::= expr STAR|SLASH|REM expr */
150588 189, /* (186) expr ::= expr CONCAT expr */
150589 242, /* (187) likeop ::= NOT LIKE_KW|MATCH */
150590 189, /* (188) expr ::= expr likeop expr */
150591 189, /* (189) expr ::= expr likeop expr ESCAPE expr */
150592 189, /* (190) expr ::= expr ISNULL|NOTNULL */
150593 189, /* (191) expr ::= expr NOT NULL */
150594 189, /* (192) expr ::= expr IS expr */
150595 189, /* (193) expr ::= expr IS NOT expr */
150596 189, /* (194) expr ::= NOT expr */
150597 189, /* (195) expr ::= BITNOT expr */
150598 189, /* (196) expr ::= PLUS|MINUS expr */
150599 243, /* (197) between_op ::= BETWEEN */
150600 243, /* (198) between_op ::= NOT BETWEEN */
150601 189, /* (199) expr ::= expr between_op expr AND expr */
150602 244, /* (200) in_op ::= IN */
150603 244, /* (201) in_op ::= NOT IN */
150604 189, /* (202) expr ::= expr in_op LP exprlist RP */
150605 189, /* (203) expr ::= LP select RP */
150606 189, /* (204) expr ::= expr in_op LP select RP */
150607 189, /* (205) expr ::= expr in_op nm dbnm paren_exprlist */
150608 189, /* (206) expr ::= EXISTS LP select RP */
150609 189, /* (207) expr ::= CASE case_operand case_exprlist case_else END */
150610 247, /* (208) case_exprlist ::= case_exprlist WHEN expr THEN expr */
150611 247, /* (209) case_exprlist ::= WHEN expr THEN expr */
150612 248, /* (210) case_else ::= ELSE expr */
150613 248, /* (211) case_else ::= */
150614 246, /* (212) case_operand ::= expr */
150615 246, /* (213) case_operand ::= */
150616 233, /* (214) exprlist ::= */
150617 224, /* (215) nexprlist ::= nexprlist COMMA expr */
150618 224, /* (216) nexprlist ::= expr */
150619 245, /* (217) paren_exprlist ::= */
150620 245, /* (218) paren_exprlist ::= LP exprlist RP */
150621 164, /* (219) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
150622 249, /* (220) uniqueflag ::= UNIQUE */
150623 249, /* (221) uniqueflag ::= */
150624 193, /* (222) eidlist_opt ::= */
150625 193, /* (223) eidlist_opt ::= LP eidlist RP */
150626 203, /* (224) eidlist ::= eidlist COMMA nm collate sortorder */
150627 203, /* (225) eidlist ::= nm collate sortorder */
150628 250, /* (226) collate ::= */
150629 250, /* (227) collate ::= COLLATE ID|STRING */
150630 164, /* (228) cmd ::= DROP INDEX ifexists fullname */
150631 164, /* (229) cmd ::= VACUUM vinto */
150632 164, /* (230) cmd ::= VACUUM nm vinto */
150633 251, /* (231) vinto ::= INTO expr */
150634 251, /* (232) vinto ::= */
150635 164, /* (233) cmd ::= PRAGMA nm dbnm */
150636 164, /* (234) cmd ::= PRAGMA nm dbnm EQ nmnum */
150637 164, /* (235) cmd ::= PRAGMA nm dbnm LP nmnum RP */
150638 164, /* (236) cmd ::= PRAGMA nm dbnm EQ minus_num */
150639 164, /* (237) cmd ::= PRAGMA nm dbnm LP minus_num RP */
150640 184, /* (238) plus_num ::= PLUS INTEGER|FLOAT */
150641 185, /* (239) minus_num ::= MINUS INTEGER|FLOAT */
150642 164, /* (240) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
150643 253, /* (241) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
150644 255, /* (242) trigger_time ::= BEFORE|AFTER */
150645 255, /* (243) trigger_time ::= INSTEAD OF */
150646 255, /* (244) trigger_time ::= */
150647 256, /* (245) trigger_event ::= DELETE|INSERT */
150648 256, /* (246) trigger_event ::= UPDATE */
150649 256, /* (247) trigger_event ::= UPDATE OF idlist */
150650 258, /* (248) when_clause ::= */
150651 258, /* (249) when_clause ::= WHEN expr */
150652 254, /* (250) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
150653 254, /* (251) trigger_cmd_list ::= trigger_cmd SEMI */
150654 260, /* (252) trnm ::= nm DOT nm */
150655 261, /* (253) tridxby ::= INDEXED BY nm */
150656 261, /* (254) tridxby ::= NOT INDEXED */
150657 259, /* (255) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
150658 259, /* (256) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
150659 259, /* (257) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
150660 259, /* (258) trigger_cmd ::= scanpt select scanpt */
150661 189, /* (259) expr ::= RAISE LP IGNORE RP */
150662 189, /* (260) expr ::= RAISE LP raisetype COMMA nm RP */
150663 207, /* (261) raisetype ::= ROLLBACK */
150664 207, /* (262) raisetype ::= ABORT */
150665 207, /* (263) raisetype ::= FAIL */
150666 164, /* (264) cmd ::= DROP TRIGGER ifexists fullname */
150667 164, /* (265) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
150668 164, /* (266) cmd ::= DETACH database_kw_opt expr */
150669 263, /* (267) key_opt ::= */
150670 263, /* (268) key_opt ::= KEY expr */
150671 164, /* (269) cmd ::= REINDEX */
150672 164, /* (270) cmd ::= REINDEX nm dbnm */
150673 164, /* (271) cmd ::= ANALYZE */
150674 164, /* (272) cmd ::= ANALYZE nm dbnm */
150675 164, /* (273) cmd ::= ALTER TABLE fullname RENAME TO nm */
150676 164, /* (274) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
150677 264, /* (275) add_column_fullname ::= fullname */
150678 164, /* (276) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
150679 164, /* (277) cmd ::= create_vtab */
150680 164, /* (278) cmd ::= create_vtab LP vtabarglist RP */
150681 266, /* (279) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
150682 268, /* (280) vtabarg ::= */
150683 269, /* (281) vtabargtoken ::= ANY */
150684 269, /* (282) vtabargtoken ::= lp anylist RP */
150685 270, /* (283) lp ::= LP */
150686 236, /* (284) with ::= WITH wqlist */
150687 236, /* (285) with ::= WITH RECURSIVE wqlist */
150688 212, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
150689 212, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
150690 272, /* (288) windowdefn_list ::= windowdefn */
150691 272, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
150692 273, /* (290) windowdefn ::= nm AS LP window RP */
150693 274, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
150694 274, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
150695 274, /* (293) window ::= ORDER BY sortlist frame_opt */
150696 274, /* (294) window ::= nm ORDER BY sortlist frame_opt */
150697 274, /* (295) window ::= frame_opt */
150698 274, /* (296) window ::= nm frame_opt */
150699 275, /* (297) frame_opt ::= */
150700 275, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
150701 275, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
150702 278, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */
150703 280, /* (301) frame_bound_s ::= frame_bound */
150704 280, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */
150705 281, /* (303) frame_bound_e ::= frame_bound */
150706 281, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */
150707 279, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */
150708 279, /* (306) frame_bound ::= CURRENT ROW */
150709 282, /* (307) frame_exclude_opt ::= */
150710 282, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */
150711 283, /* (309) frame_exclude ::= NO OTHERS */
150712 283, /* (310) frame_exclude ::= CURRENT ROW */
150713 283, /* (311) frame_exclude ::= GROUP|TIES */
150714 222, /* (312) window_clause ::= WINDOW windowdefn_list */
150715 241, /* (313) over_clause ::= filter_opt OVER LP window RP */
150716 241, /* (314) over_clause ::= filter_opt OVER nm */
150717 277, /* (315) filter_opt ::= */
150718 277, /* (316) filter_opt ::= FILTER LP WHERE expr RP */
150719 159, /* (317) input ::= cmdlist */
150720 160, /* (318) cmdlist ::= cmdlist ecmd */
150721 160, /* (319) cmdlist ::= ecmd */
150722 161, /* (320) ecmd ::= SEMI */
150723 161, /* (321) ecmd ::= cmdx SEMI */
150724 161, /* (322) ecmd ::= explain cmdx */
150725 166, /* (323) trans_opt ::= */
150726 166, /* (324) trans_opt ::= TRANSACTION */
150727 166, /* (325) trans_opt ::= TRANSACTION nm */
150728 168, /* (326) savepoint_opt ::= SAVEPOINT */
150729 168, /* (327) savepoint_opt ::= */
150730 164, /* (328) cmd ::= create_table create_table_args */
150731 175, /* (329) columnlist ::= columnlist COMMA columnname carglist */
150732 175, /* (330) columnlist ::= columnname carglist */
150733 167, /* (331) nm ::= ID|INDEXED */
150734 167, /* (332) nm ::= STRING */
150735 167, /* (333) nm ::= JOIN_KW */
150736 181, /* (334) typetoken ::= typename */
150737 182, /* (335) typename ::= ID|STRING */
150738 183, /* (336) signed ::= plus_num */
150739 183, /* (337) signed ::= minus_num */
150740 180, /* (338) carglist ::= carglist ccons */
150741 180, /* (339) carglist ::= */
150742 187, /* (340) ccons ::= NULL onconf */
150743 176, /* (341) conslist_opt ::= COMMA conslist */
150744 199, /* (342) conslist ::= conslist tconscomma tcons */
150745 199, /* (343) conslist ::= tcons */
150746 200, /* (344) tconscomma ::= */
150747 204, /* (345) defer_subclause_opt ::= defer_subclause */
150748 206, /* (346) resolvetype ::= raisetype */
150749 210, /* (347) selectnowith ::= oneselect */
150750 211, /* (348) oneselect ::= values */
150751 225, /* (349) sclp ::= selcollist COMMA */
150752 226, /* (350) as ::= ID|STRING */
150753 189, /* (351) expr ::= term */
150754 242, /* (352) likeop ::= LIKE_KW|MATCH */
150755 233, /* (353) exprlist ::= nexprlist */
150756 252, /* (354) nmnum ::= plus_num */
150757 252, /* (355) nmnum ::= nm */
150758 252, /* (356) nmnum ::= ON */
150759 252, /* (357) nmnum ::= DELETE */
150760 252, /* (358) nmnum ::= DEFAULT */
150761 184, /* (359) plus_num ::= INTEGER|FLOAT */
150762 257, /* (360) foreach_clause ::= */
150763 257, /* (361) foreach_clause ::= FOR EACH ROW */
150764 260, /* (362) trnm ::= nm */
150765 261, /* (363) tridxby ::= */
150766 262, /* (364) database_kw_opt ::= DATABASE */
150767 262, /* (365) database_kw_opt ::= */
150768 265, /* (366) kwcolumn_opt ::= */
150769 265, /* (367) kwcolumn_opt ::= COLUMNKW */
150770 267, /* (368) vtabarglist ::= vtabarg */
150771 267, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */
150772 268, /* (370) vtabarg ::= vtabarg vtabargtoken */
150773 271, /* (371) anylist ::= */
150774 271, /* (372) anylist ::= anylist LP anylist RP */
150775 271, /* (373) anylist ::= anylist ANY */
150776 236, /* (374) with ::= */
150777 };
150778
150779 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
150780 ** of symbols on the right-hand side of that rule. */
150781 static const signed char yyRuleInfoNRhs[] = {
@@ -150430,89 +151067,95 @@
151067 -3, /* (285) with ::= WITH RECURSIVE wqlist */
151068 -6, /* (286) wqlist ::= nm eidlist_opt AS LP select RP */
151069 -8, /* (287) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
151070 -1, /* (288) windowdefn_list ::= windowdefn */
151071 -3, /* (289) windowdefn_list ::= windowdefn_list COMMA windowdefn */
151072 -5, /* (290) windowdefn ::= nm AS LP window RP */
151073 -5, /* (291) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
151074 -6, /* (292) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
151075 -4, /* (293) window ::= ORDER BY sortlist frame_opt */
151076 -5, /* (294) window ::= nm ORDER BY sortlist frame_opt */
151077 -1, /* (295) window ::= frame_opt */
151078 -2, /* (296) window ::= nm frame_opt */
151079 0, /* (297) frame_opt ::= */
151080 -3, /* (298) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
151081 -6, /* (299) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
151082 -1, /* (300) range_or_rows ::= RANGE|ROWS|GROUPS */
151083 -1, /* (301) frame_bound_s ::= frame_bound */
151084 -2, /* (302) frame_bound_s ::= UNBOUNDED PRECEDING */
151085 -1, /* (303) frame_bound_e ::= frame_bound */
151086 -2, /* (304) frame_bound_e ::= UNBOUNDED FOLLOWING */
151087 -2, /* (305) frame_bound ::= expr PRECEDING|FOLLOWING */
151088 -2, /* (306) frame_bound ::= CURRENT ROW */
151089 0, /* (307) frame_exclude_opt ::= */
151090 -2, /* (308) frame_exclude_opt ::= EXCLUDE frame_exclude */
151091 -2, /* (309) frame_exclude ::= NO OTHERS */
151092 -2, /* (310) frame_exclude ::= CURRENT ROW */
151093 -1, /* (311) frame_exclude ::= GROUP|TIES */
151094 -2, /* (312) window_clause ::= WINDOW windowdefn_list */
151095 -5, /* (313) over_clause ::= filter_opt OVER LP window RP */
151096 -3, /* (314) over_clause ::= filter_opt OVER nm */
151097 0, /* (315) filter_opt ::= */
151098 -5, /* (316) filter_opt ::= FILTER LP WHERE expr RP */
151099 -1, /* (317) input ::= cmdlist */
151100 -2, /* (318) cmdlist ::= cmdlist ecmd */
151101 -1, /* (319) cmdlist ::= ecmd */
151102 -1, /* (320) ecmd ::= SEMI */
151103 -2, /* (321) ecmd ::= cmdx SEMI */
151104 -2, /* (322) ecmd ::= explain cmdx */
151105 0, /* (323) trans_opt ::= */
151106 -1, /* (324) trans_opt ::= TRANSACTION */
151107 -2, /* (325) trans_opt ::= TRANSACTION nm */
151108 -1, /* (326) savepoint_opt ::= SAVEPOINT */
151109 0, /* (327) savepoint_opt ::= */
151110 -2, /* (328) cmd ::= create_table create_table_args */
151111 -4, /* (329) columnlist ::= columnlist COMMA columnname carglist */
151112 -2, /* (330) columnlist ::= columnname carglist */
151113 -1, /* (331) nm ::= ID|INDEXED */
151114 -1, /* (332) nm ::= STRING */
151115 -1, /* (333) nm ::= JOIN_KW */
151116 -1, /* (334) typetoken ::= typename */
151117 -1, /* (335) typename ::= ID|STRING */
151118 -1, /* (336) signed ::= plus_num */
151119 -1, /* (337) signed ::= minus_num */
151120 -2, /* (338) carglist ::= carglist ccons */
151121 0, /* (339) carglist ::= */
151122 -2, /* (340) ccons ::= NULL onconf */
151123 -2, /* (341) conslist_opt ::= COMMA conslist */
151124 -3, /* (342) conslist ::= conslist tconscomma tcons */
151125 -1, /* (343) conslist ::= tcons */
151126 0, /* (344) tconscomma ::= */
151127 -1, /* (345) defer_subclause_opt ::= defer_subclause */
151128 -1, /* (346) resolvetype ::= raisetype */
151129 -1, /* (347) selectnowith ::= oneselect */
151130 -1, /* (348) oneselect ::= values */
151131 -2, /* (349) sclp ::= selcollist COMMA */
151132 -1, /* (350) as ::= ID|STRING */
151133 -1, /* (351) expr ::= term */
151134 -1, /* (352) likeop ::= LIKE_KW|MATCH */
151135 -1, /* (353) exprlist ::= nexprlist */
151136 -1, /* (354) nmnum ::= plus_num */
151137 -1, /* (355) nmnum ::= nm */
151138 -1, /* (356) nmnum ::= ON */
151139 -1, /* (357) nmnum ::= DELETE */
151140 -1, /* (358) nmnum ::= DEFAULT */
151141 -1, /* (359) plus_num ::= INTEGER|FLOAT */
151142 0, /* (360) foreach_clause ::= */
151143 -3, /* (361) foreach_clause ::= FOR EACH ROW */
151144 -1, /* (362) trnm ::= nm */
151145 0, /* (363) tridxby ::= */
151146 -1, /* (364) database_kw_opt ::= DATABASE */
151147 0, /* (365) database_kw_opt ::= */
151148 0, /* (366) kwcolumn_opt ::= */
151149 -1, /* (367) kwcolumn_opt ::= COLUMNKW */
151150 -1, /* (368) vtabarglist ::= vtabarg */
151151 -3, /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */
151152 -2, /* (370) vtabarg ::= vtabarg vtabargtoken */
151153 0, /* (371) anylist ::= */
151154 -4, /* (372) anylist ::= anylist LP anylist RP */
151155 -2, /* (373) anylist ::= anylist ANY */
151156 0, /* (374) with ::= */
151157 };
151158
151159 static void yy_accept(yyParser*); /* Forward Declaration */
151160
151161 /*
@@ -150605,19 +151248,20 @@
151248 break;
151249 case 2: /* cmdx ::= cmd */
151250 { sqlite3FinishCoding(pParse); }
151251 break;
151252 case 3: /* cmd ::= BEGIN transtype trans_opt */
151253 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy420);}
151254 break;
151255 case 4: /* transtype ::= */
151256 {yymsp[1].minor.yy420 = TK_DEFERRED;}
151257 break;
151258 case 5: /* transtype ::= DEFERRED */
151259 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
151260 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
151261 case 300: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==300);
151262 {yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/}
151263 break;
151264 case 8: /* cmd ::= COMMIT|END trans_opt */
151265 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
151266 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
151267 break;
@@ -150636,11 +151280,11 @@
151280 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
151281 }
151282 break;
151283 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
151284 {
151285 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy420,0,0,yymsp[-2].minor.yy420);
151286 }
151287 break;
151288 case 14: /* createkw ::= CREATE */
151289 {disableLookaside(pParse);}
151290 break;
@@ -150651,36 +151295,36 @@
151295 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
151296 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
151297 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
151298 case 93: /* distinct ::= */ yytestcase(yyruleno==93);
151299 case 226: /* collate ::= */ yytestcase(yyruleno==226);
151300 {yymsp[1].minor.yy420 = 0;}
151301 break;
151302 case 16: /* ifnotexists ::= IF NOT EXISTS */
151303 {yymsp[-2].minor.yy420 = 1;}
151304 break;
151305 case 17: /* temp ::= TEMP */
151306 case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
151307 {yymsp[0].minor.yy420 = 1;}
151308 break;
151309 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
151310 {
151311 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy420,0);
151312 }
151313 break;
151314 case 20: /* create_table_args ::= AS select */
151315 {
151316 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy491);
151317 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491);
151318 }
151319 break;
151320 case 22: /* table_options ::= WITHOUT nm */
151321 {
151322 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
151323 yymsp[-1].minor.yy420 = TF_WithoutRowid | TF_NoVisibleRowid;
151324 }else{
151325 yymsp[-1].minor.yy420 = 0;
151326 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
151327 }
151328 }
151329 break;
151330 case 23: /* columnname ::= nm typetoken */
@@ -150705,30 +151349,30 @@
151349 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
151350 break;
151351 case 28: /* scanpt ::= */
151352 {
151353 assert( yyLookahead!=YYNOCODE );
151354 yymsp[1].minor.yy104 = yyLookaheadToken.z;
151355 }
151356 break;
151357 case 29: /* ccons ::= CONSTRAINT nm */
151358 case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
151359 {pParse->constraintName = yymsp[0].minor.yy0;}
151360 break;
151361 case 30: /* ccons ::= DEFAULT scanpt term scanpt */
151362 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy104,yymsp[0].minor.yy104);}
151363 break;
151364 case 31: /* ccons ::= DEFAULT LP expr RP */
151365 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
151366 break;
151367 case 32: /* ccons ::= DEFAULT PLUS term scanpt */
151368 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy130,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104);}
151369 break;
151370 case 33: /* ccons ::= DEFAULT MINUS term scanpt */
151371 {
151372 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy130, 0);
151373 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy104);
151374 }
151375 break;
151376 case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
151377 {
151378 Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
@@ -150738,319 +151382,319 @@
151382 }
151383 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
151384 }
151385 break;
151386 case 35: /* ccons ::= NOT NULL onconf */
151387 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy420);}
151388 break;
151389 case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
151390 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy420,yymsp[0].minor.yy420,yymsp[-2].minor.yy420);}
151391 break;
151392 case 37: /* ccons ::= UNIQUE onconf */
151393 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy420,0,0,0,0,
151394 SQLITE_IDXTYPE_UNIQUE);}
151395 break;
151396 case 38: /* ccons ::= CHECK LP expr RP */
151397 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy130);}
151398 break;
151399 case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
151400 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy420);}
151401 break;
151402 case 40: /* ccons ::= defer_subclause */
151403 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy420);}
151404 break;
151405 case 41: /* ccons ::= COLLATE ID|STRING */
151406 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
151407 break;
151408 case 44: /* refargs ::= */
151409 { yymsp[1].minor.yy420 = OE_None*0x0101; /* EV: R-19803-45884 */}
151410 break;
151411 case 45: /* refargs ::= refargs refarg */
151412 { yymsp[-1].minor.yy420 = (yymsp[-1].minor.yy420 & ~yymsp[0].minor.yy527.mask) | yymsp[0].minor.yy527.value; }
151413 break;
151414 case 46: /* refarg ::= MATCH nm */
151415 { yymsp[-1].minor.yy527.value = 0; yymsp[-1].minor.yy527.mask = 0x000000; }
151416 break;
151417 case 47: /* refarg ::= ON INSERT refact */
151418 { yymsp[-2].minor.yy527.value = 0; yymsp[-2].minor.yy527.mask = 0x000000; }
151419 break;
151420 case 48: /* refarg ::= ON DELETE refact */
151421 { yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420; yymsp[-2].minor.yy527.mask = 0x0000ff; }
151422 break;
151423 case 49: /* refarg ::= ON UPDATE refact */
151424 { yymsp[-2].minor.yy527.value = yymsp[0].minor.yy420<<8; yymsp[-2].minor.yy527.mask = 0x00ff00; }
151425 break;
151426 case 50: /* refact ::= SET NULL */
151427 { yymsp[-1].minor.yy420 = OE_SetNull; /* EV: R-33326-45252 */}
151428 break;
151429 case 51: /* refact ::= SET DEFAULT */
151430 { yymsp[-1].minor.yy420 = OE_SetDflt; /* EV: R-33326-45252 */}
151431 break;
151432 case 52: /* refact ::= CASCADE */
151433 { yymsp[0].minor.yy420 = OE_Cascade; /* EV: R-33326-45252 */}
151434 break;
151435 case 53: /* refact ::= RESTRICT */
151436 { yymsp[0].minor.yy420 = OE_Restrict; /* EV: R-33326-45252 */}
151437 break;
151438 case 54: /* refact ::= NO ACTION */
151439 { yymsp[-1].minor.yy420 = OE_None; /* EV: R-33326-45252 */}
151440 break;
151441 case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
151442 {yymsp[-2].minor.yy420 = 0;}
151443 break;
151444 case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
151445 case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
151446 case 156: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==156);
151447 {yymsp[-1].minor.yy420 = yymsp[0].minor.yy420;}
151448 break;
151449 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
151450 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
151451 case 198: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==198);
151452 case 201: /* in_op ::= NOT IN */ yytestcase(yyruleno==201);
151453 case 227: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==227);
151454 {yymsp[-1].minor.yy420 = 1;}
151455 break;
151456 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
151457 {yymsp[-1].minor.yy420 = 0;}
151458 break;
151459 case 61: /* tconscomma ::= COMMA */
151460 {pParse->constraintName.n = 0;}
151461 break;
151462 case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
151463 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy420,yymsp[-2].minor.yy420,0);}
151464 break;
151465 case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
151466 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy420,0,0,0,0,
151467 SQLITE_IDXTYPE_UNIQUE);}
151468 break;
151469 case 65: /* tcons ::= CHECK LP expr RP onconf */
151470 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy130);}
151471 break;
151472 case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
151473 {
151474 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy420);
151475 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy420);
151476 }
151477 break;
151478 case 68: /* onconf ::= */
151479 case 70: /* orconf ::= */ yytestcase(yyruleno==70);
151480 {yymsp[1].minor.yy420 = OE_Default;}
151481 break;
151482 case 69: /* onconf ::= ON CONFLICT resolvetype */
151483 {yymsp[-2].minor.yy420 = yymsp[0].minor.yy420;}
151484 break;
151485 case 72: /* resolvetype ::= IGNORE */
151486 {yymsp[0].minor.yy420 = OE_Ignore;}
151487 break;
151488 case 73: /* resolvetype ::= REPLACE */
151489 case 157: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==157);
151490 {yymsp[0].minor.yy420 = OE_Replace;}
151491 break;
151492 case 74: /* cmd ::= DROP TABLE ifexists fullname */
151493 {
151494 sqlite3DropTable(pParse, yymsp[0].minor.yy147, 0, yymsp[-1].minor.yy420);
151495 }
151496 break;
151497 case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
151498 {
151499 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy491, yymsp[-7].minor.yy420, yymsp[-5].minor.yy420);
151500 }
151501 break;
151502 case 78: /* cmd ::= DROP VIEW ifexists fullname */
151503 {
151504 sqlite3DropTable(pParse, yymsp[0].minor.yy147, 1, yymsp[-1].minor.yy420);
151505 }
151506 break;
151507 case 79: /* cmd ::= select */
151508 {
151509 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
151510 sqlite3Select(pParse, yymsp[0].minor.yy491, &dest);
151511 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy491);
151512 }
151513 break;
151514 case 80: /* select ::= WITH wqlist selectnowith */
151515 {
151516 Select *p = yymsp[0].minor.yy491;
151517 if( p ){
151518 p->pWith = yymsp[-1].minor.yy523;
151519 parserDoubleLinkSelect(pParse, p);
151520 }else{
151521 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523);
151522 }
151523 yymsp[-2].minor.yy491 = p;
151524 }
151525 break;
151526 case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
151527 {
151528 Select *p = yymsp[0].minor.yy491;
151529 if( p ){
151530 p->pWith = yymsp[-1].minor.yy523;
151531 parserDoubleLinkSelect(pParse, p);
151532 }else{
151533 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy523);
151534 }
151535 yymsp[-3].minor.yy491 = p;
151536 }
151537 break;
151538 case 82: /* select ::= selectnowith */
151539 {
151540 Select *p = yymsp[0].minor.yy491;
151541 if( p ){
151542 parserDoubleLinkSelect(pParse, p);
151543 }
151544 yymsp[0].minor.yy491 = p; /*A-overwrites-X*/
151545 }
151546 break;
151547 case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
151548 {
151549 Select *pRhs = yymsp[0].minor.yy491;
151550 Select *pLhs = yymsp[-2].minor.yy491;
151551 if( pRhs && pRhs->pPrior ){
151552 SrcList *pFrom;
151553 Token x;
151554 x.n = 0;
151555 parserDoubleLinkSelect(pParse, pRhs);
151556 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
151557 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
151558 }
151559 if( pRhs ){
151560 pRhs->op = (u8)yymsp[-1].minor.yy420;
151561 pRhs->pPrior = pLhs;
151562 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
151563 pRhs->selFlags &= ~SF_MultiValue;
151564 if( yymsp[-1].minor.yy420!=TK_ALL ) pParse->hasCompound = 1;
151565 }else{
151566 sqlite3SelectDelete(pParse->db, pLhs);
151567 }
151568 yymsp[-2].minor.yy491 = pRhs;
151569 }
151570 break;
151571 case 84: /* multiselect_op ::= UNION */
151572 case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
151573 {yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-OP*/}
151574 break;
151575 case 85: /* multiselect_op ::= UNION ALL */
151576 {yymsp[-1].minor.yy420 = TK_ALL;}
151577 break;
151578 case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
151579 {
151580 yymsp[-8].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy147,yymsp[-4].minor.yy130,yymsp[-3].minor.yy442,yymsp[-2].minor.yy130,yymsp[-1].minor.yy442,yymsp[-7].minor.yy420,yymsp[0].minor.yy130);
151581 }
151582 break;
151583 case 88: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
151584 {
151585 yymsp[-9].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy442,yymsp[-6].minor.yy147,yymsp[-5].minor.yy130,yymsp[-4].minor.yy442,yymsp[-3].minor.yy130,yymsp[-1].minor.yy442,yymsp[-8].minor.yy420,yymsp[0].minor.yy130);
151586 if( yymsp[-9].minor.yy491 ){
151587 yymsp[-9].minor.yy491->pWinDefn = yymsp[-2].minor.yy395;
151588 }else{
151589 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy395);
151590 }
151591 }
151592 break;
151593 case 89: /* values ::= VALUES LP nexprlist RP */
151594 {
151595 yymsp[-3].minor.yy491 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0);
151596 }
151597 break;
151598 case 90: /* values ::= values COMMA LP nexprlist RP */
151599 {
151600 Select *pRight, *pLeft = yymsp[-4].minor.yy491;
151601 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0);
151602 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
151603 if( pRight ){
151604 pRight->op = TK_ALL;
151605 pRight->pPrior = pLeft;
151606 yymsp[-4].minor.yy491 = pRight;
151607 }else{
151608 yymsp[-4].minor.yy491 = pLeft;
151609 }
151610 }
151611 break;
151612 case 91: /* distinct ::= DISTINCT */
151613 {yymsp[0].minor.yy420 = SF_Distinct;}
151614 break;
151615 case 92: /* distinct ::= ALL */
151616 {yymsp[0].minor.yy420 = SF_All;}
151617 break;
151618 case 94: /* sclp ::= */
151619 case 127: /* orderby_opt ::= */ yytestcase(yyruleno==127);
151620 case 134: /* groupby_opt ::= */ yytestcase(yyruleno==134);
151621 case 214: /* exprlist ::= */ yytestcase(yyruleno==214);
151622 case 217: /* paren_exprlist ::= */ yytestcase(yyruleno==217);
151623 case 222: /* eidlist_opt ::= */ yytestcase(yyruleno==222);
151624 {yymsp[1].minor.yy442 = 0;}
151625 break;
151626 case 95: /* selcollist ::= sclp scanpt expr scanpt as */
151627 {
151628 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[-2].minor.yy130);
151629 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[0].minor.yy0, 1);
151630 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy442,yymsp[-3].minor.yy104,yymsp[-1].minor.yy104);
151631 }
151632 break;
151633 case 96: /* selcollist ::= sclp scanpt STAR */
151634 {
151635 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
151636 yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, p);
151637 }
151638 break;
151639 case 97: /* selcollist ::= sclp scanpt nm DOT STAR */
151640 {
151641 Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
151642 Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
151643 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
151644 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, pDot);
151645 }
151646 break;
151647 case 98: /* as ::= AS nm */
151648 case 109: /* dbnm ::= DOT nm */ yytestcase(yyruleno==109);
151649 case 238: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==238);
151650 case 239: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==239);
151651 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
151652 break;
151653 case 100: /* from ::= */
151654 {yymsp[1].minor.yy147 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy147));}
151655 break;
151656 case 101: /* from ::= FROM seltablist */
151657 {
151658 yymsp[-1].minor.yy147 = yymsp[0].minor.yy147;
151659 sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy147);
151660 }
151661 break;
151662 case 102: /* stl_prefix ::= seltablist joinop */
151663 {
151664 if( ALWAYS(yymsp[-1].minor.yy147 && yymsp[-1].minor.yy147->nSrc>0) ) yymsp[-1].minor.yy147->a[yymsp[-1].minor.yy147->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy420;
151665 }
151666 break;
151667 case 103: /* stl_prefix ::= */
151668 {yymsp[1].minor.yy147 = 0;}
151669 break;
151670 case 104: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
151671 {
151672 yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151673 sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy147, &yymsp[-2].minor.yy0);
151674 }
151675 break;
151676 case 105: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
151677 {
151678 yymsp[-8].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy147,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151679 sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy147, yymsp[-4].minor.yy442);
151680 }
151681 break;
151682 case 106: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
151683 {
151684 yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy491,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151685 }
151686 break;
151687 case 107: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
151688 {
151689 if( yymsp[-6].minor.yy147==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy130==0 && yymsp[0].minor.yy200==0 ){
151690 yymsp[-6].minor.yy147 = yymsp[-4].minor.yy147;
151691 }else if( yymsp[-4].minor.yy147->nSrc==1 ){
151692 yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151693 if( yymsp[-6].minor.yy147 ){
151694 struct SrcList_item *pNew = &yymsp[-6].minor.yy147->a[yymsp[-6].minor.yy147->nSrc-1];
151695 struct SrcList_item *pOld = yymsp[-4].minor.yy147->a;
151696 pNew->zName = pOld->zName;
151697 pNew->zDatabase = pOld->zDatabase;
151698 pNew->pSelect = pOld->pSelect;
151699 if( pOld->fg.isTabFunc ){
151700 pNew->u1.pFuncArg = pOld->u1.pFuncArg;
@@ -151059,215 +151703,215 @@
151703 pNew->fg.isTabFunc = 1;
151704 }
151705 pOld->zName = pOld->zDatabase = 0;
151706 pOld->pSelect = 0;
151707 }
151708 sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy147);
151709 }else{
151710 Select *pSubquery;
151711 sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy147);
151712 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy147,0,0,0,0,SF_NestedFrom,0);
151713 yymsp[-6].minor.yy147 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy147,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy130,yymsp[0].minor.yy200);
151714 }
151715 }
151716 break;
151717 case 108: /* dbnm ::= */
151718 case 122: /* indexed_opt ::= */ yytestcase(yyruleno==122);
151719 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
151720 break;
151721 case 110: /* fullname ::= nm */
151722 {
151723 yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
151724 if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0);
151725 }
151726 yymsp[0].minor.yy147 = yylhsminor.yy147;
151727 break;
151728 case 111: /* fullname ::= nm DOT nm */
151729 {
151730 yylhsminor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
151731 if( IN_RENAME_OBJECT && yylhsminor.yy147 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy147->a[0].zName, &yymsp[0].minor.yy0);
151732 }
151733 yymsp[-2].minor.yy147 = yylhsminor.yy147;
151734 break;
151735 case 112: /* xfullname ::= nm */
151736 {yymsp[0].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
151737 break;
151738 case 113: /* xfullname ::= nm DOT nm */
151739 {yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
151740 break;
151741 case 114: /* xfullname ::= nm DOT nm AS nm */
151742 {
151743 yymsp[-4].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
151744 if( yymsp[-4].minor.yy147 ) yymsp[-4].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151745 }
151746 break;
151747 case 115: /* xfullname ::= nm AS nm */
151748 {
151749 yymsp[-2].minor.yy147 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
151750 if( yymsp[-2].minor.yy147 ) yymsp[-2].minor.yy147->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
151751 }
151752 break;
151753 case 116: /* joinop ::= COMMA|JOIN */
151754 { yymsp[0].minor.yy420 = JT_INNER; }
151755 break;
151756 case 117: /* joinop ::= JOIN_KW JOIN */
151757 {yymsp[-1].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
151758 break;
151759 case 118: /* joinop ::= JOIN_KW nm JOIN */
151760 {yymsp[-2].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
151761 break;
151762 case 119: /* joinop ::= JOIN_KW nm nm JOIN */
151763 {yymsp[-3].minor.yy420 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
151764 break;
151765 case 120: /* on_opt ::= ON expr */
151766 case 137: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==137);
151767 case 144: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==144);
151768 case 210: /* case_else ::= ELSE expr */ yytestcase(yyruleno==210);
151769 case 231: /* vinto ::= INTO expr */ yytestcase(yyruleno==231);
151770 {yymsp[-1].minor.yy130 = yymsp[0].minor.yy130;}
151771 break;
151772 case 121: /* on_opt ::= */
151773 case 136: /* having_opt ::= */ yytestcase(yyruleno==136);
151774 case 138: /* limit_opt ::= */ yytestcase(yyruleno==138);
151775 case 143: /* where_opt ::= */ yytestcase(yyruleno==143);
151776 case 211: /* case_else ::= */ yytestcase(yyruleno==211);
151777 case 213: /* case_operand ::= */ yytestcase(yyruleno==213);
151778 case 232: /* vinto ::= */ yytestcase(yyruleno==232);
151779 {yymsp[1].minor.yy130 = 0;}
151780 break;
151781 case 123: /* indexed_opt ::= INDEXED BY nm */
151782 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
151783 break;
151784 case 124: /* indexed_opt ::= NOT INDEXED */
151785 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
151786 break;
151787 case 125: /* using_opt ::= USING LP idlist RP */
151788 {yymsp[-3].minor.yy200 = yymsp[-1].minor.yy200;}
151789 break;
151790 case 126: /* using_opt ::= */
151791 case 158: /* idlist_opt ::= */ yytestcase(yyruleno==158);
151792 {yymsp[1].minor.yy200 = 0;}
151793 break;
151794 case 128: /* orderby_opt ::= ORDER BY sortlist */
151795 case 135: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==135);
151796 {yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;}
151797 break;
151798 case 129: /* sortlist ::= sortlist COMMA expr sortorder */
151799 {
151800 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy130);
151801 sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy420);
151802 }
151803 break;
151804 case 130: /* sortlist ::= expr sortorder */
151805 {
151806 yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy130); /*A-overwrites-Y*/
151807 sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy420);
151808 }
151809 break;
151810 case 131: /* sortorder ::= ASC */
151811 {yymsp[0].minor.yy420 = SQLITE_SO_ASC;}
151812 break;
151813 case 132: /* sortorder ::= DESC */
151814 {yymsp[0].minor.yy420 = SQLITE_SO_DESC;}
151815 break;
151816 case 133: /* sortorder ::= */
151817 {yymsp[1].minor.yy420 = SQLITE_SO_UNDEFINED;}
151818 break;
151819 case 139: /* limit_opt ::= LIMIT expr */
151820 {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,0);}
151821 break;
151822 case 140: /* limit_opt ::= LIMIT expr OFFSET expr */
151823 {yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);}
151824 break;
151825 case 141: /* limit_opt ::= LIMIT expr COMMA expr */
151826 {yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy130,yymsp[-2].minor.yy130);}
151827 break;
151828 case 142: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
151829 {
151830 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy147, &yymsp[-1].minor.yy0);
151831 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy147,yymsp[0].minor.yy130,0,0);
151832 }
151833 break;
151834 case 145: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
151835 {
151836 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy147, &yymsp[-3].minor.yy0);
151837 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
151838 sqlite3Update(pParse,yymsp[-4].minor.yy147,yymsp[-1].minor.yy442,yymsp[0].minor.yy130,yymsp[-5].minor.yy420,0,0,0);
151839 }
151840 break;
151841 case 146: /* setlist ::= setlist COMMA nm EQ expr */
151842 {
151843 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy130);
151844 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1);
151845 }
151846 break;
151847 case 147: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
151848 {
151849 yymsp[-6].minor.yy442 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy442, yymsp[-3].minor.yy200, yymsp[0].minor.yy130);
151850 }
151851 break;
151852 case 148: /* setlist ::= nm EQ expr */
151853 {
151854 yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy130);
151855 sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1);
151856 }
151857 yymsp[-2].minor.yy442 = yylhsminor.yy442;
151858 break;
151859 case 149: /* setlist ::= LP idlist RP EQ expr */
151860 {
151861 yymsp[-4].minor.yy442 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy200, yymsp[0].minor.yy130);
151862 }
151863 break;
151864 case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
151865 {
151866 sqlite3Insert(pParse, yymsp[-3].minor.yy147, yymsp[-1].minor.yy491, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, yymsp[0].minor.yy426);
151867 }
151868 break;
151869 case 151: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
151870 {
151871 sqlite3Insert(pParse, yymsp[-3].minor.yy147, 0, yymsp[-2].minor.yy200, yymsp[-5].minor.yy420, 0);
151872 }
151873 break;
151874 case 152: /* upsert ::= */
151875 { yymsp[1].minor.yy426 = 0; }
151876 break;
151877 case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
151878 { yymsp[-10].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy442,yymsp[-5].minor.yy130,yymsp[-1].minor.yy442,yymsp[0].minor.yy130);}
151879 break;
151880 case 154: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
151881 { yymsp[-7].minor.yy426 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy442,yymsp[-2].minor.yy130,0,0); }
151882 break;
151883 case 155: /* upsert ::= ON CONFLICT DO NOTHING */
151884 { yymsp[-3].minor.yy426 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
151885 break;
151886 case 159: /* idlist_opt ::= LP idlist RP */
151887 {yymsp[-2].minor.yy200 = yymsp[-1].minor.yy200;}
151888 break;
151889 case 160: /* idlist ::= idlist COMMA nm */
151890 {yymsp[-2].minor.yy200 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy200,&yymsp[0].minor.yy0);}
151891 break;
151892 case 161: /* idlist ::= nm */
151893 {yymsp[0].minor.yy200 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
151894 break;
151895 case 162: /* expr ::= LP expr RP */
151896 {yymsp[-2].minor.yy130 = yymsp[-1].minor.yy130;}
151897 break;
151898 case 163: /* expr ::= ID|INDEXED */
151899 case 164: /* expr ::= JOIN_KW */ yytestcase(yyruleno==164);
151900 {yymsp[0].minor.yy130=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151901 break;
151902 case 165: /* expr ::= nm DOT nm */
151903 {
151904 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
151905 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
151906 if( IN_RENAME_OBJECT ){
151907 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
151908 sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
151909 }
151910 yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
151911 }
151912 yymsp[-2].minor.yy130 = yylhsminor.yy130;
151913 break;
151914 case 166: /* expr ::= nm DOT nm DOT nm */
151915 {
151916 Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
151917 Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -151275,95 +151919,95 @@
151919 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
151920 if( IN_RENAME_OBJECT ){
151921 sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
151922 sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
151923 }
151924 yylhsminor.yy130 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
151925 }
151926 yymsp[-4].minor.yy130 = yylhsminor.yy130;
151927 break;
151928 case 167: /* term ::= NULL|FLOAT|BLOB */
151929 case 168: /* term ::= STRING */ yytestcase(yyruleno==168);
151930 {yymsp[0].minor.yy130=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
151931 break;
151932 case 169: /* term ::= INTEGER */
151933 {
151934 yylhsminor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
151935 }
151936 yymsp[0].minor.yy130 = yylhsminor.yy130;
151937 break;
151938 case 170: /* expr ::= VARIABLE */
151939 {
151940 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
151941 u32 n = yymsp[0].minor.yy0.n;
151942 yymsp[0].minor.yy130 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
151943 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy130, n);
151944 }else{
151945 /* When doing a nested parse, one can include terms in an expression
151946 ** that look like this: #1 #2 ... These terms refer to registers
151947 ** in the virtual machine. #N is the N-th register. */
151948 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
151949 assert( t.n>=2 );
151950 if( pParse->nested==0 ){
151951 sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
151952 yymsp[0].minor.yy130 = 0;
151953 }else{
151954 yymsp[0].minor.yy130 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
151955 if( yymsp[0].minor.yy130 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy130->iTable);
151956 }
151957 }
151958 }
151959 break;
151960 case 171: /* expr ::= expr COLLATE ID|STRING */
151961 {
151962 yymsp[-2].minor.yy130 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy130, &yymsp[0].minor.yy0, 1);
151963 }
151964 break;
151965 case 172: /* expr ::= CAST LP expr AS typetoken RP */
151966 {
151967 yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
151968 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy130, yymsp[-3].minor.yy130, 0);
151969 }
151970 break;
151971 case 173: /* expr ::= ID|INDEXED LP distinct exprlist RP */
151972 {
151973 yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy420);
151974 }
151975 yymsp[-4].minor.yy130 = yylhsminor.yy130;
151976 break;
151977 case 174: /* expr ::= ID|INDEXED LP STAR RP */
151978 {
151979 yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
151980 }
151981 yymsp[-3].minor.yy130 = yylhsminor.yy130;
151982 break;
151983 case 175: /* expr ::= ID|INDEXED LP distinct exprlist RP over_clause */
151984 {
151985 yylhsminor.yy130 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy442, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy420);
151986 sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395);
151987 }
151988 yymsp[-5].minor.yy130 = yylhsminor.yy130;
151989 break;
151990 case 176: /* expr ::= ID|INDEXED LP STAR RP over_clause */
151991 {
151992 yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
151993 sqlite3WindowAttach(pParse, yylhsminor.yy130, yymsp[0].minor.yy395);
151994 }
151995 yymsp[-4].minor.yy130 = yylhsminor.yy130;
151996 break;
151997 case 177: /* term ::= CTIME_KW */
151998 {
151999 yylhsminor.yy130 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
152000 }
152001 yymsp[0].minor.yy130 = yylhsminor.yy130;
152002 break;
152003 case 178: /* expr ::= LP nexprlist COMMA expr RP */
152004 {
152005 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy442, yymsp[-1].minor.yy130);
152006 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
152007 if( yymsp[-4].minor.yy130 ){
152008 yymsp[-4].minor.yy130->x.pList = pList;
152009 }else{
152010 sqlite3ExprListDelete(pParse->db, pList);
152011 }
152012 }
152013 break;
@@ -151373,101 +152017,101 @@
152017 case 182: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==182);
152018 case 183: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==183);
152019 case 184: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==184);
152020 case 185: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==185);
152021 case 186: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==186);
152022 {yymsp[-2].minor.yy130=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);}
152023 break;
152024 case 187: /* likeop ::= NOT LIKE_KW|MATCH */
152025 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
152026 break;
152027 case 188: /* expr ::= expr likeop expr */
152028 {
152029 ExprList *pList;
152030 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
152031 yymsp[-1].minor.yy0.n &= 0x7fffffff;
152032 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy130);
152033 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy130);
152034 yymsp[-2].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
152035 if( bNot ) yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy130, 0);
152036 if( yymsp[-2].minor.yy130 ) yymsp[-2].minor.yy130->flags |= EP_InfixFunc;
152037 }
152038 break;
152039 case 189: /* expr ::= expr likeop expr ESCAPE expr */
152040 {
152041 ExprList *pList;
152042 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
152043 yymsp[-3].minor.yy0.n &= 0x7fffffff;
152044 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152045 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy130);
152046 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130);
152047 yymsp[-4].minor.yy130 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
152048 if( bNot ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152049 if( yymsp[-4].minor.yy130 ) yymsp[-4].minor.yy130->flags |= EP_InfixFunc;
152050 }
152051 break;
152052 case 190: /* expr ::= expr ISNULL|NOTNULL */
152053 {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy130,0);}
152054 break;
152055 case 191: /* expr ::= expr NOT NULL */
152056 {yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy130,0);}
152057 break;
152058 case 192: /* expr ::= expr IS expr */
152059 {
152060 yymsp[-2].minor.yy130 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy130,yymsp[0].minor.yy130);
152061 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-2].minor.yy130, TK_ISNULL);
152062 }
152063 break;
152064 case 193: /* expr ::= expr IS NOT expr */
152065 {
152066 yymsp[-3].minor.yy130 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy130,yymsp[0].minor.yy130);
152067 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy130, yymsp[-3].minor.yy130, TK_NOTNULL);
152068 }
152069 break;
152070 case 194: /* expr ::= NOT expr */
152071 case 195: /* expr ::= BITNOT expr */ yytestcase(yyruleno==195);
152072 {yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy130, 0);/*A-overwrites-B*/}
152073 break;
152074 case 196: /* expr ::= PLUS|MINUS expr */
152075 {
152076 yymsp[-1].minor.yy130 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy130, 0);
152077 /*A-overwrites-B*/
152078 }
152079 break;
152080 case 197: /* between_op ::= BETWEEN */
152081 case 200: /* in_op ::= IN */ yytestcase(yyruleno==200);
152082 {yymsp[0].minor.yy420 = 0;}
152083 break;
152084 case 199: /* expr ::= expr between_op expr AND expr */
152085 {
152086 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152087 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy130);
152088 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy130, 0);
152089 if( yymsp[-4].minor.yy130 ){
152090 yymsp[-4].minor.yy130->x.pList = pList;
152091 }else{
152092 sqlite3ExprListDelete(pParse->db, pList);
152093 }
152094 if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152095 }
152096 break;
152097 case 202: /* expr ::= expr in_op LP exprlist RP */
152098 {
152099 if( yymsp[-1].minor.yy442==0 ){
152100 /* Expressions of the form
152101 **
152102 ** expr1 IN ()
152103 ** expr1 NOT IN ()
152104 **
152105 ** simplify to constants 0 (false) and 1 (true), respectively,
152106 ** regardless of the value of expr1.
152107 */
152108 if( IN_RENAME_OBJECT==0 ){
152109 sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy130);
152110 yymsp[-4].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy420],1);
152111 }
152112 }else if( yymsp[-1].minor.yy442->nExpr==1 ){
152113 /* Expressions of the form:
152114 **
152115 ** expr1 IN (?1)
152116 ** expr1 NOT IN (?2)
152117 **
@@ -151480,134 +152124,134 @@
152124 ** But, the RHS of the == or <> is marked with the EP_Generic flag
152125 ** so that it may not contribute to the computation of comparison
152126 ** affinity or the collating sequence to use for comparison. Otherwise,
152127 ** the semantics would be subtly different from IN or NOT IN.
152128 */
152129 Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr;
152130 yymsp[-1].minor.yy442->a[0].pExpr = 0;
152131 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
152132 /* pRHS cannot be NULL because a malloc error would have been detected
152133 ** before now and control would have never reached this point */
152134 if( ALWAYS(pRHS) ){
152135 pRHS->flags &= ~EP_Collate;
152136 pRHS->flags |= EP_Generic;
152137 }
152138 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, yymsp[-3].minor.yy420 ? TK_NE : TK_EQ, yymsp[-4].minor.yy130, pRHS);
152139 }else{
152140 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152141 if( yymsp[-4].minor.yy130 ){
152142 yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy442;
152143 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130);
152144 }else{
152145 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442);
152146 }
152147 if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152148 }
152149 }
152150 break;
152151 case 203: /* expr ::= LP select RP */
152152 {
152153 yymsp[-2].minor.yy130 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
152154 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy130, yymsp[-1].minor.yy491);
152155 }
152156 break;
152157 case 204: /* expr ::= expr in_op LP select RP */
152158 {
152159 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152160 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, yymsp[-1].minor.yy491);
152161 if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152162 }
152163 break;
152164 case 205: /* expr ::= expr in_op nm dbnm paren_exprlist */
152165 {
152166 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
152167 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
152168 if( yymsp[0].minor.yy442 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy442);
152169 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy130, 0);
152170 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy130, pSelect);
152171 if( yymsp[-3].minor.yy420 ) yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy130, 0);
152172 }
152173 break;
152174 case 206: /* expr ::= EXISTS LP select RP */
152175 {
152176 Expr *p;
152177 p = yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
152178 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy491);
152179 }
152180 break;
152181 case 207: /* expr ::= CASE case_operand case_exprlist case_else END */
152182 {
152183 yymsp[-4].minor.yy130 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy130, 0);
152184 if( yymsp[-4].minor.yy130 ){
152185 yymsp[-4].minor.yy130->x.pList = yymsp[-1].minor.yy130 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy130) : yymsp[-2].minor.yy442;
152186 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy130);
152187 }else{
152188 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442);
152189 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy130);
152190 }
152191 }
152192 break;
152193 case 208: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
152194 {
152195 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy130);
152196 yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy130);
152197 }
152198 break;
152199 case 209: /* case_exprlist ::= WHEN expr THEN expr */
152200 {
152201 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy130);
152202 yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy130);
152203 }
152204 break;
152205 case 212: /* case_operand ::= expr */
152206 {yymsp[0].minor.yy130 = yymsp[0].minor.yy130; /*A-overwrites-X*/}
152207 break;
152208 case 215: /* nexprlist ::= nexprlist COMMA expr */
152209 {yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy130);}
152210 break;
152211 case 216: /* nexprlist ::= expr */
152212 {yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy130); /*A-overwrites-Y*/}
152213 break;
152214 case 218: /* paren_exprlist ::= LP exprlist RP */
152215 case 223: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==223);
152216 {yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;}
152217 break;
152218 case 219: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
152219 {
152220 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
152221 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy420,
152222 &yymsp[-11].minor.yy0, yymsp[0].minor.yy130, SQLITE_SO_ASC, yymsp[-8].minor.yy420, SQLITE_IDXTYPE_APPDEF);
152223 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
152224 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
152225 }
152226 }
152227 break;
152228 case 220: /* uniqueflag ::= UNIQUE */
152229 case 262: /* raisetype ::= ABORT */ yytestcase(yyruleno==262);
152230 {yymsp[0].minor.yy420 = OE_Abort;}
152231 break;
152232 case 221: /* uniqueflag ::= */
152233 {yymsp[1].minor.yy420 = OE_None;}
152234 break;
152235 case 224: /* eidlist ::= eidlist COMMA nm collate sortorder */
152236 {
152237 yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420);
152238 }
152239 break;
152240 case 225: /* eidlist ::= nm collate sortorder */
152241 {
152242 yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy420, yymsp[0].minor.yy420); /*A-overwrites-Y*/
152243 }
152244 break;
152245 case 228: /* cmd ::= DROP INDEX ifexists fullname */
152246 {sqlite3DropIndex(pParse, yymsp[0].minor.yy147, yymsp[-1].minor.yy420);}
152247 break;
152248 case 229: /* cmd ::= VACUUM vinto */
152249 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy130);}
152250 break;
152251 case 230: /* cmd ::= VACUUM nm vinto */
152252 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy130);}
152253 break;
152254 case 233: /* cmd ::= PRAGMA nm dbnm */
152255 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
152256 break;
152257 case 234: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -151625,55 +152269,55 @@
152269 case 240: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
152270 {
152271 Token all;
152272 all.z = yymsp[-3].minor.yy0.z;
152273 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
152274 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy524, &all);
152275 }
152276 break;
152277 case 241: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
152278 {
152279 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy420, yymsp[-4].minor.yy498.a, yymsp[-4].minor.yy498.b, yymsp[-2].minor.yy147, yymsp[0].minor.yy130, yymsp[-10].minor.yy420, yymsp[-8].minor.yy420);
152280 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
152281 }
152282 break;
152283 case 242: /* trigger_time ::= BEFORE|AFTER */
152284 { yymsp[0].minor.yy420 = yymsp[0].major; /*A-overwrites-X*/ }
152285 break;
152286 case 243: /* trigger_time ::= INSTEAD OF */
152287 { yymsp[-1].minor.yy420 = TK_INSTEAD;}
152288 break;
152289 case 244: /* trigger_time ::= */
152290 { yymsp[1].minor.yy420 = TK_BEFORE; }
152291 break;
152292 case 245: /* trigger_event ::= DELETE|INSERT */
152293 case 246: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==246);
152294 {yymsp[0].minor.yy498.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy498.b = 0;}
152295 break;
152296 case 247: /* trigger_event ::= UPDATE OF idlist */
152297 {yymsp[-2].minor.yy498.a = TK_UPDATE; yymsp[-2].minor.yy498.b = yymsp[0].minor.yy200;}
152298 break;
152299 case 248: /* when_clause ::= */
152300 case 267: /* key_opt ::= */ yytestcase(yyruleno==267);
152301 case 315: /* filter_opt ::= */ yytestcase(yyruleno==315);
152302 { yymsp[1].minor.yy130 = 0; }
152303 break;
152304 case 249: /* when_clause ::= WHEN expr */
152305 case 268: /* key_opt ::= KEY expr */ yytestcase(yyruleno==268);
152306 { yymsp[-1].minor.yy130 = yymsp[0].minor.yy130; }
152307 break;
152308 case 250: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
152309 {
152310 assert( yymsp[-2].minor.yy524!=0 );
152311 yymsp[-2].minor.yy524->pLast->pNext = yymsp[-1].minor.yy524;
152312 yymsp[-2].minor.yy524->pLast = yymsp[-1].minor.yy524;
152313 }
152314 break;
152315 case 251: /* trigger_cmd_list ::= trigger_cmd SEMI */
152316 {
152317 assert( yymsp[-1].minor.yy524!=0 );
152318 yymsp[-1].minor.yy524->pLast = yymsp[-1].minor.yy524;
152319 }
152320 break;
152321 case 252: /* trnm ::= nm DOT nm */
152322 {
152323 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -151695,62 +152339,62 @@
152339 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
152340 "within triggers");
152341 }
152342 break;
152343 case 255: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
152344 {yylhsminor.yy524 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy130, yymsp[-6].minor.yy420, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy104);}
152345 yymsp[-7].minor.yy524 = yylhsminor.yy524;
152346 break;
152347 case 256: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
152348 {
152349 yylhsminor.yy524 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy200,yymsp[-2].minor.yy491,yymsp[-6].minor.yy420,yymsp[-1].minor.yy426,yymsp[-7].minor.yy104,yymsp[0].minor.yy104);/*yylhsminor.yy524-overwrites-yymsp[-6].minor.yy420*/
152350 }
152351 yymsp[-7].minor.yy524 = yylhsminor.yy524;
152352 break;
152353 case 257: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
152354 {yylhsminor.yy524 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy130, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy104);}
152355 yymsp[-5].minor.yy524 = yylhsminor.yy524;
152356 break;
152357 case 258: /* trigger_cmd ::= scanpt select scanpt */
152358 {yylhsminor.yy524 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy491, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); /*yylhsminor.yy524-overwrites-yymsp[-1].minor.yy491*/}
152359 yymsp[-2].minor.yy524 = yylhsminor.yy524;
152360 break;
152361 case 259: /* expr ::= RAISE LP IGNORE RP */
152362 {
152363 yymsp[-3].minor.yy130 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
152364 if( yymsp[-3].minor.yy130 ){
152365 yymsp[-3].minor.yy130->affinity = OE_Ignore;
152366 }
152367 }
152368 break;
152369 case 260: /* expr ::= RAISE LP raisetype COMMA nm RP */
152370 {
152371 yymsp[-5].minor.yy130 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
152372 if( yymsp[-5].minor.yy130 ) {
152373 yymsp[-5].minor.yy130->affinity = (char)yymsp[-3].minor.yy420;
152374 }
152375 }
152376 break;
152377 case 261: /* raisetype ::= ROLLBACK */
152378 {yymsp[0].minor.yy420 = OE_Rollback;}
152379 break;
152380 case 263: /* raisetype ::= FAIL */
152381 {yymsp[0].minor.yy420 = OE_Fail;}
152382 break;
152383 case 264: /* cmd ::= DROP TRIGGER ifexists fullname */
152384 {
152385 sqlite3DropTrigger(pParse,yymsp[0].minor.yy147,yymsp[-1].minor.yy420);
152386 }
152387 break;
152388 case 265: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
152389 {
152390 sqlite3Attach(pParse, yymsp[-3].minor.yy130, yymsp[-1].minor.yy130, yymsp[0].minor.yy130);
152391 }
152392 break;
152393 case 266: /* cmd ::= DETACH database_kw_opt expr */
152394 {
152395 sqlite3Detach(pParse, yymsp[0].minor.yy130);
152396 }
152397 break;
152398 case 269: /* cmd ::= REINDEX */
152399 {sqlite3Reindex(pParse, 0, 0);}
152400 break;
@@ -151763,11 +152407,11 @@
152407 case 272: /* cmd ::= ANALYZE nm dbnm */
152408 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
152409 break;
152410 case 273: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
152411 {
152412 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy147,&yymsp[0].minor.yy0);
152413 }
152414 break;
152415 case 274: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
152416 {
152417 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -151775,16 +152419,16 @@
152419 }
152420 break;
152421 case 275: /* add_column_fullname ::= fullname */
152422 {
152423 disableLookaside(pParse);
152424 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy147);
152425 }
152426 break;
152427 case 276: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
152428 {
152429 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy147, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
152430 }
152431 break;
152432 case 277: /* cmd ::= create_vtab */
152433 {sqlite3VtabFinishParse(pParse,0);}
152434 break;
@@ -151791,11 +152435,11 @@
152435 case 278: /* cmd ::= create_vtab LP vtabarglist RP */
152436 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
152437 break;
152438 case 279: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
152439 {
152440 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy420);
152441 }
152442 break;
152443 case 280: /* vtabarg ::= */
152444 {sqlite3VtabArgInit(pParse);}
152445 break;
@@ -151804,186 +152448,208 @@
152448 case 283: /* lp ::= LP */ yytestcase(yyruleno==283);
152449 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
152450 break;
152451 case 284: /* with ::= WITH wqlist */
152452 case 285: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==285);
152453 { sqlite3WithPush(pParse, yymsp[0].minor.yy523, 1); }
152454 break;
152455 case 286: /* wqlist ::= nm eidlist_opt AS LP select RP */
152456 {
152457 yymsp[-5].minor.yy523 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491); /*A-overwrites-X*/
152458 }
152459 break;
152460 case 287: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
152461 {
152462 yymsp[-7].minor.yy523 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy491);
152463 }
152464 break;
152465 case 288: /* windowdefn_list ::= windowdefn */
152466 { yylhsminor.yy395 = yymsp[0].minor.yy395; }
152467 yymsp[0].minor.yy395 = yylhsminor.yy395;
152468 break;
152469 case 289: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
152470 {
152471 assert( yymsp[0].minor.yy395!=0 );
152472 sqlite3WindowChain(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy395);
152473 yymsp[0].minor.yy395->pNextWin = yymsp[-2].minor.yy395;
152474 yylhsminor.yy395 = yymsp[0].minor.yy395;
152475 }
152476 yymsp[-2].minor.yy395 = yylhsminor.yy395;
152477 break;
152478 case 290: /* windowdefn ::= nm AS LP window RP */
152479 {
152480 if( ALWAYS(yymsp[-1].minor.yy395) ){
152481 yymsp[-1].minor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
152482 }
152483 yylhsminor.yy395 = yymsp[-1].minor.yy395;
152484 }
152485 yymsp[-4].minor.yy395 = yylhsminor.yy395;
152486 break;
152487 case 291: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
152488 {
152489 yymsp[-4].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, 0);
152490 }
152491 break;
152492 case 292: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
152493 {
152494 yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, yymsp[-2].minor.yy442, yymsp[-1].minor.yy442, &yymsp[-5].minor.yy0);
152495 }
152496 yymsp[-5].minor.yy395 = yylhsminor.yy395;
152497 break;
152498 case 293: /* window ::= ORDER BY sortlist frame_opt */
152499 {
152500 yymsp[-3].minor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, 0);
152501 }
152502 break;
152503 case 294: /* window ::= nm ORDER BY sortlist frame_opt */
152504 {
152505 yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
152506 }
152507 yymsp[-4].minor.yy395 = yylhsminor.yy395;
152508 break;
152509 case 295: /* window ::= frame_opt */
152510 {
152511 yylhsminor.yy395 = yymsp[0].minor.yy395;
152512 }
152513 yymsp[0].minor.yy395 = yylhsminor.yy395;
152514 break;
152515 case 296: /* window ::= nm frame_opt */
152516 {
152517 yylhsminor.yy395 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy395, 0, 0, &yymsp[-1].minor.yy0);
152518 }
152519 yymsp[-1].minor.yy395 = yylhsminor.yy395;
152520 break;
152521 case 297: /* frame_opt ::= */
152522 {
152523 yymsp[1].minor.yy395 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
152524 }
152525 break;
152526 case 298: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
152527 {
152528 yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy420, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy10);
152529 }
152530 yymsp[-2].minor.yy395 = yylhsminor.yy395;
152531 break;
152532 case 299: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
152533 {
152534 yylhsminor.yy395 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy420, yymsp[-3].minor.yy273.eType, yymsp[-3].minor.yy273.pExpr, yymsp[-1].minor.yy273.eType, yymsp[-1].minor.yy273.pExpr, yymsp[0].minor.yy10);
152535 }
152536 yymsp[-5].minor.yy395 = yylhsminor.yy395;
152537 break;
152538 case 301: /* frame_bound_s ::= frame_bound */
152539 case 303: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==303);
152540 {yylhsminor.yy273 = yymsp[0].minor.yy273;}
152541 yymsp[0].minor.yy273 = yylhsminor.yy273;
152542 break;
152543 case 302: /* frame_bound_s ::= UNBOUNDED PRECEDING */
152544 case 304: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==304);
152545 case 306: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==306);
152546 {yylhsminor.yy273.eType = yymsp[-1].major; yylhsminor.yy273.pExpr = 0;}
152547 yymsp[-1].minor.yy273 = yylhsminor.yy273;
152548 break;
152549 case 305: /* frame_bound ::= expr PRECEDING|FOLLOWING */
152550 {yylhsminor.yy273.eType = yymsp[0].major; yylhsminor.yy273.pExpr = yymsp[-1].minor.yy130;}
152551 yymsp[-1].minor.yy273 = yylhsminor.yy273;
152552 break;
152553 case 307: /* frame_exclude_opt ::= */
152554 {yymsp[1].minor.yy10 = 0;}
152555 break;
152556 case 308: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
152557 {yymsp[-1].minor.yy10 = yymsp[0].minor.yy10;}
152558 break;
152559 case 309: /* frame_exclude ::= NO OTHERS */
152560 case 310: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==310);
152561 {yymsp[-1].minor.yy10 = yymsp[-1].major; /*A-overwrites-X*/}
152562 break;
152563 case 311: /* frame_exclude ::= GROUP|TIES */
152564 {yymsp[0].minor.yy10 = yymsp[0].major; /*A-overwrites-X*/}
152565 break;
152566 case 312: /* window_clause ::= WINDOW windowdefn_list */
152567 { yymsp[-1].minor.yy395 = yymsp[0].minor.yy395; }
152568 break;
152569 case 313: /* over_clause ::= filter_opt OVER LP window RP */
152570 {
152571 yylhsminor.yy395 = yymsp[-1].minor.yy395;
152572 assert( yylhsminor.yy395!=0 );
152573 yylhsminor.yy395->pFilter = yymsp[-4].minor.yy130;
152574 }
152575 yymsp[-4].minor.yy395 = yylhsminor.yy395;
152576 break;
152577 case 314: /* over_clause ::= filter_opt OVER nm */
152578 {
152579 yylhsminor.yy395 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
152580 if( yylhsminor.yy395 ){
152581 yylhsminor.yy395->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
152582 yylhsminor.yy395->pFilter = yymsp[-2].minor.yy130;
152583 }else{
152584 sqlite3ExprDelete(pParse->db, yymsp[-2].minor.yy130);
152585 }
152586 }
152587 yymsp[-2].minor.yy395 = yylhsminor.yy395;
152588 break;
152589 case 316: /* filter_opt ::= FILTER LP WHERE expr RP */
152590 { yymsp[-4].minor.yy130 = yymsp[-1].minor.yy130; }
152591 break;
152592 default:
152593 /* (317) input ::= cmdlist */ yytestcase(yyruleno==317);
152594 /* (318) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==318);
152595 /* (319) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=319);
152596 /* (320) ecmd ::= SEMI */ yytestcase(yyruleno==320);
152597 /* (321) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==321);
152598 /* (322) ecmd ::= explain cmdx */ yytestcase(yyruleno==322);
152599 /* (323) trans_opt ::= */ yytestcase(yyruleno==323);
152600 /* (324) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==324);
152601 /* (325) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==325);
152602 /* (326) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==326);
152603 /* (327) savepoint_opt ::= */ yytestcase(yyruleno==327);
152604 /* (328) cmd ::= create_table create_table_args */ yytestcase(yyruleno==328);
152605 /* (329) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==329);
152606 /* (330) columnlist ::= columnname carglist */ yytestcase(yyruleno==330);
152607 /* (331) nm ::= ID|INDEXED */ yytestcase(yyruleno==331);
152608 /* (332) nm ::= STRING */ yytestcase(yyruleno==332);
152609 /* (333) nm ::= JOIN_KW */ yytestcase(yyruleno==333);
152610 /* (334) typetoken ::= typename */ yytestcase(yyruleno==334);
152611 /* (335) typename ::= ID|STRING */ yytestcase(yyruleno==335);
152612 /* (336) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=336);
152613 /* (337) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=337);
152614 /* (338) carglist ::= carglist ccons */ yytestcase(yyruleno==338);
152615 /* (339) carglist ::= */ yytestcase(yyruleno==339);
152616 /* (340) ccons ::= NULL onconf */ yytestcase(yyruleno==340);
152617 /* (341) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==341);
152618 /* (342) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==342);
152619 /* (343) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=343);
152620 /* (344) tconscomma ::= */ yytestcase(yyruleno==344);
152621 /* (345) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=345);
152622 /* (346) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=346);
152623 /* (347) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=347);
152624 /* (348) oneselect ::= values */ yytestcase(yyruleno==348);
152625 /* (349) sclp ::= selcollist COMMA */ yytestcase(yyruleno==349);
152626 /* (350) as ::= ID|STRING */ yytestcase(yyruleno==350);
152627 /* (351) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=351);
152628 /* (352) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==352);
152629 /* (353) exprlist ::= nexprlist */ yytestcase(yyruleno==353);
152630 /* (354) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=354);
152631 /* (355) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=355);
152632 /* (356) nmnum ::= ON */ yytestcase(yyruleno==356);
152633 /* (357) nmnum ::= DELETE */ yytestcase(yyruleno==357);
152634 /* (358) nmnum ::= DEFAULT */ yytestcase(yyruleno==358);
152635 /* (359) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==359);
152636 /* (360) foreach_clause ::= */ yytestcase(yyruleno==360);
152637 /* (361) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==361);
152638 /* (362) trnm ::= nm */ yytestcase(yyruleno==362);
152639 /* (363) tridxby ::= */ yytestcase(yyruleno==363);
152640 /* (364) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==364);
152641 /* (365) database_kw_opt ::= */ yytestcase(yyruleno==365);
152642 /* (366) kwcolumn_opt ::= */ yytestcase(yyruleno==366);
152643 /* (367) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==367);
152644 /* (368) vtabarglist ::= vtabarg */ yytestcase(yyruleno==368);
152645 /* (369) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==369);
152646 /* (370) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==370);
152647 /* (371) anylist ::= */ yytestcase(yyruleno==371);
152648 /* (372) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==372);
152649 /* (373) anylist ::= anylist ANY */ yytestcase(yyruleno==373);
152650 /* (374) with ::= */ yytestcase(yyruleno==374);
152651 break;
152652 /********** End reduce actions ************************************************/
152653 };
152654 assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
152655 yygoto = yyRuleInfoLhs[yyruleno];
@@ -152442,148 +153108,148 @@
153108 ** might be implemented more directly using a hand-written hash table.
153109 ** But by using this automatically generated code, the size of the code
153110 ** is substantially reduced. This is important for embedded applications
153111 ** on platforms with limited memory.
153112 */
153113 /* Hash score: 214 */
153114 /* zKWText[] encodes 950 bytes of keyword text in 629 bytes */
153115 /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
153116 /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYCONSTRAINTERSECTIES */
153117 /* AVEPOINTOFFSETRANSACTIONATURALTERAISEXCEPTRIGGEREFERENCES */
153118 /* UNIQUERYWITHOUTERELEASEXCLUSIVEXISTSATTACHAVINGLOBEGINNERANGE */
153119 /* BETWEENOTHINGROUPSCASCADETACHCASECOLLATECREATECURRENT_DATE */
153120 /* IMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTUPDATEVALUES */
153121 /* VIRTUALIMITWHENOTNULLWHERECURSIVEAFTERENAMEANDEFAULT */
153122 /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */
153123 /* ARTITIONDEFERREDISTINCTDROPRECEDINGFAILFILTEREPLACEFOLLOWING */
153124 /* FROMFULLIFISNULLORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */
153125 /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */
153126 static const char zKWText[628] = {
153127 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
153128 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
153129 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
153130 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
153131 'E','R','R','A','B','L','E','L','S','E','X','C','L','U','D','E','L','E',
153132 'T','E','M','P','O','R','A','R','Y','C','O','N','S','T','R','A','I','N',
153133 'T','E','R','S','E','C','T','I','E','S','A','V','E','P','O','I','N','T',
153134 'O','F','F','S','E','T','R','A','N','S','A','C','T','I','O','N','A','T',
153135 'U','R','A','L','T','E','R','A','I','S','E','X','C','E','P','T','R','I',
153136 'G','G','E','R','E','F','E','R','E','N','C','E','S','U','N','I','Q','U',
153137 'E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S','E',
153138 'X','C','L','U','S','I','V','E','X','I','S','T','S','A','T','T','A','C',
153139 'H','A','V','I','N','G','L','O','B','E','G','I','N','N','E','R','A','N',
153140 'G','E','B','E','T','W','E','E','N','O','T','H','I','N','G','R','O','U',
153141 'P','S','C','A','S','C','A','D','E','T','A','C','H','C','A','S','E','C',
153142 'O','L','L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N',
153143 'T','_','D','A','T','E','I','M','M','E','D','I','A','T','E','J','O','I',
153144 'N','S','E','R','T','L','I','K','E','M','A','T','C','H','P','L','A','N',
153145 'A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','U','P','D',
153146 'A','T','E','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M',
153147 'I','T','W','H','E','N','O','T','N','U','L','L','W','H','E','R','E','C',
153148 'U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E','A','N',
153149 'D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E','M','E',
153150 'N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M','I','T',
153151 'C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R','R','E',
153152 'N','T','_','T','I','M','E','S','T','A','M','P','A','R','T','I','T','I',
153153 'O','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
153154 'R','O','P','R','E','C','E','D','I','N','G','F','A','I','L','F','I','L',
153155 'T','E','R','E','P','L','A','C','E','F','O','L','L','O','W','I','N','G',
153156 'F','R','O','M','F','U','L','L','I','F','I','S','N','U','L','L','O','R',
153157 'D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O','V',
153158 'E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S',
153159 'U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I','N',
153160 'G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B','Y',
153161 'I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y',
153162 };
153163 /* aKWHash[i] is the hash value for the i-th keyword */
153164 static const unsigned char aKWHash[127] = {
153165 75, 111, 127, 73, 108, 29, 0, 0, 83, 0, 77, 63, 0,
153166 37, 33, 78, 15, 0, 126, 86, 57, 120, 128, 19, 0, 0,
153167 133, 0, 131, 123, 0, 22, 98, 0, 9, 0, 0, 117, 71,
153168 0, 69, 6, 0, 49, 95, 140, 0, 129, 106, 0, 0, 54,
153169 0, 109, 24, 0, 17, 0, 134, 56, 23, 26, 5, 58, 135,
153170 101, 0, 0, 139, 112, 62, 138, 59, 115, 65, 0, 96, 0,
153171 105, 45, 0, 104, 0, 0, 0, 100, 97, 102, 107, 119, 14,
153172 31, 118, 0, 81, 0, 136, 116, 137, 61, 124, 132, 80, 121,
153173 88, 30, 85, 0, 0, 99, 35, 125, 122, 0, 130, 0, 0,
153174 41, 0, 91, 89, 90, 0, 20, 87, 113, 82,
153175 };
153176 /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
153177 ** then the i-th keyword has no more hash collisions. Otherwise,
153178 ** the next keyword with the same hash is aKWHash[i]-1. */
153179 static const unsigned char aKWNext[140] = {
153180 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
153181 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
153182 0, 0, 0, 21, 0, 0, 12, 0, 0, 0, 0, 0, 0,
153183 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153184 51, 28, 0, 0, 38, 0, 0, 0, 44, 0, 0, 0, 3,
153185 0, 0, 67, 1, 66, 0, 0, 0, 36, 0, 47, 0, 0,
153186 0, 0, 0, 48, 50, 76, 0, 0, 42, 0, 60, 0, 0,
153187 0, 43, 0, 16, 55, 10, 0, 0, 0, 0, 0, 0, 0,
153188 11, 72, 93, 0, 0, 8, 0, 110, 0, 103, 40, 53, 70,
153189 0, 114, 0, 74, 52, 0, 0, 92, 39, 46, 0, 68, 32,
153190 84, 0, 34, 27, 25, 18, 94, 0, 64, 79,
153191 };
153192 /* aKWLen[i] is the length (in bytes) of the i-th keyword */
153193 static const unsigned char aKWLen[140] = {
153194 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
153195 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7,
153196 6, 9, 4, 2, 10, 9, 4, 9, 4, 6, 2, 3, 11,
153197 6, 2, 7, 5, 5, 6, 7, 10, 6, 5, 7, 4, 5,
153198 7, 9, 6, 6, 6, 4, 5, 5, 5, 7, 7, 6, 5,
153199 7, 3, 6, 4, 7, 6, 12, 9, 4, 6, 4, 5, 4,
153200 7, 6, 5, 6, 6, 7, 5, 4, 7, 3, 2, 4, 5,
153201 9, 5, 6, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5,
153202 17, 12, 7, 9, 8, 8, 2, 4, 9, 4, 6, 7, 9,
153203 4, 4, 2, 6, 5, 8, 6, 4, 5, 8, 4, 3, 9,
153204 5, 5, 6, 4, 6, 2, 2, 9, 3, 7,
153205 };
153206 /* aKWOffset[i] is the index into zKWText[] of the start of
153207 ** the text for the i-th keyword. */
153208 static const unsigned short int aKWOffset[140] = {
153209 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
153210 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
153211 86, 90, 90, 94, 99, 106, 114, 117, 123, 126, 126, 129, 131,
153212 136, 140, 141, 146, 150, 154, 159, 165, 175, 178, 183, 183, 187,
153213 191, 197, 205, 211, 216, 221, 224, 227, 231, 236, 242, 248, 248,
153214 254, 255, 259, 265, 269, 276, 282, 294, 303, 305, 311, 315, 320,
153215 322, 329, 334, 339, 345, 351, 357, 362, 365, 365, 365, 368, 372,
153216 375, 384, 388, 394, 396, 403, 405, 407, 416, 420, 426, 432, 440,
153217 445, 445, 445, 461, 470, 477, 478, 485, 488, 497, 501, 506, 513,
153218 522, 526, 530, 532, 538, 542, 550, 556, 559, 564, 572, 572, 576,
153219 585, 590, 595, 601, 604, 607, 610, 612, 617, 621,
153220 };
153221 /* aKWCode[i] is the parser symbol code for the i-th keyword */
153222 static const unsigned char aKWCode[140] = {
153223 TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
153224 TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
153225 TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
153226 TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
153227 TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
153228 TK_EXCLUDE, TK_DELETE, TK_TEMP, TK_TEMP, TK_OR,
153229 TK_CONSTRAINT, TK_INTERSECT, TK_TIES, TK_SAVEPOINT, TK_INTO,
153230 TK_OFFSET, TK_OF, TK_SET, TK_TRANSACTION,TK_ACTION,
153231 TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCEPT,
153232 TK_TRIGGER, TK_REFERENCES, TK_UNIQUE, TK_QUERY, TK_WITHOUT,
153233 TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_EXCLUSIVE, TK_EXISTS,
153234 TK_ATTACH, TK_HAVING, TK_LIKE_KW, TK_BEGIN, TK_JOIN_KW,
153235 TK_RANGE, TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP,
153236 TK_CASCADE, TK_ASC, TK_DETACH, TK_CASE, TK_COLLATE,
153237 TK_CREATE, TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
153238 TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
153239 TK_ABORT, TK_UPDATE, TK_VALUES, TK_VIRTUAL, TK_LIMIT,
153240 TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL,
153241 TK_WHERE, TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND,
153242 TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
153243 TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
153244 TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DEFERRED, TK_DISTINCT,
153245 TK_IS, TK_DROP, TK_PRECEDING, TK_FAIL, TK_FILTER,
153246 TK_REPLACE, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_IF,
153247 TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER,
153248 TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED,
153249 TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW,
153250 TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY,
153251 };
153252 /* Check to see if z[0..n-1] is a keyword. If it is, write the
153253 ** parser symbol code for that keyword into *pType. Always
153254 ** return the integer n (the length of the token). */
153255 static int keywordCode(const char *z, int n, int *pType){
@@ -152625,121 +153291,125 @@
153291 testcase( i==20 ); /* LEFT */
153292 testcase( i==21 ); /* THEN */
153293 testcase( i==22 ); /* END */
153294 testcase( i==23 ); /* DEFERRABLE */
153295 testcase( i==24 ); /* ELSE */
153296 testcase( i==25 ); /* EXCLUDE */
153297 testcase( i==26 ); /* DELETE */
153298 testcase( i==27 ); /* TEMPORARY */
153299 testcase( i==28 ); /* TEMP */
153300 testcase( i==29 ); /* OR */
153301 testcase( i==30 ); /* CONSTRAINT */
153302 testcase( i==31 ); /* INTERSECT */
153303 testcase( i==32 ); /* TIES */
153304 testcase( i==33 ); /* SAVEPOINT */
153305 testcase( i==34 ); /* INTO */
153306 testcase( i==35 ); /* OFFSET */
153307 testcase( i==36 ); /* OF */
153308 testcase( i==37 ); /* SET */
153309 testcase( i==38 ); /* TRANSACTION */
153310 testcase( i==39 ); /* ACTION */
153311 testcase( i==40 ); /* ON */
153312 testcase( i==41 ); /* NATURAL */
153313 testcase( i==42 ); /* ALTER */
153314 testcase( i==43 ); /* RAISE */
153315 testcase( i==44 ); /* EXCEPT */
153316 testcase( i==45 ); /* TRIGGER */
153317 testcase( i==46 ); /* REFERENCES */
153318 testcase( i==47 ); /* UNIQUE */
153319 testcase( i==48 ); /* QUERY */
153320 testcase( i==49 ); /* WITHOUT */
153321 testcase( i==50 ); /* WITH */
153322 testcase( i==51 ); /* OUTER */
153323 testcase( i==52 ); /* RELEASE */
153324 testcase( i==53 ); /* EXCLUSIVE */
153325 testcase( i==54 ); /* EXISTS */
153326 testcase( i==55 ); /* ATTACH */
153327 testcase( i==56 ); /* HAVING */
153328 testcase( i==57 ); /* GLOB */
153329 testcase( i==58 ); /* BEGIN */
153330 testcase( i==59 ); /* INNER */
153331 testcase( i==60 ); /* RANGE */
153332 testcase( i==61 ); /* BETWEEN */
153333 testcase( i==62 ); /* NOTHING */
153334 testcase( i==63 ); /* GROUPS */
153335 testcase( i==64 ); /* GROUP */
153336 testcase( i==65 ); /* CASCADE */
153337 testcase( i==66 ); /* ASC */
153338 testcase( i==67 ); /* DETACH */
153339 testcase( i==68 ); /* CASE */
153340 testcase( i==69 ); /* COLLATE */
153341 testcase( i==70 ); /* CREATE */
153342 testcase( i==71 ); /* CURRENT_DATE */
153343 testcase( i==72 ); /* IMMEDIATE */
153344 testcase( i==73 ); /* JOIN */
153345 testcase( i==74 ); /* INSERT */
153346 testcase( i==75 ); /* LIKE */
153347 testcase( i==76 ); /* MATCH */
153348 testcase( i==77 ); /* PLAN */
153349 testcase( i==78 ); /* ANALYZE */
153350 testcase( i==79 ); /* PRAGMA */
153351 testcase( i==80 ); /* ABORT */
153352 testcase( i==81 ); /* UPDATE */
153353 testcase( i==82 ); /* VALUES */
153354 testcase( i==83 ); /* VIRTUAL */
153355 testcase( i==84 ); /* LIMIT */
153356 testcase( i==85 ); /* WHEN */
153357 testcase( i==86 ); /* NOTNULL */
153358 testcase( i==87 ); /* NOT */
153359 testcase( i==88 ); /* NO */
153360 testcase( i==89 ); /* NULL */
153361 testcase( i==90 ); /* WHERE */
153362 testcase( i==91 ); /* RECURSIVE */
153363 testcase( i==92 ); /* AFTER */
153364 testcase( i==93 ); /* RENAME */
153365 testcase( i==94 ); /* AND */
153366 testcase( i==95 ); /* DEFAULT */
153367 testcase( i==96 ); /* AUTOINCREMENT */
153368 testcase( i==97 ); /* TO */
153369 testcase( i==98 ); /* IN */
153370 testcase( i==99 ); /* CAST */
153371 testcase( i==100 ); /* COLUMN */
153372 testcase( i==101 ); /* COMMIT */
153373 testcase( i==102 ); /* CONFLICT */
153374 testcase( i==103 ); /* CROSS */
153375 testcase( i==104 ); /* CURRENT_TIMESTAMP */
153376 testcase( i==105 ); /* CURRENT_TIME */
153377 testcase( i==106 ); /* CURRENT */
153378 testcase( i==107 ); /* PARTITION */
153379 testcase( i==108 ); /* DEFERRED */
153380 testcase( i==109 ); /* DISTINCT */
153381 testcase( i==110 ); /* IS */
153382 testcase( i==111 ); /* DROP */
153383 testcase( i==112 ); /* PRECEDING */
153384 testcase( i==113 ); /* FAIL */
153385 testcase( i==114 ); /* FILTER */
153386 testcase( i==115 ); /* REPLACE */
153387 testcase( i==116 ); /* FOLLOWING */
153388 testcase( i==117 ); /* FROM */
153389 testcase( i==118 ); /* FULL */
153390 testcase( i==119 ); /* IF */
153391 testcase( i==120 ); /* ISNULL */
153392 testcase( i==121 ); /* ORDER */
153393 testcase( i==122 ); /* RESTRICT */
153394 testcase( i==123 ); /* OTHERS */
153395 testcase( i==124 ); /* OVER */
153396 testcase( i==125 ); /* RIGHT */
153397 testcase( i==126 ); /* ROLLBACK */
153398 testcase( i==127 ); /* ROWS */
153399 testcase( i==128 ); /* ROW */
153400 testcase( i==129 ); /* UNBOUNDED */
153401 testcase( i==130 ); /* UNION */
153402 testcase( i==131 ); /* USING */
153403 testcase( i==132 ); /* VACUUM */
153404 testcase( i==133 ); /* VIEW */
153405 testcase( i==134 ); /* WINDOW */
153406 testcase( i==135 ); /* DO */
153407 testcase( i==136 ); /* BY */
153408 testcase( i==137 ); /* INITIALLY */
153409 testcase( i==138 ); /* ALL */
153410 testcase( i==139 ); /* PRIMARY */
153411 *pType = aKWCode[i];
153412 break;
153413 }
153414 }
153415 return n;
@@ -152747,11 +153417,11 @@
153417 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
153418 int id = TK_ID;
153419 keywordCode((char*)z, n, &id);
153420 return id;
153421 }
153422 #define SQLITE_N_KEYWORD 140
153423 SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
153424 if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
153425 *pzName = zKWText + aKWOffset[i];
153426 *pnName = aKWLen[i];
153427 return SQLITE_OK;
@@ -154715,10 +155385,12 @@
155385 { SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
155386 { SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
155387 { SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
155388 { SQLITE_DBCONFIG_RESET_DATABASE, SQLITE_ResetDatabase },
155389 { SQLITE_DBCONFIG_DEFENSIVE, SQLITE_Defensive },
155390 { SQLITE_DBCONFIG_WRITABLE_SCHEMA, SQLITE_WriteSchema|
155391 SQLITE_NoSchemaError },
155392 };
155393 unsigned int i;
155394 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
155395 for(i=0; i<ArraySize(aFlagOp); i++){
155396 if( aFlagOp[i].op==op ){
@@ -168496,11 +169168,11 @@
169168
169169 zName = sqlite3_value_text(argv[0]);
169170 nName = sqlite3_value_bytes(argv[0])+1;
169171
169172 if( argc==2 ){
169173 if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[1]) ){
169174 void *pOld;
169175 int n = sqlite3_value_bytes(argv[1]);
169176 if( zName==0 || n!=sizeof(pPtr) ){
169177 sqlite3_result_error(context, "argument type mismatch", -1);
169178 return;
@@ -168523,11 +169195,11 @@
169195 sqlite3_result_error(context, zErr, -1);
169196 sqlite3_free(zErr);
169197 return;
169198 }
169199 }
169200 if( fts3TokenizerEnabled(context) || sqlite3_value_frombind(argv[0]) ){
169201 sqlite3_result_blob(context, (void *)&pPtr, sizeof(pPtr), SQLITE_TRANSIENT);
169202 }
169203 }
169204
169205 SQLITE_PRIVATE int sqlite3Fts3IsIdChar(char c){
@@ -184160,53 +184832,49 @@
184832 ** entry for each cell in the r-tree node. Each entry is itself a
184833 ** list, containing the 8-byte rowid/pageno followed by the
184834 ** <num-dimension>*2 coordinates.
184835 */
184836 static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
 
184837 RtreeNode node;
184838 Rtree tree;
184839 int ii;
184840 int nData;
184841 int errCode;
184842 sqlite3_str *pOut;
184843
184844 UNUSED_PARAMETER(nArg);
184845 memset(&node, 0, sizeof(RtreeNode));
184846 memset(&tree, 0, sizeof(Rtree));
184847 tree.nDim = (u8)sqlite3_value_int(apArg[0]);
184848 if( tree.nDim<1 || tree.nDim>5 ) return;
184849 tree.nDim2 = tree.nDim*2;
184850 tree.nBytesPerCell = 8 + 8 * tree.nDim;
184851 node.zData = (u8 *)sqlite3_value_blob(apArg[1]);
184852 nData = sqlite3_value_bytes(apArg[1]);
184853 if( nData<4 ) return;
184854 if( nData<NCELL(&node)*tree.nBytesPerCell ) return;
184855
184856 pOut = sqlite3_str_new(0);
184857 for(ii=0; ii<NCELL(&node); ii++){
 
 
184858 RtreeCell cell;
184859 int jj;
184860
184861 nodeGetCell(&tree, &node, ii, &cell);
184862 if( ii>0 ) sqlite3_str_append(pOut, " ", 1);
184863 sqlite3_str_appendf(pOut, "{%lld", cell.iRowid);
184864 for(jj=0; jj<tree.nDim2; jj++){
184865 #ifndef SQLITE_RTREE_INT_ONLY
184866 sqlite3_str_appendf(pOut, " %g", (double)cell.aCoord[jj].f);
 
184867 #else
184868 sqlite3_str_appendf(pOut, " %d", cell.aCoord[jj].i);
 
184869 #endif
184870 }
184871 sqlite3_str_append(pOut, "}", 1);
184872 }
184873 errCode = sqlite3_str_errcode(pOut);
184874 sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
184875 sqlite3_result_error_code(ctx, errCode);
 
 
 
 
 
 
 
184876 }
184877
184878 /* This routine implements an SQL function that returns the "depth" parameter
184879 ** from the front of a blob that is an r-tree node. For example:
184880 **
@@ -198080,11 +198748,11 @@
198748
198749 return rc;
198750 }
198751
198752 /*
198753 ** This function is called from within sqlite3changeset_apply_v2() when
198754 ** a conflict is encountered and resolved using conflict resolution
198755 ** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE)..
198756 ** It adds a conflict resolution record to the buffer in
198757 ** SessionApplyCtx.rebase, which will eventually be returned to the caller
198758 ** of apply_v2() as the "rebase" buffer.
@@ -200859,12 +201527,13 @@
201527 */
201528 static void sqlite3Fts5HashClear(Fts5Hash*);
201529
201530 static int sqlite3Fts5HashQuery(
201531 Fts5Hash*, /* Hash table to query */
201532 int nPre,
201533 const char *pTerm, int nTerm, /* Query term */
201534 void **ppObj, /* OUT: Pointer to doclist for pTerm */
201535 int *pnDoclist /* OUT: Size of doclist in bytes */
201536 );
201537
201538 static int sqlite3Fts5HashScanInit(
201539 Fts5Hash*, /* Hash table to query */
@@ -202930,11 +203599,11 @@
203599 *pnScore = nScore;
203600 if( piPos ){
203601 sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
203602 if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
203603 if( iAdj<0 ) iAdj = 0;
203604 *piPos = (int)iAdj;
203605 }
203606
203607 return rc;
203608 }
203609
@@ -203158,11 +203827,11 @@
203827 nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
203828 p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
203829 if( p==0 ){
203830 rc = SQLITE_NOMEM;
203831 }else{
203832 memset(p, 0, (size_t)nByte);
203833 p->nPhrase = nPhrase;
203834 p->aIDF = (double*)&p[1];
203835 p->aFreq = &p->aIDF[nPhrase];
203836 }
203837
@@ -203321,11 +203990,11 @@
203990 pNew = sqlite3_realloc64(pBuf->p, nNew);
203991 if( pNew==0 ){
203992 *pRc = SQLITE_NOMEM;
203993 return 1;
203994 }else{
203995 pBuf->nSpace = (int)nNew;
203996 pBuf->p = pNew;
203997 }
203998 }
203999 return 0;
204000 }
@@ -203545,11 +204214,11 @@
204214 if( *pRc==SQLITE_OK ){
204215 pRet = sqlite3_malloc64(nByte);
204216 if( pRet==0 ){
204217 if( nByte>0 ) *pRc = SQLITE_NOMEM;
204218 }else{
204219 memset(pRet, 0, (size_t)nByte);
204220 }
204221 }
204222 return pRet;
204223 }
204224
@@ -204014,11 +204683,11 @@
204683 if( p==0 ){
204684 *pzErr = sqlite3_mprintf("parse error in tokenize directive");
204685 rc = SQLITE_ERROR;
204686 }else{
204687 rc = sqlite3Fts5GetTokenizer(pGlobal,
204688 (const char**)azArg, (int)nArg, &pConfig->pTok, &pConfig->pTokApi,
204689 pzErr
204690 );
204691 }
204692 }
204693 }
@@ -204124,11 +204793,11 @@
204793 *pzOut = 0;
204794
204795 if( zOut==0 ){
204796 *pRc = SQLITE_NOMEM;
204797 }else{
204798 memcpy(zOut, zIn, (size_t)(nIn+1));
204799 if( fts5_isopenquote(zOut[0]) ){
204800 int ii = fts5Dequote(zOut);
204801 zRet = &zIn[ii];
204802 *pbQuoted = 1;
204803 }else{
@@ -206138,11 +206807,11 @@
206807 nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
206808 pRet = sqlite3_malloc64(nByte);
206809 if( pRet==0 ){
206810 pParse->rc = SQLITE_NOMEM;
206811 }else{
206812 memset(pRet, 0, (size_t)nByte);
206813 }
206814 }else if( (pNear->nPhrase % SZALLOC)==0 ){
206815 int nNew = pNear->nPhrase + SZALLOC;
206816 sqlite3_int64 nByte;
206817
@@ -206214,11 +206883,11 @@
206883 sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
206884 pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
206885 if( pSyn==0 ){
206886 rc = SQLITE_NOMEM;
206887 }else{
206888 memset(pSyn, 0, (size_t)nByte);
206889 pSyn->zTerm = ((char*)pSyn) + sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer);
206890 memcpy(pSyn->zTerm, pToken, nToken);
206891 pSyn->pSynonym = pPhrase->aTerm[pPhrase->nTerm-1].pSynonym;
206892 pPhrase->aTerm[pPhrase->nTerm-1].pSynonym = pSyn;
206893 }
@@ -206374,11 +207043,11 @@
207043 sqlite3_int64 nByte;
207044 Fts5Colset *pColset;
207045 nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
207046 pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
207047 if( pColset ){
207048 memcpy(pColset, pColsetOrig, (size_t)nByte);
207049 }
207050 pNew->pRoot->pNear->pColset = pColset;
207051 }
207052 }
207053
@@ -206591,11 +207260,11 @@
207260 Fts5Colset *pRet;
207261 if( pOrig ){
207262 sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
207263 pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
207264 if( pRet ){
207265 memcpy(pRet, pOrig, (size_t)nByte);
207266 }
207267 }else{
207268 pRet = 0;
207269 }
207270 return pRet;
@@ -207608,11 +208277,11 @@
208277 if( pNew->aSlot==0 ){
208278 sqlite3_free(pNew);
208279 *ppNew = 0;
208280 rc = SQLITE_NOMEM;
208281 }else{
208282 memset(pNew->aSlot, 0, (size_t)nByte);
208283 }
208284 }
208285 return rc;
208286 }
208287
@@ -207692,40 +208361,51 @@
208361 pHash->nSlot = nNew;
208362 pHash->aSlot = apNew;
208363 return SQLITE_OK;
208364 }
208365
208366 static int fts5HashAddPoslistSize(
208367 Fts5Hash *pHash,
208368 Fts5HashEntry *p,
208369 Fts5HashEntry *p2
208370 ){
208371 int nRet = 0;
208372 if( p->iSzPoslist ){
208373 u8 *pPtr = p2 ? (u8*)p2 : (u8*)p;
208374 int nData = p->nData;
208375 if( pHash->eDetail==FTS5_DETAIL_NONE ){
208376 assert( nData==p->iSzPoslist );
208377 if( p->bDel ){
208378 pPtr[nData++] = 0x00;
208379 if( p->bContent ){
208380 pPtr[nData++] = 0x00;
208381 }
208382 }
208383 }else{
208384 int nSz = (nData - p->iSzPoslist - 1); /* Size in bytes */
208385 int nPos = nSz*2 + p->bDel; /* Value of nPos field */
208386
208387 assert( p->bDel==0 || p->bDel==1 );
208388 if( nPos<=127 ){
208389 pPtr[p->iSzPoslist] = (u8)nPos;
208390 }else{
208391 int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
208392 memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
208393 sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
208394 nData += (nByte-1);
208395 }
208396 }
208397
208398 nRet = nData - p->nData;
208399 if( p2==0 ){
208400 p->iSzPoslist = 0;
208401 p->bDel = 0;
208402 p->bContent = 0;
208403 p->nData = nData;
208404 }
208405 }
208406 return nRet;
208407 }
208408
208409 /*
208410 ** Add an entry to the in-memory hash table. The key is the concatenation
208411 ** of bByte and (pToken/nToken). The value is (iRowid/iCol/iPos).
@@ -207778,11 +208458,11 @@
208458
208459 /* Allocate new Fts5HashEntry and add it to the hash table. */
208460 p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
208461 if( !p ) return SQLITE_NOMEM;
208462 memset(p, 0, sizeof(Fts5HashEntry));
208463 p->nAlloc = (int)nByte;
208464 zKey = fts5EntryKey(p);
208465 zKey[0] = bByte;
208466 memcpy(&zKey[1], pToken, nToken);
208467 assert( iHash==fts5HashKey(pHash->nSlot, (u8*)zKey, nToken+1) );
208468 p->nKey = nToken;
@@ -207833,11 +208513,11 @@
208513 pPtr = (u8*)p;
208514
208515 /* If this is a new rowid, append the 4-byte size field for the previous
208516 ** entry, and the new rowid for this entry. */
208517 if( iRowid!=p->iRowid ){
208518 fts5HashAddPoslistSize(pHash, p, 0);
208519 p->nData += sqlite3Fts5PutVarint(&pPtr[p->nData], iRowid - p->iRowid);
208520 p->iRowid = iRowid;
208521 bNew = 1;
208522 p->iSzPoslist = p->nData;
208523 if( pHash->eDetail!=FTS5_DETAIL_NONE ){
@@ -207950,11 +208630,13 @@
208630 memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
208631
208632 for(iSlot=0; iSlot<pHash->nSlot; iSlot++){
208633 Fts5HashEntry *pIter;
208634 for(pIter=pHash->aSlot[iSlot]; pIter; pIter=pIter->pHashNext){
208635 if( pTerm==0
208636 || (pIter->nKey+1>=nTerm && 0==memcmp(fts5EntryKey(pIter), pTerm, nTerm))
208637 ){
208638 Fts5HashEntry *pEntry = pIter;
208639 pEntry->pScanNext = 0;
208640 for(i=0; ap[i]; i++){
208641 pEntry = fts5HashEntryMerge(pEntry, ap[i]);
208642 ap[i] = 0;
@@ -207978,12 +208660,13 @@
208660 /*
208661 ** Query the hash table for a doclist associated with term pTerm/nTerm.
208662 */
208663 static int sqlite3Fts5HashQuery(
208664 Fts5Hash *pHash, /* Hash table to query */
208665 int nPre,
208666 const char *pTerm, int nTerm, /* Query term */
208667 void **ppOut, /* OUT: Pointer to new object */
208668 int *pnDoclist /* OUT: Size of doclist in bytes */
208669 ){
208670 unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm);
208671 char *zKey = 0;
208672 Fts5HashEntry *p;
@@ -207993,15 +208676,24 @@
208676 assert( p->nKey+1==(int)strlen(zKey) );
208677 if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
208678 }
208679
208680 if( p ){
208681 int nHashPre = sizeof(Fts5HashEntry) + nTerm + 1;
208682 int nList = p->nData - nHashPre;
208683 u8 *pRet = (u8*)(*ppOut = sqlite3_malloc64(nPre + nList + 10));
208684 if( pRet ){
208685 Fts5HashEntry *pFaux = (Fts5HashEntry*)&pRet[nPre-nHashPre];
208686 memcpy(&pRet[nPre], &((u8*)p)[nHashPre], nList);
208687 nList += fts5HashAddPoslistSize(pHash, p, pFaux);
208688 *pnDoclist = nList;
208689 }else{
208690 *pnDoclist = 0;
208691 return SQLITE_NOMEM;
208692 }
208693 }else{
208694 *ppOut = 0;
208695 *pnDoclist = 0;
208696 }
208697
208698 return SQLITE_OK;
208699 }
@@ -208030,11 +208722,11 @@
208722 ){
208723 Fts5HashEntry *p;
208724 if( (p = pHash->pScan) ){
208725 char *zKey = fts5EntryKey(p);
208726 int nTerm = (int)strlen(zKey);
208727 fts5HashAddPoslistSize(pHash, p, 0);
208728 *pzTerm = zKey;
208729 *ppDoclist = (const u8*)&zKey[nTerm+1];
208730 *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1);
208731 }else{
208732 *pzTerm = 0;
@@ -210500,35 +211192,44 @@
211192 Fts5Index *p, /* FTS5 backend */
211193 const u8 *pTerm, int nTerm, /* Term to seek to */
211194 int flags, /* Mask of FTS5INDEX_XXX flags */
211195 Fts5SegIter *pIter /* Object to populate */
211196 ){
 
211197 int nList = 0;
211198 const u8 *z = 0;
211199 int n = 0;
211200 Fts5Data *pLeaf = 0;
211201
211202 assert( p->pHash );
211203 assert( p->rc==SQLITE_OK );
211204
211205 if( pTerm==0 || (flags & FTS5INDEX_QUERY_SCAN) ){
211206 const u8 *pList = 0;
211207
211208 p->rc = sqlite3Fts5HashScanInit(p->pHash, (const char*)pTerm, nTerm);
211209 sqlite3Fts5HashScanEntry(p->pHash, (const char**)&z, &pList, &nList);
211210 n = (z ? (int)strlen((const char*)z) : 0);
211211 if( pList ){
211212 pLeaf = fts5IdxMalloc(p, sizeof(Fts5Data));
211213 if( pLeaf ){
211214 pLeaf->p = (u8*)pList;
211215 }
211216 }
211217 }else{
211218 p->rc = sqlite3Fts5HashQuery(p->pHash, sizeof(Fts5Data),
211219 (const char*)pTerm, nTerm, (void**)&pLeaf, &nList
211220 );
211221 if( pLeaf ){
211222 pLeaf->p = (u8*)&pLeaf[1];
211223 }
211224 z = pTerm;
211225 n = nTerm;
211226 pIter->flags |= FTS5_SEGITER_ONETERM;
211227 }
211228
211229 if( pLeaf ){
 
211230 sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
 
 
 
211231 pLeaf->nn = pLeaf->szLeaf = nList;
211232 pIter->pLeaf = pLeaf;
211233 pIter->iLeafOffset = fts5GetVarint(pLeaf->p, (u64*)&pIter->iRowid);
211234 pIter->iEndofDoclist = pLeaf->nn;
211235
@@ -215241,11 +215942,11 @@
215942 if( rc==SQLITE_OK ){
215943 nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
215944 pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
215945 if( pCsr ){
215946 Fts5Global *pGlobal = pTab->pGlobal;
215947 memset(pCsr, 0, (size_t)nByte);
215948 pCsr->aColumnSize = (int*)&pCsr[1];
215949 pCsr->pNext = pGlobal->pCsr;
215950 pGlobal->pCsr = pCsr;
215951 pCsr->iCsrId = ++pGlobal->iNextId;
215952 }else{
@@ -215522,11 +216223,11 @@
216223
216224 nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
216225 nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
216226 pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
216227 if( pSorter==0 ) return SQLITE_NOMEM;
216228 memset(pSorter, 0, (size_t)nByte);
216229 pSorter->nIdx = nPhrase;
216230
216231 /* TODO: It would be better to have some system for reusing statement
216232 ** handles here, rather than preparing a new one for each query. But that
216233 ** is not possible as SQLite reference counts the virtual table objects.
@@ -217256,11 +217957,11 @@
217957 int nArg, /* Number of args */
217958 sqlite3_value **apUnused /* Function arguments */
217959 ){
217960 assert( nArg==0 );
217961 UNUSED_PARAM2(nArg, apUnused);
217962 sqlite3_result_text(pCtx, "fts5: 2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f", -1, SQLITE_TRANSIENT);
217963 }
217964
217965 /*
217966 ** Return true if zName is the extension on one of the shadow tables used
217967 ** by this module.
@@ -217679,11 +218380,11 @@
218380 nByte = sizeof(Fts5Storage) /* Fts5Storage object */
218381 + pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */
218382 *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
218383 if( !p ) return SQLITE_NOMEM;
218384
218385 memset(p, 0, (size_t)nByte);
218386 p->aTotalSize = (i64*)&p[1];
218387 p->pConfig = pConfig;
218388 p->pIndex = pIndex;
218389
218390 if( bCreate ){
@@ -220589,11 +221290,11 @@
221290 int iTbl = 0;
221291 while( i<128 ){
221292 int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
221293 int n = (aFts5UnicodeData[iTbl] >> 5) + i;
221294 for(; i<128 && i<n; i++){
221295 aAscii[i] = (u8)bToken;
221296 }
221297 iTbl++;
221298 }
221299 }
221300
@@ -222020,12 +222721,12 @@
222721 }
222722 #endif /* SQLITE_CORE */
222723 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
222724
222725 /************** End of stmt.c ************************************************/
222726 #if __LINE__!=222726
222727 #undef SQLITE_SOURCE_ID
222728 #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2aalt2"
222729 #endif
222730 /* Return the source-id for this library */
222731 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
222732 /************************** End of sqlite3.c ******************************/
222733
+26 -3
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.28.0"
127127
#define SQLITE_VERSION_NUMBER 3028000
128
-#define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07e2f93"
128
+#define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -187,10 +187,13 @@
187187
** [sqlite_compileoption_get()] and the [compile_options pragma].
188188
*/
189189
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
190190
SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
191191
SQLITE_API const char *sqlite3_compileoption_get(int N);
192
+#else
193
+# define sqlite3_compileoption_used(X) 0
194
+# define sqlite3_compileoption_get(X) ((void*)0)
192195
#endif
193196
194197
/*
195198
** CAPI3REF: Test To See If The Library Is Threadsafe
196199
**
@@ -2197,10 +2200,21 @@
21972200
** <li> The [PRAGMA writable_schema=ON] statement.
21982201
** <li> Writes to the [sqlite_dbpage] virtual table.
21992202
** <li> Direct writes to [shadow tables].
22002203
** </ul>
22012204
** </dd>
2205
+**
2206
+** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
2207
+** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
2208
+** "writable_schema" flag. This has the same effect and is logically equivalent
2209
+** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF].
2210
+** The first argument to this setting is an integer which is 0 to disable
2211
+** the writable_schema, positive to enable writable_schema, or negative to
2212
+** leave the setting unchanged. The second parameter is a pointer to an
2213
+** integer into which is written 0 or 1 to indicate whether the writable_schema
2214
+** is enabled or disabled following this call.
2215
+** </dd>
22022216
** </dl>
22032217
*/
22042218
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
22052219
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
22062220
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2210,11 +2224,12 @@
22102224
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
22112225
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
22122226
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
22132227
#define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
22142228
#define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2215
-#define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
2229
+#define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
2230
+#define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */
22162231
22172232
/*
22182233
** CAPI3REF: Enable Or Disable Extended Result Codes
22192234
** METHOD: sqlite3
22202235
**
@@ -4962,10 +4977,12 @@
49624977
** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
49634978
** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
49644979
** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
49654980
** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
49664981
** against a virtual table.
4982
+** <tr><td><b>sqlite3_value_frombind&nbsp;&nbsp;</b>
4983
+** <td>&rarr;&nbsp;&nbsp;<td>True if value originated a bound parameter
49674984
** </table></blockquote>
49684985
**
49694986
** <b>Details:</b>
49704987
**
49714988
** These routines extract type, size, and content information from
@@ -5022,10 +5039,15 @@
50225039
** was unchanging). ^Within an [xUpdate] method, any value for which
50235040
** sqlite3_value_nochange(X) is true will in all other respects appear
50245041
** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
50255042
** than within an [xUpdate] method call for an UPDATE statement, then
50265043
** the return value is arbitrary and meaningless.
5044
+**
5045
+** ^The sqlite3_value_frombind(X) interface returns non-zero if the
5046
+** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
5047
+** interfaces. ^If X comes from an SQL literal value, or a table column,
5048
+** and expression, then sqlite3_value_frombind(X) returns zero.
50275049
**
50285050
** Please pay particular attention to the fact that the pointer returned
50295051
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
50305052
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
50315053
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5068,10 +5090,11 @@
50685090
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
50695091
SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
50705092
SQLITE_API int sqlite3_value_type(sqlite3_value*);
50715093
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
50725094
SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
5095
+SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
50735096
50745097
/*
50755098
** CAPI3REF: Finding The Subtype Of SQL Values
50765099
** METHOD: sqlite3_value
50775100
**
@@ -10904,11 +10927,11 @@
1090410927
**
1090510928
** Argument pIn must point to a buffer containing a changeset nIn bytes
1090610929
** in size. This function allocates and populates a buffer with a copy
1090710930
** of the changeset rebased rebased according to the configuration of the
1090810931
** rebaser object passed as the first argument. If successful, (*ppOut)
10909
-** is set to point to the new buffer containing the rebased changset and
10932
+** is set to point to the new buffer containing the rebased changeset and
1091010933
** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
1091110934
** responsibility of the caller to eventually free the new buffer using
1091210935
** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
1091310936
** are set to zero and an SQLite error code returned.
1091410937
*/
1091510938
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.28.0"
127 #define SQLITE_VERSION_NUMBER 3028000
128 #define SQLITE_SOURCE_ID "2019-03-17 23:59:02 cc5ab96715ebb1089b4e9aa647badd2510aaa056f26004718f921f4ac07e2f93"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -187,10 +187,13 @@
187 ** [sqlite_compileoption_get()] and the [compile_options pragma].
188 */
189 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
190 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
191 SQLITE_API const char *sqlite3_compileoption_get(int N);
 
 
 
192 #endif
193
194 /*
195 ** CAPI3REF: Test To See If The Library Is Threadsafe
196 **
@@ -2197,10 +2200,21 @@
2197 ** <li> The [PRAGMA writable_schema=ON] statement.
2198 ** <li> Writes to the [sqlite_dbpage] virtual table.
2199 ** <li> Direct writes to [shadow tables].
2200 ** </ul>
2201 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
2202 ** </dl>
2203 */
2204 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2205 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2206 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2210,11 +2224,12 @@
2210 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2211 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2212 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
2213 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
2214 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2215 #define SQLITE_DBCONFIG_MAX 1010 /* Largest DBCONFIG */
 
2216
2217 /*
2218 ** CAPI3REF: Enable Or Disable Extended Result Codes
2219 ** METHOD: sqlite3
2220 **
@@ -4962,10 +4977,12 @@
4962 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
4963 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4964 ** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
4965 ** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
4966 ** against a virtual table.
 
 
4967 ** </table></blockquote>
4968 **
4969 ** <b>Details:</b>
4970 **
4971 ** These routines extract type, size, and content information from
@@ -5022,10 +5039,15 @@
5022 ** was unchanging). ^Within an [xUpdate] method, any value for which
5023 ** sqlite3_value_nochange(X) is true will in all other respects appear
5024 ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
5025 ** than within an [xUpdate] method call for an UPDATE statement, then
5026 ** the return value is arbitrary and meaningless.
 
 
 
 
 
5027 **
5028 ** Please pay particular attention to the fact that the pointer returned
5029 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
5030 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
5031 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5068,10 +5090,11 @@
5068 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5069 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
5070 SQLITE_API int sqlite3_value_type(sqlite3_value*);
5071 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5072 SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
 
5073
5074 /*
5075 ** CAPI3REF: Finding The Subtype Of SQL Values
5076 ** METHOD: sqlite3_value
5077 **
@@ -10904,11 +10927,11 @@
10904 **
10905 ** Argument pIn must point to a buffer containing a changeset nIn bytes
10906 ** in size. This function allocates and populates a buffer with a copy
10907 ** of the changeset rebased rebased according to the configuration of the
10908 ** rebaser object passed as the first argument. If successful, (*ppOut)
10909 ** is set to point to the new buffer containing the rebased changset and
10910 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
10911 ** responsibility of the caller to eventually free the new buffer using
10912 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
10913 ** are set to zero and an SQLite error code returned.
10914 */
10915
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.28.0"
127 #define SQLITE_VERSION_NUMBER 3028000
128 #define SQLITE_SOURCE_ID "2019-04-03 17:48:10 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -187,10 +187,13 @@
187 ** [sqlite_compileoption_get()] and the [compile_options pragma].
188 */
189 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
190 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
191 SQLITE_API const char *sqlite3_compileoption_get(int N);
192 #else
193 # define sqlite3_compileoption_used(X) 0
194 # define sqlite3_compileoption_get(X) ((void*)0)
195 #endif
196
197 /*
198 ** CAPI3REF: Test To See If The Library Is Threadsafe
199 **
@@ -2197,10 +2200,21 @@
2200 ** <li> The [PRAGMA writable_schema=ON] statement.
2201 ** <li> Writes to the [sqlite_dbpage] virtual table.
2202 ** <li> Direct writes to [shadow tables].
2203 ** </ul>
2204 ** </dd>
2205 **
2206 ** [[SQLITE_DBCONFIG_WRITABLE_SCHEMA]] <dt>SQLITE_DBCONFIG_WRITABLE_SCHEMA</dt>
2207 ** <dd>The SQLITE_DBCONFIG_WRITABLE_SCHEMA option activates or deactivates the
2208 ** "writable_schema" flag. This has the same effect and is logically equivalent
2209 ** to setting [PRAGMA writable_schema=ON] or [PRAGMA writable_schema=OFF].
2210 ** The first argument to this setting is an integer which is 0 to disable
2211 ** the writable_schema, positive to enable writable_schema, or negative to
2212 ** leave the setting unchanged. The second parameter is a pointer to an
2213 ** integer into which is written 0 or 1 to indicate whether the writable_schema
2214 ** is enabled or disabled following this call.
2215 ** </dd>
2216 ** </dl>
2217 */
2218 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2219 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2220 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
@@ -2210,11 +2224,12 @@
2224 #define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
2225 #define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
2226 #define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
2227 #define SQLITE_DBCONFIG_RESET_DATABASE 1009 /* int int* */
2228 #define SQLITE_DBCONFIG_DEFENSIVE 1010 /* int int* */
2229 #define SQLITE_DBCONFIG_WRITABLE_SCHEMA 1011 /* int int* */
2230 #define SQLITE_DBCONFIG_MAX 1011 /* Largest DBCONFIG */
2231
2232 /*
2233 ** CAPI3REF: Enable Or Disable Extended Result Codes
2234 ** METHOD: sqlite3
2235 **
@@ -4962,10 +4977,12 @@
4977 ** <tr><td><b>sqlite3_value_numeric_type&nbsp;&nbsp;</b>
4978 ** <td>&rarr;&nbsp;&nbsp;<td>Best numeric datatype of the value
4979 ** <tr><td><b>sqlite3_value_nochange&nbsp;&nbsp;</b>
4980 ** <td>&rarr;&nbsp;&nbsp;<td>True if the column is unchanged in an UPDATE
4981 ** against a virtual table.
4982 ** <tr><td><b>sqlite3_value_frombind&nbsp;&nbsp;</b>
4983 ** <td>&rarr;&nbsp;&nbsp;<td>True if value originated a bound parameter
4984 ** </table></blockquote>
4985 **
4986 ** <b>Details:</b>
4987 **
4988 ** These routines extract type, size, and content information from
@@ -5022,10 +5039,15 @@
5039 ** was unchanging). ^Within an [xUpdate] method, any value for which
5040 ** sqlite3_value_nochange(X) is true will in all other respects appear
5041 ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other
5042 ** than within an [xUpdate] method call for an UPDATE statement, then
5043 ** the return value is arbitrary and meaningless.
5044 **
5045 ** ^The sqlite3_value_frombind(X) interface returns non-zero if the
5046 ** value X originated from one of the [sqlite3_bind_int|sqlite3_bind()]
5047 ** interfaces. ^If X comes from an SQL literal value, or a table column,
5048 ** and expression, then sqlite3_value_frombind(X) returns zero.
5049 **
5050 ** Please pay particular attention to the fact that the pointer returned
5051 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
5052 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
5053 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
@@ -5068,10 +5090,11 @@
5090 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
5091 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
5092 SQLITE_API int sqlite3_value_type(sqlite3_value*);
5093 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5094 SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
5095 SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
5096
5097 /*
5098 ** CAPI3REF: Finding The Subtype Of SQL Values
5099 ** METHOD: sqlite3_value
5100 **
@@ -10904,11 +10927,11 @@
10927 **
10928 ** Argument pIn must point to a buffer containing a changeset nIn bytes
10929 ** in size. This function allocates and populates a buffer with a copy
10930 ** of the changeset rebased rebased according to the configuration of the
10931 ** rebaser object passed as the first argument. If successful, (*ppOut)
10932 ** is set to point to the new buffer containing the rebased changeset and
10933 ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the
10934 ** responsibility of the caller to eventually free the new buffer using
10935 ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut)
10936 ** are set to zero and an SQLite error code returned.
10937 */
10938

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button